Commit 980a360c authored by Jake Read's avatar Jake Read
Browse files

wrap notes

parent cb7f289a
......@@ -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 --;
} else if (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.
- re-integrate I and D terms
- tune back in
- set 'units per rev'
- test, OK
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment