Agenda
- Setup a keep alive network for couplers
- Evaluate and test the keep alive network for couplers
Goal
When running a control loop processes with a rPLC coupler and their respective physical processes (electrical motors running, moving parts, etc) it is extremely important that if a certain coupler goes out of order then dependent on it couplers also do stop work. The idea is that if one component from the system is mail functioning the entire system stops work. In case of rPLC coupler this safety feature is implemented with so called keep alive network. The keep alive network itself consists of one MASTER coupler and one or many SLAVE couplers. The MASTER coupler keeps broadcasting "signals" over the network which represent that the coupler is alive thus all SLAVE coupler know that everything is OK. In case of not receiving such "signals" from MASTER withing a designated time interval SLAVE couplers assume that they must stop work on go to so called safe mode.
At end of this howto one will be able to:
- run multiple couplers with a keep alive network between them based on multicast OPC Ua Pub / Sub
- test the keep alive network functioning
Requirements
You need to have gone thoroughly from following how tos. Please note that the order is important!
- You will need at least two physical rPLC coupler devices . You can read how to build a coupler here
- You will need to have a proper operating system installed on the couplers. You can read how to install here
- You will need to setup SlapOS on these couplers. You can read how to setup it here.
- You will need a proper setup of multicast network. You can read how to setup it here.
Architecture
Following figure shows one master coupler and two dependent on it slave couplers.
![](https://rplc.nexedi.com/P-OSIE.TSN.Keep.Alive.Master.Slave Architecture?format=)
The real implementation of the keep alive network for couplers is based on OPC UA Pub / Sub mechanism on top of an TSN capable IPv4 (or IPv6) multicast network.
Keep alive network setup
For the sake of tutorial we will create a keep alive network between two couplers: stm32mp1-2 (with ID=1 and acting as a master) and stm32mp1-3 (with ID=2 and acting as a slave). Our goal will be to test at the end that a stop of a master coupler stops slave coupler as well.
Setup master coupler in SlapOS
We assume that you have a coupler and it has a proper coupler instance in SlapOS as described in here. To make a coupler act like a master we need to adjust parameters as shown below:
![](https://rplc.nexedi.com/rplc-HowTo.Setup.KeepAliveNetwork.Screenshot1?format=)
where the parameters mean
- id - the unique integer ID of the coupler. It must be unique for each coupler in the same network
- heart_beat - a parameter which turn coupler into a master (makes it send heart beat "signals" on the network)
Setup slave coupler in SlapOS
We assume that you have a coupler and it has a proper coupler instance in SlapOS as described in here. To make a coupler act like a slave we need to adjust parameters as shown below:
![](https://rplc.nexedi.com/rplc-HowTo.Setup.KeepAliveNetwork.Screenshot2?format=)
where the parameters mean
- id - the unique integer ID of the coupler. It must be unique for each coupler in the same network
- heart_beat_id_list - a parameter which instructs coupler that it must monitor for keep alive "signals" coming from coupler with respective ID (1 in this case). If no such a "signals" is received a coupler will go to a safe mode.
Test proper functioning of keep alive network
By default with configuration above the once both slave and master couplers' instance processes are started the slave coupler will automatically go to normal functioning mode once a keep alivŠµ "signal"is received from master coupler this is indicated by following log as seen in image (keep in mind that your setup may differ in terms of slappart number!)
![](https://rplc.nexedi.com/rplc-HowTo.Setup.KeepAliveNetwork.Screenshot3?format=)
In order to simulate a master coupler mail functioning it is enough just to stop it by issuing command below.
![](https://rplc.nexedi.com/rplc-HowTo.Setup.KeepAliveNetwork.Screenshot4?format=)
Then on respective slave coupler you should see following logs (in red) which means that slave coupler is in safe mode.
![](https://rplc.nexedi.com/rplc-HowTo.Setup.KeepAliveNetwork.Screenshot5?format=)
You can again start already stopped master coupler by issuing command below (see image) and make sure that slave coupler goes immediately to safe mode
![](https://rplc.nexedi.com/rplc-HowTo.Setup.KeepAliveNetwork.Screenshot6?format=)
The keep alive network is designed in such a way that it covers all aspects of a mail functioning of the system. It will prevent dependent coupler from working by putting them in a safe mode in all cases of:
- entire network failure (due to physical connecting cable cut)
- router and / or intermediate switch failure
- application error in coupler code
- and more