How to open Logic Analyzer and run RS485 with industrial Raspberry PLC
Send data through RS485 from your Raspberry Pi PLC and receive it in the Saleae Logic Analyzer thanks to Raspberry Pi automation!
27 December, 2021 by
How to open Logic Analyzer and run RS485 with industrial Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez

Introduction

According to Wikipedia, a logic analyzer is an electronic instrument that captures and displays multiple signals from a digital system or digital circuit.

In this post, we will learn how to connect a logic analyzer to a MAX485 module and the Raspberry Pi based PLC, and we will learn how to see incoming and outgoing data using Python programmed code.

Latest Posts

How to connect MAX485 & Logic Analyzer

First of all, we are going to set the connections.

Connect the hardware, as you can see in the table and picture below:

RASPBERRY PLC
SALEAE
LOGIC
ANALYZER
MAX485PC
GNDGNDGND, RE, DE
5V
VCC
A+
A
B+
B

CH1RO


USBUSB
How to connect MAX485 & Logic Analyzer - How to open Logic Analyzer and run RS485 with Raspberry Pi PLC

Send data through RS485

From the Raspberry Pi industrial PLC, we are going to run a basic test about sending data through the RS485 port. 

You can use the programming language that you like the most. We are going to send the text "hello" using the Python programming language.

1. Access to your Raspberry Pi PLC controller.

2. Create a file called test-rs485.py

touch test-rs485.py

3. Give permissions to the file:

chmod 755 test-rs485.py

4. Edit your file and add this code:

from time import sleep
from serial import Serial
with Serial('/dev/ttySC0', 115200) as s:
    while True:
        tx = "hello"
        sleep(0.5)
        s.write(tx.encode())
        s.flush
5. Run the script:
python test-rs485.py

Install Saleae Logic Analyzer Software

Once the hardware is correctly connected and you are sending data from the open source PLC Raspberry Pi RS485 port, you can go to Saleae's website and download the package that fits you better. In our case, we are going to download the Linux 64 bit .zip.

Install Saleae Logic Analyzer Software - How to open Logic Analyzer and run RS485 with Raspberry Pi PLC

Click on it and download it. Once downloaded, extract files and double-click on the Logic file to launch the software.

Launch the Logic Analyzer Software

Once you launch the software, you should see a window like this:

Window - Launch the Logic Analyzer Software - How to open Logic Analyzer and run RS485 with Raspberry Pi PLC

You can see the 8 channels on the left, and another panel on the right.

1. On the right, click on the  symbol next to Analyzers > Async Serial.

2. Set the same baud rate as in the Raspberry code. In our case: 115200. Leave the rest by default. Click on Save.

3. Click on Start.

4. Scroll in and out to get closer to the lines with the bytes, and adjust it so that you can see the data clearly.

Lines with bytes 1 - Launch the Logic Analyzer Software - How to open Logic Analyzer and run RS485 with Raspberry Pi PLC
Lines with bytes 2 - Launch the Logic Analyzer Software - How to open Logic Analyzer and run RS485 with Raspberry Pi PLC
Lines with bytes 3 - Launch the Logic Analyzer Software - How to open Logic Analyzer and run RS485 with Raspberry Pi PLC

Data Representation

The points from the frame received represent the bits from the data in little-endian, so the least significant bit (also LSB) will be the first one to be read.

In this case, we can see that we get the following, from binary to ASCII:

  • 01101000: h

  • 01100101: e

  • 01101100: l

  • 01101100: l

  • 01101111: o

  • (framing error) 

Anyway, in the decoded protocols from the panel on the right, you can see the data you get 

Data representation - How to open Logic Analyzer and run RS485 with Raspberry Pi PLC

Now, it is your turn! Would you like to know how to send data through Serial Port?

Check this out >

How to open Logic Analyzer and run RS485 with industrial Raspberry PLC
Boot & Work Corp. S.L., Fernandez Queralt Martinez
27 December, 2021
Share this post
Archive

Looking for your ideal Programmable Logic Controller?

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

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


Industrial PLC comparison >>>

Do you want more information?

Just fill the form!

Tell me more!