PDA

View Full Version : 38Khz Modulator



Gord11
- 27th September 2011, 10:40
hello,

Can anyone help with this?

I wanted to make an IR data link, i can use the method described elsewhere using a 555 with pin 4 connected
to my PIC, but i understand this can be unstable.

So i was going to use two PIC's (or actual 3 if you include the decoder) one would provide the 38Khz and the other provides
the serial out. (the receiver would be one of the 38Khz modules).

I can produce the code to make the PIC output pretty close to the 38Khz, but i not sure how i can implement the serial in at the same
time, how to turn on or off the 38Khz with the serial in.

I have seen ASM code to do this, but i don't understand it.

So what i am trying to do is output the serial on a 38Khz carrier, can anyone suggest how this can be achieved in code????

Many Thanks


Gordon.

HenrikOlsson
- 27th September 2011, 11:04
I'm not sure what you mean by turn the 38kHz on or off with the serial in. I suspect you mean how to modulate it with serial out?

Since you haven't said what PIC you're using I'm going to assume it has a CCP module. Set that up to provide the 38kHz carrier, connect the IR-LED between the PWM output and the serial output (with a current limit resistor). Depending on which way you connect the LED you'll get "true" or "inverted" output.

If you want to push more current thru the LED than the PIC can supply (~25mA) then simply AND the two signals (PWM and serial) and use the output to drive the LED via a MOSFET or whatever.

/Henrik.

Bruce
- 27th September 2011, 12:23
Here's one way if you have a 16F1827 http://www.picbasic.co.uk/forum/showthread.php?p=84227#post84227

And another way http://www.rentron.com/Micro-Bot/IR_Serial.htm with any PIC with hardware PWM.

Gord11
- 27th September 2011, 12:57
Hi Henrik / Bruce,

Thankyou for the pointers..

I have been trying things out on various PIC's, but they all have PWM. What you have described is exactly what i am trying to do.

I completly overlooked this.

Thanks again,

Gordon.

languer
- 27th September 2011, 21:05
You can see another example on the following two links:
http://www.electro-tech-online.com/content/361-basic-ir-communications.html
http://www.electro-tech-online.com/blogs/languer/156-ir-beam-break-test-bed.html

Gord11
- 28th September 2011, 08:14
Ok,

I understood the electronics, but have have been looking at the datasheet for the 12F683.

I am sure this is going to end up being a simple answer, but i have been looking at the duty cycle settings for the PWM, it's just not making
sense to me!

I have seem other posts, setting the CLPR1L to 13, which would be half (50%) of the 26uS period. But when i look at the calculation for the duty cycle in the
datasheet i am not understanding. If you put 13 in the CLPR1L (ie. 1101), does this then add to CCP1CON 5:4, (i.e.00) to make 1101 00 = 52 - then 52*0.25*1=13uS........

(0.25 Tosc & 1 prescaler).

Also, why does it say in the datasheet, 10bit PWM. Max 20Khz?

As you can tell i am still at the very start of understanding PIC programming.

Gordon,,