CAP1Sup / Intellistep

A rework of the terribly coded firmware from the BTT S42B v2 boards
GNU General Public License v3.0
45 stars 10 forks source link

Bug in StepperMotor::getHardStepCNT() #92

Closed IhorNehrutsa closed 3 years ago

IhorNehrutsa commented 3 years ago

https://github.com/CAP1Sup/Intellistep/blob/f292d5d595b82d5efa1879fca8f6c93d19482ed4/src/hardware/motor.cpp#L145-L148 If direction of input pulses is negative the return is positive instead of -1 return 65535 instead of -2 return 65534 instead of -3 return 65533 ...

CAP1Sup commented 3 years ago

Was the overflow incorrectly handled? What do you think is the issue here?

IhorNehrutsa commented 3 years ago

Overflow is not happen.I check it. Thre is uint32 to int32 convertation bug.

IhorNehrutsa commented 3 years ago

CNT is defined as uint32_t, but has count diapasone 0...65535 as uint16_t We should treat it as int16_t -32768... 32767. Like in the encoder. I will test this tomorrow.