View previous topic :: View next topic |
Author |
Message |
Joy
Joined: 28 Feb 2009 Posts: 23
|
Posted: Fri Jul 23, 2010 8:13 am Post subject: timer calculation |
|
|
Config Timer1 = Timer , Prescale = 1 , Compare A = Toggle , Clear Timer = 1
Compare1a = 131
please tell me the time(ms) interval after which oc1a pin will be toggled ??
& tell me how did u calculated it...
Thank you |
|
Back to top |
|
|
Neill
Joined: 08 Dec 2008 Posts: 55
|
Posted: Fri Jul 23, 2010 9:06 am Post subject: |
|
|
Well the prescale factor is 1 so the toggle will occur every 131 clock cycles.
If the prescale was 8 then it would be every 1048(131x8) clock cycles.
If your clock is 1MHz then 131 cycles will be (1/1000000)*131 = 131uS or 0.131mS or around 7.6kHz. |
|
Back to top |
|
|
Joy
Joined: 28 Feb 2009 Posts: 23
|
Posted: Fri Jul 23, 2010 9:32 am Post subject: |
|
|
m using 12mhz clock |
|
Back to top |
|
|
Joy
Joined: 28 Feb 2009 Posts: 23
|
Posted: Fri Jul 23, 2010 9:42 am Post subject: |
|
|
so for 12mhz it comes out to b 91.6khz ..
i wonder why my program works??
by using this code i am sending rc5 signals .. which must b 38khz ..
also the tsop1738 decodes the signal .. m confused |
|
Back to top |
|
|
amirf
Joined: 25 Aug 2009 Posts: 154
|
Posted: Fri Jul 23, 2010 10:11 am Post subject: |
|
|
pls check AVR Timer Calculator by Jack Tidwell |
|
Back to top |
|
|
Joy
Joined: 28 Feb 2009 Posts: 23
|
Posted: Fri Jul 23, 2010 10:13 am Post subject: |
|
|
can u give a link to it??
coz m getting many such calculators |
|
Back to top |
|
|
kimmi
Joined: 24 Feb 2006 Posts: 1922 Location: Denmark
|
Posted: Fri Jul 23, 2010 11:16 am Post subject: |
|
|
LINK _________________ / Kim |
|
Back to top |
|
|
for_ro
Joined: 11 Nov 2007 Posts: 260
|
Posted: Fri Jul 23, 2010 11:34 am Post subject: |
|
|
Joy wrote: | so for 12mhz it comes out to b 91.6khz ..
i wonder why my program works??
by using this code i am sending rc5 signals .. which must b 38khz ..
also the tsop1738 decodes the signal .. m confused |
The Timer toggles the output pin with a frequency of 91.6KHz which results in an output frequency of 91.6 / 2 = 45.8KHz.
I wouldn't be too surprised that the TSOP filter bandwidth allows this frequency to be recognized. |
|
Back to top |
|
|
Joy
Joined: 28 Feb 2009 Posts: 23
|
Posted: Fri Jul 23, 2010 4:24 pm Post subject: |
|
|
oh k .. i got that .. thank you
btw what freq range the tsop can identify??
m using standard tsop 1738 |
|
Back to top |
|
|
six1
Joined: 27 Feb 2009 Posts: 553
|
Posted: Fri Jul 23, 2010 4:36 pm Post subject: |
|
|
Compare1a = 158 might be ok |
|
Back to top |
|
|
Joy
Joined: 28 Feb 2009 Posts: 23
|
Posted: Fri Jul 23, 2010 4:45 pm Post subject: |
|
|
ok that i calculated ..
btw cane i make a retro-reflact sensor using this tsop .. i mean can i send a rc5 code and recieve it back for obstacle detection ?? |
|
Back to top |
|
|
for_ro
Joined: 11 Nov 2007 Posts: 260
|
Posted: Fri Jul 23, 2010 6:49 pm Post subject: |
|
|
Joy wrote: | ok that i calculated ..
btw cane i make a retro-reflact sensor using this tsop .. i mean can i send a rc5 code and recieve it back for obstacle detection ?? |
Why do you want to send a complex signal as the RC5 code just for detecting an obstacle? If you just send a frequency of 38Khz with modulated 1KHz pseudo signal it would be much easier to detect. And you wouldn't need to recognize the RC5, which blocks your µC for about 150ms, if you use the GetRC5 function. |
|
Back to top |
|
|
Joy
Joined: 28 Feb 2009 Posts: 23
|
Posted: Sat Jul 24, 2010 2:12 am Post subject: |
|
|
oh k .. i cant understand what it means "send a frequency of 38Khz with modulated 1KHz pseudo signal" .. please describe .. |
|
Back to top |
|
|
Joy
Joined: 28 Feb 2009 Posts: 23
|
Posted: Sat Jul 24, 2010 2:21 am Post subject: |
|
|
& how do i detect it??
coz i dont want any rc5 or any remote signal to be detected instead of obstacle .. |
|
Back to top |
|
|
ollopa
Joined: 03 Sep 2007 Posts: 233 Location: California
|
Posted: Sat Jul 24, 2010 7:44 am Post subject: |
|
|
Slight correction from the datasheet
The output frequency in CTC mode is Fo = (Fclk)/(2*Prescale*(1+OCRnx))
So that should be 12MHz/(2*1*(1+131)) = 45.45454 kHz. I use CTC mode a lot.... |
|
Back to top |
|
|
|