@@ -1367,4 +1367,35 @@ Competing approaches would be

I think the second manner is actually best, so I'm giving that a shot. First step I take is to translate from rotary measurements -> linear / unrolled-rotary position, wrapping around & incrementing a 'revolutions' count, then I calculate 'real position' with revs * angular_pos.

Just taking a minute to figure out the particulars on this one... `a r i t h m e t i c`

\ No newline at end of file

Just taking a minute to figure out the particulars on this one... `a r i t h m e t i c`

OK, here's my counting-the-revs code

```cpp

// stash this,

enc_reading=result;

// stash old measurement, pull new from LUT

a_reading_last=a_reading;

a_reading=lut[result*2];

// check for wraps around the circle,

// i.e. if we went from 359 -> 1 degs, we have gone around once,

// if we went from 1 -> 359, we have decrimented one rev

if(a_reading-a_reading_last>180.0F){

revolutions--;

}elseif(a_reading_last-a_reading>180.0F){

revolutions++;

}

// now we have a real position measurement:

p_est_last=p_est;

p_est=(float)revolutions*360.0F+a_reading;

```

Now I can do the derivative, error, and integral all in terms of actual error on the long number line, no wrapping to worry about. Great: do it once, forget about it.

I think I'll get that back up and running... and target a wider range of positions, should be all tuned in already, and then I'm kind of finished with this step... next would be to bring it into a real machine context, benchtop test a new VM with an accel controller feeding it positions.