Sunday, September 20, 2015

Debugging Digital Circuits with a Logic Analyzer

While working with digital systems of various kinds, sometimes we face unexpected behaviors from those tiny embedded platforms. Sometimes it can be a hardware defect and sometimes it's just a bug in our code that runs on those systems. Unlike other platforms such as personal computers and smartphones, debugging these embedded systems is very hard and complicated. In this domain, one important tool that helps the developers to look in to the lower level functionalities of a digital circuit is a logic analyzer.

In our lab, we had a very nice logic analyzer tool donated to us by a past colleague who worked here. The tool is Logic manufactured by Saleae. Today I put my hands on it and tried some simple things to get familiarized with the device. First I programmed an Arduino Uno board to blink its on-board LED connected to the pin 13. Then I connected the Logic to the Arduino board. Ground pin of Logic was connected to a Ground pin of Arduino board. Then, pin 1 of the Logic is connected to the Arduino pin 13 using a jumper wire.

Go over to the download page of the Saleae website and download the required software. In my case, I downloaded version 1.1.15 for Ubuntu 12.04. Simply uncompress the ZIP file and there we have an executable file. I ran it from a terminal by issuing the command sudo ./Logic and the software started up. Connect the Logic device to to the computer using the USB cable and then simply clicking on the Start button will capture the data. Having a 1000 millisecond delay between the turning on and off of the LED, I was able to see the output from the software interface as shown below.

Arduino Uno pin 13 switching with 1000 ms delays

Timing seems very precise. Once the pin 13 became high, it took about 1000.872 milliseconds before it switch back to low. In our program code, the delay was set as 1000 milliseconds. As the second test, I removed the delays placed in the code, That means our LED is turning on and off as faster as the AVR microcontroller can perform. Our logic analyzer says that pin 13 stays about 4 microseconds in high state before it return to low.

Arduino Uno pin 13 switching without explicitly placed delays

I think this device will help me in my future endeavors with digital circuits. Let's see what it will bring to me.

Reference:
[1] https://www.saleae.com/
[2] https://www.youtube.com/watch?v=7OCPWCdg2ys


No comments:

Post a Comment