Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StallGuard Example not working #90

Open
MilanVDB opened this issue Mar 29, 2020 · 1 comment
Open

StallGuard Example not working #90

MilanVDB opened this issue Mar 29, 2020 · 1 comment

Comments

@MilanVDB
Copy link

MilanVDB commented Mar 29, 2020

Hi,

Simple Sketch works fine. Now I am trying to run a Stepper with the TMC2130 and an Arduino UNO. I tried to use the StallGuard Example but when compiling it says

exit status 1
'PORTF' was not declared in this scope

@Lecerof
Copy link

Lecerof commented Apr 28, 2020

I have the same issue. Seems like teemuatlut is using bit manipulation to step the motor with interrupts. Such operations are much faster than using digital write. PORTF is present in Mega2560 but not in Nano (which I use) and it covers the analog pins A0-A7 on the Mega so the STEP-pin in our case. What you need to do is to either use another port and change the code, or to not use ports (and change the code).

So, how to solve it?
I solved it still using ports by changing the port to PORTD (D0-D7 on my Nano) since this is present in my Nano (and in your UNO which is based on AtMega168: https://www.arduino.cc/en/Reference/PortManipulation). I connected the STEP pin to D7. Then I changed the interrupt function to do an XOR with PORTD and a bitmask.

So I changed these two lines:
https://github.com/teemuatlut/TMC2130Stepper/blob/master/examples/StallGuard/StallGuard.ino#L99-L100

to
PORTD ^= (1 << 7)
or what ever pin you use as step pin on PORTD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants