PLC- Touchberry PI RS485/RS232

In this post we are going to learn how to send data between Industrial Shields PLCs and TouchBerry PI PanelPc. In order to apply or implement the functionalities and examples described, the TouchBerry PI is assumed to include the suitable preloaded image. All PanelPC acquired as of 21-08-2015 will include the required image. For those PanelPC acquired before 21-08-2015 the procedure to install the new compatible image will be provided via email.

RS485

Industrial Shields PLCs provide the A B connection for RS485 protocol. Raspberry PI 2B requires to configure the control/chip pin (any GPIOS) to connect to the MAX485 component. For this example we take pin 25 from the TouchBerry PI D37 connector (GPIOS 18) as chip/control pin. Steps to configure the 25 PIN as chip/control on Raspberry Pi.

With the code above the Raspberry PI RS485 protocol is set-up and configured to transmit state.

Table 3. Touchberry PI to MAX485 connection reference

D37 connector

MAX485

22 (GND)

–>

RE

23 (TX)

–>

DI

24 (RX)

–>

RO

25 (CS)

–>

DE

*TX and RX cables connection is not cross between D37 to MAX485 Now to test that the communication between PLC and Rasberrry PI is enabled we are going to send some sentences through RS485 and RS232.

Open minicom on Touchberry PI.

Type the following:

sudo minicom -D /dev/ttyAMA0 -b 4800

Any code written on the console should be send through RS485 to the PLC. With the Serial Monitor on the PLC we can see the code typed on the Touchberry PI console. The Arduino code to read messages on the RS48 Bus is here. Another example shows the Arduino code to send data to the Touchberry PI through the RS485 bus.

RS232

For RS232 there is no control pin, compared to RS485, so no configuration instructions are required. To connect the PanelPC to the MAX232 the pins 22 (GND), 23 (TX), 24 (RX) (Table 4) are to be linked to to the MAX232 pins GND, TX, RX Table.4