Page 1 of 1

Remote Control Project

Posted: 04 August 2011, 8:09 AM
by geocool
I'm trying to control my sony TV with the IR Transmiter.
I Need to send signal for 2.4ms then pause for 0.6ms and then send 1.2ms for Binary-1 or 0.6ms for Binary-0 with a pause of 0.6ms between them.

http://www.zbasic.net/forum/about676.html
I found this topic where there is OutBurst subroutine that i can use as freqout.I searched in documents for a pause subroutine and i noticed that pause and delay subroutines use seconds.And the question is how can I use μS ? Also will OutBurst work for what I wanna do ?

Thanks In Advance :)

Re: Remote Control Project

Posted: 04 August 2011, 9:14 AM
by dkinzer
geocool wrote:how can I use μS ? Also will OutBurst work for what I wanna do ?
I don't think that you're going to get the precise timing that you need using a pause/delay strategy. A better approach is to use an external oscillator running at the IR carrier frequency (typically 36KHz to 40KHz) and then use OutputCapture() to generate a pulse stream to modulate (i.e. turn on and off) the carrier frequency. Examples of gated IR oscillators can be found in many places on the Internet including this one.

Remote Control Project

Posted: 04 August 2011, 10:47 AM
by twesthoff
Don-
Back in 2008 you helped me generate a 40Hz signal on pin D.7.
If it can make a 40KHz pulse, that might mean an external source may not be necessary for the IR signal.
Here is the code I used then. Can this method be used at 40KHz?
Tom

Code: Select all

Sub Output40HzOn()
       'Turns on 40Hz signal at pin D.7, Divided by 2 for 20Hz in PLD
       'Used to pulse Ctone at 20Hz for incoming call ringing
       Const T2mode As Byte = bx0001_1111
       Register.TCCR2 = 0                                 'Stop Timer2
       Register.TCNT2 = 0
       Register.OCR2 = 180                                 '40Hz=(14745600/1024/20/2)=180
       Register.TCCR2 = T2mode               'Start Timer2
     End Sub


On 8/4/2011 12:14 PM, ZBasic wrote:
geocool wrote: how can I use μS ? Also will OutBurst work for what I wanna do ? I don't think that you're going to get the precise timing that you need using a pause/delay strategy. A better approach is to use an external oscillator running at the IR carrier frequency (typically 36KHz to 40KHz) and then use OutputCapture() to generate a pulse stream to modulate (i.e. turn on and off) the carrier frequency. Examples of gated IR oscillators can be found in many places on the Internet including this one.



- Don Kinzer




Re: Remote Control Project

Posted: 04 August 2011, 11:41 AM
by dkinzer
twesthoff wrote:Can this method be used at 40KHz?
Sure. The code below, adapted from yours, will generate a 38.4KHz signal on the OC2A pin. The physical pin corresponding to OC2A varies across devices. It corresponds to D.7 of mega644/mega1284-based devices and appears on pin 25 on the 24-pin ZX devices.

Code: Select all

Sub Output38KHz()
   If Semaphore(Register.Timer2Busy) Then
     'Turns on 38.4KHz signal at pin D.7
     Const T2modeA As Byte = bx0100_0010  ' toggle OC2A on match
     Const T2modeB As Byte = bx0000_0010  ' div by 8
     Call PutPin(D.7, 0)                  ' make OC2A pin an output
     Register.TCCR2B = 0                  'Stop Timer2
     Register.TCNT2 = 0
     Register.OCR2A = CByte(14745600\8\38400\2-1)
     Register.TCCR2A = T2modeA
     Register.TCCR2B = T2modeB            'Start Timer2
   End If
EndSub
[edit: added use of timerBusy flag]

Posted: 05 August 2011, 7:43 AM
by dlh
Nearly all IR receivers have very wide carrier bandwidth (e.g.±5kHz) and are tolerant of ± 10% variation in pulse/space durations so precision is not a necessity. Many IR protocols date back 40+ years when components were themselves less precise, especially for battery powered remote controls.