Skip to content

v1.0.2 - Improves Encoder Tick Management

Compare
Choose a tag to compare
@sphawes sphawes released this 13 Nov 16:21
· 31 commits to main since this release

Summary

v1.0.2 fixes a bug with managing the encoder tick count when resetting the value to prevent an integer overflow. Users that noticed they had to reset their pick position after many feeds should find an improvement with this release.

Details

Photon we tracks the number of mm moved as ground truth, because that's the metric we ultimately care about. We keep track of where we are with an absolute value of mm moved from feeder boot. If we just count up forever, we'll eventually have an integer overflow, so Photon keeps an eye on the running tick count, and if it's ever an integer, we reset the ticks and mm traveled back to zero to keep our current distance counter low.

The way the feeder knows it's in position is if the current tick is within some threshold of the desired tick. However, when we reset the tick and mm count when our tick count is an integer, a negative tick count will accrue if the tape is at an allowable position based on the threshold, but not the exact goal tick.

This release fixes this bug by 1) reducing the threshold to 0, so the drive motor only stops (and brakes) when we reach the exact goal tick, and 2) if we happen to not be at the exact goal tick when we reset the tick count, we take that difference into account when resetting. This required updating PhotonFeeder::resetEncoderPosition to accept a value to reset to, as opposed to always resetting to zero.