Yahoo Groups archive

AVR-Chat

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

Thread

Re: [AVR-Chat] Digest Number 1313

Re: [AVR-Chat] Digest Number 1313

2006-03-04 by Shibu Krishnan

hi geeks,
we had recently bought a new AVR MP3 Developement kit. i would like to know abt how to burn the chip, we have got only usb port. we tried out with FLIP. but it is giving lot of problems. do any of u people have some idea? then pls help me to solve the problem.
thanking you.
shibu,

AVR-Chat@yahoogroups.com wrote:
Show quoted textHide quoted text
There are 5 messages in this issue.

Topics in this digest:

1. Re: plz help me
From: kelvin kooger
2. RE: Bi-Colour LED coontrol with one pin?
From: "Roy"
3. Butterfly (ATMega169?) programming problem.
From: "catalin_cluj"
4. Re: Bi-Colour LED coontrol with one pin?
From: Peter Gargano
5. Re: Bi-Colour LED coontrol with one pin?
From: kholt@sonic.net


________________________________________________________________________
________________________________________________________________________

Message: 1
Date: Thu, 2 Mar 2006 19:09:20 -0800 (PST)
From: kelvin kooger
Subject: Re: plz help me

First I must say that I am expert in BASCOM.
Is the syntax on config lcd correct ? * 1a ....... hex ?

G Teh Boy wrote:
hi
i can not this program compileing with BASCOM plz help me

$regfile = "m8535.dat"
' we use internal osc 8000000 for atmega8535
$crystal = 8000000
Config Lcdpin = Pin , Db4 = Pinc.3 , Db5 = Pinc.2 , Db6 = Pinc.1 , Db7 = Pinc.0 , E = Pinc.5 , Rs = Pinc.4
Config Lcd = 16 * 1a
Config Adc = Single , Prescaler = Auto
Deflcdchar 0 , 24 , 24 , 32 , 32 , 32 , 32 , 32 , 32 'we replace ? with number 0
Dim W As Word , Channel As Byte
Start Adc
Cursor Off
Do
W = Getadc(0)
W = W / 2
Home
Lcd W ; Chr(0) ; "C"
Waitms 100
Select Case W
Case Is =< 10 :
Cls
Home L
Lcd " Low"
Case 11 To 34 :
Cls
Home L
Lcd " Normal"
Case Is >= 35
Cls
Home L
Lcd " High"
End Select 'end program select
Loop
End






compiling give this erorr
Error : 202 Line : 6 .EQU not found, probably using functions that are not supported by the selected chip [ADCSR] , in File : C:\NONAME1.BAS
Error : 1 Line : 9 Unknown statement [.EQU not found for:ADCSR] , in File : C:\NONAME1.BAS
Error : 1 Line : 33 Unknown statement [.EQU not found for:ADCSR] , in File : C:\NONAME1.BAS
Error : 1 Line : 33 Unknown statement [.EQU not found for:ADCSR] , in File : C:\NONAME1.BAS
Error : 1 Line : 33 Unknown statement [.EQU not found for:ADCSR] , in File : C:\NONAME1.BAS
Error : 1 Line : 33 Unknown statement [.EQU not found for:ADCSR] , in File : C:\NONAME1.BAS

---------------------------------
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre.

---------------------------------
YAHOO! GROUPS LINKS


Visit your group "AVR-Chat" on the web.

To unsubscribe from this group, send an email to:
AVR-Chat-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


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





---------------------------------
Yahoo! Mail
Use Photomail to share photos without annoying attachments.

[This message contained attachments]



________________________________________________________________________
________________________________________________________________________

Message: 2
Date: Fri, 3 Mar 2006 20:27:50 +1300
From: "Roy"
Subject: RE: Bi-Colour LED coontrol with one pin?

See attached WORD file of the Switcher CAD III plot of the circuit
below.
_______________________________________

Roy Hopkins
22 Grenada Street
Tauranga
New Zealand
_______________________________________
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On
Behalf Of Russell Shaw
Sent: Thursday, 2 March 2006 7:44 p.m.
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Bi-Colour LED coontrol with one pin?

Peter Gargano wrote:
> I can't figure this out simply. I'm sure there is a simple solution
> tho'. Chip is the Mega-168 that I want to add an extra function to.
>
> Assume I have either a two or three pin bi-colour LED (ie. either back

> to back LEDs with two pins, or two LEDs with a common pin).
>
> I have a single pin on an AVR processor that can either be LOW, HIGH,
> or Tri-state.
>
> I want to drive the LEDs either both OFF, one on, or the other on, but

> NOT both on.
>
> SO, I have three states the pin can be in, and three states for the
> LED to be in.
>
+5VCC
--+----------+--
| |
AVR |c NPN >
---+ LEDs \|b__ < 10k
| +-->|---+ /| | >
|pin | | 220ohms |e | |
+-----+ +-----\/\/\-------+ +----+
| | | |e | |
| +--|<---+ \|b__| >
---+ /| < 10k
|c PNP >
| |
----+----------+---- GND


_____


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.1/272 - Release Date: 1/03/2006


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 268.1.1/272 - Release Date: 1/03/2006




[This message contained attachments]



________________________________________________________________________
________________________________________________________________________

Message: 3
Date: Fri, 03 Mar 2006 05:10:09 -0000
From: "catalin_cluj"
Subject: Butterfly (ATMega169?) programming problem.

Hi,
I've been succesfully building hex files with WinAVR and programming
them with AVR Studio 4 (and the original Butterfly bootloader)... until
the cable broke in the middle of programming.
Now, I can still program, but verification fails:

"Address: 0x0000, Expected: 0x940c, Received: 0x2121"

and nothing runs...
What's happenning, why that address?
I thought if 0x0000 is toast, the bootloader shouldn't work either...
nothing should work.
Obviously, something still works, as pushing the button down allows
AvrProg to connect, and program.

Is it toast? Would ISP programming fix it?

Thank yo,

Cat






________________________________________________________________________
________________________________________________________________________

Message: 4
Date: Sat, 04 Mar 2006 03:29:33 +1100
From: Peter Gargano
Subject: Re: Bi-Colour LED coontrol with one pin?

Roy wrote:
> See attached WORD file of the Switcher CAD III plot of the circuit below.

Thanks Roy for the analysis info.

> *From:* *Russell Shaw

Thanks Russell for the original circuit.

One problem of course is getting enough current to drive the LEDs to a
reasonable brightness. This is mostly due to having them run from what
is effectively a 2.5 Volt rail. Differences in brightness between red
and green LEDs because of different operating voltages is also
exacerbated.

I'm leaning towards using a shift register like the 74HC595 and
sending it data via the SPI - in my current design this allows me to
control up to 8 LEDs with just the original extra pin! And it takes
about the same PCB real estate too.

Peter






.






________________________________________________________________________
________________________________________________________________________

Message: 5
Date: Fri, 3 Mar 2006 10:52:39 -0800 (PST)
From: kholt@sonic.net
Subject: Re: Bi-Colour LED coontrol with one pin?


You could offset the 2.5V to favor the green LED; however
I have found that most red/green modules have very poor
response in the green LED, no matter what you do. If you
have the space, you could put two separate LEDs back-to-back.
Although you might like to use a truer green color, you are
probably stuck with the awful yellowish-green because of the
lower forward voltage.
Ken

> Roy wrote:
>> See attached WORD file of the Switcher CAD III plot of the circuit
>> below.
>
> Thanks Roy for the analysis info.
>
>> *From:* *Russell Shaw
>
> Thanks Russell for the original circuit.
>
> One problem of course is getting enough current to drive the LEDs to a
> reasonable brightness. This is mostly due to having them run from what
> is effectively a 2.5 Volt rail. Differences in brightness between red
> and green LEDs because of different operating voltages is also
> exacerbated.
>
> I'm leaning towards using a shift register like the 74HC595 and
> sending it data via the SPI - in my current design this allows me to
> control up to 8 LEDs with just the original extra pin! And it takes
> about the same PCB real estate too.
>
> Peter
>
>
>
>
>
>
> .
>
>
>
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>




________________________________________________________________________
________________________________________________________________________



------------------------------------------------------------------------
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AVR-Chat/

<*> To unsubscribe from this group, send an email to:
AVR-Chat-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

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




Yahoo! Mail
Bring photos to life! New PhotoMail makes sharing a breeze.

How to measure a pulse width

2006-03-07 by wbounce

I need to measure how long a pulse is. I have a m128. The pulse goes +5V for 1ms to 36.9ms and then goes 0v for a fixed 65ms. I need to time how long the +5V part is in 10us increments. How would I do that? I will wire the sensor generating the pulse to a pin. I seem to remember something about a capture ability but I do not understand how it works or how to set it up. The fact that the pulse is assymetrical probably does not help.
I am already using timer0 fir a ms timer and timer3 (a and b) for pwm output. so I guess I would have to use timer1 or 2.

Re: [AVR-Chat] How to measure a pulse width

2006-03-07 by James Washer

In a word... well... 3 letters... CTC
On Mon, 6 Mar 2006 23:14:48 -0500
"wbounce" <wbounce@safeplace.net> wrote:
Show quoted textHide quoted text
> I need to measure how long a pulse is. I have a m128. The pulse goes +5V
> for 1ms to 36.9ms and then goes 0v for a fixed 65ms. I need to time how
> long the +5V part is in 10us increments. How would I do that? I will
> wire the sensor generating the pulse to a pin. I seem to remember
> something about a capture ability but I do not understand how it works
> or how to set it up. The fact that the pulse is assymetrical probably
> does not help.
>  
> I am already using timer0 fir a ms timer and timer3 (a and b) for pwm
> output. so I guess I would have to use timer1 or 2.
>

Re: [AVR-Chat] How to measure a pulse width

2006-03-07 by Ned Konz


On Mar 6, 2006, at 8:14 PM, wbounce wrote:

I need to measure how long a pulse is. I have a m128. The pulse goes +5V for 1ms to 36.9ms and then goes 0v for a fixed 65ms. I need to time how long the +5V part is in 10us increments. How would I do that? I will wire the sensor generating the pulse to a pin. I seem to remember something about a capture ability but I do not understand how it works or how to set it up. The fact that the pulse is assymetrical probably does not help.
I am already using timer0 fir a ms timer and timer3 (a and b) for pwm output. so I guess I would have to use timer1 or 2.


Well, 10usec is 1/3690 th of 36.9 msec, so you're going to need a 16-bit timer.

You have Timer1 and Timer3 to choose from.

You're already using Timer3.

That narrows it down.

Look in the Atmega128 datasheet under "16-bit Timer/Counter / Input Capture Unit" to find the gory details of how you'd use Timer1 to do pulse timing.

The asymmetry doesn't matter, as you're only measuring the high part.

As far as 10usec resolution, this would depend on how fast your system clock was. At (say) 16MHz, your system clock would be 62.5nsec; you could then clock the timers at systemClock/256 to get 16usec resolution. Or systemClock/128 to get 8usec resolution.

At systemClock/128, your maximum pulse width would be (65535*(128/16e6)), or about 524msec. You could even go for a faster clock.

The pin you'd use would be ICP1, a/k/a PD4.

And, above all, don't panic. For it says in the datasheet:

The Input Capture unit is easy to use in normal mode. However, observe that the maximum
interval between the external events must not exceed the resolution of the counter.
If the interval between events are too long, the timer overflow interrupt or the prescaler
must be used to extend the resolution for the capture unit.

Good luck,
--
Ned Konz


Re: [AVR-Chat] How to measure a pulse width

2006-03-07 by David Kelly

On Tue, Mar 07, 2006 at 07:35:20AM -0800, Ned Konz wrote:
> 
> At systemClock/128, your maximum pulse width would be (65535* 
> (128/16e6)), or about 524msec. You could even go for a faster clock.

If 10 uS is an absolute requirement then use a 12.800 MHz crystal (its a
standard part) and use the 128 divider.

-- 
David Kelly N4HHE, dkelly@HiWAAY.net
========================================================================
Whom computers would destroy, they must first drive mad.

RE: [AVR-Chat] How to measure a pulse width

2006-03-08 by wbounce

I guess I forgot to say I was operating at 16MHZ. 16us is probably close enough. So I hook the sensor to PIND4 and set timer1 to a prescale of 256 Then I need to enable the TICIE1 interrupt in TIMSK. But I still do not understand how I time the "high" part. In the interrupt routine, I guess I disable interrupts and save ICR1 to a variable and reenable interrupts. Then the variable holds the elapsed time but how do I know it it the "high" time and not the low time. On page 115 under Input Capture Unit it mentions "and this change conforms to the setting of the edge detector, a capture is triggerred." But I do not see anything about how to set the "edge detector." Ideally it should start timing on the rising edge and trigger the capture on the falling edge.
Also what happens if the input capture exceed the timer resolution?
Show quoted textHide quoted text
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of Ned Konz
Sent: Tuesday, March 07, 2006 10:35 AM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] How to measure a pulse width


On Mar 6, 2006, at 8:14 PM, wbounce wrote:

I need to measure how long a pulse is. I have a m128. The pulse goes +5V for 1ms to 36.9ms and then goes 0v for a fixed 65ms. I need to time how long the +5V part is in 10us increments. How would I do that? I will wire the sensor generating the pulse to a pin. I seem to remember something about a capture ability but I do not understand how it works or how to set it up. The fact that the pulse is assymetrical probably does not help.
I am already using timer0 fir a ms timer and timer3 (a and b) for pwm output. so I guess I would have to use timer1 or 2.


Well, 10usec is 1/3690 th of 36.9 msec, so you're going to need a 16-bit timer.

You have Timer1 and Timer3 to choose from.

You're already using Timer3.

That narrows it down.

Look in the Atmega128 datasheet under "16-bit Timer/Counter / Input Capture Unit" to find the gory details of how you'd use Timer1 to do pulse timing.

The asymmetry doesn't matter, as you're only measuring the high part.

As far as 10usec resolution, this would depend on how fast your system clock was. At (say) 16MHz, your system clock would be 62.5nsec; you could then clock the timers at systemClock/256 to get 16usec resolution. Or systemClock/128 to get 8usec resolution.

At systemClock/128, your maximum pulse width would be (65535*(128/16e6)), or about 524msec. You could even go for a faster clock.

The pin you'd use would be ICP1, a/k/a PD4.

And, above all, don't panic. For it says in the datasheet:

The Input Capture unit is easy to use in normal mode. However, observe that the maximum
interval between the external events must not exceed the resolution of the counter.
If the interval between events are too long, the timer overflow interrupt or the prescaler
must be used to extend the resolution for the capture unit.

Good luck,
--
Ned Konz


RE: [AVR-Chat] How to measure a pulse width

2006-03-08 by wbounce

My understanding of CTC (Clear Timer on Compare) is to generate or
output a PWM not time an input. 
Show quoted textHide quoted text
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On
Behalf Of James Washer
Sent: Tuesday, March 07, 2006 12:16 AM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] How to measure a pulse width



In a word... well... 3 letters... CTC
On Mon, 6 Mar 2006 23:14:48 -0500
"wbounce" <wbounce@safeplace.net> wrote:

> I need to measure how long a pulse is. I have a m128. The pulse goes 
> +5V for 1ms to 36.9ms and then goes 0v for a fixed 65ms. I need to 
> time how long the +5V part is in 10us increments. How would I do that?

> I will wire the sensor generating the pulse to a pin. I seem to 
> remember something about a capture ability but I do not understand how

> it works or how to set it up. The fact that the pulse is assymetrical 
> probably does not help.
>  
> I am already using timer0 fir a ms timer and timer3 (a and b) for pwm 
> output. so I guess I would have to use timer1 or 2.
> 


 
Yahoo! Groups Links

Re: [AVR-Chat] How to measure a pulse width

2006-03-08 by Ned Konz


On Mar 7, 2006, at 8:49 PM, wbounce wrote:

I guess I forgot to say I was operating at 16MHZ. 16us is probably close enough. So I hook the sensor to PIND4 and set timer1 to a prescale of 256

OK, that'd give you a resolution of 1/16 MHz (or 16usec).

Then I need to enable the TICIE1 interrupt in TIMSK.

Yes. But you also have to set up the input capture.

So look at TCCR1B, in which you have to set up ICNC1 and ICES1.

The setting of ICES1 is important:

• Bit 6 – ICESn: Input Capture Edge Select
This bit selects which edge on the Input Capture Pin (ICPn) that is used to trigger a capture
event. When the ICESn bit is written to zero, a falling (negative) edge is used as
trigger, and when the ICESn bit is written to one, a rising (positive) edge will trigger the
capture.
When a capture is triggered according to the ICESn setting, the counter value is copied
into the Input Capture Register (ICRn). The event will also set the Input Capture Flag
(ICFn), and this can be used to cause an Input Capture Interrupt, if this interrupt is
enabled.
When the ICRn is used as TOP value (see description of the WGMn3:0 bits located in
the TCCRnA and the TCCRnB Register), the ICPn is disconnected and consequently
the Input Capture function is disabled.

So let's think about it: you want to have the first interrupt happen on a rising edge. And the second interrupt should happen on the falling edge.

So you'd set up ICES1 to be 1 at first.
You might also like to set up a pointer to an area in RAM where you'll save the timer information.
And maybe a counter to tell how many edges you've seen.

In the ICP1 interrupt handler you'd do this:

* save the value of TCNT1L and TCNT1H to where your pointer points (incrementing it)
* increment (or decrement) your edge counter
* complement ICES1 so you can see the complementary edge
* if this was the falling edge (that is, if ICES1 was 0) then you can compute the high period by subtracting the last value from the first value (both 16 bits).

But I still do not understand how I time the "high" part. In the interrupt routine, I guess I disable interrupts and save ICR1 to a variable

Yes.

and reenable interrupts.

Not really necessary; the RETI instruction will do this for you.

Then the variable holds the elapsed time but how do I know it it the "high" time and not the low time.

Because you set ICES1 to be 0 to catch the falling edge (after setting it to be 1 to catch the rising edge).

On page 115 under Input Capture Unit it mentions "and this change conforms to the setting of the edge detector, a capture is triggerred." But I do not see anything about how to set the "edge detector." Ideally it should start timing on the rising edge and trigger the capture on the falling edge.
Also what happens if the input capture exceed the timer resolution?

Exceeds the resolution, or exceeds the total period?

You have to make sure that the period you're timing is no longer than the period taken by 65536 counts of your timer if you want a reliable count.

Otherwise, you have to extend the counter length by keeping an extension counter that's incremented in the Timer1 overflow handler. But if you've set up Timer1 so that the overflow period is always longer than the intervals you're timing (the high or the low periods if you're complementing ICES1) then subtracting the two numbers will work fine, even if there's an overflow in between (as long as there's only 1 maximum).

Imagine a free-running Timer1.

First you set up ICES1 to 1, and enable the IC1 interrupt.

When you get the IC1 interrupt, it'll be for the rising edge. You capture TCCNT1L/H.

Let's say that it's 0xC000.

Then you complement ICES1 to catch the falling edge.

The next interrupt you capture TCCNT1L/H into another variable.

Let's say that it's overflowed, and now reads 0x1000.

That is, the counter has advanced by 0x5000 counts.
And it's overflowed betwen 0xFFFF and 0x0000, but you don't care:
If you subtract 0xC000 from 0x1000 you will get 0x5000.

Same thing would happen if you'd read it as 0x1000 and 0x6000.

--
Ned Konz


Re: [AVR-Chat] How to measure a pulse width

2006-03-08 by Zack Widup

On Tue, 7 Mar 2006, Ned Konz wrote:

> 
> > I guess I forgot to say I was operating at 16MHZ. 16us is probably  
> > close enough. So I hook the sensor to PIND4 and set timer1 to a  
> > prescale of 256
> 
> OK, that'd give you a resolution of 1/16 MHz (or 16usec).
> 

1/(16 MHz) = 0.0625 usec (62.5 nsec).  Much faster!

Zack

RE: [AVR-Chat] How to measure a pulse width

2006-03-09 by wbounce

Thanks for the explanation. I think I can put the missing pieces together and code it tommorrow.
Show quoted textHide quoted text
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On Behalf Of Ned Konz
Sent: Wednesday, March 08, 2006 1:14 AM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] How to measure a pulse width


On Mar 7, 2006, at 8:49 PM, wbounce wrote:

I guess I forgot to say I was operating at 16MHZ. 16us is probably close enough. So I hook the sensor to PIND4 and set timer1 to a prescale of 256

OK, that'd give you a resolution of 1/16 MHz (or 16usec).

Then I need to enable the TICIE1 interrupt in TIMSK.

Yes. But you also have to set up the input capture.

So look at TCCR1B, in which you have to set up ICNC1 and ICES1.

The setting of ICES1 is important:

• Bit 6 – ICESn: Input Capture Edge Select
This bit selects which edge on the Input Capture Pin (ICPn) that is used to trigger a capture
event. When the ICESn bit is written to zero, a falling (negative) edge is used as
trigger, and when the ICESn bit is written to one, a rising (positive) edge will trigger the
capture.
When a capture is triggered according to the ICESn setting, the counter value is copied
into the Input Capture Register (ICRn). The event will also set the Input Capture Flag
(ICFn), and this can be used to cause an Input Capture Interrupt, if this interrupt is
enabled.
When the ICRn is used as TOP value (see description of the WGMn3:0 bits located in
the TCCRnA and the TCCRnB Register), the ICPn is disconnected and consequently
the Input Capture function is disabled.

So let's think about it: you want to have the first interrupt happen on a rising edge. And the second interrupt should happen on the falling edge.

So you'd set up ICES1 to be 1 at first.
You might also like to set up a pointer to an area in RAM where you'll save the timer information.
And maybe a counter to tell how many edges you've seen.

In the ICP1 interrupt handler you'd do this:

* save the value of TCNT1L and TCNT1H to where your pointer points (incrementing it)
* increment (or decrement) your edge counter
* complement ICES1 so you can see the complementary edge
* if this was the falling edge (that is, if ICES1 was 0) then you can compute the high period by subtracting the last value from the first value (both 16 bits).

But I still do not understand how I time the "high" part. In the interrupt routine, I guess I disable interrupts and save ICR1 to a variable

Yes.

and reenable interrupts.

Not really necessary; the RETI instruction will do this for you.

Then the variable holds the elapsed time but how do I know it it the "high" time and not the low time.

Because you set ICES1 to be 0 to catch the falling edge (after setting it to be 1 to catch the rising edge).

On page 115 under Input Capture Unit it mentions "and this change conforms to the setting of the edge detector, a capture is triggerred." But I do not see anything about how to set the "edge detector." Ideally it should start timing on the rising edge and trigger the capture on the falling edge.
Also what happens if the input capture exceed the timer resolution?

Exceeds the resolution, or exceeds the total period?

You have to make sure that the period you're timing is no longer than the period taken by 65536 counts of your timer if you want a reliable count.

Otherwise, you have to extend the counter length by keeping an extension counter that's incremented in the Timer1 overflow handler. But if you've set up Timer1 so that the overflow period is always longer than the intervals you're timing (the high or the low periods if you're complementing ICES1) then subtracting the two numbers will work fine, even if there's an overflow in between (as long as there's only 1 maximum).

Imagine a free-running Timer1.

First you set up ICES1 to 1, and enable the IC1 interrupt.

When you get the IC1 interrupt, it'll be for the rising edge. You capture TCCNT1L/H.

Let's say that it's 0xC000.

Then you complement ICES1 to catch the falling edge.

The next interrupt you capture TCCNT1L/H into another variable.

Let's say that it's overflowed, and now reads 0x1000.

That is, the counter has advanced by 0x5000 counts.
And it's overflowed betwen 0xFFFF and 0x0000, but you don't care:
If you subtract 0xC000 from 0x1000 you will get 0x5000.

Same thing would happen if you'd read it as 0x1000 and 0x6000.

--
Ned Konz


Re: [AVR-Chat] How to measure a pulse width

2006-03-09 by Ned Konz

On Mar 8, 2006, at 5:38 AM, Zack Widup wrote:

> On Tue, 7 Mar 2006, Ned Konz wrote:
>
>>
>>> I guess I forgot to say I was operating at 16MHZ. 16us is probably
>>> close enough. So I hook the sensor to PIND4 and set timer1 to a
>>> prescale of 256
>>
>> OK, that'd give you a resolution of 1/16 MHz (or 16usec).
>>
>
> 1/(16 MHz) = 0.0625 usec (62.5 nsec).  Much faster!

See, I shouldn't write emails past a certain hour...

Quite right!

Re: [AVR-Chat] How to measure a pulse width

2006-03-09 by Zack Widup

On Wed, 8 Mar 2006, Ned Konz wrote:

> 
> On Mar 8, 2006, at 5:38 AM, Zack Widup wrote:
> 
> > On Tue, 7 Mar 2006, Ned Konz wrote:
> >
> >>
> >>> I guess I forgot to say I was operating at 16MHZ. 16us is probably
> >>> close enough. So I hook the sensor to PIND4 and set timer1 to a
> >>> prescale of 256
> >>
> >> OK, that'd give you a resolution of 1/16 MHz (or 16usec).
> >>
> >
> > 1/(16 MHz) = 0.0625 usec (62.5 nsec).  Much faster!
> 
> See, I shouldn't write emails past a certain hour...
> 
> Quite right!
> 

Yeah, we all do that once in a while.  How many times have I done 
something similar?  :)

Zack

Winavr question

2006-03-14 by wbounce

In the Math routine documentation it said that sin function returns the sin of the angle in radians. So is the input angle to the sin function also in radians? or dgrees?

Re: [AVR-Chat] Winavr question

2006-03-14 by Zack Widup

Yes, the input has to be in radians.

degrees * pi/180 = radians

or

degrees/57.295779... = radians

The output would be a decimal number between -1 and +1.

Zack
Show quoted textHide quoted text
On Mon, 13 Mar 2006, wbounce wrote:

> In the Math routine documentation it said that sin function returns the
> sin of the angle in radians. So is the input angle to the sin function
> also in radians? or dgrees?
>  
>  
>  
>

Re: [AVR-Chat] Winavr question

2006-03-14 by Mike Perks

wbounce wrote:
In the Math routine documentation it said that sin function returns the sin of the angle in radians. So is the input angle to the sin function also in radians? or dgrees?
Before going further I think you need to get some grounding in basic trigonometry otherwise you will struggle with the algorithmic work you will need. The sine mathematical function is a ratio of two lengths (the opposite and hypotenuse of a triangle) and therefore does not have any units. This also answers your other question on the formulas for Sine and Cosine. I hope you also understand how many radians there are in 360 degrees and can convert between the two.

Mike
http://home.austin.rr.com/perks/micros/

Re: [AVR-Chat] Winavr question

2006-03-14 by Thomas Keller

wbounce wrote:
> In the Math routine documentation it said that sin function returns 
> the sin of the angle in radians. So is the input angle to the sin 
> function also in radians? or dgrees?
   The angle input tot he fiunction must be in radians, to obtain a 
correct output.

tom

RE: [AVR-Chat] Winavr question

2006-03-14 by wbounce

thanks
Show quoted textHide quoted text
-----Original Message-----
From: AVR-Chat@yahoogroups.com [mailto:AVR-Chat@yahoogroups.com] On
Behalf Of Zack Widup
Sent: Tuesday, March 14, 2006 12:02 AM
To: AVR-Chat@yahoogroups.com
Subject: Re: [AVR-Chat] Winavr question


Yes, the input has to be in radians.

degrees * pi/180 = radians

or

degrees/57.295779... = radians

The output would be a decimal number between -1 and +1.

Zack

On Mon, 13 Mar 2006, wbounce wrote:

> In the Math routine documentation it said that sin function returns 
> the sin of the angle in radians. So is the input angle to the sin 
> function also in radians? or dgrees?
>  
>  
>  
> 



 
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.