RS485 HalfDuplex Sensor in RealTime

Topics about the Software of Revolution Pi
Post Reply
Mopele
Posts: 1
Joined: 03 May 2021, 13:28

RS485 HalfDuplex Sensor in RealTime

Post by Mopele »

Hello,
I am planning on a project, where I want to read out a RS485 Sensor with the RevPi. This should be really fast, like 1kHz, so 1000 times a second. Before I buy the RevPi and the Sensor I want to have an expert opinion if this is possible.
I think the Revpi has a realtime linux right? If yes, how do I use it to read and write to the serial every 14ms?

The Dataformat from the sensor is this: 1 Startbit, 8 Datenbits, 1 Paritätsbit (gerade), 1 Stoppbit. Is the parity-bit a problem?

I also plan on hooking up a second sensor to the RevPi, should I get a second one for that or can I use the same connector and dasy-chain them?

Thanks so much for your advice! I am sure it will really help me!
User avatar
p.rosenberger
Posts: 91
Joined: 03 Jul 2020, 11:07

Re: RS485 HalfDuplex Sensor in RealTime

Post by p.rosenberger »

Hi Mopele,

this depends on the Revpi you want to use. The RS485 of the Connect is implemented with an USB FTDI chip. Which might give you a worse realtime experience. The RevPi Flat has tow RS485 which utilize the internal UARTs of the BCM2837. But I'm afraid I can't give you a definitive answer for this.

The 14ms don't seem to hard to reach, but maybe some on has done something similar and can give some insight view.

Best Regards
Philipp
User avatar
RR4711
Posts: 229
Joined: 22 Feb 2018, 13:28

Re: RS485 HalfDuplex Sensor in RealTime

Post by RR4711 »

I honestly doubt the 14ms is "easy to archive" as even your piBridge protocoll stack / kernel mode driver had issues keeping up with the traffic on the RS485 even at the 115200 baud on the piBridge using the internal UART of the SoC.

I made extensive tests even isolating a core and dedicating it to just the kernel / Kernel Thread handling the UART but we still had corrupted messages. There was lots of debugging which led to releases of new DIO and AIO FW and updates to the kernel.

I'm not sure if there were more improvements made in the latest Kernels but I will also do more tests to see if that is finally fixed. So from my experience I think it will be quite challenging (though AFAIR a RT Kernel was demostrated to have latencies around 70us on a Raspi 3).
User avatar
p.rosenberger
Posts: 91
Joined: 03 Jul 2020, 11:07

Re: RS485 HalfDuplex Sensor in RealTime

Post by p.rosenberger »

Hi RR4711,

the PiBridge is a chapter on its own. And you are right the realtime latencies of the Raspi3 are around 70us (also up to a little more then 100us). OSADL has a Raspi3 in its test rack[1]. It depends on how much data should be processes over the UART (RS485) and what should be done with the data. But 14ms might be doable. In the end only a test with the real load will show it.

Best Regards
Philipp

[1] https://www.osadl.org/Latency-plot-of-s ... l?shadow=1
Post Reply