Hi folks, could somebody show me how to set the LED to flash at 38Khz please.
I've tried playing around with the delay times right down to a few microseconds but cannot come anywhere close to 38Khz.
I've attached my flowchart for you to look at.
Thanks a lot- John
How to achieve 38Khz
Moderator: Benj
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: How to achieve 38Khz
Hi John,
Attached is a Flowchart that flash LED connected to port GP2 at 38KHz. (Period = 26us so its 38.46KHz to be more precise )
To achieve this more easily:
1) I have changed the internal oscillator from 4 to 8MHz (adding a C code block with osccon=0x70; changes osc speed).
I was not sure on what duty cycle you required so set duty cycle to 50%.
You can change the duty cycle if you wish buy changed the 50, but the resolution is not that great.
2) Using internal pwm instead of delays. So you can only have 38KHz at port GP2. this is determined by actual hardware.
You will not be able to change that.
Note the brightness of LED will be dependent on the duty. so as a very rough flawed guide think of 50% at 1/2 brightness and 25 at a 1/4 brightness.
Obviously you will not see the LED flash
Martin
Attached is a Flowchart that flash LED connected to port GP2 at 38KHz. (Period = 26us so its 38.46KHz to be more precise )
To achieve this more easily:
1) I have changed the internal oscillator from 4 to 8MHz (adding a C code block with osccon=0x70; changes osc speed).
I was not sure on what duty cycle you required so set duty cycle to 50%.
You can change the duty cycle if you wish buy changed the 50, but the resolution is not that great.
2) Using internal pwm instead of delays. So you can only have 38KHz at port GP2. this is determined by actual hardware.
You will not be able to change that.
Note the brightness of LED will be dependent on the duty. so as a very rough flawed guide think of 50% at 1/2 brightness and 25 at a 1/4 brightness.
Obviously you will not see the LED flash
Martin
- Attachments
-
- I LED FLASH 12F683 38KHz V2.fcf
- (7 KiB) Downloaded 217 times
Martin
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: How to achieve 38Khz
Thanks Martin, appreciate your help.
Will play around with it for a while.
Thanks again =John
Will play around with it for a while.
Thanks again =John
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: How to achieve 38Khz
Thanks Martin. Have [layed around with the flowchart a bit.
Could you explain to me what you mean by the "resolution not being too good"
The objective is to build an IR Transmitter that will be part of a breakbeam system so it's important that the IR LED can "flash" as intensly as possible in order to achieve distance.
So, I,ve set the duty at 90% to see what happens. Any thoughts??? Cheers John
Could you explain to me what you mean by the "resolution not being too good"
The objective is to build an IR Transmitter that will be part of a breakbeam system so it's important that the IR LED can "flash" as intensly as possible in order to achieve distance.
So, I,ve set the duty at 90% to see what happens. Any thoughts??? Cheers John
-
- Matrix Staff
- Posts: 9520
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: How to achieve 38Khz
To me the resolution is how small is the smallest number to change the pwm duty.JDR04 wrote:Could you explain to me what you mean by the "resolution not being too good"
With the flowchart I posted should be fine for your requirements of 90%.
However the resolution will not allow 90,89,88,87 ect
It will probably be 90,88,85 or something like that.
Yes at least with 38KHz you can have a much higher pulse current than if you was only using a steady current.JDR04 wrote:Any thoughts
E.g if maximum steady current is say 100mA, then pulse current can be 10 times (or more)than that, allowing much further distances.
Best to look at the IR emitter datasheet.
You just need to make sure that maximum recommended on time (e.g 100us) is adhered to.
Also do not drive ir device directly from microcontroller.
Use some type of buffer like a transistor.
Martin
Martin
-
- Posts: 271
- Joined: Tue Mar 05, 2013 10:49 pm
- Has thanked: 111 times
- Been thanked: 13 times
- Contact:
Re: How to achieve 38Khz
Thanks for that.
I'm thinking of usung a transistor type driver circuit like the one attached. I think I will have to recalculate the resistor values.
Could I use a 2N2222 tranny for this do you think?
What do you think? Thanks a lot John
I'm thinking of usung a transistor type driver circuit like the one attached. I think I will have to recalculate the resistor values.
Could I use a 2N2222 tranny for this do you think?
What do you think? Thanks a lot John
- Attachments
-
- LED & TRANSISTOR Circuit.png
- (49.1 KiB) Downloaded 2360 times