Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Timing issues with EV3 UART sensors. #24
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...
However, quite often, this happens...
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.
The hard fix would be to make receiving the UART data in the BrickPi happen asynchronously and cache the most recent value. Then the EV3_Update function could always just return the most recent value without having to wait for a send and receive to/from the UART sensor.