Skip to content

Timing issues with EV3 UART sensors. #24

@dlech

Description

@dlech

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...

selection_012

  1. The RPi polls the BrickPi by executing the BrickPiUpdateValues function.
  2. The BrickPi sends a keep-alive (called NAK in the code) to the UART sensor.
  3. The UART sensor sends back data in response to keep-alive.
  4. The BrickPi sends the data back to the RPi.

However, quite often, this happens...

selection_013

  1. The RPi polls the BrickPi by executing the BrickPiUpdateValues function.
  2. The BrickPi sends a keep-alive (called NAK in the code) to the UART sensor.
  3. (This happens after 4, which is too late.) The UART sensor sends back data in response to keep-alive.
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions