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.
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 |
|GND||GND||GND, RE, DE|
Send data through RS485
1. Access to your Raspberry Pi PLC controller.
2. Create a file called 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:
tx = "hello"
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.
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:
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.
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:
Anyway, in the decoded protocols from the panel on the right, you can see the data you get