Best way to implement pin writing checks

Topics about the Software of Revolution Pi
Post Reply
dmason1992
Posts: 5
Joined: 27 Jan 2021, 17:53

Best way to implement pin writing checks

Post by dmason1992 »

Hi All,

I have been reading through the https://revpimodio.org/ documentation as we are using that to control our IO module and interface with the python code in the rest of our system (ROS - Robotic Operating System). In other hardware environments I'm accustomed to the write operation returning a boolean indication that it was able to do so successfully. I can't see anywhere that this functionality is available using revpimodio? At the moment we are following the write command with a read command to the same output pin which allows us to perform this check but it doesn't feel like the most effective methodology. I have seen that there is an IO error counter is this the best way to track it? We currently have it set to 0 and aren't using that at all.

Has anyone got some good methods they are willing to share or have I missed something entirely?
VdH
Posts: 28
Joined: 04 Aug 2018, 21:32

Re: Best way to implement pin writing checks

Post by VdH »

You need to be aware that "pin writing" is not "process image writing". Process image writing can be checked by checking the RevPiModIo error state. Whenever the software is not able to write periodically in time (defined by the cycle interval of RebPiModIO) you will get an error state.
Once the data is written to the process image, the next stage is the cyclic transmission of process data to the IO modules via PiBridge. This process is completely asynchronous to the RevPiModIO cycle. If the driver "PiControl" in charge of this task cannot write to or read from the IO module, it increments the error counter RS485ErrorCnt which you can access via process image.
There is no wired feedback from the IO Outputs. If you need to be absolutely sure to have the written value at the pins, there is no other way but connecting wires from the outputs to the inputs and to read the inputs by your software.
Simply reading the outputs does not result in what you want: The reading process tells you only what is in the process image but not what is at the pins. Theoretically, even a 0-error count does not prove the outputs to be correctly set. You can test this by simply disconnecting the IO powerline for the outputs. This error e.g. could be detected by reading the IO error status (Undervoltage is detected and sets an error). But other errors like a damaged output MOSFET would not be seen.
There are not many IO controllers offering a complete feedback loop (at the pin level). So if you need to be sure about the output voltage level you always would need to use a complete set of inputs connected to the outputs to detect any errors at the hardware level.
Post Reply