Redundancy in Automation System
Introduction
The purpose of this example is to demonstrate how a CDPPort and PortMUX can be used to achieve switching between redundant applications providing two alternative sources of input data. Redundancy is typically used to achieve high availability for mission-critical systems to allow parts of the system to fail while the system as a whole does not lose its function. Depending on the systems requirements this requires both the hardware and the software in the system to be redundant. This example demonstrates only one aspect of making a redundant solution, selecting between two sources of redundant data.
The example makes use of NoCode and LowCode programming similar to PLC IEC 61131-3 with C++ being used instead of Structured Text to declare interfaces and code based blocks in CDP Studio, the independent automation software for open PC-based real-time distributed control systems.
This example does not cover setting up controllers and redundant networks between the controllers to achieve hardware redundancy, but just to show that building redundant systems with CDP Framework is feasible.
How to Run the Example
To run the example from CDP Studio, open Welcome mode and find it under Examples. Next, in Configure mode right-click on the library project and select Build, then right-click on the system project and select Run & Connect. See the Running the Example Project tutorial for more information.
Project Overview
This example includes:
- A library project containing one interface/port pair for data and one port for redundancy source selection values
- IWaveData - defines an interface port that can be used as a proxy port in configuration. IWaveData is used when just the connection of the port chain needs to be propagated to some other location.
- WaveData - inherits from IWaveData and adds data values SinValue and CosValue. WaveData should be used when propagating data to the port location is necessary.
- RDSource - contains data values Reset and StartTime that are needed to select the best working data source for wave data.
- A system project containing three applications:
- Consumer - contains RDSelector, PortMUX and WaveAnalyzer components which are connected by WaveData, RDSource and Control ports.
- ProducerA - contains WaveSource (the wave data generator) and WDSource (watchdog timer).
- ProducerB - contains WaveSource (the wave data generator) and WDSource (watchdog timer).
In this example, the Consumer application has a Control port that contains Time, Offset and Amplitude for the producer WaveSource control.
The Consumer application's RDSelector monitors the changing timestamp in RDSource ports and when both are updating it prefers the Index of the RDSource that has the smaller StartTime. PortMUX uses the Index from RDSelector to switch between the two separate sources of WaveData to have stable sine and cosine signals for the WaveAnalyzer.
The two producer applications ProducerA and ProducerB contain a WaveSource that generate sine and cosine waves with Time and other configuration from Consumer applications. They provide the wave data in WaveData port and also provide RDSource port with information about their startup time and current timestamp that the consumer can monitor for changes.
RDSelector
RDSelector monitors the changing Reset value in RDSource port with WatchdogTimer operator. When the Reset stops updating the WatchdogTimer will set its Timeout output high. The Timeout is used to control a MUX operator to switch from the StartTime value coming from the producer application to 0 value.
The PriorityEncoder is setup up to ignore zero values and to pick the lowest valued input index (Mode is set to InvertedPriority). The output from the encoder is used to finally create the Index output for the RDSelector.
The RDSource port is code-based for it to be possible to control the disconnecting behaviour of the StartTime value in the port. The StartTime value should go to zero as soon as the source application closes so the last value is not kept. If the StartTime would keep the last value it may be present for a short while when the source reconnects and this may cause the PriorityEncoder to the new connecting application as the source for a short while because the StartTime is still old.
For this reason the RDSource port code sets the KeepLastValueOnDisconnect to be "0".
StartTime.SetKeepLastValueOnDisconnect("0");
PortMUX
The standard PortMUX component is used to switch between the two producer application WaveData ports. The WaveData ports are code-based ports with local value properties in the PortMUX to speed up the multiplexer switching. When the data is locally available the switching will be considerably faster compared to when the output port of the PortMUX would need to connect to the values in the producer application when the switch occurs.
IWaveData and WaveData
The port pair is provided as an example implementation on how to have both interface and concrete implementation with CDPPort. The interface IWaveData can be used as a proxy port and WaveData when local values are required. This kind of port pair ensures that users can only connect IWaveData or WaveData ports to each other and can't make mistakes while connection ports.
Note: The only exception to the connecting rule is when connecting such a port to CDPPort or connecting CDPPushPort to such a port. These connections will always be allowed.
IWaveData and WaveData are both created with Port wizard (Add New -> CDP Port Model). Also, the inheritance of WaveData in C++ has been set to IWaveData and the BaseModel has been set to RedundantSourcesLib.IWaveData. For both models, the Routing attributes modifier called Routing has been set to RedundantSourcesLib.IWaveData to restrict the routing behaviour to work only for models inheriting from IWaveData.
Testing the redundancy
The project also contains Analyze mode plot configurations file called RDPlots.cac, which can be loaded in Analyze mode. When running the example system and looking at the plotted values it is possible to monitor the redundancy source switching. For this, one of the Producer applications needs to be stopped, this can be done in Application Output pane by using the stop button in the correct applications tab. The Consumer plot contains the Index value showing the WaveData source being used.
Get started with CDP Studio today
Let us help you take your great ideas and turn them into the products your customer will love.