KurtE
Senior Member+
Currently I am playing around with my Teensy Bioloid Servo controller code and I am migrating the servo interpolation code from the host code into the Servo controller code...
Basically every N milliseconds (example 20), the code walks through the different servo locations and adds (or subtracts) a delta to the current position and then we output a SYNC_WRITE command over the serial port(1mbs). Example case is 3dof hexapod with maybe a pan/tilt. So 20 servos. If all servos are moving, the SYNC_WRITE command would be something like:
0xff 0xff <id> <length> <SYNC_WRITE> <2 bytes per servo><id 0><new pos 0 L> <new pos 0 H> ... <id servo 20> <new pos 20 L><new pos 20 H><checksum>.
So talking about output of 20*3+7 or 67 bytes...
Right now in my Teensy code base I am trying to decide if this will work within an Interval Timer, as I believe that the interval timer runs as an ISR. In the majority of cases, my packets will be under the default size for Serial1 tx buffer, and as such the Serial1.write calls will simply copy the data into the buffer. However not sure what happens if I fill the output buffer within the Interval timer ISR...
So I will probably answer my own question. Should I instead just do this in the main loop? Simply check to see if the appropriate time has expired and call off to do the interpolation. My guess is it is safer to go this route.
Note: My main hexapod currently only has Pan servo (removed tilt), so the actual SYNC_WRITE would be 64 bytes if all servos are moving.
Thoughts?
Thanks
Kurt
Basically every N milliseconds (example 20), the code walks through the different servo locations and adds (or subtracts) a delta to the current position and then we output a SYNC_WRITE command over the serial port(1mbs). Example case is 3dof hexapod with maybe a pan/tilt. So 20 servos. If all servos are moving, the SYNC_WRITE command would be something like:
0xff 0xff <id> <length> <SYNC_WRITE> <2 bytes per servo><id 0><new pos 0 L> <new pos 0 H> ... <id servo 20> <new pos 20 L><new pos 20 H><checksum>.
So talking about output of 20*3+7 or 67 bytes...
Right now in my Teensy code base I am trying to decide if this will work within an Interval Timer, as I believe that the interval timer runs as an ISR. In the majority of cases, my packets will be under the default size for Serial1 tx buffer, and as such the Serial1.write calls will simply copy the data into the buffer. However not sure what happens if I fill the output buffer within the Interval timer ISR...
So I will probably answer my own question. Should I instead just do this in the main loop? Simply check to see if the appropriate time has expired and call off to do the interpolation. My guess is it is safer to go this route.
Note: My main hexapod currently only has Pan servo (removed tilt), so the actual SYNC_WRITE would be 64 bytes if all servos are moving.
Thoughts?
Thanks
Kurt