Help using logic analyzer on Arduino

Rob, thanks very much! I am looking to get very coarse measurements. Right now my board has a 1.5F super capacitor on it, hold up time is well over a second, probably close to 2 seconds. The cap takes a lot of time to charge. I am thinking I just need 200ms hold up time, so a smaller cap that charges faster. So a very coarse measurement, with a wide safety margin in case there is a card that is a real current hog.

Graynomad:
I use a couple of macros

#ifdef CLIENT_ATmega328

#define PULSE0 asm("sbi 5,0\nnop\nnop\nnop\nnop\ncbi 5,0");  // PORTB bit 0, 328 Arduino D8
#define PULSE1 asm("sbi 5,1\nnop\nnop\nnop\nnop\ncbi 5,1");  // PORTB bit 1, 328 Arduino D9
#endif

Rob, please forgive my ignorance of AVR ASM. I guess the instruction "sbi 5,0" sets port B bit 5 low, then "ncbi 5,0" sets it high? If so, why two separate instructions?

Nand-flash chip on a mega, I would have been sunk if I did not have the width & speed of the Logicport.

Agreed, and I may have similar issues soon interfacing with external SRAM.

3-4 MS before the ISR got called,

WTF? That's a heck of an interrupt latency. There must be something else at play there like somebody disabling ints for too long.

I guess the instruction "sbi 5,0" sets port B bit 5 low, then "ncbi 5,0" sets it high? If so, why two separate instructions?

Because it's a pulse, you set it high then set it low. You could also have a SET and CLEAR macro that each just did one of the instructions.

Re profiling...

Of course we can trigger and measure to get timing, we can do that 10 or more times and record the numbers but that's not a very good statistical sample.

Does anyone have a good way to, for example, run a test all day and get max, min, avg etc times?


Rob

Graynomad:
Because it's a pulse, you set it high then set it low. You could also have a SET and CLEAR macro that each just did one of the instructions.

No no, I understand its a pulse.

What I mean is, if sbi 5,0 sets it low, I would think sbi 5,1 would set it high? Why use different machine instructions?

sbi 5,0 to turn bit on then cbi 5,0 to turn bit off. :wink:

I see, they aren't write instructions in the normal sense, the 5 is the address of the register (PORTB is at address 5) and the 0 is the bit number.

The writing of a 1 or 0 is implied in the SBI and CBI instructions.


Rob

Just in case people missed the question buried in post #22,

Does anyone have a good way to, for example, run a test all day and get max, min, avg etc times?


Rob

Graynomad:
Just in case people missed the question buried in post #22,

Does anyone have a good way to, for example, run a test all day and get max, min, avg etc times?


Rob

I've done that kind of stuff before but not using a logic analyzer.
I've profiled disk drivers in live running operating systems before and
used a combination of high resolution counter/timers, buffers and even some additional storage
to log the data in real time and then post process it all later.

Given the large storage capabilities in the Logic s/w, you might be able to run a trace for "a bit"
of time, then export the data and post process it to get the numbers you want.
The CSV export format looks pretty easy to parse.
Probably won't be able to import it into a spread sheet as things like MSFT Excel can only handle
65536 rows.

But even that only gets you a few minutes until you really slow down the sampling rate.
1Mhz gets you a few hours.

min and max might be much easier as for those you might be able to get away tracking those
in software. Depending on your timing and resolution needs, you could even use the
Arduino micros() call and then keep track of the min an max deltas. It is only two numbers
which for many situations won't add too much overhead to calculate and compare.
The extremes may actually be more important to know than the average.

--- bill

Graynomad:

3-4 MS before the ISR got called,

WTF? That's a heck of an interrupt latency. There must be something else at play there like somebody disabling ints for too long.

Sorry- that was a major typo. I've updated the original post. PLEASE RE-READ that post everyone!

Graynomad:
Does anyone have a good way to, for example, run a test all day and get max, min, avg etc times?

The problem I am seeing with Arduino IDE 0023 on Windows XP, SP3 is that when the IDE is running with the console open for many hours,
there is a loss of communication to the Arduino. Red error messages are displayed in the lower half of the console.

Others have reported something similar.
I need to double check to make sure the screensaver or power management isn't kicking in and turning off the USB port.

cappy2112:
The problem I am seeing with Arduino IDE 0023 on Windows XP, SP3 is that when the IDE is running with the console open for many hours,
there is a loss of communication to the Arduino. Red error messages are displayed in the lower half of the console.

Others have reported something similar.
I need to double check to make sure the screensaver or power management isn't kicking in and turning off the USB port.

I use TerraTerm.

cappy2112:

Graynomad:

3-4 MS before the ISR got called,

WTF? That's a heck of an interrupt latency. There must be something else at play there like somebody disabling ints for too long.

Sorry- that was a major typo. I've updated the original post. PLEASE RE-READ that post everyone!

Graynomad:
Does anyone have a good way to, for example, run a test all day and get max, min, avg etc times?

Haha... When I read that, I read it as uS to begin with... Funny how our brains do those things...

skyjumper:

cappy2112:
I used the Logic analyzer to profile my ISR response & latency time.

I was seeing 3-4uS before the ISR got called, and ~6uS inside the ISR.
Oddly enough, getting back from the ISR to loop() took a horrible amount of time. I never understood why.
There were some posts about the ISR not clearing the interrupt flag. I tried clearing it in the ISR, but didn't reach any reasonable conclusions.

I'm starting to think it may be better to bite the bullet and ditch the Arduino safety net.
At the same time I'm not looking forward to bringing up a microcontroller from scratch.

skyjumper:
Thanks for posting those numbers, that's very helpful.

I'm sure you understand this but for those who don't...

The ~6uS of ISR time is mostly due to what I'm doing in the ISR. This is not a specification by any means, and is actually quite long for a typical ISR.
My application doesn't need very fast response.

Small typo. BIG difference :slight_smile:

The extremes may actually be more important to know than the average.

Exactly, in a system that has to respond within say 100uS the only thing that matters is if it ever takes > 100uS and it would be nice to stress test for 2 days and see if it ever happens.

I suppose that can be done with timed triggers if that feature is available, but average times in a function and other profiling is useful as well.

I'm just wondering if it's worth adding some hardware to allow a plug-in debugger to help with this, of interest to maybe < 1% of Arduino users but an interesting project.


Rob

skyjumper:

cappy2112:
The problem I am seeing with Arduino IDE 0023 on Windows XP, SP3 is that when the IDE is running with the console open for many hours,
there is a loss of communication to the Arduino. Red error messages are displayed in the lower half of the console.

Others have reported something similar.
I need to double check to make sure the screensaver or power management isn't kicking in and turning off the USB port.

I use TerraTerm.

We use that too, but going back and forth between the IDE to compile & download, then having to close the com port is a pain.
For an overnight run while monitoring the UART is just fine.

BTW- there is a virtual com port software called com0cm which creates virtual com ports, so that multiple apps can effectively use the same com ports at the same time.
Obviously there is some stream multiplexing going on, but when it works it makes life easy.

I haven't been able to get it working yet- but others have figured it out.