What does a logic analyzer do?

That's the question..

Since your google/bing appears to be broken...

http://www.hvwtech.com/products_view.asp?ProductID=157

It looks at signals for you. You have to figure what to look at what information will help you.

bing appears to be broken

Its appearance isn't the only thing broken.

At its most basic, a logic analyzer serves the purpose of, well - analyzing logic circuits. Generally, logic analyzers are very specialized oscilloscopes, with multiple input channels (for each "bit" or logic-level line being analyzed), capable of monitoring those channels and generating a trace for each channel. Some logic analyzers only care about high/low logic-level shifting, and reflect the trace in a "crisp" high/low perfect square wave fashion. Others show the true voltage-level-over-time (just like a regular oscilloscope - in fact, a good multi-channel oscilloscope can serve as a logic analyzer). The difference between the two will be a matter of cost; the one that can capture and allow you to analyze the full waveform is going to be very expensive (because it is, essentially a multi-channel o-scope with a ton of memory - never cheap once you get past four channels).

The difference between the two, and how to choose, is basically up to your budget and your needs. The scope that only cares about high/low transistions over time, on each channel, is going to be much, much cheaper, of course. It can tell you about state transitions over time (why this is useful I'll explain in a bit), some can analyze the traces captured and do protocol analysis on the data (so you can tell what if anything is causing an issue with a serial connection, or a parallel bus, or whatever). What it can't tell you (which full-waveform capture can) is that the i/o line being monitored has excessive noise or some other electrical issue which is causing the data to be lost or garbled; but, as noted, such extras come at a steep price.

Now - why would you need such a device? Well, let's imagine a very simple circuit, consisting of say, a 555 timer running as an astable multivibrator, generating a clock pulse at some rate. This pulse is then being fed into a j/k flip-flip, and one output of that flip-flop drives an LED (so you have a blinking LED), and one output drives a BCD counter IC, whose outputs are tied to a BCD->7-segment decoder IC, which drives a 7-segment LED display. So, when the LED is off, the counter is advanced by one "tick", and the count appears on the 7 segment display.

Now - let's say after you've put this all together, you notice for some reason something isn't working right. How would figure it out? Ok, maybe this is a simple example, and you wouldn't -really- need a logic analyzer, but it would sure be handy.

Basically, to trace the issue, you start from your clock source. You would attach one line of the analyzer to the output of the 555, another to one output of the flip-flop, and another line to the output of the other line of the flip-flop. Then watch the traces on the screen. What you would get would look something like this (bad ascii art ahead!):

+----+ +----+ +----+ +----+
| | | | | | | |
CLK ----+ +----+ +----+ +----+ +----

  • +----+ +----+ +----+ +----+
    | | | | | | | | |
    LED +----+ +----+ +----+ +----+ +----

+----+ +----+ +----+ +----+ +----
| | | | | | | | |
BCD + +----+ +----+ +----+ +----+

This is somewhat like what you would see on a regular no-frills logic analyzer; if you notice, the traces for the LED and BCD input pins are slightly out of sync with the CLK (clock) pin (from the 555 timer - that's the pin you'd set as a "trigger"); that's because there is a particular propagation time-delay inherent in logic circuits; in this case, the slight lag is being caused by the flip-flop (in reality, you'd probably see these lines shifting a bit as the analyzer and circuit ran, simply because the delay may or may not be very consistent over time).

If your logic analyzer allows for it, and there are more channels available, you can put the probes on other i/o lines, to verify that they are transitioning states properly, and at the right time, as the circuit runs (as compared to all the other i/o lines).

Seeing the propagation delay time-lag is very important; if you've looked at any datasheet describing a digital IC or system, depending on its complexity and use, it will likely have some kind of chart (a timing chart) that looks something like the above; these charts let you know what the timing of the system should be for the pins involved for that particular component for the circuit it is in to work properly. If your data doesn't arrive on time or whatnot, your circuit's timing and the chart for the component may not match, and may cause all kinds of issues, from a non-functioning system, to lost data, to a ton of other "gremlins" in the circuit. In a very complex circuit, a logic analyzer may be the only thing that can save your bacon.

Now, the kind of analyzer that can let you see the whole waveform (glitches and all), while expensive, can help to isolate certain problems related to noise or other signal degradation on the lines; I can't draw an ascii art waveform to show what I mean, but for instance, if your i/o lines are exhibiting slow rise or fall times, the upward and downward "swoops" of the waveform wouldn't be shown as perfectly vertical lines, but curved ones instead. Such issues can spell a lot of trouble in a digital system. You could also see the effects of switch contact bouncing, external noise issues that cause erratic behavior, and tons of other things. But it all comes at a hefty price.

So, finally - what good is such a device for an Arduino? Well, it can be really helpful for analyzing protocols, like I2C, SPI, TTL serial, etc - you can tell, even with the simple analyzers, if propagation delays (perhaps caused by the length of the cable, or other reasons) are causing issues. If you are driving an LCD or other circuit with multiple bits of information from the Arduino, you can tell if the bits are arriving all at the proper time, and whether what you think you coded is really outputting what the circuit expects.

In a nutshell, a logic analyzer is like a multi-channel logic-probe with storage. Now - if you've been following along, you will note that for a simple device of such a nature, that it should be possible to build such an analyzer with the Arduino; after all, it has digital i/o lines, and it can monitor, record, and relay the information to a PC for display...

Such a system exists; here's but one example (of many):

I hope this TL;DR tutorial didn't bore you too much - logic analyzers can be a very useful tool, depending on what you're doing in digital electronics, so knowing about them and where they can fit in your toolbox is helpful.

:slight_smile:

first of all Cr0sh , Bore me?! How would this ever bore me! :smiley: This is what I have been looking for! I mean the way you explained it was much better than things I found on google!

Now I see why it would be useful to have such a tool when designing circuits!

Your post is what I call a golden post! I see you took the time to write everything out in a very simple and easy to understand way so thanks ALOT for that!

Ill check out the arduino logic analyzer and maybe try making that for fun eh?

If you want to see one in action check out my analysis of the I2C protocol here:

And also here about interrupts:

You can see the relationship between the various signals, and how far apart they are.

I strongly disagree with advertising being shoved in your face so I won't mention which analyzer I have (nor do those links). I don't have any connection with any analyzer company anyway.

I find the analyzer extremely useful when debugging protocols between Arduinos, or Arduinos and their peripherals, such as I2C, serial, SPI, 1-wire, and so on.

In particular, if your program isn't working you may be wondering:

  • Is it sending out anything?
  • If so, what?
  • Is there any response? eg. Ack/Nak, nothing
  • What is the response?
  • In what order are things being done?
  • How long do things take do to?

Basically, using an analyzer can save your hours or days of time. Knowing whether the problem is at the sending end, the receiving end, or simply the data being sent, is a huge time-saver.

I bought one of these Logic Analyzers from Saleae - #1 with Professional Engineers about a year ago. It works great and has saved me many hours while trouble-shooting. Not only does it display logic levels but it has built-in code to display the contents of SPI, I2C, etc messages! At $150 it's a steal. (and the hardware fits in a shirt pocket with room left for your smartphone)

For the record I'm in no way affiliated with the manufacturer.

Since someone else mentioned the name, that is the one I used for my screenshots. And I agree it is small and easy to use. Mac and PC as well.

Well! I almost committed a "faux-pas" there; I was about to edit your comment to point out that "PC" should be "Windows", because for the longest time (a couple of years, at least), Saleae claimed to be working on a port for Linux, but I never saw anything; I had heard that it could work under Wine...

But - before I posted, I decided to check it all out - and surprise! - there is a Linux port now! This makes me -extremely- happy; I've been wanting one of these for a while for my bench, but the only thing holding me back was that issue. Now I'm glad to know they have it sorted out...finally.

:slight_smile:

I've been wanting one of these for a while for my bench,

Get one now then Cr0sh, they are the greatest thing since sliced bread.


Rob

The other thing I did recently with mine is write a custom analyzer. First you simply export the captured data, like this:

$timescale 1 ns $end
$scope module top $end
$var wire 1 ! D+ $end
$var wire 1 " D- $end
$upscope $end
$enddefinitions $end
#11203489791
0!
0"
#11620156416
1!
1"
#11620156458
0!
0"
#11691340750
1"
#11984726750
0"
#12012045916
1"
#12012962958

They are the timestamps at which logic levels changed, so you can see that after (say) 66 ns a pin went from 0 to 1. So then with a bit of mucking around you can deduce the width of pulses, and so on. I used that to analyze USB data.

Of course, built-in stuff like I2C, SPI, async serial, 1-wire is all done with built-in analyzers in the GUI interface, so that is super-simple to use.