I ran across a very puzzling increase in the motor and encoder status function timings as the delay between calls goes up.
The “normal average” time for two get_motor_status(), (left+right), seems to be around 110us, and the “normal average” time for two get_motor_encoder() calls seems to be around 100us.
If I insert successively longer delay between each set of two calls, the time goes up to 300us for the (left+right) calls.
Any ideas what is going on with these weird timings?
(BTW, I also tested repeated runs with delay always 0.010 sec , no increase in timings.)
Here is my test code: timeMotorStatus.py and timeGetMotorEncoder.py
Timings for get_motor_encoder()
“”"
pi@Carl : ~/Carl/systests/motors $ ./timeGetMotorEncoder.py
Timing get_motor_encoder().
Timing: 0.000113
Timing: 0.000098
Timing: 0.000096
Timing: 0.000091
Timing: 0.000097
Timing: 0.000092
Timing: 0.000090
Timing: 0.000092
Timing: 0.000103
Timing: 0.000092
Delay between readings: 1ms
2x get_motor_encoder() Average Time: 96 us
…
Delay between readings: 5ms
2x get_motor_encoder() Average Time: 99 us
…
Delay between readings: 10ms
2x get_motor_encoder() Average Time: 106 us
…
Delay between readings: 100ms
2x get_motor_encoder() Average Time: 140 us
…
Delay between readings: 500ms
2x get_motor_encoder() Average Time: 298 us
…
Delay between readings: 1000ms
2x get_motor_encoder() Average Time: 301 us
…
Delay between readings: 2000ms
2x get_motor_encoder() Average Time: 302 us
“”"
Timings for get_motor_status()
“”"
Timing get_motor_status().
Timing: 0.000128
Timing: 0.000115
Timing: 0.000109
Timing: 0.000114
Timing: 0.000113
Timing: 0.000108
Timing: 0.000108
Timing: 0.000108
Timing: 0.000114
Timing: 0.000108
Delay between readings: 5ms
2x get_motor_status() Average Time: 112 us
…
Delay between readings: 10ms
2x get_motor_status() Average Time: 116 us
…
Delay between readings: 100ms
2x get_motor_status() Average Time: 140 us
…
Delay between readings: 500ms
2x get_motor_status() Average Time: 287 us
…
Delay between readings: 1000ms
2x get_motor_status() Average Time: 291 us
…
Delay between readings: 2000ms
2x get_motor_status() Average Time: 317 us