dIMU and the C demo


There is something fishy with the C demo code for the dIMU sensor.

When I run it, it seems to randomly pause the execution for nearly a second. My first idea was that pi has problems with the X system overhead for the text display. The problem gets far more obvious if you comment out the sleep command at the end of the loop. But on my fresh minibrick system without X I see the same behaviour…

Next i tried the python dIMU example: no problem whatsoever, all running smooth and fast, no stops, no nothing, even if i drop the sleep command at the end.

When I stop the python demo program with <ctrl>-C I can run it again and again. But the C demo wouldn’t start, it only sets up the sensor and finishes. Unplugging the sensor does not help, I have to reboot to get the C program back to work. I can <ctrl>-C the C program and start it again, no problem, but I can’t run it after the phython program.

Both programs get more or less the same results. I assume the reading is ok, als long as it works.




made some small changes to the demo programs. No output, 100 loops, calc maxTime and minTime per Loop in milliseconds. Result: maxTime in C is totally over the top, maxTime in phython is not good, I don’t like it to be factor 2 or 3 higher then minTime, but ok. In the end the python program runs 10 times faster then the C program. Interesting: what kills the C program is the sys time, nut the user time. No idea what to make out of all this…

pi@dex ~/src $ time ./gyrolib
BrickPiSetup: 0
BrickPiSetupSensors: 0
maxTime = 5039; minTime = 12

real 0m52.026s
user 0m3.290s
sys 0m10.270s
pi@dex ~/src $ time python DI-dIMU_Test.py
Accelerometer Gyroscope
maxTime: 59 minTime: 46

real 0m5.289s
user 0m4.460s
sys 0m0.550s
pi@dex ~/src $ time python DI-dIMU_Test.py
Accelerometer Gyroscope
maxTime: 104 minTime: 45

real 0m5.292s
user 0m4.460s
sys 0m0.450s