Digital logic

Looking at a Signal Trace

Now I'll set up a simple test to show what the logic analyzer can do. Figure 2 shows a simple test circuit: one LED and one resistor hooked up to a Raspberry Pi. Instructions on how to do this can be found online [1]. Make sure you hook up the LED to the correct pin (GPIO17, in this case). Put the code shown in Listing 1 in using your favorite text editor on the Pi.

Listing 1

01 import RPi.GPIO as GPIO
02 import time
04 # to use Pi board pin numbers
05 GPIO.setmode(GPIO.BCM)
07 pin = 17
09 # set up GPIO output channel
10 GPIO.setup(pin, GPIO.OUT, pull_up_down=GPIO.PUD_DOWN)
11 GPIO.setup(pin, GPIO.OUT)
14 # blink GPIO17 50 times
15 for i in range(0,50):
16         GPIO.output(pin,GPIO.HIGH)
17         time.sleep(0.01)
18         GPIO.output(pin,GPIO.LOW)
19         time.sleep(0.01)
20         GPIO.output(pin,GPIO.HIGH)
21         time.sleep(0.02)
22         GPIO.output(pin,GPIO.LOW)
23         time.sleep(0.02)
25         time.sleep(0.5);
26 GPIO.cleanup()
Figure 2: Raspberry Pi 1 Model B with the LED connected.

Execute the code by typing:

sudo python

This code blinks an LED on GPIO17 100 times first for 10ms and then for 20ms.

Figure 3 shows the resulting trace from the logic analyzer. You can clearly see the first 10ms blink followed by the 20ms second blink.

Figure 3: BlinkLED logic trace.

Although this is a simple example, it really shows the power of using a logic analyzer. These signals are impossible to see with just a multimeter.

Setting a Trigger

A logic analyzer needs to be told when to start storing state data. All logic analyzers have a maximum limit on the amount of data that can be stored (10 billion samples for this logic analyzer). The trigger also tells you where to start looking for a specific event (going through 10 billion samples can be a real problem. You need to be smarter than just capturing tons of data).

You can set a trigger condition to start showing the data. A trigger condition can range from simple (e.g., triggering on a rising or falling edge of a single signal) to very complex (e.g., configuring the analyzer to decode the higher levels of the TCP/IP stack and triggering on a certain HTTP packet or on a type of I2C packet ). At this point, the user sets the analyzer to "run" mode, either triggering once or repeatedly.

Once the data is captured, it can be displayed several ways – again, from simple (showing waveforms or state listings) to complex (showing decoded I2C protocol traffic, as demonstrated later). Some more complex analyzers can also operate in a "compare" mode, in which they compare each captured data set to a previously recorded data set and halt capture or visually notify the operator when this data set is either matched or not. This functionality is useful for long-term specialized testing.

With the Saleae Logic 8 Analyzer, you can trigger on the following conditions on one channel:

  • Rising edge of a signal
  • Falling edge of a signal
  • Width of a pulse either high or low

You can set the other channels to require the channels to be either high or low during the previously selected edge. After selecting an edge, note that other channels will display a button with an 'X', which indicates "don't care." You can only set one channel to an edge condition. The rest of the channels can only to be set to level conditions.

Note that this provides a lot of flexibility in capturing signals. You can set a control signal in software to feed into one channel and then capture the rest of the channels, or you can set a trigger to look for all 1s on the other channels anytime you see a rising edge of channel 0 for example.

The logic analyzer will typically store a lot of data before the trigger, so if you had an I2C module that resets itself, for example, you could trigger on the reset and then look back in the pre-trigger buffer to find the offending I2C command.

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content