I have a setup, connecting a Razor IMU sensor board, with a RS-485 Breakout board, to a USB-RS485 Serial Interface via USB-cable into my laptop. I run a software on the laptop (Max/MSP) that sends out polling messages to the sensor, waits for the response data, and on receiving the response triggers automatically a new polling message. It's a constant loop:
- send out a polling message
- wait for a response
- on response go to 1.
I want this polling to be as fast as possible, as i'll have to hook up 21 of these sensors to the same RS485-bus. The firmware on the Razor is programmed with the Arduino IDE, and according to the code there should only be a ~2ms delay between the polling message and the writing of the response. The firmware also spends 12ms every 20ms on sensor-allocation-and-calculation. This calculation sometimes delays the response to the polling. I am aware of that and all results are accordingly.
My problem right now is that the polling of the sensor is stuck at an update-rate of average 15 milliseconds. I looked at the data with my small usb-oscillosope and made a diagram (>PDF).
My oscilloscope sits directly on the USB-RS485-interface and sees the polling go out, and the response message come in. The delay between these two lies between 2 to 13 ms. This difference is explainable with the fact that sometimes the razor is busy doing its sensor-math-calculations. The weird fact is, that even though the responses come in with different delays, the polling always seems to go out at the same interval of about 15ms.
We also implemented the same setup with
- coding the firmware in C and programming the Razor with avr-dude
- doing the software-polling in Python code
- on Mac OSX and PC Windows 7
All possible combinations resulted in the same 15ms interval. So the problem is neither in the Arduino-code, nor within Max/MSP. I have the suspicion that the problem could be due to the USB-RS485 Serial Interface and/or the necessary FTDI driver.
Does this problem sound familiar to anyone??