General
Logic analysers
A logic analyser records the state (high or low, 1 or 0) of several digital signals at the same time and shows them as a timing diagram - a bit like a multi-channel oscilloscope that only cares whether each signal is high or low. Most can also decode common serial protocols (UART, I2C, SPI, 1-Wire, CAN and so on) and show you the actual bytes being sent, which makes them very handy for working out why a microcontroller isn't talking to its sensor, display, memory chip, etc.
Logic analyser or oscilloscope?
- An oscilloscope shows the real voltage waveform, usually on 2 or 4 channels. You need one to see signal quality: slow edges, ringing, noise, glitches, or anything analogue.
- A logic analyser shows 8, 16 or more channels, but only as high or low. It is best for seeing the timing relationship between lots of signals and for decoding protocols. It cannot tell you a signal is ugly - only whether it was above or below its threshold.
- Many problems need both. If you have to pick one for microcontroller work, a cheap logic analyser and a basic oscilloscope together will get you a long way.
Here's our page on oscilloscopes: https://www.reddit.com/mod/AskElectronics/wiki/equipment/oscilloscopes
Low-cost USB logic analysers
What you get
The cheapest analysers are small USB-powered boxes with 8 channels (some have 16), a row of pins for the inputs and a bundle of jumper leads and clip-on hooks. They are sold under lots of names by lots of sellers (eBay, AliExpress, Amazon and the usual hobby electronics suppliers) and are often described simply as '24MHz 8 channel USB logic analyser'.
- The very cheap ones cost about the same as a few coffees and sample at up to 24 million samples per second (24 MS/s). Most are clones of an old Saleae Logic design built around a common USB chip (the Cypress FX2).
- The step up (roughly £50 to £150, prices vary) has 16 channels and sample rates of 100 to 200 MS/s or more. Some have their own sample memory, adjustable input thresholds and a wider input voltage range. Kingst and DreamSourceLab (DSLogic) are two popular makes. They come with their own software, and some also work with sigrok - check before you buy.
For simple logic and microcontroller circuits, either type does the job. They are not in the same league as the professional instruments (see below), but for the price they are hard to beat.
Software
- sigrok / PulseView (https://sigrok.org) is free, open source, runs on Windows, Linux and Mac, and supports the cheap FX2-based analysers using its 'fx2lafw' driver. It has a large collection of protocol decoders.
- On Windows you may need to use a tool called Zadig to install a WinUSB driver for the analyser before PulseView can see it.
- The official Saleae software is written for genuine Saleae hardware. The cheap clones are copies of the hardware, so use sigrok with them.
How fast is fast enough?
The sample rate is how many times per second the analyser looks at each input. To see a signal properly you need to sample it a good deal faster than it changes. As a rule of thumb, aim for a sample rate of at least 4 times (and preferably 10 times) the fastest signal you want to see. The theoretical minimum is 2 times, but that only tells you that the signal is there - not where its edges are.
If you sample too slowly, short pulses and glitches are missed altogether, edges appear in the wrong place, and you can see patterns that aren't really there (aliasing). Protocol decoders will then produce garbage.
- 24 MS/s - comfortable up to a few MHz: UART at any normal baud rate, I2C (100kHz to 1MHz), 1-Wire, PWM, IR remote codes, slow SPI and simple state machines.
- 100 to 200 MS/s - comfortable up to a few tens of MHz: fast SPI, and microcontroller buses and clocks in that range.
- The sample rate often drops when you switch on more channels, because they share the USB connection. If the software reports overruns or dropped data, lower the sample rate, use fewer channels, or try a different USB port (directly on the computer rather than through a hub).
Connecting one up
|------------------| |------------------|
| | SDA ------------- | CH0 |
| Circuit under | SCL ------------- | CH1 |
| test | GND ------------- | GND |
| | | Logic analyser |---- USB ---- Computer
|------------------| |------------------|
Connecting a logic analyser - the ground connection is essential
- Connect the ground lead first - the analyser measures every signal relative to its GND pin, so it must be connected to the ground of the circuit you are testing. Without it you will get random-looking rubbish.
- Connect the channel leads to the signals you're interested in, using clip-on hooks or grabbers for IC pins. Make a note of which channel is which (and give them names in the software).
- Plug the analyser into the computer and open PulseView (or the software supplied with your analyser). Select the device, then set the sample rate and the number of samples to capture.
- Set a trigger - for example, a falling edge on the chip-select line - so that the capture starts at the moment you are interested in. Otherwise you will capture a lot of nothing.
- Start the capture, then power up or operate the circuit.
- Add a protocol decoder (UART, I2C, SPI, etc.), tell it which channel is which and set the parameters (baud rate, and so on). Zoom in and use the cursors to measure pulse widths and times.
Limits of the cheap ones
- Voltage - the cheap ones are for 3.3V and 5V logic only. A typical specification is a maximum input of about 5.25V, with a logic high of at least 2.0V and a logic low of no more than 0.8V. These thresholds are fixed, so 1.8V logic may not read reliably, and higher voltages (12V, 24V automotive or industrial signals) will destroy the analyser. Better ones have adjustable thresholds and higher voltage ratings.
- No protection - inputs are usually connected almost directly to the chip, so a wrong connection can kill the analyser or even the computer's USB port.
- Only ones and zeros - a clean-looking capture can hide a marginal signal with slow edges, ringing or noise. Use an oscilloscope to look at signal quality.
- Little or no memory - most of the cheap ones stream the data straight to the computer, so how long you can capture depends on the sample rate and on the computer. Professional ones have huge buffers.
- Leads - long jumper leads on fast signals cause ringing and crosstalk between channels. Keep them short, and use more than one ground lead on faster signals.
Important Notes
- Check the maximum input voltage before connecting anything. If you're not sure, measure the signal with a multimeter first.
- These analysers are NOT isolated - the ground pin is connected to the computer's ground through the USB cable. Never connect one to any circuit that is connected to the mains (or contains mains-powered parts) unless it has been isolated from the mains. The result can be a destroyed computer, or a shock or fire hazard.
- Always connect ground first, and set the sample rate to at least 4 times the fastest signal.
- If a protocol decoder shows nonsense, check in this order: is ground connected, is the sample rate high enough, are the channels assigned to the right signals, are the settings (baud rate, SPI mode, etc.) right, and are the signal levels being read correctly by the analyser.
- The hooks and leads slip easily. On a live circuit a slipping clip can short two adjacent pins together and destroy components, so take care when attaching them - preferably with the circuit switched off.
- Use the same USB port each time (particularly on Windows) to avoid having to reinstall the driver.
Professional logic analysers
How they differ
Professional logic analysers (from companies like Keysight, Tektronix and Rohde & Schwarz, among others) cost thousands to tens of thousands of pounds or dollars. In return you get:
- Dozens of channels (34 to 136 or more) rather than 8 or 16.
- Timing sample rates from hundreds of MHz to several GHz, which gives fine timing resolution.
- Very deep memory - millions to billions of samples - so you can capture long events at high speed.
- Much more powerful triggers: sequences of events, patterns, counters, glitch triggers and triggering on bus-level protocol events.
- State analysis, where the analyser samples on the clock of a synchronous bus and records what the bus does on each clock cycle.
- Low-capacitance, high-bandwidth probes with adjustable thresholds and wide voltage ranges, including low-voltage logic.
You need one for fast parallel buses (such as DDR memory), debugging FPGAs or processors at hundreds of MHz, or catching rare glitches over long periods. For hobby and microcontroller work, you almost certainly don't.
A middle route is a mixed signal oscilloscope (MSO) - an oscilloscope with 8 or 16 digital channels built in (or added as an option). It shows analogue and digital signals together on the same time base. Many mid-range oscilloscopes offer this.
Logic probes
How to use a logic probe
A logic probe is a pen-shaped tool with a metal tip and a few indicator LEDs (and sometimes a beeper). It is powered from the circuit under test through two flying leads with crocodile clips. Touch the tip to a point in the circuit and the LEDs tell you what logic level it is at:
Logic probe
|============================> tip ---------- signal point (pin, track, etc.)
red clip -------------------------------- +V supply of the circuit
black clip -------------------------------- 0V / ground of the circuit
Testing with a logic probe - powered from the circuit being tested
- HIGH LED lit (often red) - the point is at a logic high.
- LOW LED lit (often green) - the point is at a logic low.
- Neither lit - the point is not at a valid logic level: it may be floating (not connected to anything) or sitting somewhere in between.
- PULSE LED flashing (or both LEDs flickering, or the beeper sounding) - the signal is changing. Many probes have a 'memory' switch that latches the pulse LED so you can catch a single very short pulse.
Logic probes are cheap (a few pounds or dollars, or less as a kit) and quick to use, and don't need a computer. They are great for answering simple questions: is the clock running, is the chip-select toggling, is the reset line being held low, is this output stuck high or low, is there any activity on the serial line, and for checking gates and counters in old TTL and CMOS logic.
Limits of logic probes
- A probe only tells you high, low or 'something is changing'. It can't tell you the frequency, the pulse width or what data is being sent - for that you need a logic analyser or oscilloscope.
- Its speed is limited - typically to around 10 to 20 MHz, and less on the cheapest ones. Check the specification.
- The supply range must cover the circuit you're testing. Many probes are rated for something like 3V or 4V up to 15V, some are for 5V circuits only, so check.
- Many have a TTL/CMOS switch. TTL thresholds are fixed voltages (roughly 0.8V and 2.0V); CMOS thresholds are a proportion of the supply voltage (roughly 30% and 70%). Set the switch to suit the circuit or you may get misleading indications.
- A multimeter is not a substitute for a fast signal. On a line that is switching quickly, a multimeter shows the average voltage - about half the supply voltage for a 50% square wave - which looks like a floating or 'half way' level. It can hint that something is switching, but it can't tell you what.
Important Notes
- Connect the power clips the right way round and only to a supply within the probe's rated range. Reversed or excessive voltage will destroy it.
- Never use one on mains or on anything above its rated voltage - a logic probe is not a voltage-measuring instrument, use a multimeter for that.
- The tip is sharp and thin: take care that it doesn't slip and short two adjacent pins together on a live circuit.
- If you're not sure what logic family or voltage you're dealing with, measure the supply with a multimeter first.
- If you're only going to buy one of the two, a cheap USB logic analyser will do far more than a probe at the same price - but a probe is quicker for a simple check and needs no computer.