I need to know if I can get acceleration data from an IMU at 500Hz via USB.
I've been going through the code that the manufacturer provides and trying to improve it. Right now I cannot go faster than 166Hz. Things I've tried:
-
Switched from streaming mode to polling. The reason is that in streaming mode the SDK of the manufacturer uses the ioctl library to know if there is new data to be read. The faster I would go was 10Hz. In polling mode, every N milliseconds data gets read from the port using a standard read command. I went from 10Hz to 166Hz, that is, for N=6. But with N<6 I get no improvement. 166Hz is a ceiling right now.
-
Increased the process priority. This has no effect at all. Maybe because I'm only running the browser and the code I'm working on?
Yes, I know linux is not a real time system. At the end of the day I'll have to live with that. I may use xenomai later on the code. But right now I need to know how fast I can go. Not theoretically, but in a real application. Any ideas about how to increase the performance?
EDIT: This are the timestamps of the time I get the data, in millisencods. Note the bursts.
1449258970519
1449258970519
1449258970525
1449258970531
1449258970531
1449258970543
1449258970543
1449258970543
1449258970549
1449258970555
1449258970555
1449258970562
1449258970567
1449258970567
1449258970573
1449258970579
1449258970579
1449258970585
EDIT: The amount of data that I have to transfer is very small… say at most 16 floats, plus some headers. I can safely assume 128 bytes is enough. So 128×1000 is still A LOT less than the 480 Mpbs that USB 2 offers.
Best Answer
You can get 166Hz.. that's interesting as I thought the default polling rate for USB was 125Hz.
Still, you'll possibly need to modify your kernel, drivers/usb/input/hid-core.c - set the polling rate there. There's a fair bit of info on the internet about updating mouse polling rates to 1000Hz (those gamers....) either with a tweak to the configuration. It might have some info relevant to your device.
You'll probably have to post this question on a Linux board to get detailed info however.
The other alternative is to buffer - most cases don't matter if you poll at 100Hz if each read grabs 10 commands of data!