PDA

View Full Version : What's the best way to output 30 to 40 kHz from a 12F683 pin?



fizyxman
- 31st May 2009, 19:24
Hi all -
This forum has already been tons of help, but now I have a question I can't find the answer to. I'm trying to build a minimum parts IR transceiver using a 12F683. I'd like to encode the IR beam at either 30 or 40 kHz (selectable) to minimize ambient light and allow two units to operate in the same area without them getting confused. I've got an darlington pair to give me adequate current and am using encoded receivers, I just don't know if it's possible to code the switch routine in PBP or if I need to do it in assembly. It seems that the docs are telling my the freq is too high for HPWM. I'd like the IR signal to run constantly.

Peace - Fiz

mister_e
- 31st May 2009, 21:14
HPWM limit is as stated in your manual. To reach higher frequency, you need to write the PWM register manually. Use PICMultiCalc to find PR2 and Timer Prescaller value, then plug the DutyCycle values in CCP1CON and CCPR1L registers... double check your datasheet to confirm.

PicMultiCalc download
http://www.picbasic.co.uk/forum/atta...7&d=1225550328

flotulopex
- 31st May 2009, 23:04
T2CON = %00000100
CCP1CON = %00001100
CCPR1L = 50
PR2 = x
@8MHz, x=
56 for +/- 34kHz
54 for +/- 36kHz
52 for +/- 38kHz
48 for +/- 40kHz
46 for +/- 42kHz

Frequencies shown here are not 100% accurate but for most IR receivers, they'll work well.

fizyxman
- 31st May 2009, 23:17
Thanks for the quick responses -

I'll try the values you gave me out in the morning (I'm a teacher) at school. mister_e the URL you posted didn't work (it has an ellipsis ... in it). If possible I'd like to get that calculator since we're hoping to scale this up to use up to 8 different transmitter/receiver pair, though I anticipate having to do substantial filtering/additional encoding. But that's for another day...

Thanks again - Fiz

BTW mister_e I live just over the border in VT.

fizyxman
- 31st May 2009, 23:22
Found it on another post. Thanks a ton or is it tonne? ;)

Fiz

mister_e
- 1st June 2009, 00:08
ton or tonne... both are the same to me ;)