Encoder error on x axis after 2684mm with 1/4 microstepping

During my initial setup and calibration, I started to experiment with enabling microstepping on the farmduino 14 board. I have found that enabling this feature significantly reduces the noise of farmbot’s stepper motors, especially for the z index. I understand that there is a tradeoff for speed, but, being that its quieter, I could make up for time by performing operations at night.

Anyways, I have my farmbot set to 1/4 microstepping and updated the motor section of the device page to set the microsteps / step to 4.

Side rant: it took me a while to realize that the correct settings were to only change this value. The confusion came in due to the javascript back calculating the associated values. For example, it changed the x / y steps per mm to 1.25 because it divided it by 4 on blur of the field. In addition to affecting the steps per mm, it also changed the encoder scaling and all the motor speeds. It was a little painful, since I eventually discovered that I needed to go back and change all these values back to the defaults.

Okay so the issue. My max track length for the x axis is 2757mm. With 1/4 microstepping, I found that if I ask the x axis to go to a location that is <= 2684 it would reach the location and the reflected location value (from the encoder) would be correct. If I go to >= 2685, the farmbot would reach the location and then the encoder would update the location to report -2668. At this point, if I ask farmbot to go to 0, it continues to travel in the forward direction since it thinks it’s instantly on the negative axis. This seems like a variable in the farmduino firmware is overflowing causing it to flip, but I haven’t had time to troubleshoot it.

Thank you for the detailed bug report! The issue was indeed an overflow error, which has been fixed and will be included with the next FarmBot OS release.

1 Like

Thanks, I checked out your branch at https://github.com/FarmBot/farmbot-arduino-firmware/tree/scaling_overflow_bug_fix and uploaded it to my farmduino. It is working now.