Go Down

Topic: SUMP compatible logic analyzer code for Arduino. (Read 101830 times) previous topic - next topic


It's not meant to run continuous.
Logic analyzer (opposite to oscilloscope) run single once they get the trigger


yes , i realize that . and now it works .
but how i can configure pc software to run continous ??

As barbudor mentioned it doesn't run continously.  There are USB logic analyzers that send the samples real-time across the USB bus and the PC uses its virtually unlimited memory to record millions of samples or whatever.  Those cost real money unfortunately and don't usually come with a nice open source client either.  So it is a trade off, but using SUMP on the Arduino is cheap and easy and you don't need to dedicate the Arduino full time to use as a logic analyzer if you don't want, you can always reload a different sketch.

Here is a great video someone made showing the use of the Arduino generic logic analyzer (AGLA).


It is a great demonstration of looking at the clock, data, latch and 3 outputs from a shift register driven by an Arduino.

You can setup a trigger to start capturing when you see a specific pin toggle.  You can add a button and press it yourself when you need to trigger if you have to, but ideally something in the logic signal you're looking at will be the trigger.  In the shift register demo video he has two Arduinos, one with AGLA and one driving the shift register.  If you added a debug pin toggle somewhere in the code on the non-AGLA Arduino, you could trigger on that pin with AGLA.

That is actually the technique I use to time the sample rates.  I use the OLS (Openbench Logic Sniffer) hardware to watch a debug pin on the AGLA.  When I sample I toggle the debug pin a few times, then turn it on, sample, turn it off.  Since I have a trigger setup on the OLS to watch the debug pin it will start capturing when I initially toggle the pin.  Then I can measure the time between pin on, sample, pin off to see how long the sample took.


I'm sorry to resurrect an old topic, but I can't get the code on github to compile.

Here's the error:
c:/program files (x86)/arduino-1.5.2/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: .../logic_analyzer.cpp.elf section .text will not fit in region text
c:/program files (x86)/arduino-1.5.2/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/bin/ld.exe: region text overflowed by 10552 bytes

As you can see from the error, I'm running 1.5.2, but I get the same error when running 1.0.5.

From a google search, it appears others compiling C inside gcc have had similar issues, and it seems to have something to do with casting.  Unfortunately, outside of the IDE, I'm not the most capable programmer.

Any one else having a similar issue, or solved it?


What board type do you have selected?  I'm using the 1.0.5 IDE and with either Arduino Uno or Duemilanove w/ATmega328 it verifies with no size issues.

If you're using an ATmega168 you'll need to comment out either the 'captureInline4mhz()' or the 'captureInline2mhz()' call around line 314 or 318.

Can you change the Arduino IDE preferences to show verbose messages during compilation?
Then you could PM me the last 20-30 lines of the logs or a pastebin link.

I might change that part to a #ifdef so it just automatically comments out the 2mhz version on a '168.


How do i open all the channels in Logic Sniffer. I am using windows operating system and i am only able to view one channel as if now.. the channel on pin 8.


How do i open all the channels in Logic Sniffer. I am using windows operating system and i am only able to view one channel as if now.. the channel on pin 8.

What Arduino hardware are you using and what version of the Logic Sniffer client?
You should always see more than 1 channel in the client.  Do you mean you are only seeing 1 channel change, or literally only seeing a single line in the client?
Can you post a screenshot of the client window?   Or PM it to me.


Feb 20, 2014, 07:59 am Last Edit: Feb 20, 2014, 07:17 pm by gismo Reason: 1
I'm glad this thread is still alive.

I have a few questions and I can't really get it to work... I've got a Duemilanova and Win7 x64.
Here's my steps:
1. Download Arduino Code from here: https://github.com/gillham/logic_analyzer
2. Open all .ino files in zip.
3. Copy all code from 2mhz and 4mhz files and paste at bottom into the logic_analyzer.ino file
4. Compile and upload. done.
5. SIGH. no problems.
6. Download latest version of Logic Sniffer v0.9.7:  http://www.lxtreme.nl/ols/ols-0.9.7-full.zip
7. Unzip to C:\Temp
8. Copy and paste both .CFG files into \plugins folder [You will get a warning to overwrite] Don't overwrite. Cancel. Append .ORIG to end or the original files. Paste again with no errors.
9. Right-click on Run.bat-> Run as administrator (if not, then it will not detect java and the application will not start)
11. Logic Sniffer Top menu goto Capture-> Begin Capture
12.Connection Type: Serial Port // Analyzer port - [com3 in my case] // Port Speed: 115200bps
13. Device type: [Expected Device MISSING Arduino Generic Logic Analyzer]
14. Close Logic Sniffer.
15. Go back to plug-in folder and remove the newly pasted .CFG files and rename the .ORIG files from step 8 back to normal.
16. Restart Logic Sniffer. Repeat steps 11,12,13. "Arduino Generic Logic Analyzer" now shows up in the Device Type Drop Down Menu.
17. Click "Show device metadata" -> result "Detection failed!"
18. Goto Acquisition Tab
19. Number Scheme: Default // Sampling Clock Internal // Sampling Rate 1.000Mhz // Channel Groups : 0 // Recording Size 1.00kB //Options: [non checked]
20.Goto Triggers tab. Trigger Enabled Checked. // Type: SIMPLE. // Other settings left at default.
21. Click Capture in bottom Right and window closes.

I've got two wires hooked up into an I2C bus to pins 8 and 9 on the Duemilanova. I'm not getting anything in Logic Sniffer. What am I doing wrong? Why does step 17 fail? Otherwise, I don't get an error messages. I even tried manually running some I2C commands and clicking repeat capture button, but no luck either.

Also, Regarding Disabling Auto-Reset, I used a 10uF cap between Reset and ground: http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection#.UwWrZfldXTc

Thanks in advance!

I changed the sample rate to 500kHz and 200kHz and started clicking repeat capture while my I2C bus is operating and I am able to read I2C! ...there's got to be a better way to capture the signal...

How is the trigger supposed to to work?


Hey @gismo

You can configure the trigger in the "OLS Capture Settings" dialog ( you already found that dialog aren't you).
As gillham describes in his readme, only the "Mask" and the "Value" options work in his logic analyzer.
All ticked channels can trigger a capture.
The required state of the channel (HIGH/LOW). Remember to set the Value to the state that it receives on your desired start time.

To finally start the capture all Mask and Value bits have to match the signals on the Arduino (if you just want one channel to trigger you only set the corresponding  Mask).

The only remaining problem is that the first channel change is used in the trigger process and therefore maybe not included in the stored data. I manged that issue by adding a channel that is only supposed to give a trigger signal. In addition that trigger signal is fired a few  uSeconds before the I2c Bus will send it's start command ( only matters if you are capturing up in the MHz regions) .

I hope I could help you! Otherwise,  take for example a look in gillhams code at line 500 ff. (inside the function captureMicro()  ) to really know whats going on in the trigger process (btw: <3 open source :) ).

@gillham Your logic sniffer worked just great for my little software-I2C debug session and i had it up and running in about two hours from first time i noticed it to the first useful capture! Thanks a lot! Nevertheless my next electronics device will be a logic analyser. ;)


Feb 24, 2014, 06:12 pm Last Edit: Feb 24, 2014, 06:15 pm by gismo Reason: 1

Thanks for the update. I got it all figured it out.  XD . Prior to you post I ended up googling some OLS tutorials.

First: The latest update 0.9.7 already has the config files and the config files included with the Arduino code don't work with this version.

Just to expand on your post and to clarify what I did to get it to work for me and because a picture is worth 1000 words:

Note: The button Show Device Metadata does not work.

More on triggers:

Before/After Ratio is the time as a percentage of the entire capture time to record BEFORE and AFTER the Trigger. This is because some data might be moving before the trigger that you want to capture. 10/90 //15/85 is more that enough for the I2C I'm capturing.

Mask Yes, the input pins on which you want to listen for a trigger. IMO, the interface could be a little better here.

Value Checked = Triggered on 1/HIGH/Rising edge // Unchecked = Triggers on 0/LOW/Falling edge <- Needed for I2C because it's open drain and SDA and SCL are high. SDA pulled low initiates transaction.

"Action [ ] Start Capture" is grayed out. I was wondering the same thing some of you are thinking..., I need to check that because I want to start capture when I get a trigger, right?! Well it doesn't matter. You can't check it, and it will capture anyway. Another UI issue IMO.

Also, the 10uF capacitor seems to work alright...I think. Occasionally I need to unplug the USB from the Duemilanova and plug it back in and/or restart OLS to recognize the device.

@gillham THANKS!


Apr 15, 2014, 04:40 am Last Edit: Apr 15, 2014, 04:49 am by c0love Reason: 1
Looking for a little guidance to see if I am using this logic analyzer correctly.  It looks like I am getting a lot of noise in the capture.  New to Arduino and my first attempt at a logic analyzer.  I am trying to capture the RF codes of the remote controlled power outlets.  I plan on hacking them to wire them in as 3-way switches across the house and few other use cases and control through arduino. I have wanted to mess around with this project for awhile now so here I go.

I have everything setup.  I verified that the sketch is able to return the proper status messages through the serial console.  I verified that my RF modules work because I can send and receive serial commands between two arduinos with the modules attached.  When I connect the Arduino with the RF moduel to the logic analyzer and configure it the profiles and settings  I get a lot of "noise" in the capture without even pushing any buttons on the RF remote that I am trying to capture.  The noise isn't consistent, but there is always something.  When I push a button on the remote it doesn't seem to produce a consistent output so I am not sure that it is actually capturing any data from the remote.  I have tried every Sampling Rate.  The higher the sampling rate the less "noise" I see but no usable output from what I see.  

I have read all of the examples of people doing similar work with IR remotes and other projects that I could find online but I couldn't find an answer to this.  I didn't see anyone using this Arduino Logic Analyzer for RF remotes.  They were normally using some type of commercial logic analyzer.  I would appreciate any input on if this should work and possible solutions.

This is my setup:
* Arduino Uno R2

* This 433 MHZ RF receiver module hooked to Pin8 on the arudiuno (It has two data pins and I tried both with the same result)

* Logic Analyzer downloaded from https://github.com/gillham/logic_analyzer

* OLS 0.97 http://www.lxtreme.nl/ols/ols-0.9.7-full.zip
   > Capture data view:

   > Connection Settings:

  > Acquisition Settings:

  > Trigger Settings:


You do get a lot of noise with most RF receivers like this. The trick is to start the capture and then press the TX remote button so the receiver is receiving when the capture is happening or you may be able to capture the TX remote if you know where to connect the probe on the remote control.
Don't PM me for help as I will ignore it.


this is a great project and I will be testing it this week on mega.
Now I'm wondering if it can run on arduino DUE which has Atmel SAM3X8E ARM Cortex-M3 CPU 84MHz clock and 96KB SRAM. So it  has much more power and it cost same or even less than Mega2560. I try to compile code in IDE and there was a lots of errors (see below). I do not know how different this two board is. One difference is that DUE is 3.3V but I'm plannig some circuit to divide voltage so it can measure little more than 5V (mega), let's say 12V.

My question is: it is possible to port code to arduino DUE and can it be extend for DUE more power. Or it is better to buy dedicated logic analyzer? I think for Mega2560 or DUE price it is possible to buy some.

Code: [Select]

Arduino: 1.5.6-r2 (Windows 8), Board: "Arduino Due (Programming Port)"

Build options changed, rebuilding all

logic_analyzer.ino: In function 'void setup()':
logic_analyzer:231: error: 'DDRD' was not declared in this scope
logic_analyzer.ino: In function 'void captureMicro()':
logic_analyzer:501: error: 'PINB' was not declared in this scope
logic_analyzer:509: error: 'cli' was not declared in this scope
logic_analyzer:518: error: 'DDRD' was not declared in this scope
logic_analyzer:520: error: 'PORTD' was not declared in this scope
logic_analyzer:537: error: 'PINB' was not declared in this scope
logic_analyzer:550: error: 'PINB' was not declared in this scope
logic_analyzer:569: error: 'PINB' was not declared in this scope
logic_analyzer:577: error: 'sei' was not declared in this scope
logic_analyzer.ino: In function 'void captureMilli()':
logic_analyzer:617: error: 'PINB' was not declared in this scope
logic_analyzer:627: error: 'PINB' was not declared in this scope
logic_analyzer:638: error: 'PINB' was not declared in this scope
logic_analyzer:650: error: 'PINB' was not declared in this scope
logic_analyzer:654: error: 'PINB' was not declared in this scope
logic_analyzer.ino: In function 'void triggerMicro()':
logic_analyzer:686: error: 'cli' was not declared in this scope
logic_analyzer:695: error: 'DDRD' was not declared in this scope
logic_analyzer:697: error: 'PORTD' was not declared in this scope
logic_analyzer:730: error: 'PINB' was not declared in this scope
logic_analyzer:772: error: 'PINB' was not declared in this scope
logic_analyzer:791: error: 'PINB' was not declared in this scope
logic_analyzer:826: error: 'PINB' was not declared in this scope
logic_analyzer:837: error: 'sei' was not declared in this scope
logic_analyzer_inline_2mhz.ino: In function 'void captureInline2mhz()':
logic_analyzer_inline_2mhz:55: error: 'PINB' was not declared in this scope
logic_analyzer_inline_2mhz:63: error: 'cli' was not declared in this scope
logic_analyzer_inline_2mhz:71: error: 'DDRD' was not declared in this scope
logic_analyzer_inline_2mhz:72: error: 'PORTD' was not declared in this scope
logic_analyzer_inline_2mhz:93: error: 'PINB' was not declared in this scope
logic_analyzer_inline_2mhz:14438: error: 'sei' was not declared in this scope
logic_analyzer_inline_4mhz.ino: In function 'void captureInline4mhz()':
logic_analyzer_inline_4mhz:55: error: 'PINB' was not declared in this scope
logic_analyzer_inline_4mhz:63: error: 'cli' was not declared in this scope
logic_analyzer_inline_4mhz:71: error: 'DDRD' was not declared in this scope
logic_analyzer_inline_4mhz:72: error: 'PORTD' was not declared in this scope
logic_analyzer_inline_4mhz:93: error: 'PINB' was not declared in this scope
logic_analyzer_inline_4mhz:14438: error: 'sei' was not declared in this scope

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.


Porting to Duo will not be a trivial task as the code uses a lot of bare metal code. I would suggest investing in a dedicated hardware logic analyser, you can pick up some really good devices for between £10 and £30.
Don't PM me for help as I will ignore it.


I was doing more research yesterday night and I find that dedicated logic analyzer will be better. On ebay it cost from $10. But still going to buy DUE :)


Hey appreciate the thanks, glad you're able to get some use out of my project.
I have a number of variations of the Arduino now for testing and with the code updates to the OLS client to include my config files I need to cleanup my project a little so there is less confusion about what is needed.  Hopefully that will happen before too long so people picking up my project for the first time aren't confused by somewhat outdated information.

Anyway, regarding using a DUE or getting a real logic analyzer, I strongly recommend the Open Workbench Logic Sniffer (OLS) for $50 from Seeedstudio for more serious work.  The $10 logic analyzer's on eBay tend to be Cypress EZ-USB FX2LP development boards that clone the Saleae Logic firmware or similar.  Then people seem to (illegally) use the Seleae Logic software with these clone boards.  Sadly you end up with a proprietary logic analyzer and software that is essentially pirated.  Not what you really want IMHO.  $50 for the OLS is a great way to go.  The authentic, licensed Saleae Logic package for $149 sounds good based on what I've read about it, but certainly isn't open source or open hardware.

The Logic Analyzers on eBay seem to be based on Cypress EZ-USB FX2LP boards.  These have an 8051 compatible core and decent speed.  In theory it would be possible to create SUMP compatible firmware to replace the cloned firmware being used.  Then the OLS alternative client could be used with it as well.  I might investigate doing that at some point in the future, but no promises.  I think the ATMega328p based code is good enough and really a hardware board like the OLS should be the next logical step.

More likely future work would be incorporating Leonardo changes back into my code versus trying to get a completely different platform working.

Note that the Arduino USB Nano boards on eBay for around $7 should work with my code and can easily be dedicated as a logic analyzer at that price.  It is hard to beat $7 for basic functionality.  I should be getting one in a week or so and will verify it works well.

As I mentioned earlier in this thread I did a proof of concept of an ethernet based AGLA since the OLS client supports talking to a logic analyzer over tcp/ip.  I haven't messed with that code recently, but it was working with a WizNet W5100 based board.  I didn't see much demand for a such a thing, but are a few corner cases it could be useful.  For example helping to debug some sensors or similar in their production location outside or in the shop etc where you can't sit and watch it with your laptop due to environmental concerns like it is cold / hot / up high / uncomfortable conditions etc.  Then sitting at your desk and using the AGLA over the network would be nice.  Due to the ethernet needing the SPI the port used by capture routines needs to be adjusted and tweaked, which I might get to at some point.

Anyway, I will try to cleanup the documentation / code to reflect modern OLS clients and ATMega328 based Arduinos. (And hopefully add ATMega32U4 like Leonardo)  If you have any feature requests that are reasonable or just general suggestions let me know.  Note that the code is doing most of the what it can with the limited hardware already.
Things that aren't really practical or limit the specs too much:
-- Advanced triggers, unless very low sample rate is used. (get a nice FPGA based OLS)
-- Bit stuffing samples for one channel to get 8192 samples.  Again, needs a really low sample rate due to the amount of manipulation needed.  End result is fairly unusable due to low speed.  The Mega is a better solution if you have one, or the OLS (24KB of samples) or the Logic Shrimp (also available at Seeedstudio) which has 4 channels and 256K samples per channel.
-- More channels.  Again, would significantly reduce the sample rate and also the number of samples.
-- More speed.  The fastest we can sample is 5.33MHz and the timing isn't ideal with the OLS client so 4MHz is it right now.  The 5.33MHz rate might be usable with some tweaks with the OLS client or settings.  I'm not sure here, but 4MHz to 5.33MHz might not be worth the effort.  If you really need it faster, the OLS hardware does 200MHz loosely and 100MHz is precise timing.

Some of these features might be nice for an alternative firmware with lower samples rates.  I'm just not sure it is worth the effort for 100kHz or 10kHz sample rates rather than just using the OLS.  One of my goals was to have generally straight-forward code for an Arduino and I think so far I have been able to do it fairly well.

I'm thinking of reorganizing the repository to have separate directories for versions like megaram or ethernet, in addition a main one that supports most boards via #ifdef like currently.  That way test, PoC or alternative versions (like Leonardo or Due or Cypress EZ-USZB) could be on the main branch in their own directories.

Feedback & suggestions welcomed, but no guarantees on getting to them. ;-)

Go Up