Go Down

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


Jul 31, 2011, 05:45 pm Last Edit: Jul 31, 2011, 06:00 pm by caroper Reason: 1
Well I Created a header with a 100 and 10 ohm in series to bridge 5v to reset, but it appears that the Mega is still resetting.
any other Ideas?


Edit the plugins\ols.profile-agla.cfg File
line42: device.open.portdelay = 1000

The default was 500ms Delay increasing to 1second (1000ms) works fine without the 110ohm resister.


Jul 31, 2011, 09:38 pm Last Edit: Jul 31, 2011, 09:45 pm by gillham Reason: 1
I was going to post this morning to let you know about that setting, but you found it on your own.  Good job!  Glad to hear that helps on your Mega.

I have not tried my code on a Mega and the timing is hand tuned to the 16Mhz ATMega328 on the regular Arduino boards.  I don't have a Mega to test it, but since it is running at the same clock rate it might be fairly close already.

Let me know how it goes for you and if you have something you can test with to see how accurate the timing is that would be useful.  If you have another Arduino with a 16MHz crystal and ATMega328, I could get you a small signal generator sketch that you could use to measure with your Mega running AGLA.

If there is enough interest from other Mega users I can pick one up and test it out.  Basically I just use some debugging to toggle an extra pin inside the capture routines and time those toggles with my Open Bench Logic Sniffer.  It is accurate up to 100MHz so I can easily measure the Arduino pins.  I highly recommend the Open Bench Logic Sniffer for anyone getting further into things than my AGLA can provide.  Of course I think the AGLA is pretty nice for "free" on your existing Arduino, but obviously has some inherent limits.

Edit:  Forgot to address your question about the Makefile.  You did the right thing using the Arduino IDE and ignoring the Makefile.  That is only for command line use if you want to skip the Arduino IDE.  Especially useful with the 'arduino-core' package under Debian.  I have compiled on my ARM based Sheeva plug computer for the Arduino using the Makefile so it can be handy.


Thanks gillham,

For the application on hand accurate timing was not needed, I just wanted to demonstrate the relative timing on a simple sequential logic experiment, but your code has captured my imagination and I would like to take it further. I switched it to using PORTC and adjusted the profile to an 8Bit sample. I saw your timing code, It occurred to me that it could be used as an external clock to run the circuit under test, but I haven't tried that yet. I would be interested to see  your signal generator sketch, but unfortunately I only have the 2 Arduino Mega boards on hand.

I have a pic32 explorer and, hopefully, some chipKit MAX32's arriving this week so once the project that they were ordered for is completed, I may dedicate one to this application.

What I have in mind is an interface to a breadboard system, such as this http://www.radioshack.com/product/index.jsp?productId=3814337.
A dual channel scope, 8 channel logic analyser, a frequency counter and a simple multimeter application running on a cheap board, possibly enclosed in the Learning Labs case, would make a great learning tool for kids of all ages. Bandwidth in the audio range for the scope and up to one Mhz for the digital portions would probably be within the capability of a high end chip.



I ordered an Arduino Mega 2560 from SFE, should be here later this week.  I'll work on adding better support and get the timing tuned as needed.

I like your idea of combining oscilloscope ("The cheapest dual trace scope in the galaxy" style), logic analyzer, function generator etc into a workbench toolkit that is ready to go.  It could be done just by adding a couple extra commands (similar to the debug options) or extend SUMP slightly

My current function generator code is rather simplistic and is set for my 8MHz Arduino Pro Mini.  I use 1 button and 1 LED for the UI and it works ok.  Timing is fairly accurate according to my OLS hardware, since it is using a hardware timer, but running on a 16MHz Arduino the values will be off by a factor of 2.

Anyway, I'll attach my simple function generator for anyone interested.  Make sure you use current limiting resistors as appropriate so you don't damage anything.  If you connect your target board, logic analyzer, signal generator etc, it is too easy to have pins in the wrong mode, (both output, one high, one low etc) and over current the pins on one or both devices.  1k Ohm for example on the appropriate pins will limit 5V to 5mA.

Rugged Circuits has a great page about what not to do.  ( http://ruggedcircuits.com/html/ancp01.html )


Thanks gillham, I'll give it a try.

Any Idea where I can get documentation on the SUMP protocol so I can try and integrate the analog read into the data?



There original SUMP protocol is here: http://www.sump.org/projects/analyzer/protocol/
The extended version is here: http://dangerousprototypes.com/docs/The_Logic_Sniffer%27s_extended_SUMP_protocol

It seems like a couple 8bit "short commands" could be added as long as they don't overlap with anything listed in the above links.
My initial thought would be something like below.  These couldn't all be 8 bit short commands though as things like the function generator at least need parameters like what frequency or function.  I was just picking simple mnemonics so you could connect serially and press 'A' for example.  Might need a 'T' command to say "send values in text not binary" when doing that I guess.
Code: [Select]

#define SUMP_MULTIMETER_AMP_DC 0x41 // ASCII 'A' for Ampere
#define SUMP_MULTIMETER_AMP_AC 0x42 // ASCII 'B' (can't think of a mnemonic)
#define SUMP_FREQUENCY_COUNTER 0x43 // ASCII 'C' for Counter
#define SUMP_MULTIMETER_FARAD 0x46 // ASCII 'F' for Farad
#define SUMP_FUNCTION_GENERATOR 0x47 // ASCII 'G' for Generator
#define SUMP_MULTIMETER_HENRY 0x48 // ASCII 'H' for Henry
#define SUMP_MULTIMETER 0x4E // ASCII 'M' for Meter
#define SUMP_MULTIMETER_OHM 0x4F // ASCII 'O' for Ohm
#define SUMP_MULTIMETER_VOLT_AC 0x52 // ASCII 'R' for RMS maybe?
#define SUMP_OSCILLOSCOPE 0x53 // ASCII 'S' for Scope
#define SUMP_MULTIMETER_VOLT_DC 0x56 // ASCII 'V' for Volt
#define SUMP_MULTIMETER_WATT 0x57 // ASCII 'W' for Watt

It wouldn't really make sense for a SUMP logic analyzer client to use these extended commands, but adding them to my existing logic analyzer code would make it easy to have a device that responds to SUMP for the OLS client and does the extra functions as well.


I guess short commands are impractical since many of the functions need a 'type' (what to measure, or what kind of function to generate) followed by a 'range' or 'value' (what frequency to generate).  So perhaps the 1st byte commands could be:

Code: [Select]

#define SUMP_FREQUENCY_COUNTER 0x43 // ASCII 'C' for Counter
#define SUMP_FUNCTION_GENERATOR 0x46 // ASCII 'F' for Function
#define SUMP_MULTIMETER 0x4E // ASCII 'M' for Meter
#define SUMP_OSCILLOSCOPE 0x4F // ASCII 'O' for Oscilloscope

After that the 4 byte parameters can be whatever is needed for the appropriate functions.


I've added initial Mega 2560 support to the logic analyzer.  Please check it out here:

The Mega 2560 supports allows 8 channels (using PORTA, pins 22-29, but you can configure it) and 7K samples.  I have done some basic timing tests and it is fairly accurate.  I will tune it with my Open Bench Logic Sniffer soon, but it seems very usable already.

Please test it and let me know how it works for you.  I've added the two device profiles to the repository so they're easy to find.


Thanks gillham,

Looks good, I just did a quick sample with no inputs connected and channel 0 read High and the rest Low, I guess that pin has an internal pull-up assigned.  Thanks for confirming the timing and increasing the sample size.

I found this and thought you my be interested:

It is a bit too slow for our needs and looks old ( Help about says 2003 ) but is a great concept, if all you need is low speed switching and sampling. I am going to use it to do a Proof of Concept for the Bread-boarding tool interface. but I may have to write the target code myself to get the sort of performance I will need.

Is anyone out there aware of any other Control Panel / Virtual instrument tools that work with serial I/O ?
I have not managed to find anything customisable between this program on the low end and lab-view on the high end of the scale. They all seam to be designed to work with SPICE with no physical Real World interface or they are designed to work with dedicated hardware.

I did find a device that does provide all the functianality, but at a much higher speed and accuracy than I had in mind, with a corospondingly higher price tag too :) but I will include it here as It is a good target to aim for.




Aug 04, 2011, 10:52 am Last Edit: Aug 04, 2011, 11:02 am by al1fch Reason: 1


Regarding virtual instruments, I'm not familiar with many.  I've seen the cheap 'scope and another "miniscope" ( http://tomeko.net/miniscope_v2b/index.php?lang=en ) project.

I was kind of assuming something written in Processing would be best.  That way it is cross platform and could be used in conjunction with Firmata for example.

The thing with the oscilloscope is that the sample rate would be really low.  It would be better than nothing, and I'm not saying it isn't worth doing, but you won't get that many samples across the serial port.  Something like 11k 8 bit samples/second @115200 baud would be best case.

About the logic shrimp..  I prefer the Open Bench  Logic Sniffer.  Only a few dollars more and more capable.   The whole point of my code for the Arduino is "cheap & dirty" without paying $35-$50 and just using what you have.  I wouldn't expect anyone to buy a Mega to run my logic analyzer code, the OLS is cheaper. :)


I guys I am new to arduino.
I work on LCD , TV, SMPS, etc.
Sometimes I have to look up an IC data sheet and see what kind of wave it should put out on a certian pin so I can confirm the suspect IC is working.

Is there a way with this logic analyzser that I can use the arduino to test an IC just to confirm it works properly.

I test the PWM IC on SMPS and , sometimes the MCU on the main board.

Thanks for your input.


Something not mentioned - The direction to read it is from right to left?
I tested grounding pin 8 and that seems to suggest the LAST state change is at the beginning.


I guys I am new to arduino.
I work on LCD , TV, SMPS, etc.
Sometimes I have to look up an IC data sheet and see what kind of wave it should put out on a certian pin so I can confirm the suspect IC is working.

Is there a way with this logic analyzser that I can use the arduino to test an IC just to confirm it works properly.

You should be able to use a logic analyzer if the specs in the data sheet match the capabilities of an AGLA setup.  With limited numbers of samples and a limited sample rate it depends on the type of chip and what its digital signal is supposed to look like.  If the IC's pin transitions are in the 10s of microseconds you should be able to catch something.  You might want to read this page about all of the ways you can hook stuff up wrong and damage the pins on your Arduino: http://ruggedcircuits.com/html/ancp01.html

You might want to investigate the Bus Pirate ( http://dangerousprototypes.com/docs/Bus_Pirate ) as well since it is designed for interfacing to chips like you mentioned.


I imagine your code with some SDRAM !!!

I created a test branch ("logic_analyzer_megaram" branch on https://github.com/gillham/logic_analyzer/ ) with preliminary support for external SRAM on the Arduino Mega2560.  I am using the Rugged Circuits QuadRAM board ( http://ruggedcircuits.com/html/quadram.html ) myself.

The QuadRAM is paged, but without using any paging it adds a readily addressable 55KB of space for a capture buffer.  My test branch supports capturing up to 55KB if you have the '#define MEGARAM 1' uncommented. 

Due to some extra cycles on the external memory interface the sampling takes a bit longer and I had to adjust the timing a little.  Currently a regular (non triggered) capture at 1MHz is no longer accurate due to the increased delays with the external SRAM, but 500KHz and lower appears to be fairly accurate.  Triggered captures are not accurate at 500KHz (they weren't at 1MHz already) but are semi-accurate at 200KHz and lower.

Anyway, if someone has an external SRAM setup and can test this functionality I would appreciate feedback.  Rugged Circuits has the board on sale for $19.95 which isn't bad for a 512KB expansion module.  I'm not affiliated with them, I've just bought one of their boards.

Also, as the external memory interface uses the pins I had previously sampled on the Mega, I switched to analog pins 0 to 7.  I was avoiding using the analog pins previously so they would be available for other uses, but as I haven't added any other features to the firmware at this point, I switched pins.  The main branch has not been switched to A0-A7, but I might do that in the future.

Go Up