Pages: [1] 2   Go Down
Author Topic: Arduinolyzer: Arduino Logic Analyzer  (Read 3031 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So I'm just out of college and sort of bummed by the lack of expensive EE equipment. I'm a CompE without a scope, logic analyzer, or any of the other $1000+ tools from the lab.

I came up with a quick solution for the logic analyzer and first test look like works pretty decently. I'm thinking it might be a cool project if there was a decent GUI attached.

From what I can tell, I can capture short bursts of data up to 206kHz.

Quick question, though: has anyone encountered problems where really long arrays crash a program? There are a million ways to change this for more compression, but at present I can only store up to about 175 logic changes before I start getting garbage or crashes.
« Last Edit: October 09, 2008, 12:46:50 am by yikes128 » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Source here:
http://www.allweapons.net/projects/arduinolyzer/source.c
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks like the problem is caused by the 875 bytes consumed by your array of logic_structs . The chip only has 1k of ram and some of that is used by the arduino start up code.

Your struct consists of 5  bytes (Boolean is a byte), you could increase your array size by using 15 bits for cycle and 1 bit for the logic level. This would increase the max array size to around from 175 to around 440. But it would reduce the maximum value of cycles to 32k  If this is an approach that you want to take and your not already familiar with bitfields, have a look at using that to manage the data in your structure.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks! That's very helpful.
Logged

Wigan
Offline Offline
Newbie
*
Karma: 0
Posts: 25
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello!

Did you ever fix this?

really interested in trying it!

Thanks!
Logged

London
Offline Offline
Tesla Member
***
Karma: 10
Posts: 6250
Have fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks like the code has not changed, I am not sure if yikes128 is still around.

It may work as is if you have a board with 2k of RAM (a 328 controller).
But bear in mind this is limited to a single channel at a maximum data rate of around 200kHz
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 5557
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
But bear in mind this is limited to a single channel at a maximum data rate of around 200kHz

Udo's in the playground seems somewhat better in the task (though more difficult to follow, and you need to use the avr tools directly according to the comments to get it into your arduino); it uses an unrolled loop in assembler to sample a single port (D) quickly 1024 times upon a trigger on one of the pins (via a bitmask), then prints the results to the serial port.

http://www.arduino.cc/playground/Main/LogicAnalyzer

Personally, it seems like a better option, even if it is more difficult to follow; I think if you took it, made some modifications to it, added on a button interface and a KS0108 GLCD gui - you would have a very nice little low-cost logic analyzer...

One thing it does seem to lack is any form of inter-sample timing; it is basically digitizing the port as fast as possible, each sample "in between" time is the number of clock cycles for each "set" of sampling instructions in the unrolled loop (it turns off the interrupts during the sampling phase, I think, so they don't cause issues, then turns them back on after it is done).

It looks like it was written for the 168; I am not sure if you would need to modify anything for the 328 (you could increase the sample buffer, though).

 smiley
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

0
Offline Offline
Full Member
***
Karma: 2
Posts: 109
ArduiYES!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just added a reply to http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1269604194 about an interesting alternative
for the logic analyser (I think).
Being an Arduino newbie I am not sure if there is a good match between the arduino and this thing, but there might be.

am I correct that on an 16mhz avr, this unrolled code
takes an st (2 clockcycli) and in (1 clockcycle) instruction, meaning a sample rate of 16/(2+1) Mhz ?
and therefore covering less than a millisecond in a 1024 byte buffer ?
« Last Edit: May 15, 2010, 04:41:18 pm by raalst » Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 139
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Before anyone puts a whole lot of effort into logic analyzers, be sure you read about this:
http://dangerousprototypes.com/category/logic-analyzer/

$45, shipped, assembled, 32 channels (but 16 are really useful out of the box), 200Msps.

It's PIC based (unfortunately), but it's very powerful and very cheap.
Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 5557
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
am I correct that on an 16mhz avr, this unrolled code
takes an st (2 clockcycli) and in (1 clockcycle) instruction, meaning a sample rate of 16/(2+1) Mhz ?
and therefore covering less than a millisecond in a 1024 byte buffer ?

I haven't looked at it in-depth (that is, I haven't looked at how long each instruction takes, etc) - but if your numbers are correct, then yes, the sample period is going to be very short. Note that I believe it was done with a 168, with a 328 you could "double" the length (I think). Still, not a lot of time.

Potentially, you could dump the samples to an SD card, but I am not sure how you would glue the assembler together with the SD library (or if you would have to write your own assembler version?). Another alternative would be a serial EEPROM.

Udo's code is really a sampler, and not a strict analyzer; that is, it doesn't store timing information between transistions, it just stores whatever it grabs. But the same kind of system (an unrolled assembler loop) could potentially be used, only store the data on the transistion of any pin in the port (via an interrupt handler), and keep track of the time between interrupts (not sure if this can be done in an interrupt handler, though)...
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

0
Offline Offline
Full Member
***
Karma: 2
Posts: 109
ArduiYES!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

just to be clear, that link I posted tells about a digital scope, not a logic analyzer.

@cr0sh, thanks ! I need such a sampler for another purpose, and after I did the math it seems is is even too fast for me. so I can probably loop and avoid the asm stuff.

One beginners question : is there a read operation which reads a whole port (8 pins) in sketch ? ReadByte() or something ? it is imperative I read all 8 (or 4) bits at the exact same time.

Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 5557
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
One beginners question : is there a read operation which reads a whole port (8 pins) in sketch ? ReadByte() or something ? it is imperative I read all 8 (or 4) bits at the exact same time.

Look into "Direct Port Manipulation":

http://www.arduino.cc/en/Reference/PortManipulation

 smiley
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

0
Offline Offline
Full Member
***
Karma: 2
Posts: 109
ArduiYES!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

thanks again !
Logged

0
Offline Offline
Faraday Member
**
Karma: 23
Posts: 3470
20 LEDs are enough
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

With regard to my quick hack analyzer / sampler: I changed it to make it available from the IDE. However I did not try it. Hopefully I made no typos...

Since it allocates 1K for the buffer and serial needs some space as well you need a 328 or 644 to run it. Otherwise you need to make the buffer smaller.

And one more thought: it is only reasonable if you have way more time than money. As already mentioned you can get much better ones for little money.

Udo
« Last Edit: May 20, 2010, 05:16:44 pm by udoklein » Logged

Check out my experiments http://blog.blinkenlight.net

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 39
Posts: 5557
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
And one more thought: it is only reasonable if you have way more time than money. As already mentioned you can get much better ones for little money.

I still think taking your code (or a version of it), and marrying it up to the KS0108 with some kind of simple button interface would make for a neat project; kinda a complement to the seeedstudio o-scope...

 smiley
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Pages: [1] 2   Go Up
Jump to: