Setup:
Spin a V5 motor at 6 volts in a 50ms loop. Print out the raw encoder values along with the system high resolution timer (for a time reference). Do the math to find out how many raw ticks you get per 50ms loop.
Observations:
I’m seeing 83-86 raw counts per 50ms loop, mostly 84 and 85 once we’re up to speed. I see a tick up to 93 or 94 raw counts, sometimes at 145003us intervals, and sometimes at 140003us intervals. It’s very consistent.
I’ve tried this with VCS and RMS, both C++ and Python. Same results. I’ve also left the counter running versus resetting it every loop and using a different motor. I’ve set the motor speed with voltage and percent power, read the encoder in degrees, raw, and rotations. No change. I also thought that maybe the debugger or console might cause a periodic delay, but disconnecting and pushing the output to the V5 Brain LCD didn’t change anything either.
Any ideas on what I’m seeing, and if it’s expected or not?
int main(void) {
// Start here
motor1.resetRotation();
motor1.spin(vex::directionType::fwd,6,vex::voltageUnits::volt);
int loop = 1;
timer t = timer();
while(loop < 500) {
std::cout << (t.systemHighResolution());
std::cout << (" ");
std::cout << (motor1.rotation(vex::rotationUnits::raw));
std::cout << ("\n");
loop = loop + 1;
sleepMs(50);
}
}
Sample output (the first and last rows are the odd counts, the last two columns are calculated in Excel):
Time in us | Raw Encoder Count | Time Delta | Rotation Delta |
---|---|---|---|
3138624 | 4831 | 50000 | 93 |
3188624 | 4916 | 50000 | 85 |
3238624 | 5000 | 50000 | 84 |
3288624 | 5085 | 50000 | 85 |
3338624 | 5170 | 50000 | 85 |
3388624 | 5254 | 50000 | 84 |
3438625 | 5338 | 50001 | 84 |
3488625 | 5422 | 50000 | 84 |
3538625 | 5508 | 50000 | 86 |
3588625 | 5592 | 50000 | 84 |
3638625 | 5676 | 50000 | 84 |
3688625 | 5761 | 50000 | 85 |
3738625 | 5846 | 50000 | 85 |
3788625 | 5930 | 50000 | 84 |
3838625 | 6014 | 50000 | 84 |
3888625 | 6100 | 50000 | 86 |
3938625 | 6184 | 50000 | 84 |
3988626 | 6269 | 50001 | 85 |
4038626 | 6353 | 50000 | 84 |
4088626 | 6438 | 50000 | 85 |
4138626 | 6522 | 50000 | 84 |
4188626 | 6607 | 50000 | 85 |
4238626 | 6691 | 50000 | 84 |
4288626 | 6776 | 50000 | 85 |
4338626 | 6860 | 50000 | 84 |
4388626 | 6945 | 50000 | 85 |
4438627 | 7029 | 50001 | 84 |
4488627 | 7114 | 50000 | 85 |
4538627 | 7198 | 50000 | 84 |
4588627 | 7291 | 50000 | 93 |