VACTUAL is a signed 24 bit value (sign=motor run direction) and therefore needs to be declared as signed long, not unsigned. Currently, only positive values are returned, even if the motor runs in "negative" direction. This put me to trouble when using VACTUAL to run the motor, and using an interrupt routine to count INDEX pulses and checking VACTUAL sign to determine current direction.
File TMC2208Stepper.cpp (lines 328ff):
void TMC2208Stepper::VACTUAL(uint32_t input) // change to int32_t
uint32_t TMC2208Stepper::VACTUAL() // change to int32_t
Proof: When I typecast the return value of VACTUAL to (signed long), everything works fine.
PS: Great library, saved me loads of work! Great work!
VACTUAL is a signed 24 bit value (sign=motor run direction) and therefore needs to be declared as signed long, not unsigned. Currently, only positive values are returned, even if the motor runs in "negative" direction. This put me to trouble when using VACTUAL to run the motor, and using an interrupt routine to count INDEX pulses and checking VACTUAL sign to determine current direction.
File TMC2208Stepper.cpp (lines 328ff): void TMC2208Stepper::VACTUAL(uint32_t input) // change to int32_t uint32_t TMC2208Stepper::VACTUAL() // change to int32_t
Proof: When I typecast the return value of VACTUAL to (signed long), everything works fine.
PS: Great library, saved me loads of work! Great work!