Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

IR Pulses Emulator

Status
Not open for further replies.

e.chain

New Member
Hi to all, I am plannig to build a remote to emulate certain pulses via Infrared, any ideas about schematics or source code for a PIC. The code is short, long, long, long, short, modulated by 38Khz, I have attached the timing of the pulses I want to emulate with 2 buttons.
 

Attachments

  • Code.JPG
    Code.JPG
    9.9 KB · Views: 181
Not sure what PIC/language your using, but, the following could be done;

Code:
Device = 18F452
Clock = 19

// Setup the PWM for a 38Khz 50% Duty Cycle
PR2 = %01111100 
T2CON = %00000100 
CCPR1L = %00111110 
CCP1CON = %00011100 

//Turn Off the PWM signal
Input(PORTC.2)

//Make the button an input
Input(PORTC.0)

Main_Program:
[INDENT]//Check if a button is pressed
While PORTC.0 = 0
Wend

//Control the 38Khz signal by controlling the TRIS of the PWM signal
Output(PORTC.0)
DelaymS(6)
Input(PORTC.0)
DelaymS(1)

Output(PORTC.0)
DelaymS(9)
Input(PORTC.0)
DelaymS(1)

Output(PORTC.0)
DelaymS(9)
Input(PORTC.0)
DelaymS(1)

Goto Main_Program
[/INDENT]


Written with Swordfish
 
hi mike
In swordfish its the xtal define in MHz, 19Mhz.
I suspect as its a multiple of 38 its going to be used for the 38Khz clock generation.???
 
gramo said:
Spot on Eric!

With 19Mhz you can create a very accurate 38Khz PWM signal :eek:

And with simple software you can produce accurate 38KHz with only a 4MHz clock, and IR pulses consisting of accurate numbers of whole 38KHz pulses - it's really a VERY poor application for the hardware PWM module, which gives poorer results and no worthwhile advantages.
 
I have no experience with swordfish, I really like assembler, but I think I understand. Thanks a lot Gramo, it looks easy, do you have any schematics to build the circuit.
 
Last edited:
Nigel Goodwin said:
And with simple software you can produce accurate 38KHz with only a 4MHz clock, and IR pulses consisting of accurate numbers of whole 38KHz pulses - it's really a VERY poor application for the hardware PWM module, which gives poorer results and no worthwhile advantages.

Huh? Utilizing the hardware PWM functions allows you to perform other functions at the same time, and there is less code overhead :confused:

I dont see why this is considered a "poor" application for the PWM module. Perhaps it's not the most advanced task it could be used for, but it does the job just fine... :rolleyes:
 
Last edited:
gramo said:
Huh? Utilizing the hardware PWM functions allows you to perform other functions at the same time, and there is less code overhead :confused:

Try reading what the application is!, it's not required to, and as you're manually gating the PWM you can't do anything at the same time anyway!

I dont see why this is considered a "poor" application for the PWM module. Perhaps it's not the most advanced task it could be used for, but it does the job just fine... :rolleyes:

It's less accurate than a simple software loop, because you can't easily control exact numbers of exact whole cycles - as I've said before, it's just using the hardware 'because it's there', while giving no advantages and a number of disadvantages.
 
gramo said:
Even if it starts a half mark out, it will finish a half mark late, therefore producing the same amount of detection time by the IR receiver.

Could be wrong, but it makes sense to me :eek:

It is wrong! :D

The timing in your method is in no way syncronised to the IR pulses, you don't actually send pulses for xmS - you send a specific number of complete pulses - this is how all IR remotes work. Using the PWM hardware doesn't allow this, and provides no benefits at all over doing it in software.
 
I'm just wondering how to generate an "accurate" 38-KHz square wave using any method (besides using that oddball 19-MHz clock)? Wouldn't that require toggling some output pin at something like every 13.158 usecs?
 
Oh, I see. Thank you. So a 38462-Hz square wave with a 4-MHz clock, or a 38168-Hz or 37879-Hz square wave with a 20-MHz clock is acceptable.

I would have thought the PWM module a perfect solution for off-loading the task.

Could I impose again to ask why it's important to start and stop the 38-KHz square wave output exactly at full-cycle intervals? Wouldn't the IR Decoder chip synchronize correctly? If it sees a 'short' half-cycle pulse as a result of gating the output on in the middle of a cycle, wouldn't it simply discard it since it's not 13.158-usecs in length? Also, in the Sony SIRC protocol you decode the output of the IR Decoder using "minimum" 550-usec or 1100-usec intervals (I think). Wouldn't you just insure that you gate the 38-KHz output 'on' for the required time interval plus an additional 60-usecs or more to make up for the possibility of chopping up single leading and trailing 38-KHz cycles?

Sorry to bombard you with questions but this is an interesting subject and something I plan to implement very soon.

Mike
 
<bump>

I too would be interested in seeing an IR emitter circuit(s) and interested to know what distances can be achieved (and the power requirements).

Thanks, Mike
 
Mike said:
Oh, I see. Thank you. So a 38462-Hz square wave with a 4-MHz clock, or a 38168-Hz or 37879-Hz square wave with a 20-MHz clock is acceptable.

I would have thought the PWM module a perfect solution for off-loading the task.

Could I impose again to ask why it's important to start and stop the 38-KHz square wave output exactly at full-cycle intervals? Wouldn't the IR Decoder chip synchronize correctly? If it sees a 'short' half-cycle pulse as a result of gating the output on in the middle of a cycle, wouldn't it simply discard it since it's not 13.158-usecs in length? Also, in the Sony SIRC protocol you decode the output of the IR Decoder using "minimum" 550-usec or 1100-usec intervals (I think). Wouldn't you just insure that you gate the 38-KHz output 'on' for the required time interval plus an additional 60-usecs or more to make up for the possibility of chopping up single leading and trailing 38-KHz cycles?

Sorry to bombard you with questions but this is an interesting subject and something I plan to implement very soon.

I've done a LOT with IR, and produced various test devices to control TV's, satellite receivers etc. - doing such things as changing channels every so many seconds, or pressing the backup button every so many seconds. Basically for servicing purposes, sometimes a 'sneaky device' can be very helpful - I've also bult a PIC device to multi-region N series Sony DVD players, a single press and it does it all for you :D

Like I said above, you don't send 38KHz for a specific time, that's not the way it's done - you simply send a specific exact number of cycles - that way you're EXACTLY correct, and not just a rough approximation.

There's no need to 'off load' anything, as the processor (in this case) isn't doing anything else - and even in the PWM case Gramo suggested, he's using a software loop to gate the PWM - so it can't do anything else either. Like I also said above, it's just using the hardware "because it's there", and gaining no advantage at all - and also because Gramo only programs in BASIC, so probably can't do it in software? :D

The IR hardware in my tutorials easily does 13 metres+, the full length of the service department at work - there doesn't seem much need for any more?.
 
Status
Not open for further replies.

Latest threads

Back
Top