Arduino Forum

Using Arduino => Interfacing w/ Software on the Computer => Topic started by: gillham on Feb 20, 2011, 09:21 am

Title: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Feb 20, 2011, 09:21 am
I recently implemented a logic analyzer compatible with the SUMP protocol.  It was designed for a 16MHz Arduino with the ATmega328p.  It might work fine on the ATmega168 but I haven't tested it.  I'm using a Duemilanove.  You will have to disable auto reset to make this work.  See this topic:  http://www.arduino.cc/playground/Main/DisablingAutoResetOnSerialConnection

The loops that do the sampling have been hand tuned to fairly precise timing using an Open Bench Logic Sniffer to measure the cycles.  You absolutely need a 16MHz clock for accurate data.  I haven't looked at making a version for other clock speeds but you can file a request at GitHub.

I'm very interested to hear from you if you try it on your hardware and find it useful or have trouble.  I have done limited testing of multiple channels as well as basic triggering.  If something doesn't work I would appreciate some feedback.

Get the code here: http://github.com/gillham/logic_analyzer

Here's my initial README:

SUMP compatible logic analyzer for Arduino
==========================================

This Arduino sketch implements a SUMP protocol compatible with the standard
SUMP client as well as the alternative client from here:
   http://www.lxtreme.nl/ols/

This SUMP protocol compatible logic analyzer for the Arduino board supports
5 channels consisting of digital pins 8-12, which are the first 5 bits (0-4)
of PORTB. Arduino pin 13 / bit 5 is the Arduino LED, bits 6 & 7 are the
crystal oscillator pins.
Uncomment CHAN5 below if you want to use the LED pin as an input and have
6 channels.

NOTE:
You must DISABLE the Arduino auto reset feature to use this logic analyzer
code. There are various methods to do this, some boards have a jumper,
others require you to cut a trace.  You may also install a *precisely*
120 Ohm resistor between the reset & 5V piins.  Make sure it is really
120 Ohm or you may damage your board.

To use this with the original or alternative SUMP clients,
use these settings:

Sampling rate: 1MHz (or lower)
Channel Groups: 0 (zero) only
Recording Size: 512 (or lower)
Noise Filter: doesn't matter
RLE: disabled (unchecked)

Triggering is still a work in progress, but generally works for samples
below 1MHz.  1MHz works for a basic busy wait trigger that doesn't store
until after the trigger fires.
Please try it out and report back.

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Feb 28, 2011, 11:26 pm
I updated this code today.  It now fully supports recording 1024 samples.  I had accidentally defined the samples as integers and overlooked this fact until this weekend.  The timing / padding was redone now that the loops are doing single byte assignments and compared against the OBLS again.

Note that I recently bought a "Seeeduino V2.21 (Atmega 328P)" which has a switch to disable auto-reset.  It works really well with this code.  Now that I have tried both, I definitely prefer an auto-reset disable switch or jumper over the 120 ohm resistor method.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: neurostar on Mar 05, 2011, 07:35 am
I was looking forward this for a while. Finally, we have Arduino based logic analyzer with proper GUI!
I appreciate your effort and will try soon.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Mar 06, 2011, 07:37 pm
Let me know how it works for you.  I still need to work on triggering, but the basic logic analyzer functionality is there.

Also, I have been working on a device profile with the help of the author (Jawi) of the alternative SUMP client.  Once the profile is correct and Jawi adds it, the next release of his client should have better support.  The most significant feature is it  will no longer require disabling auto-reset as he added the ability to delay a bit until the device is ready after the serial port is opened.  If you want to use the original SUMP client you'll need to disable auto-reset, but really Jawi's client is the way to go.

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: neurostar on Mar 07, 2011, 05:40 am
Tried and works great. It was a bit hard to catch sparse I2C signal without triggering but it works.
I was planing to buy the bus pirate as a logic analyzer, now I don't need it.  :)

Looking forward to see trigger and proper device profile.
I don't even bother to try original SUMP, since alternative one look better.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Mar 07, 2011, 09:21 am
Thank you for testing this code and reporting back.

I think I have a fix for basic triggering, I need to test it further and re-measure the timing before I commit it.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Mar 08, 2011, 08:25 am
I believe I've made basic parallel triggers work as they should and updated github.  Can you try the latest code with some triggers and report back?
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: neurostar on Mar 16, 2011, 09:54 pm
Sorry, I forgot to subscribe the thread. I will test and report. Thanks again. :)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: maca404 on Apr 29, 2011, 02:45 pm
Has anyone else had issues with this,  I compiled it put it on the arduino and then disabled the auto reset.   I tried the settings listed but always get " device can not be found".  The tx/rx lights blink when I try to connect so something is happening at least.  Just not sure what to test from this point.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on May 02, 2011, 04:44 am
Use the Arduino IDE's Serial Monitor tool, at 115200 bps, to send '1' or '2' and you should get something back from the logic analyzer code if it is running.  If you get the debug output, then I would say it is a problem with auto-reset not being fully disabled that prevents the SUMP client from working.

If you can, use a build from github of the newer alternative client that supports device profiles.  ( https://github.com/jawi/ols ) You'll have to check it out with git and build it yourself with maven.  Put the attached file in <git clone location>/ols.distribution/src/main/config for the 'master' branch.

The github built alternative client won't require you to disable auto-reset and it will default to values that work with the AGLA.  If you can't build it I could make a known working image available.  It is just over 3MB.

Let me know how it goes.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: BoxingOrange on Jul 26, 2011, 10:58 am
I'm looking to try this code but wanted to know which, if any, pin is used for ground, or doesn't this matter, this seems to be necessary with the original Open Bench Logic Sniffer.  I intend to load the sketch to my Arduino, leaving it connected to my PC for power, connect the probe pin(s) to those that I want to monitor and run OLS.  Has the device profile been added to the latest version of OLS, I downloaded it last night but couldn't see a specific device for the Arduino.

Thanks for any help.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jul 29, 2011, 09:14 am
Use the ground pin on the Arduino and it should work fine.  That's how I've been testing it.

The device profile hasn't been added yet, you can use the one attached to my previous post.  If enough people are using it, eventually we can get it added to distribution.

If you have any trouble getting it working, let me know.

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: caroper on Jul 31, 2011, 12:31 pm
Hi gillham,

Thanks for posting this, it looks like it is exactly what I was looking for to demonstrate simple Sequential logic, on a breadboard, without having to use a professional logic analyser. However I cant seem to get it to work :)

I Downloaded ols-0.9.4 and placed the ols.profile-agla.cfg into the plugins directory.
I have \gillham-logic_analyzer-ff10c1e compiled and loaded on a MEGA256 and it responds to the debug commands 1 and 2.
When I capture I can select the Device and the Port, the LEDs on the Arduino flash but OLS returns Capture Aborted! Device not found!.
I have not disabled auto-reset, as this is not my board so I don't want to cut the trace :)
Do I need the special build of OLS you mentioned?
if so would you be willing to provide it as I don't have the capability to Build from source.

Thanks
Chris

p.s. I didn't use the make file you provided with the pde file as I was not sure how to, have I compiled incorrectly by not using it?
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: BoxingOrange on Jul 31, 2011, 01:02 pm
Hi Chris,

I just did all this on Friday, I've compiled the latest OLS with the AGLA profile, here's a link if you want it :- http://www.mediafire.com/?84nfcq31to7p1bk


Karl
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: caroper on Jul 31, 2011, 01:09 pm
Thanks Karl,

You are a star, downloaded and installed ok, but is still get the Capture Aborted! Device not found!
I will have to fish around for a 110ohm resistor and see if that works.

Cheers
Chris


Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: caroper on Jul 31, 2011, 05:45 pm
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?

GOT IT :)

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.

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jul 31, 2011, 09:38 pm
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.

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: caroper on Aug 01, 2011, 09:27 am
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 (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.

Cheers,
Chris



Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Aug 01, 2011, 08:25 pm
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 )
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: caroper on Aug 02, 2011, 01:20 am
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?

Cheers
Chris
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Aug 02, 2011, 02:44 am
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Aug 02, 2011, 03:17 am
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Aug 04, 2011, 04:41 am
I've added initial Mega 2560 support to the logic analyzer.  Please check it out here:
https://github.com/gillham/logic_analyzer

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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: caroper on Aug 04, 2011, 09:38 am
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:
http://www.easyvitools.com/rdesign/index.html (http://www.easyvitools.com/rdesign/index.html)

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.

http://www.tina.com/English/tina/real_time_t_m (http://www.tina.com/English/tina/real_time_t_m)

Cheers
Chris

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: al1fch on Aug 04, 2011, 10:52 am
Thanks Ghillam !

I imagine your code with some SDRAM !!!
http://dangerousprototypes.com/docs/Logic_Shrimp_design_overview (http://dangerousprototypes.com/docs/Logic_Shrimp_design_overview)
or here :
http://www.ikalogic.com/scanalogic2/build.php (http://www.ikalogic.com/scanalogic2/build.php)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Aug 04, 2011, 11:31 pm
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. :)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: grant1842 on Dec 20, 2011, 01:28 am
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: tocpcs on Dec 25, 2011, 10:41 pm
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Dec 27, 2011, 09:43 pm

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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Dec 28, 2011, 01:24 am

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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Dec 28, 2011, 01:52 am
You can either download the files from the branch via the web interface, or using the git command line.
Here's how to use the commandline.

Initial checkout (of master branch) and switching to logic_analyzer_megaram branch.
$ git clone https://github.com/gillham/logic_analyzer.git
$ cd logic_analyzer
$ git checkout logic_analyzer_megaram

Switching back to the master branch is easy.
$ git checkout master
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: jettie on Dec 30, 2011, 12:07 am
Thank you gillham for your great code.

I was about to describe some difficulties i was having but they all got solved while I was typing) so thanks again.
But could you please share your signal generator sketch along with some instructions on how to use it.
I have your code on Mega 2560 and would like to test it with another Uno I have.
Thank you and a Happy New coming Year to all!
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: USMC on Dec 31, 2011, 03:17 am
I have been messing around with some IR decoding and thought I would give this a shot and had a few problems.

Has anyone updated the Sketch since Arduino 1.0 came out?

I get a compile error that "As of Arduino 1.0, the 'BYTE' keyword is no longer supported. Please use Serial.write() instead.

I started to make the modification and got stuck in a few places that had "Serial.write(0x00, BYTE );" Changing to  Serial.write(0x00); produces a new error. I figured I would ask before I spent too much time.

Thanks,
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: tocpcs on Dec 31, 2011, 03:41 am
Try here: https://github.com/gillham/logic_analyzer/branches
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: USMC on Dec 31, 2011, 06:51 am
@tocpcs: Thanks for the link.

I was able to get the latest sketch (logic_analyzer.ino) to compile after commenting out #define MEGARAM 1. I copied the .cfg files and made sure they were modified for the 1000ms delay as noted in an earlier post, still getting "device not found". I get a response from the Arduino via serial when the sketch is running by pressing 0 or 1.

Arduino Duemilanove W/Atmega 328
Macbook Pro W/OS X 10.7.2
Logic Analyzer Client 0.9.4
Logic Analyzer Sketch Release: v0.06 November 4, 2011.
Arduino 1.0

I had some similar growing pains with the Bus Pirate, but eventually got it going. Any suggestions would be great.  

-John

**UPDATE**  Increased the delay to 1500ms and it seems to be working
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Dec 31, 2011, 11:38 pm
The master branch (what shows up on the front page of http://github.com/gillham/logic_analyzer ) should work fine on 1.0 and doesn't have the Mega external SRAM support. Make sure the branch drop down says "master" and you should have the right one.

I'm working on a version for the Mega with 512kb of external SRAM (via a "QuadRAM" board). The current branch doesn't bank switch and supports 55kb. My bank switch version is in development but will support at least 443kb of samples at 500KHz.

Anyway, let me know if you have any more trouble and try the master branch if you can.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: robsbots on Feb 07, 2012, 10:33 am
Hi all

This looks like a great project. Just what I'm looking for.

I currently have a Mega1280 clone.  Any reason this should not work?

If not I'll give it a try.  Whats the best client to use. I'm on Vista.
Thanks for any pointers offered.

Carry on the great work.

Rob
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: barbudor on Apr 09, 2012, 11:21 am
Hi guys

I've read the thread from the beginning and I'd like to use this tool.
Unfortunately I am a bit lost with some steps as I am a Windows moron  :D

I managed to install Git for Windows (yeah! ;)) and grab both Gilham and Jawi tree.
I can find the Arduino sketch in Gilliam but not sure what I have to do with hundreds of files for OLS.
I understood it needs to be compiled ! Java ? Compiled ?

I also tried to get the pre-built binary from BoxOrange opst on page 1 but the file has moved away from MediaFire

So if someone could summarize me what I need to do to get OLS ready to run, or provide me a pre-built one, that would be nice.

Thanks in advance.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: jhax78 on Dec 19, 2012, 10:31 pm
is this project still maintianed?
i really would like some help to get my leonardo working with this.
thanks in advance.
sry for posting in this old thread but couldn't find any other info about it.

edit

nvm figured it out myself it's missing a line of code

[Arduino compatible config file]
Code: [Select]

# Configuration for Arduino Generic Logic Analyzer profile

# The short (single word) type of the device described in this profile
device.type = AGLA
# A longer description of the device
device.description = Arduino Generic Logic Analyzer
# The device interface, SERIAL only
device.interface = SERIAL
# The device's native clockspeed, in Hertz.
device.clockspeed = 16000000
# Whether or not double-data-rate is supported by the device (also known as the "demux"-mode).
device.supports_ddr = false
# Supported sample rates in Hertz, separated by comma's
device.samplerates = 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000
# What capture clocks are supported
device.captureclock = INTERNAL
# The supported capture sizes, in bytes
device.capturesizes = 64, 128, 256, 512, 1024
# Whether or not the noise filter is supported
device.feature.noisefilter = false
# Whether or not Run-Length encoding is supported
device.feature.rle = false
# Whether or not a testing mode is supported
device.feature.testmode = false
# Whether or not triggers are supported
device.feature.triggers = true
# The number of trigger stages
device.trigger.stages = 1
# Whether or not "complex" triggers are supported
device.trigger.complex = false

# The total number of channels usable for capturing
device.channel.count = 5
# The number of channels groups, together with the channel count determines the channels per group
device.channel.groups = 1
# Whether the capture size is limited by the enabled channel groups
device.capturesize.bound = false
# Which numbering does the device support
device.channel.numberingschemes = DEFAULT

# Is a delay after opening the port and device detection needed? (0 = no delay, >0 = delay in milliseconds)
device.open.portdelay = 1500
device.receive.timeout = 1000 // this is the Missing line
# Does the device need a high or low DTR-line to operate correctly? (high = true, low = false)
device.open.portdtr = true
# Which metadata keys correspond to this device profile? Value is a comma-separated list of (double quoted) names...
device.metadata.keys = "AGLAv0"

# In which order are samples sent back from the device? false = last sample first, true = first sample first
device.samples.reverseOrder = true

###EOF###

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: alkopop79 on Feb 03, 2013, 06:09 pm
Hi,

I followed the instructions and set up both an Arduino Duemilanove and a Mega. They both appear at Devices and when I click on the Metadata-button, I can see OLS recognises the board. Yet, when I hit Capture begin, I cannot see anything happening. I tried logic signals of different speed and kind and cannot see any waveform on the channels. What am I doing wrong?
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: alkopop79 on Feb 03, 2013, 06:17 pm
Quote
Then send a 1 or a 2. The program should respond with some status txt. This proves that your program is running!


I've tried this one and indeed, I get data back on the serial monitor. I guess the problem has to do with the settings in OLS. Any ideas?
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: audiomixer on Feb 21, 2013, 09:21 am

is this project still maintianed?
i really would like some help to get my leonardo working with this.
thanks in advance.
sry for posting in this old thread but couldn't find any other info about it.

edit

nvm figured it out myself it's missing a line of code

[Arduino compatible config file]
Code: [Select]

# Configuration for Arduino Generic Logic Analyzer profile

# The short (single word) type of the device described in this profile
device.type = AGLA
# A longer description of the device
device.description = Arduino Generic Logic Analyzer
# The device interface, SERIAL only
device.interface = SERIAL
# The device's native clockspeed, in Hertz.
device.clockspeed = 16000000
# Whether or not double-data-rate is supported by the device (also known as the "demux"-mode).
device.supports_ddr = false
# Supported sample rates in Hertz, separated by comma's
device.samplerates = 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000
# What capture clocks are supported
device.captureclock = INTERNAL
# The supported capture sizes, in bytes
device.capturesizes = 64, 128, 256, 512, 1024
# Whether or not the noise filter is supported
device.feature.noisefilter = false
# Whether or not Run-Length encoding is supported
device.feature.rle = false
# Whether or not a testing mode is supported
device.feature.testmode = false
# Whether or not triggers are supported
device.feature.triggers = true
# The number of trigger stages
device.trigger.stages = 1
# Whether or not "complex" triggers are supported
device.trigger.complex = false

# The total number of channels usable for capturing
device.channel.count = 5
# The number of channels groups, together with the channel count determines the channels per group
device.channel.groups = 1
# Whether the capture size is limited by the enabled channel groups
device.capturesize.bound = false
# Which numbering does the device support
device.channel.numberingschemes = DEFAULT

# Is a delay after opening the port and device detection needed? (0 = no delay, >0 = delay in milliseconds)
device.open.portdelay = 1500
device.receive.timeout = 1000 // this is the Missing line
# Does the device need a high or low DTR-line to operate correctly? (high = true, low = false)
device.open.portdtr = true
# Which metadata keys correspond to this device profile? Value is a comma-separated list of (double quoted) names...
device.metadata.keys = "AGLAv0"

# In which order are samples sent back from the device? false = last sample first, true = first sample first
device.samples.reverseOrder = true

###EOF###




I have had a go at the original code to include some options for the ATmega32u4 - with your config file I can get signals into OLS, but the pinout is just not right.... did you get it to work properly with all of the channels working? I have tested an other port for the input [Port F - Analog A1 - A6] but the results are inconsistent....

- michael
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: audiomixer on Feb 22, 2013, 06:31 pm
I have worked on a version for the arduino leonardo board - still not 100% functional but much better now. I have changed the port back to portB bits 2 - 7 so that the channels match again. these are pins MOSI / MISO and digital 8 - 11.

I haven't gotten the trigger to work reliably, but that might be an issue with the code itself.

I also changed the max buffer size as the leonardo has a whopping 2.5k of SRAM instead of the 2k of the UNO. therefore the buffer can be extended somewhat.the code has a few more 'if statements' to inculde ATmega32u4 specialities, but otherwise is unchanged. I tried to comment as required.

so here are the modified  files for the leonardo:

- cheers,

Michael
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Feb 22, 2013, 10:17 pm

I've tried this one and indeed, I get data back on the serial monitor. I guess the problem has to do with the settings in OLS. Any ideas?


Can you try this again using the latest code & configuration files from github? 
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jun 23, 2013, 07:24 am
A couple of updates.   I had broken triggers with my previous change to PORTD and I've fixed it.  I also went back to PORTB as the default (with PORTD as a #define option) as it seems to work better for me.

Secondly, I've added a branch with a "toy" release of a network attached logic analyzer.  If you have a Wiznet W5100 (only thing I have tested) Ethernet shield you can play around with it with Jawi's OLS client.  Configure your appropriate ip in the sketch, upload it and connect to it on port 1234 from the OLS client.
I'm using PORTD as most of PORTB is the SPI connection to the Ethernet shield.
It is on a branch if you want to mess with it:  https://github.com/gillham/logic_analyzer/tree/aglan_alpha

It isn't particularly useful, but I suppose there might be a corner case where it helps.  Anyway, check it out, it is kind of fun talking to the logic analyzer via TCP/IP.

Lastly, I uploaded a primitive function generator sketch.  I use it with my logic analyzer testing along with an Open Bench Logic Sniffer.
You might get some use out of it.  https://github.com/gillham/function_generator

One caveat about the function generator, it is setup for a LCD Keypad shield available on eBay.  Look for the "DF Robot" on the silkscreen.
If there is interest I could make a version with a different UI (one button & LED, or serial, or what?) if you want to make suggestions, you can post on github.
You can use the square wave generator (max of 8MHz) as an emergency clock source for an AVR if you need it. :)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: u271D on Jun 30, 2013, 07:27 pm
HI,
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
Bytes:
done...

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 0.9.6.1, 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!

Thanks,
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jun 30, 2013, 09:25 pm
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: u271D on Jul 09, 2013, 05:57 pm
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
Bytes:
done...
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jul 10, 2013, 11:11 pm
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: u271D on Jul 13, 2013, 02:08 pm
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!
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jul 13, 2013, 07:52 pm
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:
http://davidderiso.com/post/51075837050/arduino-open-logic-sniffer-works-great-on-the
http://letsmakerobots.com/node/31422
http://www.instructables.com/id/Nunchuk-controlled-Helicopter/step3/Preparing-the-Logic-Analyzer/

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jul 23, 2013, 07:33 am
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?
Thanks.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: u271D on Jul 23, 2013, 07:05 pm
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
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: Erni on Jul 24, 2013, 02:19 pm
Hi,

I need some help.
I have installed OLS-0.9.6.1.
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 ?

Edit:
Found this, and it is working

https://github.com/jawi/ols/wiki
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Aug 06, 2013, 08:37 pm
I've updated the AGLA code ( https://github.com/gillham/logic_analyzer (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 (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.


Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: ahmedwahdan on Sep 07, 2013, 03:30 pm
i have this problem

(http://s8.postimg.org/dol0ngtf9/ard.jpg)

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
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: AWOL on Sep 07, 2013, 03:57 pm
Where's your code?
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: ahmedwahdan on Sep 07, 2013, 04:06 pm
i attach file , i download it from github
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: barbudor on Sep 07, 2013, 06:04 pm
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: ahmedwahdan on Sep 07, 2013, 06:45 pm
yes , i realize that . and now it works .
but how i can configure pc software to run continous ??
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: barbudor on Sep 07, 2013, 06:54 pm
It's not meant to run continuous.
Logic analyzer (opposite to oscilloscope) run single once they get the trigger
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Sep 07, 2013, 09:20 pm

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).

http://www.youtube.com/watch?v=vQ5TvnRdHMM

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.

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: kiltjim on Jan 24, 2014, 09:02 pm
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?
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jan 25, 2014, 02:08 am
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: ultimatewarrior on Feb 11, 2014, 07:32 am
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Feb 11, 2014, 09:16 pm

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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gismo on Feb 20, 2014, 07:59 am
Hi!
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)
10.SIGH
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!


UPDATE:
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?
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: crun on Feb 22, 2014, 08:11 pm
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.
Mask:
All ticked channels can trigger a capture.
Value:
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. ;)

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gismo on Feb 24, 2014, 06:12 pm
@crun,

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:
(http://i.imgur.com/myGfY8t.jpg)
(http://i.imgur.com/ODy1BxM.jpg)
(http://i.imgur.com/ZbVJpfO.jpg)
(http://i.imgur.com/YcHgxPm.jpg)

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!
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: c0love on Apr 15, 2014, 04:40 am
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)
(http://i.imgur.com/7RQT8tj.png)

* 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:
      (http://i.imgur.com/rqovcPm.jpg)

   > Connection Settings:
      (http://i.imgur.com/6MpsOy9.jpg)

  > Acquisition Settings:
     (http://i.imgur.com/lfehDt9.jpg)

  > Trigger Settings:
     (http://i.imgur.com/LqTsIlN.jpg)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: Riva on Apr 15, 2014, 08:55 am
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: chasgoj on May 12, 2014, 08:47 pm
Hi,
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.

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: Riva on May 13, 2014, 08:21 am
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.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: chasgoj on May 13, 2014, 09:30 am
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 :)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jun 21, 2014, 08:16 am
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. ;-)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: tibe on Jul 06, 2014, 04:45 pm
Hi,
   just wanted to say that your code works like a charm. Loaded on a Mega 2560 using additional resistor. OLS cient 0.9.7 under Windows 7.
Amazing stuff. Thank you for sharing with the community !

Tibia
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jul 07, 2014, 02:04 am
Cool. I'm glad it is working for you.  You shouldn't need the resistor to disable auto-reset with OLS 0.9.7.   Try it without it and see if it works ok.  Just make sure you select one of the Arduino device types and then try 'show device metadata'.  It should work.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: karlitos on Sep 27, 2014, 04:11 pm
Hello,

first of all let me thank you for your great work on the Arduino logic analyzer. I was able to set-up the logic analyzer with my Arduino board and the OLS cient 0.9.7  under Linux Mint 17.

I am able to see the digital signal I would like to examine. However I am still a little bit confused how should I set up the OLS client.

I am not sure if I understand the "trigger" function right. I thought, using the "trigger" only the repeated part of the signal will be shown (as I know it from an oscilloscope).

The signal I am interrested in has a certain "preamble" constisting from a "low" state for about a 5ms, than "high" state for about a 1,5ms and then a pattern 010101010101. How should I set-up the the OLS client to be able to trigger the signal ?

My settings are:
Sampling rate: 10,000 kHz
Recording size: Maximum

The signal(s) I would like to investigate are in manchester-code. There is a option in the tools-menu on the OLS client called "Line decoder".  How can I use it so it shows me the decoded data ?

Screenshot of the signal is here:
(http://s7.directupload.net/images/140927/nj3fcyqo.png)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Sep 28, 2014, 01:14 am
Hi, I'm glad you're able to use the code.

Regarding triggering, the Arduino logic analyzer supports basic parallel triggers where it looks at the state of each pin and if they match the enabled trigger's values, it starts the capture.  What you're thinking of is a serial trigger where it samples the same pin repeatedly and compares the trigger pattern with the last N samples.  At least that is my understanding.  The Arduino logic analyzer doesn't support serial triggers.  The Open Workbench Logic Sniffer (OLS), available for $50 from Seeedstudio, supports serial triggers as well as more complex triggers.

Essentially you would set a trigger on your data pin by clicking the 'Mask' checkbox for that pin and leaving the value unchecked.  Assuming the pin is pulled high by default. (I don't see the screenshot) That will trigger when that pin is low.  Unfortunately that is all you can easily do.  Once it triggers it will begin sampling until it runs out of buffer.  At 10KHz sample rate that would be about 100ms buffer.  That should get ~93ms of your Manchester encoded data.  If you use an Arduino Mega you can get about 7x that hopefully due to the larger memory for sampling.  The OLS hardware has 24Kbytes of buffer.

Regarding the line decoder, I have only messed with it with the "test device" generated sample.  It seems to generate on channel 2.  If you use the line decoder, setting it to manchester and channel 2, and click analyze, it should generate data on channel 0 and clock on channel 1.   Then set it to non return to zero and tell it data is on channel 0 and clock on channel 1 and hit analyze.  It should decode the data.  I've never tried it with data decoded from the Arduino logic analyzer, but I would be interested in your results or even the data capture out of the OLS client.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: karlitos on Sep 28, 2014, 12:11 pm
Hello,

thank you very much for clarification. By "triggering" I ment the serial trigger as you described it. If I click the "Begin Capture" button in the OLS client and go to the "Triggers" tab in the OLS Capture Window I can set Mode to Serial. As I understand it this (serial triggering) will only work on devices supportin this feature. Will the Logic Pirate support the serial triggering ?

Anyhow I am wondering why you can not see the screenshot I put in my previous post. Please look here: http://s7.directupload.net/images/140927/nj3fcyqo.png

I am still little bit confused with the OLS client and the arudino logic analyzer. The Pin 8 on the Arduinop device represents the channel 0. If I connect the data wire to the Pin 8 I get following output: http://s14.directupload.net/images/140928/5pi2t7gw.png

When I connect the wire to the Pin 10 (channel 2) I can see additional signal on channels 1 and 3 : http://s7.directupload.net/images/140928/f6pg5kt2.png
But after hitting the "Repeat capture with current device settings" button the additional data dissapears. Then it looks like:
http://s7.directupload.net/images/140928/8n6u858c.png

Then I selected the "Line decoder", slected channel 2 for data, left the rest unchecked/empty and clicked analyze. Now I can see this: http://s7.directupload.net/images/140928/kky5ki9r.png

For me it seems, that the original signal is "altered" changed. Also, I thought that the encoded Manchaster code has half the frequency of the original signal.

Sorry for the long post, I hope you can find the screenshots I made.

Thank you for all your help - K
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Sep 28, 2014, 09:29 pm
I'm not sure the Logic Pirate supports more than basic triggering.  I think it just triggers if any of the trigger enabled pins change state.  I believe via a pin state change interrupt.  While it has a very nice sized buffer at 256k, you have to decide if you need large buffer or more sophisticated triggering.  If you just want a large buffer some of the continuous read over USB types like the Saleae Logic might be better with a capture size limited only by your computer's storage capacity.

The Open Workbench Logic Sniffer (OLS) supports most of the triggering capabilities of an HP (now Agilent) 16550A logic analyzer according to this post. http://dangerousprototypes.com/forum/viewtopic.php?f=23&t=1711#p16505 (http://dangerousprototypes.com/forum/viewtopic.php?f=23&t=1711#p16505) For serious use I do recommend the OLS and a couple of the probe cables.

Of course an Arduino is a good tool for some basic logic analyzer work as long as you work within the limitations.  Client side issues (with decoders for example) will be the same with whatever hardware you use.  Though if some of the issues are related to capture precision the better hardware will help.

Regarding phantom signals I think that is generally some noise / cross talk on the pins issues with the chip.  You can put a 1k or 10k resistor to ground on pins you're not using to pull them down.  You could also use weak pull-down (or up) resistors (say 1M ohm) on all pins, even ones used for data, to help stabilize the signal.  Of course you also might want some current limiting resistors between the Arduino pins and the signal you're measuring as well. 

Your signal does look slightly different after the line decoder pass.  You might try using the clock recovery feature in that decoder if you know the clock rate on your signal.  I don't know that much about the decoders' inner workings as I have only used a couple of them a few times.  If you capture your original signal and save the data and PM me I can take a look at it though I'm definitely not an expert on the client.

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: BordIng on Oct 29, 2014, 09:22 pm
Hallo Gilham,

your project sounds interesting. I tried to download the arduino code to my borad (Arduino Uno, ATMega 328P-PU), but I got a compiler error before I can download. I have windows 7 64bit and an Arduino software 1.5.6-r2.

Code: [Select]
logic_analyzer_inline_4mhz:13: error: stray '\' in program
logic_analyzer_inline_4mhz:13: error: stray '\' in program
logic_analyzer_inline_4mhz.ino:285:46: error: invalid suffix "fcf79a7c74b59c6a49b95b5dac7dc0" on integer constant
logic_analyzer_inline_4mhz:501: error: missing terminating " character


any clue why I have this trouble?

Best regards
BordIng
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: jotapeh on Dec 08, 2014, 08:52 pm
It doesn't seem to be mentioned anywhere - it looks as though everyone is using this with raw Arduino inputs.

Would it be wise to create probe leads with, eg. 1MΩ input impedance (with 10pf cap in parallel)? It seems like that is the standard for scopes/logic analyzers in general.

Is there a property of the Arduino that makes this unnecessary?

EDIT: The answer is yes there is a special property of the Arduino that makes it unnecessary, and I apologize for posting this rather silly question! For those curious like I was, ATMega pins are by default "high impedance" equivalent to 100MΩ resistance. See: Arduino - Digital Pins (http://arduino.cc/en/Tutorial/DigitalPins)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: sergiofink on Dec 11, 2014, 02:42 pm
Hi people,

I have a problem with the logic sniffer. I´m trying to use the logic analyzer, but when I click the button SHOW DEVICE METADATA is shown the message DETECTION FAILED NULL. My Arduino board  is MEGA2560. I´m using the logical_analyze_agla_v0_10 and the Ols-0.9.7.1 versions. In the Arduino IDE, I compiled and uploaded the firmware in the Arduino board succesfuly. I used the serial monitor in the IDE, and after to digit 1, appeared the messages below:

readCount = 7168
delayCount = 0
logicIndex = 0
triggerIndex = 0
rleEnabled = 0
Bytes:
done...

I believe that the serial port of my board is ok. what may I do to resolve this problem? Can you tell me the steps?

Best Regards

Sergio Fink
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: sergiofink on Dec 11, 2014, 03:14 pm
Hi people,

I have a problem with the logic sniffer. I´m trying to use the logic analyzer, but when I click the button SHOW DEVICE METADATA is shown the message DETECTION FAILED NULL. My Arduino board  is MEGA2560. I´m using the logical_analyze_agla_v0_10 and the Ols-0.9.7.1 versions. In the Arduino IDE, I compiled and uploaded the firmware in the Arduino board succesfuly. I used the serial monitor in the IDE, and after to digit 1, appeared the messages below:

readCount = 7168
delayCount = 0
logicIndex = 0
triggerIndex = 0
rleEnabled = 0
Bytes:
done...

I believe that the serial port of my board is ok. what may I do to resolve this problem? Can you tell me the steps?

Best Regards

Sergio Fink
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: sergiofink on Dec 11, 2014, 05:22 pm
Hi gillham,

How are you?

I tryed to do your experience. I´m using the arduino MEGA2560 board, the ols 0.0.7.1 and logical_analyzer_agla_v0_10 versions. I compiled  and uploaded in the arduino board succesfuly. I used the serial monitor in the IDE. I digited 1 and appeared the message below:
readCount = 7168
delayCount = 0
logicIndex = 0
triggerIndex = 0
rleEnabled = 0
Bytes:
done...

After this, I runed the logic analyzer client. In the Capture ==> Begin Capture, when I click SHOW DEVICE METADATA, the error message appears: DETECTION FAILED NULL.

Can you help me to resolve this problem?
Best Regards
Sergio Fink
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jan 06, 2015, 02:38 am
Code: [Select]
logic_analyzer_inline_4mhz:13: error: stray '\' in program
logic_analyzer_inline_4mhz:13: error: stray '\' in program
logic_analyzer_inline_4mhz.ino:285:46: error: invalid suffix "fcf79a7c74b59c6a49b95b5dac7dc0" on integer constant
logic_analyzer_inline_4mhz:501: error: missing terminating " character

Sorry, I haven't been checking this forum too often and don't seem to be getting email notices on updates.  Did you ever resolve this issue?  It seems like a bad download / corrupt file.  Download it again or use git to check it out locally.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jan 06, 2015, 02:46 am

It doesn't seem to be mentioned anywhere - it looks as though everyone is using this with raw Arduino inputs.

Would it be wise to create probe leads with, eg. 1MΩ input impedance (with 10pf cap in parallel)? It seems like that is the standard for scopes/logic analyzers in general.

Is there a property of the Arduino that makes this unnecessary?

EDIT: The answer is yes there is a special property of the Arduino that makes it unnecessary, and I apologize for posting this rather silly question! For those curious like I was, ATMega pins are by default "high impedance" equivalent to 100MΩ resistance. See: Arduino - Digital Pins (http://arduino.cc/en/Tutorial/DigitalPins)
It is still a good idea to use a current limiting resistor on your inputs as well as pulling unused inputs to ground via a resistor, but it isn't strictly necessary.  You'll see stray values on unused pins when the nearby pin has a signal or random high values, etc.  It is a matter of a bit of noise during the sample.  Pull the pins low (or high if you like) that you're not using will clean that up.

A prototyping shield is a good way to mount the bits.  You can even add jumpers for each line to pull it down and a row of inputs for a cable like this one:  http://www.seeedstudio.com/depot/Logic-Shrimp-probe-cable-p-837.html (5 pins) or this one: http://www.seeedstudio.com/depot/Open-logic-sniffer-probe-cable-p-619.html (9 pins)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jan 06, 2015, 02:53 am
Hi gillham,

How are you?

I tryed to do your experience. I´m using the arduino MEGA2560 board, the ols 0.0.7.1 and logical_analyzer_agla_v0_10 versions.
Make sure you are using the latest AGLA code, either the 'master' branch or agla_v0_12.  Also make sure you're using the OLS client version 0.9.7 or newer (SP2 recommended)

Quote
I compiled  and uploaded in the arduino board succesfuly. I used the serial monitor in the IDE. I digited 1 and appeared the message below:
readCount = 7168
delayCount = 0
logicIndex = 0
triggerIndex = 0
rleEnabled = 0
Bytes:
done...

After this, I runed the logic analyzer client. In the Capture ==> Begin Capture, when I click SHOW DEVICE METADATA, the error message appears: DETECTION FAILED NULL.

Can you help me to resolve this problem?
Best Regards
Sergio Fink
On the dialog box where you set the serial port and can click "show device metadata", select one of the arduino types before clicking show device metadata.  Either one should work, once you read the metadata it should switch to the Arduino Mega Logic Analyzer automatically.   The reason for this is that the Arduino needs special treatment due to the auto-reset feature.  So if you use any of the other device types you won't get the right info back due to interaction with the auto-reset.

Since you can talk to it via serial that part looks good, it should just be a matter of selecting one of the arduino profiles prior to requesting the metadata.

Let me know if you have already solved this problem or not.  Also you can open issues on the github project page ( https://github.com/gillham/logic_analyzer/issues ) and I will see them for sure.

I'll try to check this forum more often but I think I have said that before. :)
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: dpdigital on Jan 16, 2015, 07:00 pm
Can someone tell me what I am doing wrong?

I cannot get the software to recognize my Arduino UNO.  It doesn't show up in the devices list.

I have checked that the Arduino compiled successfully by using the serial monitor and I get:

readCount = 1024
delayCount = 0
logicIndex = 0
triggerIndex = 0
rleEnabled = 0
Bytes:
done...

When I go to the devices list under the capture menu, I only see:

Generic I/O
OpenBench LogicSniffer
Test Device

OLS Version says 0.9.7.2

Any ideas?

Edit:  Nevermind, I think I got it figured out....selected OpenBench and the info was there to select the Arduino.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Jan 16, 2015, 08:40 pm
Edit:  Nevermind, I think I got it figured out....selected OpenBench and the info was there to select the Arduino.
Right, this is a little confusing in the client.  
1. Under the "Capture -> Device" menu you always want to have OpenBench LogicSniffer selected.  That puts the client in SUMP mode.  
2. Then the SUMP compatible device selection is done under the "Capture -> Begin Capture" menu choice when it pops up the "OLS Capture Settings" dialog box.
3. Then under "Device type" you select one of the Arduino types.
4. Click "Show device metadata" to verify the client can talk to your device.
5. Click "Capture" to test it at the default settings. (you wouldn't normally see a signal here, just noise off your Arduino pins)

Let me know if it doesn't work for you.

Note that the "Test device" is useful as you can generate/simulate a bunch of signals and then use the various analyzers on those signals.  It is a good way to learn more about how to use the client.

If you look at the bottom of the setup() function there is a an '#if 0' section that sets up a timer to do a 100KHz toggle of pin 11.  If you set that to '#if 1' and upload the sketch, you should see that signal when you capture with the client.  It is a quick way to see if your setup is working.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: irishcream24 on Feb 05, 2015, 11:49 am
Hi all,

first of all, let me say thanks to Gilham for his hard work on this project and for keeping this thread alive. I really like the idea of using this logic analyser. I am pretty new to arduino, but I have pretty much mastered the devil ;) (I have build a alarm clock with dawn style light dimming and music player combined). I am currently undertaking a home automation project. So I have uploaded the arduino sketch fine. I opened a serial port and get "readCount = 1024 ...  done..." output when I send a 1 to the arduino. When I send a 2, I get an array of zeros, even with a pulse going to pin 8 (I used my Yun to create a pulse by taking a pin to HIGH and then LOW with delay(2); function. Is it normal to get all these zeros with a pulse on one of the input pins? If so, then I guess it is working fine. I don't seem to be picking anything up on my OLS logic sniffer, but we can address that later.

Many thanks

Irish
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Feb 05, 2015, 08:23 pm
So I have uploaded the arduino sketch fine. I opened a serial port and get "readCount = 1024 ...  done..." output when I send a 1 to the arduino. When I send a 2, I get an array of zeros, even with a pulse going to pin 8 (I used my Yun to create a pulse by taking a pin to HIGH and then LOW with delay(2); function. Is it normal to get all these zeros with a pulse on one of the input pins? If so, then I guess it is working fine. I don't seem to be picking anything up on my OLS logic sniffer, but we can address that later.
Hey Irish.  The "all zeros" is normal as it is an artifact of the auto-reset when you open the serial port.  So in this case you can try to read with OLS and whether it reads or not, you won't see it when you use the serial monitor as the Arduino gets reset.   This sounds kind of weak I know.  I was using a resistor to disable auto-reset initially during development and the OLS client didn't support the delay and such features.

I have an open feature request on my github repository to add some more diagnostics commands.  I haven't made time to work on it yet, but I hope to this week or next.  Basically I will just add a few more simple numeric commands to kick off a predetermined capture.   Then you would be able to diagnose it a bit better as it shouldn't always be zero.

Meanwhile if you change the '#if 0' below to '#if 1' and re-upload the sketch, you will have a "fake" signal on pin 11.  Run the capture at 1MHz and you should see a good signal in the OLS client.  Once you know your OLS client can talk to the sketch on the Arduino and see a signal you can move to trying your externally generated signal.  As a side note I made a basic signal generator that supports a "DF Robot" LCD screen & buttons shield.  It is pretty basic but convenient to have a 2nd Arduino and the shield nearby when working on things like this sketch.

(this is near the bottom of the Setup() function)
Code: [Select]

#if 0
/*
* This sets up timer2 at 100KHz to toggle a pin. This is useful
* for debugging as it gives an internally precise signal source.
* This doesn't work on the Arduino Mega. Use on the Uno or older.
* We're using the same clock source for the timer & our sampling.
*/
...



OLS client capture settings.  (via start capture button or menu Capture -> Begin Capture)
Connection type: serial
Analyzer port: (pick your correct serial port device)
Port speed: 115200bps
Device type: Arduino Generic Logic Analyzer

You should be able to click "Show device metadata" at this point and get some results below the button.
If it times out there could be an issue with the amount of delay needed while your Arduino is resetting (due to auto-reset)

Acquisition settings:
Number scheme: default
sampling clock: internal
sample rate: 1MHz (defaults to 4MHz so change this)
Channel groups: 0 should be checked by default
Recording size: 1kB

Then clicking 'Capture' should work and show a nice square signal on pin 11.

I will post an update here once I add some better diagnostic features to the code.  Meanwhile let me know if this is working for you or not.

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: irishcream24 on Feb 07, 2015, 04:10 pm
Thanks Gillham,

I will try out what you suggested and get back to you in a few days

Cheers
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Feb 07, 2015, 09:56 pm
Ok, I added some better diagnostic commands that allow you to initiate a capture and then dump the buffer.

Send a '?' in Serial Monitor (or screen or whatever you use) to get a list of commands.
Code: [Select]
0 = clear cmd buffer
1 = print cmd buffer
2 = print data buffer
3 = pretty print buffer
4 = capture at 4MHz
5 = capture at 1MHz
6 = capture at 500KHz


Now you can enable the sample signal timer at the bottom of setup() and then sample at 4MHz (press '4') and dump the buffer (press '2') out in hex.

I also added an experimental feature ('4' above) to print the first part of the buffer in a "visual" way with '|' characters.

Let me know if you try it and how it works.
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: mpue on Feb 10, 2015, 01:17 pm
Hi there,

I recently stumbled upon this thread.

I've successfully managed to get the Logic Analyzer running on an Arduino Uno with the OLS client. Great work!

Everything works as expected. However on a new Mega 2560 board it does not work. The board doesn't even respond to any debug command. The board is ok, I've tested other serial example sketches such as "PhysicalPixel" or some simple serial echo routines.

I even tried the DisableAutoReset thing with an 120Ohm Resistor, but still no result.

I inserted some debugging code which toggles an led if serial data comes in. That works as expected on the Arduino Uno but not on the Mega 2560. It seems to me that the 2560 board hangs on the Serial.available() call.

Does anyone have any idea what could be wrong here?

Cheers
Matthias

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: gillham on Feb 10, 2015, 10:41 pm
I inserted some debugging code which toggles an led if serial data comes in. That works as expected on the Arduino Uno but not on the Mega 2560. It seems to me that the 2560 board hangs on the Serial.available() call.
I did not test the most recent changes on my Mega as they were just the debug / serial menu stuff, but I forgot how tight the memory use was on the Mega.

I just compared the compiled results between Arduino 1.0.6 and 1.5.8 and I think the problem is I ran it out of memory under 1.0.6.  I've been using 1.5.8 and it is more efficient.  Though the Mega could be a problem with v0.12, I can see for sure that v0.13 is out of memory when compiled with 1.0.6 and just low under 1.5.8.  

If you comment out the '#define DEBUG' it should free up enough space.  Or try it with Arduino 1.5.8 assuming you're not already.  You could also delete the '?' debug command's messages.

I'll look at putting the debug strings in flash via PROGMEM to make it work again on Mega and just for overall efficiency.

I recently dug my Mega out of storage so now I can test it properly, I just didn't with these last changes.  Sorry about that, but I appreciate your pointing it out now so I can fix it right away and not have a broken version sitting out there for too long.

I'm not an Arduino expert by any stretch, but so far I haven't seen any downside to using 1.5.8 and it's more efficient compiler is definitely nicer.   Though in this case I guess it hosed me a little!  :P
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: irishcream24 on Feb 11, 2015, 01:42 pm
 ;D
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: mpue on Feb 15, 2015, 08:57 am
@gillham:

Thank you for your response. I'll give it a try and let you know.

Cheers
Matthias
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: mpue on Feb 17, 2015, 08:35 am
Hi,

just this short info @gillham:

I tried everything you've mentioned, but still cannot get it to work.

Greetings
Matthias
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: pirlouwi on Mar 24, 2015, 10:10 pm
EDIT: If I use Logic Sniffer under Windows, the detection of my Arduino Mego Logic Analyser works.
Is there something wrong in the OSX version?

I want to use Gillham's fantastic logic analyser sketch on an Arduino Nano v3 clone (with an ATMega328p inside).
In OSX 0.9.7.2 version of Logic Sniffer:
- I choose "Arduino Mega Logic Analyser"
- I click on "Show device metadata", without success.
=> I always receive a "Detection failed" error.

I tried some configuration changes, to parameters like portdelay, portdtr, but nothing helps.
Is this sketch working with such Arduino?
If yes, should I do something special to make it working?

--
Pirlouwi
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: MGeo on Apr 10, 2015, 10:31 pm
Hi,

just this short info @gillham:

I tried everything you've mentioned, but still cannot get it to work.

Greetings
Matthias
Hi gillham,

Thanks for the great software, I've used it several times on an Uno to help with project debug, it works great.  I have a project where I need the bigger buffer of the Mega 2560.  I'm having same issues as Matthias under 1.0.6.  The board checks out ok with test serial sketches.  I've tried commenting out #define DEBUG and commented out the '?' debug println's, still no luck.

I've been meaning to eval moving to 1.6, so I'll give that a try and report back.

Thanks again,
George
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: MGeo on Apr 10, 2015, 11:08 pm
Ok,

Removed Arduino 1.0.6, installed 1.6.3.

Compiled logic_analyzer on Uno, tested on ols-0.9.7.2, works great.

Compiled logic_analyzer on Mega 2560, compiles with:

Code: [Select]
Sketch uses 150,674 bytes (59%) of program storage space. Maximum is 253,952 bytes.
Global variables use 7,812 bytes (95%) of dynamic memory, leaving 380 bytes for local variables. Maximum is 8,192 bytes.
Low memory available, stability problems may occur.


Works from Arduino serial monitor now, response to "1" and "2" commands.  Looking good.

Now tested under ols-0.9.7.2, and......works!

But...timing might be off.  For same signal I get 9mS pulse width on an Uno, and 8.822ms on Mega.  Will keep testing.

George
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: MGeo on Apr 11, 2015, 04:23 am
Did some more testing.  Using an ATMega328P Uno, recording the same test PPM generator (a Turnigy 9x ATMega128A running Er9x software, measuring PXX module output) I got the following results:

logic_analyzer.ino compiled under 1.0.6:
pulse frame start to pulse frame start = 10.03 mSec - 1.03 mSec = 9.00 mSec

logic_analyzer.ino compiled under 1.6.3:
pulse frame start to pulse frame start = 9.8 mSec - 0.91 mSec = 8.89 mSec

So slightly different results for the two builds, same host board and same test article but different Arduino revision.

George
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: MGeo on Apr 18, 2015, 10:22 pm
And here is a screen cap of the same hardware generated pulse stream, using a Saleae Logic to capture the pulse stream, confirms a fairly precise 9.0 mS spacing.

Thanks
George
Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: ichilver on Mar 05, 2016, 10:51 pm
Hi

I want to capture a logic trace from a 433Mhz receiver.

I don't seem to be capturing all the trace just a very tiny part of it.

What settings to I need to change to capture the entire trace?


Also is there a way the Arduino can trigger the OLS software to start the capture as the buffer size is small.  Running on a Duemilanove.

Title: Re: SUMP compatible logic analyzer code for Arduino.
Post by: spyadav on Jun 05, 2017, 04:53 pm
I am also using it for capturing a signal, but when I start capturing on Logic Sniffer, It displays capture from generic I/O started but nothing happens afterward. Please help me?
Also there are no options for trigger or device or anything in client (mac version 9.7.2). I only see 4 fileds
 1. set device path (I set this to /dev/cu.usbmodem1421   arduino usb path), I get to set
2. Sampling rate (I set this to 500K)
3. sample depth (this is set to default 256)
4. sample width (this is set to default 1)

Also I tried it on windows PC options are same but client show capture failed Data readout interrupted EOF
Please help me