Go Down

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


Great looking project;
This is the issue I'm having
I loaded the sketch onto my uno R3 in serial monitor I type 1 and get this reply:
readCount = 1024
delayCount = 0
logicIndex = 0
triggerIndex = 0
rleEnabled = 0

so I'm thinking its loaded and working fine.
my computer windows 8 64-bit
Java 32-bit V.7 build25
The client software is ols, at first it would not start had to change path info in the run.bat file; now it starts.
I added ols.profile-agla.cfg to the plugins directory.
It has the device.open.portdelay = 1500, and device.samples.reverseOrder = true   already in it.
So Arduino Generic Logic Analyzer now shows up in the Device type drop down box; and I select it.
I select COM5, same as the Arduino IDE. If I click on "show device metadata" LED marked "L" blinks and the Rx light blniks and I get: detection failed!   null
If I select ANY other device the Rx nad Tx lights blink the device type resets its self to Arduino generic... and I get:
Device type  AGLAv0
Firmware  0.09
Protocol 2
Ancillary -

And of course if I tell it to capture I get a Capture failed! Device not found!

Any advice would be great!



Make sure you're not using a resistor to disable auto-reset.  It is not needed with newer versions of the client.

Here are some troubleshooting steps:
0. Make sure serial monitor is closed.
1. Reset Arduino via hardware button. ( you also unplug / replug if you want)
2. Click start capturing button in OLS client.
3. Set to correct com port, 115200bps, device type "original sump device" (do NOT click show device metadata)
4. Click triggers at the top, make sure they are not enabled.
5. Click Acquisition at the top, make sure it is Default, Internal, 500.0kHz, channel groups zero, 1.00kB no test/noise/RLE
6. click capture.
7. note what happens.  if necessary click 'STOP' in OLS client.
8. switch to Arduino IDE, open serial monitor, send '1' enter

Someone else with an UNO R3 reported somewhat similar symptoms and he was able to get it working after a bit.
Try adjusting these three settings: (not all at once)
device.open.portdelay = 1500
device.receive.timeout = 100
device.open.portdtr = true

You could try 2000 or 3000 for the portdelay, bump the timeout to 500 and try toggling the portdtr.  Exit the client, unplug / replug the UNO, restart the client between settings change.

I would be interested to find out what makes a difference.  I have an original UNO (bootloader updated to the rev 0001) but it works fine for me.  Since I can't reproduce these R3 problems I might just pick up an UNO R3 to test out.  At least if we can't figure out an easy fix.


Thank you for such a quick reply.
Sorry for my late reply; I didn't receive a message saying someone had replied.

I followed the first section and told OLS software that, what was plugged in was an "original sump device".
Ch.5 showed HI all other Ch were Low: see attach png image

From Serial monitor:
readCount = 1024
delayCount = 0
logicIndex = 0
triggerIndex = 0
rleEnabled = 0


Ok, it looks like it worked.  At least you got samples back from the Arduino.  Do you have a signal you can feed to it?  You need to sample at a rate that will show something based on the frequency you are generating.  E.g. if you look at a 10KHz square wave signal, try a 100KHz sample rate initially so you see the transitions.

I think I will order an R3 just to see if I can reproduce some of these issues.


OK, used 555 configured for just over 10kHz but was reading about 9.9kHz on Agilent U1272A DMM.
Pin 12 arduino = channel 4 on ols software
see the attached png, hopefully it will give you all the information;
I'm new with electronics and arduino, the book im reading said I should have a logic probe, and I saw the arduino being used as one.
Note: if I set the recording size above 1KB it doesn't stop; is there a way to have it stream data or have a bigger recording size?

Thanks again for all your help!


Looks good.  What did the measurement tool calculate?  How did it compare to your Agilent?  Sample at 1MHz for a bit more precision.

The ATmega328 doesn't have much RAM so 1KB is about the limit.  The device profile is configured for only 1KB max, but since there is something odd with it, you're getting more options with the original SUMP device profile.  Now that you know the logic analyzer is working, you might try it with the correct device profile.  You could adjust some of the timeouts as well to see if you can get it to respond properly.

I merged in a patch for basic RLE support, but I haven't spent the time yet fully testing it and getting the timing correct.  It might help you get longer capture times.  You can use triggers as well to ensure you start capture around the interesting bits.

Really if you want larger samples you have a couple of options.  I would suggest the Open Bench Logic Sniffer for $50.  It is a very nice device for the price.  It is not unlimited either but has 24KB worth and supports RLE and advanced triggering.  Another option is a USB device like one from Saleae Logic that streams the samples so you effectively have a buffer only limited by the resources in your computer.  There are trade-offs.  I am biased I guess but I think the Arduino is "good enough" a lot of the time, but the OLS is well worth the $50 versus $300 for another USB model.

If we can figure out why the UNO R3 is finicky I think you will be fine in the short term with this sketch as a logic analyzer.  Several people have used it successfully for interesting projects:


My Arduino Uno R3 arrived today and I was able to reproduce the timeout issue.  Bumping the 'device.open.portdelay' to 2000 took care of it.

For some reason the Uno R3 is slower to respond after reset than my original Uno or older Duemilenove and clones.  I will investigate it a bit further if I get a chance just to see what the deal is.

Anyway I updated the device profile on github and sent a pull request to get the change into the alternate client.  It should make it into OLS 0.9.7 (at RC1 right now) so Uno R3 users should be good once that is out.

Meanwhile can one of you folks that had problems with the R3 try bumping up the device.open.portdelay (change from 1500 to 2000) and report back?


I've got it going at device.open.portdelay = 1560, and device.receive.timeout = 100

As for accuracy, if you use the measure tool it fluctuated between 10.000kHz and 10.101kHz
My Agilent U1272A showed 10.005kHz, and my old Rat shack DMM showed 10.01kHz


Jul 24, 2013, 02:19 pm Last Edit: Jul 24, 2013, 06:22 pm by Erni Reason: 1

I need some help.
I have installed OLS-
I click on the run.bat and get the expected interface.
But when I click on "start capture" I get a box showed in the picture.
There are no way to set the baudrate or com port.

Are you using another version ?

Found this, and it is working



I've updated the AGLA code ( https://github.com/gillham/logic_analyzer ) to support 2MHz and 4MHz capture rates.  This was done by using unrolled loops based on some work by Bob Davis ( http://bobdavis321.blogspot.ca/2013/06/six-channel-3-million-samples-per.html )

The maximum sample rate at 16MHz is 5.333MHz (3 clock cycles per sample) but the timing doesn't work out right with that clock rate.  You can still get that rate by removing the NOP on the 4MHz rate if you want to experiment.  If you run your ATmega at 20MHz you can sample at 5MHz and it should work pretty well timing wise.  I haven't tried it yet, but hopefully will eventually.  Note this would generally be on your own board or a breadboard setup since the Arduino is clocked at 16MHz.

I settled on 2MHz and 4MHz as being particularly useful samples rates and they appear to be as accurate as the lower rates.  The code size is rather significant now do the unrolled loops.  It just fits on an ATmega328.  If you're using an ATmega168 you will need to comment out either the captureInline2mhz() or the captureInline4mhz() call.  Then the compiler won't link that function in and you'll be fine.  You can also comment out one of the other capture lines but I would say probably commenting out captureInline2mhz() is the way to go as it is the largest and leaves you with 4MHz.

Note that you should really not expect to use triggers with 2MHz & 4MHz since I can't check the trigger conditions at those speeds.  You can use a trigger though, just know that the sample rate for the trigger condition is below 1MHz so if you are toggling something to trigger the logic analyzer make sure the toggle is long enough to get caught.  Once the trigger fires the sampling is done at the faster clock rate.

I've tested it on an Uno and a Mega and it works as expected.  If you test it and run into any problems (besides that slow upload!) let me know by filing an issue on github or posting here.

I also added some commented out code at the end of setup() to turn on timer2 at 100KHz on pin 11.  The code is '#if 0', just set that to '#if 1' to include it.  This is really only useful to validate your setup works with a know signal that is internally generated.  Since it is internal and using the same clock the sample code is using, it should give you a nice accurate 100KHz signal to look at in the OLS client.  I've submitted a pull request to get the new sample rates into the OLS client device profiles in version 0.9.7 but the github repository also has updated device profiles.


Sep 07, 2013, 03:30 pm Last Edit: Sep 07, 2013, 03:31 pm by ahmedwahdan Reason: 1
i have this problem

logic_analyzer_inline_2mhz.ino: In function 'void captureInline2mhz()':
logic_analyzer_inline_2mhz:54: error: 'trigger' was not declared in this scope
logic_analyzer_inline_2mhz:55: error: 'trigger_values' was not declared in this scope
logic_analyzer_inline_2mhz:55: error: 'CHANPIN' was not declared in this scope
logic_analyzer_inline_2mhz:71: error: 'DEBUG_ENABLE' was not declared in this scope
logic_analyzer_inline_2mhz:72: error: 'DEBUG_ON' was not declared in this scope
logic_analyzer_inline_2mhz:74: error: 'DEBUG_OFF' was not declared in this scope
logic_analyzer_inline_2mhz:93: error: 'logicdata' was not declared in this scope
logic_analyzer_inline_2mhz:93: error: 'CHANPIN' was not declared in this scope
logic_analyzer_inline_2mhz:14444: error: 'readCount' was not declared in this scope


"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


i attach file , i download it from github


What files do you have in the directory ?
You should have all 3 INO files in a directory named "logic_analyzer" then you should open "logic_analyzer.ino" in the IDE
The 2 others INO files are sub parts and should not be compiled on their own.


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

Go Up