CODESYS Status Bytes & LEDs on the RevPi Core

RevPi IO Cycle

The overall cycle time is typically around 5 ms to 10 ms depending on the system configuration but could be longer for a large configuration.
This is the time it takes for a change in input or output to be realized in the memory of the RevPi controller. This happens usingin a background process that polls the modules to read values and writes to them when a change in the local device file is detected.

Codesys RevPi Core Mapping Values
RS485ErrorLimit1: 10
RS485ErrorLimit2: 1000
If the standard values shall be modified, you have to assign the values in the corresponding POU.

The RevPi Core modules contain LEDs of which one shows the device status and two can be used as desired.





on, green

RevPi Core is running.

on, red

The piControl driver resets, the modules connected to the PiBridge are reinitialized.



In the “RevPiLED” byte, bits 0 and 1 are set to 0.

on, green

In the “RevPiLED” byte, bit 0 is set to 1 and the bit 1 is set to 0.

on, red

In the “RevPiLED” byte, bit 0 is set to 0 and the bit 1 is set to 1.

on, orange

In the “RevPiLED” byte, bits 0 and 1 are set to 1.



In the “RevPiLED” byte, bits 2 and 3 are set to 0.

on, green

In the “RevPiLED” byte, bit 2 is set to 1 and bit 3 is set to 0.

on, red

In the “RevPiLED” byte, bit 2 is set to 0 and bit 3 is set to 1.

on, orange

In the “RevPiLED” byte, bits 2 and 3 are set to 1.

In the directory /home/pi/demo, there is the piControl.h header file in which PICONTROL_LED_A… is defined. A little sample program follows below.

The byte ’RevPiStatus’ contains the status of the piControl driver. Please note that a distinction is made here between that the I/O-Modules (DIO, DI, DO, AIO, MIO…) and piGate modules.



0, 0x01

piControl driver is running.

1, 0x02

At least one I/O module is connected that has not been configured by PiCtory.

2, 0x04

At least one I/O module by PiCtory has been configured, but it is not connected. The bit is also set if a piGate has been configured.

3, 0x08

An I/O module takes up more or less bytes in the process image than specified in the PiCtory configuration. This can happen if the version of the configuration file or the device description files used does not match the firmware in the I/O module. Get an update of PiCtory.

4, 0x10

A piGate module is connected to the left of the RevPi.

5, 0x20

A piGate module is connected to the right of RevPi.

The status byte “RS485 Count” controls the communication with the I/O modules. This is interesting for you if you want to integrate your own devices into your system.

The RevPi I/O modules (AIO, DIO, DO, DI, MIO) exchange data with the RevPi via a serial line. The data is transmitted electrically according to the RS485 standard.

The piControl driver scans which modules are connected during startup and reset. It then communicates cyclically with the modules in the order in which they are mounted on the DIN rail from left to right next to the RevPi. First, piControl reads the output values for the respective module from the process image and sends them to the I/O module. In response, the RevPi receives the input values and writes them into the process image. Then it does the same with the next module and continues sequently.

Although RS485 is insensitive to interference, it can still happen that the data is disturbed during transmission between RevPi and IO module. piControl has an internal error counter for each module. If a transmission error has occurred, the counter is incremented. The maximum value of the counter is 255. As soon as a telegram has been transferred correctly between RevPi to IO module and back, the counter is reset to 0. The first error is ignored, i.e. only if 2 or more errors occur in succession the following error handling will become active.

The value RS485ErrorCnt contains the sum of all errors. The value can therefore be between 0 and 255*n if n I/O modules are connected. At the end of each cycle, the error counter is compared with the two limit values RS485ErrorLimit1 and RS485ErrorLimit2. If it has reached RS485ErrorLimit1, a message is output in kern.log. In the next version of piControl, the default values defined in PiCtory are written to the process image. If the error counter has reached RS485ErrorLimit2, the piBridge communication is stopped.

If one of the values is set to 0, the respective check is deactivated.

RS485ErrorLimit1 is set to 10 and RS485ErrorLimit2 is set to 1000 as default.