Encoder reset on power up

Currently our encoders resets their values during power up. Has anyone figured out a way to not lose those encoder values?

What’s your usage case? This would mean that the encoder values from previous matches would be restored when you switched on the robot. Perhaps this could be beneficial for debugging, but I don’t know why you’d want to start off the actual encoder readings with the old values. I’m not debating so much as I’m just curious.

If you do want to do something like this, I’d recommend periodically writing the current encoder value to a file on the cRIO, then add code to read from that file when the cRIO boots up. Make sure to not write to the file every time through your main code loop as it will slow down your robot’s responsiveness. You might want to start a different task if using WindRiver, or create a parallel while loop if using LabVIEW.

As far as I know, there’s no other way to retain data through a power cycle.

–Ryan

We want the encoder to retain it’s values because it’s going to be use for something with our drive system. So say at the end of the match the wheels are at one position but since you shut the robot off the values of the encoder are gone so then we would therefore have to recalibrate the encoder to read 0 when the wheels are straight…

Sorry i’m a nub programmer xD so how would I go about making the the robot “write the current encoder value to a file on the cRIO, then add code to read from that file when the cRIO boots up”?

If you need to measure the absolute position of something, a quadrature encoder is not a good choice. Is there any way you can substitute a potentiometer (perhaps a multiple-turn one) or a magnetic shaft encoder?

As Alan says, an absolute sensor is a much better way to go. Consider, even if you saved the state of your drive system (for example the position of crab/swerve drive modules), there’s nothing that prevents that state from changing between matches because i.e. someone accidentally bumps the robot while it’s being transported.

While I have not used them myself, I highly respect US Digital as a brand, and it appears as if they have a couple of good choices. Depending on your budget, there’s both an optical version and a magnetic version of absolute encoder. (You may or may not have to shield the magnetic version if using it in close proximity to a motor. Someone want to comment on this?) I’d recommend getting one with an analog output for ease of use, then just wire it to an Analog Input module on the cRIO.

–Ryan