# 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 `blinkLED.py` using your favorite text editor on the Pi.

Listing 1

```01 import RPi.GPIO as GPIO
02 import time
03
04 # to use Pi board pin numbers
05 GPIO.setmode(GPIO.BCM)
06
07 pin = 17
08
09 # set up GPIO output channel
10 GPIO.setup(pin, GPIO.OUT, pull_up_down=GPIO.PUD_DOWN)
11 GPIO.setup(pin, GPIO.OUT)
12
13
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)
24
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 BlinkLED.py`

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.

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.

Express-Checkout as PDF

Pages: 8

Price \$2.95
(incl. VAT)

SINGLE ISSUES

SUBSCRIPTIONS

TABLET & SMARTPHONE APPS

UK / Australia

## Related content

• Digital logic

We show how to use a logic analyzer to isolate problems in your hardware setup.

• Managing solar power systems with SunAir boards

A successful solar power project requires data analysis and the ability to modify the system to take advantage of prevailing weather conditions.

• Digital – Analog – Mechanical

As innovative companies consistently push the envelope of progress, antiquated hardware nearly two years old falls by the wayside. We take an old iPad, an Arduino Mega, and various other materials to create an in-dash climate control app.

• SunRover Part 2 – Solar Power Controller/Power System

Putting power in your robot is more than just running wires – you'll need to make sure the power supply doesn't cause interference that will disrupt other components. This article explores the problem of electrical noise and describes the design for a multiplexing solar power system.

• Building the SunRover navigation system

The Switch Doc continues his effort to build a solar-powered robot. This month the emphasis is on the navigation system.