Statusbytes RevPi Connect

The RevPi Connect modules have LEDs, three of which can be used freely. In addition, the watchdog and the relay can be controlled via the RevPiLED LED control byte.

BitComponentMeaning
0LED A1 If the bit is set to 0, the LED is off. At 1 it lights green.
1If the bit is set to 0, the LED is off. At 1 it lights red.
2LED A2If the bit is set to 0, the LED is off. At 1 it lights green.
3If the bit is set to 0, the LED is off. At 1 it lights red.
4LED A3If the bit is set to 0, the LED is off. At 1 it lights green.
5If the bit is set to 0, the LED is off. At 1 it lights red.
6RelaisIf the bit is set to 0, the relay at connector X2 is closed, at 1 it is open.
7WatchdogTo restart the watchdog timer, the bit must be set once to 0 and once to 1 within 60 seconds.

If one LED is red and green switched on at the same time, it lights up orange.

In the directory /home/pi/demo there is the header file piControl.h in the defines PICONTROL_LED_A… for these LEDs. A small example program follows below.

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

BitMeaning
0, 0x01piControl driver running
1, 0x02At least one I/O module is connected that has not been configured with PiCtory.
2, 0x04At least one I/O module with PiCtory has been configured, but it is not connected. The bit is also set if a piGate has been configured.
3, 0x08An I/O module takes up more or less bytes in the process image than specified in the PiCtory configuration. This can only 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, 0x10A piGate module is connected to the left of the RevPi.
5, 0x20A piGate module is connected to the right of the RevPi.
6, 0x40Current value of the input at connector X2. 0 corresponds to 0V, 1 corresponds to 24V.

The programm piTest -dshows in detail which modules are connected and whether they have been configured in PiCtory or not.

PiCtory configuration

Please note that only the desired bit in the byte RevPiLED should be changed. If you want to switch on e.g. LED A3 green, you can call PiTest -w RevPiLED,16. However, this switches off LEDs A1 and A2 at the same time. You have to read the current value, change the desired bit and then write back the whole byte.

In C you can use an ioctl call that does just that. The following example also turns LED A3 green, but leaves the other LEDs unchanged.

int hd;
SPIValue sPIValue;

hd = open(PICONTROL_DEVICE, O_RDWR);
sPIValue.i16uAddress = 116;
sPIValue.i8uBit = 4;
sPIValue.i8uValue = 1;
ioctl(hd, KB_SET_VALUE, &sPIValue);

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.