I’m trying to write a code for a magnetic encoder that I have installed onto a motor.
I’m using this code written by system here.
I’m having two issues. The first I don’t understand where the 2 came from in this equation.
const float konstant = 60.0 * upDatesPerSec / (ppr * 2);
60 is for rate per MINUTE, multiplied by the updates per sec in case the frequency is increased. the PPR is dependent on the encoder. My issue is specifically with that last 2. Where did it come from?
Encoder is 12 PPR (or 20, both numbers are written in the webpage). The motor in the rover is said to have a gear ratio of 30:1.
So supposedly each revolution of the wheel should be 12*30 = 360 pulses. What I’m actually getting is 230 constantly in one direction and 130 constantly in the other direction. Not sure if there’s something wrong with the code or are the wheels literally slipping at a constant rate somehow.