In compliance with high industry standards

Browse our Blog. You will find multiple applications, solutions, code examples. Navigate using the tag cloud or search using specific criteria

How to test RS-485 from 7" Panel PC

Touchberry 7" Industrial Panel PC Communications

INTRODUCTION


The Raspberry PLC is provided with two RS-485 channel communications. Both are half-duplex and are controlled via SPI0 bus

The RS-485 it 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 reduces the noises that are induced in the transmission line.

So, let's check how to test the RS-485 in our Touchberry Pi 7"!


 

 

RELATED LINKS

How to connect 
Raspberry PLC to Wi-Fi

Read >>

 

Basics about Raspberry Pi PLC
analog outputs

Read >>


How to find your
perfect industrial PLC

Read >>

How to program Raspberry PLC
interrupt inputs with Python

Read >>

Raspberry PLC
family products

Read >>

TouchBerry Pi
family products

Read >>

REQUIREMENTS

- Toucherry 7"   See the Touchberry Family >>

HARDWARE

The Raspberry PLC is provided with two RS-485 channel communications. Both are half-duplex and are controlled via SPI0 bus. So, connect the twisted pair and shielded wire from a 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


Odoo image and text block

Looking for your ideal PLC?

Take a look at this product comparison with other industrial controllers Arduino.

We are comparing inputs, outputs, communications and other features with the ones of the relevant brands.


Industrial PLC controller comparison >>

Do you want more information?

Just fill the form!

Tell me more!