Status bytes & LEDs on RevPi Core

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

Poweron, greenRevPi Core is running
on, redThe piControl driver resets, the modules connected to the PiBridge are reinitialised.
A1offIn the “RevPiLED” byte, bits 0 and 1 are set to 0.
on, greenIn the “RevPiLED” byte, bit 0 is set to 1 and the bit 1 is set to 0.
on, redIn the “RevPiLED” byte, bit 0 is set to 0 and the bit 1 is set to 1.
on, orangeIn the “RevPiLED” byte, bits 0 and 1 are set to 1.
A2offIn the “RevPiLED” byte, bits 2 and 3 are set to 0.
on, greenIn the “RevPiLED” byte, bit 2 is set to 1 and bit 3 is set to 0.
on, redIn the “RevPiLED” byte, bit 2 is set to 0 and bit 3 is set to 1
on, orangeIn 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 programme follows below.

The “RevPiStatus” byte is given the status of the piControl driver. Please remember that the I/O-Modulen (DIO, DI, DO, AIO, …) and piGate modules are differentiated between.

0, 0x01piControl driver is running
1, 0x02There is at least one connected I/O module that has not been configured with PiCtory.
2, 0x04There is at least one I/O module that has been configured with PiCtory. The bit is also set when a piGate is configured.
3, 0x08A I/O module occupies more or less byte in the process image than stated in the PiCtory configuration. This can only happen when the version of the configuration file or the used device description files respectively do not match the firmware in the I/O module. Get yourself a PiCtory update.
4, 0x10A piGate module is connected to the left of RevPi.
5, 0x20A piGate module is connected to the right of RevPi.

The piTest -d programme details which modules are connected and whether they have been configured in PiCtory or not.

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) 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 so always in turn.

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 will the following error handling 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 RS485ErrorLimit2 has reached, the piBridge communication is stopped.

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

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