In this post we are going to learn how to send data between Industrial Shields PLCs and HummTouch PanelPc. In order to apply or implement the functionalities and examples described, the PanelPC HummTouch Linxu/Android 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.
The following chart shows the D37 connector pinout for the HummTouch (Android and Linux).
Table 1. HummingBoard/HummTouch pinout reference
||HummTouch D37 CONNECTOR pin
HummTouch supports TTL (5V-0V) serial communication through the D37 connector. MAX485 and MAX232 components are required to adapt to RS232/RS485 protocols.
Table 2. RS232/RS485 pinout
|Any GPIOS (for the example 25)
Industrial Shields PLCs provide the A B connection for RS485 protocol. HummingBoard i2 requires to configure the control/chip pin (any GPIOS) to connect to the MAX485 component. For this example we take pin 25 from the HummingBoard PI D37 connector (GPIOS 72) as chip/control pin. Steps to configure the 25 PIN as chip/control on HummingBoard i2.
- Open HummTouch console:
- User: hb
- Pass: hummingboard
- Write the following instructions
sudo su //acquire superadmin rights
echo “72” >/sys/class/gpio/export
echo out>/sys/class/gpio/gpio72/direction // define GPIOS18 (pin 25 D37) as control/chip
echo 1 >/sys/class/gpio/gpio72/value // set control/chip pin to transmit state (HIGH) 1
Table 3. Touchberry PI to MAX485 connection reference
*TX and RX cables connection is not cross between D37 to MAX485 Steps to configure the 25 PIN as chip/control on HummTouch Linux. With the code and connections above, the RS485 protocol for HummTouch (Linux) is set-up and configured to transmit state. In order to test so, the communication between PLC and the PanelPC we are going to send some sentences through RS485 and RS232.
- Open minicom on HummTouch (Linux).
- 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 HummTouch console. The Arduino code to read messages on the RS48 Bus is here. Another example shows the Arduino code to send data to the HummTouch Linux through the RS485 bus.
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
*TX and RX cables connection is not cross between D37 to MAX232.
For the Android HummTouch the conversion between TTL to RS232 and RS485 is carried out with USB-RS232 and USB-RS485 adaptors (cable and software).
This connection is quite simple. First of all, an Android serial terminal has to be installed in the HummTouch. This can be download from the following link. After that, the USB-RS232 adaptor can be connected to the PLC and HummTouch. Now the communication is configured, we just need to read and write through the RS232 terminal.
- USB-RS485 (soon to be released)
Regarding communications with the USB-RS485 adaptor, no pin configurations is required, there is no need to specify the control pin nor its state (transmit, receive). The Arduino code to read and write thorugh RS485 is the same file as for the RS232. Read and write. As for the I/Os on the HummingBoard, the GPIOS can be configured as input or outputs and its states toggeled: In this link there is an app to emulate a terminal console for Android which needs to be installed. The instructions to be typed on the console to configure the GPIOS are writen below.
echo out>/sys/class/gpio/gpio72/direction // define GPIOS 72 (pin 25 D37) as output
echo 1 >/sys/class/gpio/gpio72/value // set GPIOS 72 to HIGH state
echo 0 >/sys/class/gpio/gpio72/value // set GPIOS 72 to LOW state
echo in>/sys/class/gpio/gpio72/direction // define GPIOS 72 (pin 25 D37) as input