Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

timer calculation
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
Joy

Bascom Member



Joined: 28 Feb 2009
Posts: 23

india.gif
PostPosted: Fri Jul 23, 2010 8:13 am    Post subject: timer calculation Reply with quote

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
View user's profile Yahoo Messenger
Neill

Bascom Member



Joined: 08 Dec 2008
Posts: 55

newzealand.gif
PostPosted: Fri Jul 23, 2010 9:06 am    Post subject: Reply with quote

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
View user's profile
Joy

Bascom Member



Joined: 28 Feb 2009
Posts: 23

india.gif
PostPosted: Fri Jul 23, 2010 9:32 am    Post subject: Reply with quote

m using 12mhz clock
Back to top
View user's profile Yahoo Messenger
Joy

Bascom Member



Joined: 28 Feb 2009
Posts: 23

india.gif
PostPosted: Fri Jul 23, 2010 9:42 am    Post subject: Reply with quote

so for 12mhz it comes out to b 91.6khz .. Surprised

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
View user's profile Yahoo Messenger
amirf

Bascom Member



Joined: 25 Aug 2009
Posts: 154

indonesia.gif
PostPosted: Fri Jul 23, 2010 10:11 am    Post subject: Reply with quote

pls check AVR Timer Calculator by Jack Tidwell
Back to top
View user's profile
Joy

Bascom Member



Joined: 28 Feb 2009
Posts: 23

india.gif
PostPosted: Fri Jul 23, 2010 10:13 am    Post subject: Reply with quote

can u give a link to it??
coz m getting many such calculators
Back to top
View user's profile Yahoo Messenger
kimmi

Moderator



Joined: 24 Feb 2006
Posts: 1922
Location: Denmark

denmark.gif
PostPosted: Fri Jul 23, 2010 11:16 am    Post subject: Reply with quote

LINK
_________________
/ Kim
Back to top
View user's profile Visit poster's website MSN Messenger
for_ro

Bascom Member



Joined: 11 Nov 2007
Posts: 260

germany.gif
PostPosted: Fri Jul 23, 2010 11:34 am    Post subject: Reply with quote

Joy wrote:
so for 12mhz it comes out to b 91.6khz .. Surprised
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
View user's profile
Joy

Bascom Member



Joined: 28 Feb 2009
Posts: 23

india.gif
PostPosted: Fri Jul 23, 2010 4:24 pm    Post subject: Reply with quote

oh k .. i got that .. thank you

btw what freq range the tsop can identify??
m using standard tsop 1738
Back to top
View user's profile Yahoo Messenger
six1

Bascom Expert



Joined: 27 Feb 2009
Posts: 553

germany.gif
PostPosted: Fri Jul 23, 2010 4:36 pm    Post subject: Reply with quote

Compare1a = 158 might be ok
Back to top
View user's profile
Joy

Bascom Member



Joined: 28 Feb 2009
Posts: 23

india.gif
PostPosted: Fri Jul 23, 2010 4:45 pm    Post subject: Reply with quote

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
View user's profile Yahoo Messenger
for_ro

Bascom Member



Joined: 11 Nov 2007
Posts: 260

germany.gif
PostPosted: Fri Jul 23, 2010 6:49 pm    Post subject: Reply with quote

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
View user's profile
Joy

Bascom Member



Joined: 28 Feb 2009
Posts: 23

india.gif
PostPosted: Sat Jul 24, 2010 2:12 am    Post subject: Reply with quote

oh k .. i cant understand what it means "send a frequency of 38Khz with modulated 1KHz pseudo signal" .. please describe ..
Back to top
View user's profile Yahoo Messenger
Joy

Bascom Member



Joined: 28 Feb 2009
Posts: 23

india.gif
PostPosted: Sat Jul 24, 2010 2:21 am    Post subject: Reply with quote

& how do i detect it??

coz i dont want any rc5 or any remote signal to be detected instead of obstacle ..
Back to top
View user's profile Yahoo Messenger
ollopa

Bascom Member



Joined: 03 Sep 2007
Posts: 233
Location: California

usa.gif
PostPosted: Sat Jul 24, 2010 7:44 am    Post subject: Reply with quote

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
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum