I am powering a stepper motor using a Dspin driver. I have a pushbutton to toggle - speed and/or direction. Even if I program the 2 speeds the same, when I toggle between the 2 speeds, one is 5x slower than it should be. If I comment out either of the if statements, the remaining speed runs correctly.
Project is for a Hi-Fi turntable. Speeds will be set for 33/45 turntable speed.
I will incorporate feedback from an opto-sensor to prevent speed drift - one step (excuse the pun) at a time!
Microstepping runs quiet & smooth - certainly less vibration than the mains synchronous motor it's replacing.
The bit I've written is the pushbutton toggles for stop/start & speed selection & associated LED's.
How can - dSPIN_Run(REV, SpdCalc(200)); run at correct speed in one if statement but not in the other, yet if I comment out EITHER if statement, the other runs at correct speed? If I remove the stop/start pushbutton code leaving only speed selection still the same happens, one runs at correct speed, the other not.
It is an interesting device because it apparently can control a motor that requires up to 3 amps - however it is expensive.
I suspect the answer to your question is somewhere in all the various links but nobody seems to have taken the trouble to write a user manual and I don't have the patience to read it all - especially as Github insists on using grey type that is almost unreadable.
Programming error. if - if - else should be if - else if - else - sorted now.
I've got a 700 page cookbook that doesn't tell how to program multiple if statements.
I also have a thin C++ book that is very useful at solving such issues. Unfortunately, C++ is not same as Arduino-ese so I have to translate it.
I would love a slim easy reference Arduino programming book rather than wading through multiple example programs that "nearly" do what I want. I don't program enough to become fluent.