-
Notifications
You must be signed in to change notification settings - Fork 167
Description
I've notice that the EV3 UART sensors return an error value quite often instead of the sensor value. Usually, the value is -2, and sometimes -4. I can see these are error values returned by the EV3_Update function. I stuck my logic analyzer on it and immediately saw the problem.
Normally, the timing works like this...
- The RPi polls the BrickPi by executing the BrickPiUpdateValues function.
- The BrickPi sends a keep-alive (called NAK in the code) to the UART sensor.
- The UART sensor sends back data in response to keep-alive.
- The BrickPi sends the data back to the RPi.
However, quite often, this happens...
- The RPi polls the BrickPi by executing the BrickPiUpdateValues function.
- The BrickPi sends a keep-alive (called NAK in the code) to the UART sensor.
- (This happens after 4, which is too late.) The UART sensor sends back data in response to keep-alive.
- The BrickPi sends the data back an error because there was not data to be read.
It seems that this happens most often when data value is changing rapidly. A couple of easy fixes would be to A) wait a bit longer for the UART sensor to respond before sending an error or B) send the previous value received.
I've worked around this for now by filtering out the error values, but it makes the sensor unresponsive for noticeable periods of time, which does not make for good robot building. Also, some of the sensors can return negative values in certain modes, so I also have to filter out possibly good data in those modes, which is not nice.

