| Posted: 05:21am 12 Feb 2024 |
|
|
|
And now a 1 output pin version of the program above. 38kHz carrier added to the Bitstream. Same circuit as above minus the 1N914.
' NEC IR Remote Control repeater. - 1 pin version Dim integer dev, key 'codes for Device (address) and Button (data) Const IRpin = MM.Info(pinno gp1) 'output pin, change as needed SetPin IRpin, dout : Pin(IRpin) = 0 ' IR code output
SetPin gp6, IR ' IR receiver input, change as needed IR dev, key , Rx.int Print "Waiting for input"
Sub Rx.int ' get IR codes Print "dev"; dev,Bin$(dev,8), "key";key,Bin$(key,8);" Recieved code" Pause 2000 'delay to separate original and repeated code NECsend IRpin,dev,key ' call transmitter sub Print "Waiting for input" End Sub
Do : Loop
End
Sub NECsend IRpin As integer, dev As integer, key As integer Print "dev";dev,Bin$(dev,8), "key";key,Bin$(key,8);" Data to send" Local integer word, c(72), i, d(2200), n
word = (dev<<16) + (key<<8) + ((255 Xor key )And 255) 'assemble 32 bits
Pin(IRpin) = 0
Print "Data to convert " Bin$(word,32)
Math set 1, c() c(0)=16 : c(1)=8 ' start pulse time units - 1 unit = 562S
For i = 2 To 68 Step 2 c(i)= ((word>>(32-i/2)) And 1)*2 + 1 'decode 32 bit word to bit time units Next
Print c(66)=1 'end pulse time units c(67)=72 : c(68)=16 :c(69)=4 :c(70)=1 :c(71)=172
Math scale c(), 562, c() 'restore time values to uS ' Math V_PRINT c() 'print the bitstream
Math set 13 , d() 'Load d() with PWM, 13=1000/(38*2)uS = half cycle @ 38kHz unit = 42 'half cycles - basic time unit D(unit * 16) = 562 * 8 'pause after start pulse train n = 2
For m=(unit * (16 + 1)) To 2100 Step unit 'load data after start sequence d(m) = c(n) 'copy data duration (short = 0, long = 1) Inc n, 2 'skip to next data bit Print n,m, c(n), d(m) Next
Device bitstream IRpin, 2199, d() 'send the data
Pause 100 Pin(IRpin) = 0 End Sub Edited 2024-02-12 15:28 by phil99 |