INTRODUCTION
The Touchberry Panel PC control for industrial monitoring is provided with two RS-485 communication channels. Both are half-duplex and are controlled via SPI0 bus.
The RS-485 is defined as a multipoint differential bus system. It is ideal for transmitting at high speeds over long distances and through noisy channels since the twisted pair and shielded wire reduce the noises induced in the transmission line.
So, let's check how to test the RS-485 in your HMI industrial touchscreen Touchberry Pi 7" Panel PC monitoring for industrial control!
HARDWARE
The industrial Raspberry Pi monitoring for industrial automation has two RS-485 channel communications. Both are Half-Duplex and are controlled via SPI0 bus. So, connect the twisted pair and shielded wire from an RS-485 port to the other one, and add a jumper for the Half-Duplex, as shown in the picture below:
SOFTWARE
1. Open up a terminal window and create a new file called rs485.sh like this:
touch rs485.sh
2. Give permissions to execute it:
chmod 755 rs485.sh
3. Modify the file content with the nano editor:
sudo nano rs485.sh
4. Copy and paste the following code to the file:
#!/bin/bash
if [ -d /sys/class/gpio/gpio27/ ] ; then
echo 27 > /sys/class/gpio/unexport
fi
stty sane 115200 -F /dev/ttyS0 raw -echo
echo 27 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio27/direction
echo 1 > /sys/class/gpio/gpio27/value
echo 17 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio17/direction
echo 0 > /sys/class/gpio/gpio17/value
cat /dev/ttyS0 > /tmp/rs485.txt &
cat_pid=$!
sleep 2
echo "OK" > /dev/ttyS0
RESULT=$(cat /tmp/rs485.txt | tr -d '\0')
{ kill -9 ${cat_pid} && wait ${cat_pid}; } &> /dev/null
if [ -n "${RESULT}" ] ; then
echo rs485 true "${RESULT}"
else
echo rs485 false "RS-485 cannot read from /dev/ttyS0"
fi
Exit the file with Ctrl + X > Yes > Enter.
5. Execute the script and get the output as shown below:
sudo ./rs485.sh

How to test RS-485 of 7" Industrial Panel PC