Go Down

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

gillham

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.

irishcream24

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

gillham

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.


irishcream24

Thanks Gillham,

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

Cheers

gillham

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.

mpue

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


gillham

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


mpue

@gillham:

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

Cheers
Matthias

mpue

Hi,

just this short info @gillham:

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

Greetings
Matthias

pirlouwi

#100
Mar 24, 2015, 10:10 pm Last Edit: Mar 26, 2015, 10:15 am by pirlouwi
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

MGeo

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

MGeo

#102
Apr 10, 2015, 11:08 pm Last Edit: Apr 10, 2015, 11:24 pm by MGeo
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

MGeo

#103
Apr 11, 2015, 04:23 am Last Edit: Apr 11, 2015, 04:26 am by MGeo
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

MGeo

#104
Apr 18, 2015, 10:22 pm Last Edit: Apr 18, 2015, 10:22 pm by MGeo
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

Go Up