According to Wikipedia, a logic analyzer is an electronic instrument that captures and displays multiple signals from a digital system or digital circuit. A logic analyzer may convert the captured data into timing diagrams, protocol decodes, state machine traces, assembly language, or may correlate assembly with source-level software.
In this blog, we will learn how to connect a logic analyzer to the Raspberry PLC through Serial port, and we will learn how to see the incoming and outcoming data.
HOW TO CONNECT LOGIC ANALYZER & RASPBERRY
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||LAPTOP|
SEND DATA THROUGH SERIAL PORT
From the Raspberry PLC, we are going to execute a very basic test about sending data through the serial port.
You can use the programming language that you like the most. We are going to send an 'a' using bash script.
1. Access to your Raspberry PLC.
2. Create a file called test.sh
3. Give permissions to the file:
chmod 755 test.sh
4. Edit your file and add this code:
stty 115200 -F /dev/ttyS0
while [ 1 ] ; do
echo -ne "a" > /dev/ttyS0
5. Run the script:
INSTALL SALEAE LOGIC ANALYZER SOFTWARE
Once the hardware is correctly connected and you are sending data from the Raspberry PLC's serial 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. Select the chanel 00 and name it as TX.
2. By the channel 0 selected, click on the symbol next to Analyzers of the panel on the right > Async Serial.
3. Select Serial 0 - 'TX'.
4. Set the same baudrate as in the Raspberry code. In our case: 115200. Leave the rest by default. Click on Save.
5. Do the same for the RX, from step 1 to 4.
6. Go to the Start button and click on the arrows. Select 4Ms/s and 2 seconds, as there is a 0.5 delay in our code, and will allow to see 4 incoming data.
7. Click on any place.
8. Click on the Start button.
9. Get your data!
The points from the frame received, represents 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 an 10000110, but read as a little endian like 01100001, so if we convert this to hexadecimal, we get 61, which is an 'a' in ASCII.
Now, explore the logic analyzer software and explore all the possibilities it offers! Check it out >