Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Thread

Delay issue

Delay issue

2008-09-05 by englsprogeny

I am setting 2 outputs high (n milliseconds apart)

Problem is that when I look at them with my logic analyzer, the
distance between them going high isn't always what I've coded.

My configuration is:

Compiling with WinAVR 
ATMega8
External clock (8Mhz crystal)
My Fuses are set correctly

-------------------------------

I've modified the makefile to have:

F_CPU = 8000000



-------------------------------
C Source:


#include <avr\io.h>
#include <avr\delay.h>

int main(void) 
{	
	
	//set port c as all output
	DDRC = 0xff;
	
	PORTC = 0x20;
		
	_delay_ms(37);	
	
	PORTC |= 0x10;
	
	
}


At 30 ms the timing is correct.  Anything above or below 30ms, the
timing moves in the right direction but not in correct proportion.

Maybe it's my [PC based] logic analyzer.
Thanks for your suggestions.

Re: [AVR-Chat] Delay issue

2008-09-05 by David VanHorn

What's the resolution on your logic analyzer?

The other thing would be to look at how the time delay is implemented.

Re: Delay issue

2008-09-05 by englsprogeny

--- In AVR-Chat@yahoogroups.com, "David VanHorn" <microbrix@...> wrote:
>
> What's the resolution on your logic analyzer?
> 
> The other thing would be to look at how the time delay is implemented.
>

My Logic Analyzer is running at 1 Mhz.

I bought the "DISco" from: http://www.hobbylab.us/  

When you say "how it is implemented" do you mean code-wise?

Thanks for your help, David.

David

Re: Delay issue

2008-09-05 by englsprogeny

--- In AVR-Chat@yahoogroups.com, "David VanHorn" <microbrix@...> wrote:
>
> > My Logic Analyzer is running at 1 Mhz.
> 
> Ok, then it shouldn't be a resolution issue.
> Could it be large capacitance values hosing up rise/fall times?
> 
> 
> > When you say "how it is implemented" do you mean code-wise?
> 
> Yup.
>


I am running it right off the Mega8... maybe my test leads are too
long.  Still, if I put in 150ms it shouldn't be switching the second
bit high at 30ms.  Know what I mean?

I put the code I'm using in the original post.  I'm going to see if I
have some settings wrong with this analyzer.  Still, you'd think that
the signal would show up later than expected [not earlier (as it does
now)] Thanks again for your input.

Re: [AVR-Chat] Re: Delay issue

2008-09-05 by Sander Pool

Thanks for that link! I've been looking for a PC based logic analyzer.

    Sander

englsprogeny wrote:
Show quoted textHide quoted text
>
> --- In AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com>, 
> "David VanHorn" <microbrix@...> wrote:
> >
> > What's the resolution on your logic analyzer?
> >
> > The other thing would be to look at how the time delay is implemented.
> >
>
> My Logic Analyzer is running at 1 Mhz.
>
> I bought the "DISco" from: http://www.hobbylab.us/ 
> <http://www.hobbylab.us/>
>
> When you say "how it is implemented" do you mean code-wise?
>
> Thanks for your help, David.
>
> David
>
>

Re: [AVR-Chat] Re: Delay issue

2008-09-05 by David VanHorn

On Fri, Sep 5, 2008 at 2:00 PM, Sander Pool <sander@tungstentech.com> wrote:
>
> Thanks for that link! I've been looking for a PC based logic analyzer.

I have a nice little FPGA based unit called an ANT-8

Pretty amazing for such a tiny device.

Re: [AVR-Chat] Re: Delay issue

2008-09-05 by David VanHorn

> My Logic Analyzer is running at 1 Mhz.

Ok, then it shouldn't be a resolution issue.
Could it be large capacitance values hosing up rise/fall times?


> When you say "how it is implemented" do you mean code-wise?

Yup.

Re: [AVR-Chat] Re: Delay issue

2008-09-05 by Sander Pool

I just saw that their larger device doesn't do analog. That's a bummer. 
It would have been pretty spectacular to have a 75 MHz analog scope for 
$275 :)

Thanks for the ant reference. Looks like you can't get it anymore but 
the newer units are also quite reasonable. http://www.bugblat.com/index.html

    Sander

David VanHorn wrote:
Show quoted textHide quoted text
>
> On Fri, Sep 5, 2008 at 2:00 PM, Sander Pool <sander@tungstentech.com 
> <mailto:sander%40tungstentech.com>> wrote:
> >
> > Thanks for that link! I've been looking for a PC based logic analyzer.
>
> I have a nice little FPGA based unit called an ANT-8
>
> Pretty amazing for such a tiny device.
>
>

Re: Delay issue

2008-09-05 by englsprogeny

No interrupts.  It's the code that I originally submitted.  It's very
simple.


--- In AVR-Chat@yahoogroups.com, Philippe Habib <phabib@...> wrote:
Show quoted textHide quoted text
>
> Do you have any interrupt tasks that could be executing and delaying  
> the switching?
> On Sep 5, 2008, at 12:21 PM, englsprogeny wrote:
> 
> > --- In AVR-Chat@yahoogroups.com, "David VanHorn" <microbrix@>  
> > wrote:
> >>
> >>> My Logic Analyzer is running at 1 Mhz.
> >>
> >> Ok, then it shouldn't be a resolution issue.
> >> Could it be large capacitance values hosing up rise/fall times?
> >>
> >>
> >>> When you say "how it is implemented" do you mean code-wise?
> >>
> >> Yup.
> >>
> >
> >
> > I am running it right off the Mega8... maybe my test leads are too
> > long.  Still, if I put in 150ms it shouldn't be switching the second
> > bit high at 30ms.  Know what I mean?
> >
> > I put the code I'm using in the original post.  I'm going to see if I
> > have some settings wrong with this analyzer.  Still, you'd think that
> > the signal would show up later than expected [not earlier (as it does
> > now)] Thanks again for your input.
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
>

Re: [AVR-Chat] Delay issue

2008-09-05 by Richard Reeves

> Compiling with WinAVR 
> ATMega8
> External clock (8Mhz crystal)
> My Fuses are set correctly
> 
> -------------------------------
> 
> I've modified the makefile to have:
> 
> F_CPU = 8000000
> 
> 
> 
> -------------------------------
> C Source:
> 
> 
> #include <avr\io.h>
> #include <avr\delay.h>
> 
> int main(void) 
> {	
> 	
> 	//set port c as all output
> 	DDRC = 0xff;
> 	
> 	PORTC = 0x20;
> 		
> 	_delay_ms(37);	
> 	
> 	PORTC |= 0x10;
> 	
> 	
> }
> 
It works in AVR Studio with different delay times giving the correct 
timing.  I also simulated it in Proteus, which agreed.  What have you 
set the optimisation level to in the project options?  Level -O0 
causes timing errors (and produces a warning when you compile).




Richard---------------------
Vacuum Cleaners-
...helpful household appliances or electronic carpet parasites set to 
take over the World? 
Make up your own mind -but get it right first time, your planet 
depends on you!

Re: [AVR-Chat] Re: Delay issue

2008-09-05 by Philippe Habib

Do you have any interrupt tasks that could be executing and delaying  
the switching?
Show quoted textHide quoted text
On Sep 5, 2008, at 12:21 PM, englsprogeny wrote:

> --- In AVR-Chat@yahoogroups.com, "David VanHorn" <microbrix@...>  
> wrote:
>>
>>> My Logic Analyzer is running at 1 Mhz.
>>
>> Ok, then it shouldn't be a resolution issue.
>> Could it be large capacitance values hosing up rise/fall times?
>>
>>
>>> When you say "how it is implemented" do you mean code-wise?
>>
>> Yup.
>>
>
>
> I am running it right off the Mega8... maybe my test leads are too
> long.  Still, if I put in 150ms it shouldn't be switching the second
> bit high at 30ms.  Know what I mean?
>
> I put the code I'm using in the original post.  I'm going to see if I
> have some settings wrong with this analyzer.  Still, you'd think that
> the signal would show up later than expected [not earlier (as it does
> now)] Thanks again for your input.
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>

Re: [AVR-Chat] Delay issue

2008-09-05 by John Samperi

At 01:25 AM 6/09/2008, you wrote:
>Compiling with WinAVR

How old is your winAvr package?

The latest delay_ms can go up up 65,535 ms.

The older packages up to 262ms/clock or something like that,
which, at 8 MHz would be about 32.75ms max



Regards

John Samperi

********************************************************
Ampertronics Pty. Ltd.
11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
Tel. (02) 9674-6495       Fax (02) 9674-8745
Website  http://www.ampertronics.com.au
*Electronic Design * Custom Products * Contract Assembly
********************************************************

Re: Delay issue

2008-09-06 by englsprogeny

I knew John would have the answer!!!

That's when it cuts off.... about 30ms! 

Thanks, John(again).



--- In AVR-Chat@yahoogroups.com, John Samperi <samperi@...> wrote:
Show quoted textHide quoted text
>
> At 01:25 AM 6/09/2008, you wrote:
> >Compiling with WinAVR
> 
> How old is your winAvr package?
> 
> The latest delay_ms can go up up 65,535 ms.
> 
> The older packages up to 262ms/clock or something like that,
> which, at 8 MHz would be about 32.75ms max
> 
> 
> 
> Regards
> 
> John Samperi
> 
> ********************************************************
> Ampertronics Pty. Ltd.
> 11 Brokenwood Place Baulkham Hills, NSW 2153 AUSTRALIA
> Tel. (02) 9674-6495       Fax (02) 9674-8745
> Website  http://www.ampertronics.com.au
> *Electronic Design * Custom Products * Contract Assembly
> ********************************************************
>

Logic Analyzer (was Re: Delay issue)

2008-09-06 by Stefan Wimmer

--- In AVR-Chat@yahoogroups.com, Sander Pool <sander@...> wrote:
>
> 
> Thanks for that link! I've been looking for a PC based logic analyzer.
> 
>     Sander

If you need something "a bit faster than 75MHz" have a look at 
http://www.pctestinstruments.com

I have it and am quite satisfied with it. Of course it has't such a 
wellfangled trigger unit like an HP16500, but just compare the 
prices! :-)

I especialy like the I2C, SPI, UART and CAN analyzer modes. They are 
very useful, dealing with embedded systems.

Stefan

Re: [AVR-Chat] Logic Analyzer (was Re: Delay issue)

2008-09-06 by Sander Pool

Hi Stefan,

that looks very nice but do you know of something comparable for analog 
signals? I mean google will find plenty of selection and I know about 
http://www.bitscope.com/ but if someone has first hand experience with 
an analog/digital scope I'd like to hear about it.

    Sander

Stefan Wimmer wrote:
Show quoted textHide quoted text
>
> --- In AVR-Chat@yahoogroups.com <mailto:AVR-Chat%40yahoogroups.com>, 
> Sander Pool <sander@...> wrote:
> >
> >
> > Thanks for that link! I've been looking for a PC based logic analyzer.
> >
> > Sander
>
> If you need something "a bit faster than 75MHz" have a look at
> http://www.pctestinstruments.com <http://www.pctestinstruments.com>
>
> I have it and am quite satisfied with it. Of course it has't such a
> wellfangled trigger unit like an HP16500, but just compare the
> prices! :-)
>
> I especialy like the I2C, SPI, UART and CAN analyzer modes. They are
> very useful, dealing with embedded systems.
>
> Stefan
>
> _,___

Logic Analyzer (was Re: Delay issue)

2008-09-07 by Stefan Wimmer

--- In AVR-Chat@yahoogroups.com, Sander Pool <sander@...> wrote:
>
> 
> Hi Stefan,
> 
> that looks very nice but do you know of something comparable for 
analog 
> signals? 

Sorry, no. My TDS220 doesn't really qualify as USB-Scope ;-)
I always owned a "real oscilloscope" since I was 16 and never had the 
need to get some of the PC scopes. 

BTW: You can download the LogicPort software from pctestinstruments.com 
and play with it: when it doesn't find its hardware during startup, it 
will run in a demo mode.

Stefan

RE: [AVR-Chat] Delay issue

2008-09-08 by Julian Higginson

Are you driving this code as you showed here, always using constants for the
delay time? Or was this a simplified code snippet for clarity?

Because if you use variables in a call to _delay_ms() I'm pretty sure you
need the floating point maths library included for it to do what you want.


Hope this helps,


Julian Higginson
Bruttour International P/L
http://www.bruttour.com.au
Ph: +612 9987 1581
Show quoted textHide quoted text
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf
Of englsprogeny
Sent: Saturday, 6 September 2008 1:25 AM
To: AVR-Chat@yahoogroups.com
Subject: [AVR-Chat] Delay issue

I am setting 2 outputs high (n milliseconds apart)

Problem is that when I look at them with my logic analyzer, the
distance between them going high isn't always what I've coded.

My configuration is:

Compiling with WinAVR 
ATMega8
External clock (8Mhz crystal)
My Fuses are set correctly

-------------------------------

I've modified the makefile to have:

F_CPU = 8000000



-------------------------------
C Source:


#include <avr\io.h>
#include <avr\delay.h>

int main(void) 
{	
	
	//set port c as all output
	DDRC = 0xff;
	
	PORTC = 0x20;
		
	_delay_ms(37);	
	
	PORTC |= 0x10;
	
	
}


At 30 ms the timing is correct.  Anything above or below 30ms, the
timing moves in the right direction but not in correct proportion.

Maybe it's my [PC based] logic analyzer.
Thanks for your suggestions.




------------------------------------

Yahoo! Groups Links

Re: Delay issue

2008-09-08 by englsprogeny

Thanks Julian

I was using an older version of Winavr.  This older varsion has a 
32ms limit on its delays.  If I want longer delays I can switch to a 
newer WinAVR or do multiple iterations.

Thanks again for your input.



-- In AVR-Chat@yahoogroups.com, "Julian Higginson" <julian.h@...> 
wrote:
>
> Are you driving this code as you showed here, always using 
constants for the
> delay time? Or was this a simplified code snippet for clarity?
> 
> Because if you use variables in a call to _delay_ms() I'm pretty 
sure you
> need the floating point maths library included for it to do what 
you want.
> 
> 
> Hope this helps,
> 
> 
> Julian Higginson
> Bruttour International P/L
> http://www.bruttour.com.au
> Ph: +612 9987 1581
> 
> -----Original Message-----
> From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On 
Behalf
Show quoted textHide quoted text
> Of englsprogeny
> Sent: Saturday, 6 September 2008 1:25 AM
> To: AVR-Chat@yahoogroups.com
> Subject: [AVR-Chat] Delay issue
> 
> I am setting 2 outputs high (n milliseconds apart)
> 
> Problem is that when I look at them with my logic analyzer, the
> distance between them going high isn't always what I've coded.
> 
> My configuration is:
> 
> Compiling with WinAVR 
> ATMega8
> External clock (8Mhz crystal)
> My Fuses are set correctly
> 
> -------------------------------
> 
> I've modified the makefile to have:
> 
> F_CPU = 8000000
> 
> 
> 
> -------------------------------
> C Source:
> 
> 
> #include <avr\io.h>
> #include <avr\delay.h>
> 
> int main(void) 
> {	
> 	
> 	//set port c as all output
> 	DDRC = 0xff;
> 	
> 	PORTC = 0x20;
> 		
> 	_delay_ms(37);	
> 	
> 	PORTC |= 0x10;
> 	
> 	
> }
> 
> 
> At 30 ms the timing is correct.  Anything above or below 30ms, the
> timing moves in the right direction but not in correct proportion.
> 
> Maybe it's my [PC based] logic analyzer.
> Thanks for your suggestions.
> 
> 
> 
> 
> ------------------------------------
> 
> Yahoo! Groups Links
>

Re: Delay issue

2008-09-08 by englsprogeny

Thanks Julian

I was using an older version of Winavr.  This older varsion has a 
32ms limit on its delays.  If I want longer delays I can switch to a 
newer WinAVR or do multiple iterations.

Thanks again for your input.



-- In AVR-Chat@yahoogroups.com, "Julian Higginson" <julian.h@...> 
wrote:
>
> Are you driving this code as you showed here, always using 
constants for the
> delay time? Or was this a simplified code snippet for clarity?
> 
> Because if you use variables in a call to _delay_ms() I'm pretty 
sure you
> need the floating point maths library included for it to do what 
you want.
> 
> 
> Hope this helps,
> 
> 
> Julian Higginson
> Bruttour International P/L
> http://www.bruttour.com.au
> Ph: +612 9987 1581
> 
> -----Original Message-----
> From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On 
Behalf
Show quoted textHide quoted text
> Of englsprogeny
> Sent: Saturday, 6 September 2008 1:25 AM
> To: AVR-Chat@yahoogroups.com
> Subject: [AVR-Chat] Delay issue
> 
> I am setting 2 outputs high (n milliseconds apart)
> 
> Problem is that when I look at them with my logic analyzer, the
> distance between them going high isn't always what I've coded.
> 
> My configuration is:
> 
> Compiling with WinAVR 
> ATMega8
> External clock (8Mhz crystal)
> My Fuses are set correctly
> 
> -------------------------------
> 
> I've modified the makefile to have:
> 
> F_CPU = 8000000
> 
> 
> 
> -------------------------------
> C Source:
> 
> 
> #include <avr\io.h>
> #include <avr\delay.h>
> 
> int main(void) 
> {	
> 	
> 	//set port c as all output
> 	DDRC = 0xff;
> 	
> 	PORTC = 0x20;
> 		
> 	_delay_ms(37);	
> 	
> 	PORTC |= 0x10;
> 	
> 	
> }
> 
> 
> At 30 ms the timing is correct.  Anything above or below 30ms, the
> timing moves in the right direction but not in correct proportion.
> 
> Maybe it's my [PC based] logic analyzer.
> Thanks for your suggestions.
> 
> 
> 
> 
> ------------------------------------
> 
> Yahoo! Groups Links
>

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.