Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 13:51 24 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : IR Remote Control programs for the NEC Protocol and Variants.

Author Message
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 11:50am 30 Aug 2024
Copy link to clipboard 
Print this post

Here is a MMBasic version of the NECsend Subroutine that supports 8 and 16 bit Device Codes,
with or without bit order reversal*** and the Samsung32 variant.
Tested on Picomite and ArmMiteF4.

***The MMBasic IR reading command outputs codes with MSB first and 16 bit Device Code so this is the default setting
but the NEC specifies LSB first. This can be selected with an extra parameter if you have codes intended for that format.

Usage:
Call "NECsend DeviceCode, KeyCode [, Variant]"

If using the Sub in an existing program that can't have a separate Variant parameter the parameter can instead be bit shifted up 16 and added to the DeviceCode.

eg Inc DeviceCode, (Variant << 16)
Then Call "NECsend DeviceCode, KeyCode

Variant:
0  standard NEC 16 bit DeviceCode, MSB first (default)
1  Samsung32
2  standard NEC 8 bit DeviceCode, MSB first
3  standard NEC 16 bit DeviceCode, LSB first
4  standard NEC 8 bit DeviceCode, LSB first

' "NECsend with option for Samsung32 variant.bas"
'Dim Integer IRpin=MM.Info(pinno GP0) 'for Picomite - set your output pin
Dim Integer IRpin=MM.Info(pinno PA0) 'for ArmMiteF4 - set your output pin
Dim Integer dev, key, V 'for standard NEC V = 0, or omit. V = 1 for Samsung32
'for 8 bit NEC Dev code V = 2
'for 16 bit, LSB first NEC Dev code V = 3
'for 8 bit, LSB first NEC Dev code V = 4

'Alternatively those variants can instead be denoted by adding them to Dev above bit 16
'eg. for S32 (V=1) Device 5 Dev = &H10005 = 65541
Do
'Your program here.
 Input "Enter Device, Key, Variant (NEC=0, S32=1) codes "; dev, key, V
 NECsend IRpin, dev, key, V
Loop

Sub NECsend IRpin As integer, Dev As integer, Key As integer, V As integer
Local Integer word, d(1390), m, n = 1
Local Float T
Pin(IRpin) = 0
Math set 13, d() 'fill array. 13=1000/(38*2) uS - duration of a half cycle @ 38kHz
'Math set 14, d() 'to overcome F4 timing error use this instead of line above

If V = 0 Then V = (Dev >> 16) ' if V missing or 0 then look for V in Dev above bit 16
Dev = Dev AND &Hffff

If V = 1 Then
  dev = ((Dev AND 255) * &H0202020202 AND &H010884422010) MOD 1023 'ensure 8 bits only &
  key = ((Key AND 255) * &H0202020202 AND &H010884422010) MOD 1023 ' reverse bit order
  word = (dev<<24) + (dev<<16) + (key<<8) + 255-key 'assemble 32 bits
  BitBang bitstream IRpin, 330, d() 'send 4.5ms start 38kHz
 Else

  If (V=2) OR (V=4) Then dev = (Dev << 8) + 255-Dev  'convert 8 bit address to 16 if required
  If (V=3) OR (V=4) Then
    key = ((Key AND 255) * &H0202020202 AND &H010884422010) MOD 1023 ' reverse Key bit order, 8 bit
    dev16 = (((dev AND 255) * &H0202020202 AND &H010884422010) MOD 1023) << 8 ' reverse Dev bit order, low byte
    dev = dev16 + ((dev >> 8) * &H0202020202 AND &H010884422010) MOD 1023  'now reverse high byte & swap bytes
  EndIf
  word = (dev<<16) + (key<<8) + 255-key ':Print Bin$(word,32) 'assemble 32 bits '16 bit address only
  BitBang bitstream IRpin, 620, d() 'send 9ms start 38kHz
EndIf

T = Timer' :Print t
For m = 42 To 1386 Step 42  'load data after start sequence, step 42 = 21 cycle IR pulse
 d(m) = (((word>>(32-n)) AND 1)*2 + 1) * 560  'convert bits to duration (short = 0, long = 1)
 Inc n ':Print d(m); 'step to next data bit
Next

Do : Loop Until Timer > T+4.3 ':Print Timer-T 'less than 4.5 due processing time, adjust for CPU speed
BitBang bitstream IRpin, 1386, d() 'send the data

'Pin(IRpin) = 0
End Sub

'Samsung32 specification:-
  'coding: Pulse Distance (same as NEC, fixed length pulses, long pause=1 short=0)
  'Frame: 1 start + 32 Coding + 1 Stop bit (same as NEC)
  'Data: 8 bit address + 8 bit address + 8 bit command + inverted 8 bit command - all bytes LSB first
  '       (old NEC 8bit address similar but 2nd copy inverted. Most NEC use 16bit address)
  'Start Bit: 4500uS pulse 4500uS pause (NEC Start Bit: 9000uS pulse 4500uS pause)
  'Data: 0 bit = 550uS pulse + 550uS pause, 1 bit = 550uS pulse + 1650uS pause
  '              (close enough to NEC - 562.5uS, difference = 1/2 cycle & 38kHz)
  'Stop Bit 550uS pulse (almost same as NEC - 562.5uS)
  'Repetition after 47mS
End

The current F4 BitBang Bitstream command has a small timing error, however for most devices it is close enough.
If some don't work changing: Math set 13, d() to Math set 14, d() should fix it.

The MMBasic IR command reads Sony and standard NEC codes but not the Samsung32 variant.
So here is a IR code reader for the Samsung32 variant. Tested on a PicoMite.
Samsung32 has a 4.5mS start pulse instead of 9mS and has an 8 bit device code repeated without inverting.
Bit timings are multiples of 550uS instead of 562.5uS but I found 560uS works for both.
' "Samsung32 IR code receiver.bas"
' tested on PicoMite v5.09.00 126MHz to 400MHz
Dim Integer Dev, Key, IRpin=MM.Info(pinno GP6) ' set your pin
SetPin IRpin, INTL, IR_Rx_Samsung32
Print
Print "Dev", "Key"

Do : Loop

Sub IR_Rx_Samsung32
 SetPin IRpin, off :SetPin IRpin, DIN 'stop interrupt and prepare to get data
 Local float T=Timer, T1, Tmax=300, Z=T+Tmax
 Local Integer n, m

 Do :Loop Until Pin(IRpin)Or(Timer>Z),:Do While Pin(IRpin)And(Timer<Z):Loop :T1=Timer-T
 'wait for start sequence to complete then get time, falling edge to falling edge
 For n=0 To 31
  T=Timer :Do :Loop Until Pin(IRpin):Do While Pin(IRpin):Loop :T1=Timer-T

  If T1>1.4 And T1<2.4 Then 'measure bits, add to word, LSB first into MSB and shifting down
    m=(m>>1) + &H80000000 'add 1
   Else
    m=m>>1 'add 0
  EndIf
 Next

 SetPin IRpin, off
'  Print :Print Bin$(m,32), "Bit order reversed so MSB is on the left" :Print

'  Print Bin$(m And &Hff,8), Bin$(m>>16 And &Hff,8) 'show assembled bytes 1 & 3 (m is in reverse order)
'  Print Bin$(m>>8 And &Hff,8), Bin$(255-(m>>24) And &Hff,8) 'show assembled bytes 2 & inverted 4
   'error check. compare byte 1 and byte 2
 If ((m And 255) = ((m>>8) And 255)) And (((m>>16) And 255) = (255-((m>>24) And 255))) Then
   dev = m And &Hff 'get device code
   key = m >> 16  And &Hff 'get key code
   Print Dev, Key
  Else
   dev=-1 :key=-1
 EndIf

 Pause 300 'prevent re-triggering, Samsung remote always sends code twice
 SetPin IRpin, INTL, IR_Rx_Samsung32 'prepare for next input

End Sub

'Samsung32 specification:-
  'coding: Pulse Distance
  'Frame: 1 start + 32 Coding + 1 Stop bits
  'Data: 8 bit address + 8 bit address + 8 bit command + inverted 8 bit command all LSB first
  'Start Bit: 4500uS pulse 4500uS pause
  'Data: 0 bit = 550uS pulse + 550uS pause, 1 bit = 550uS pulse + 1650uS pause
  'Stop Bit 550uS pulse
  'Repetition after 47mS
  'on the remote control I have a button press always sends the code at least twice

Edited 2024-08-30 22:00 by phil99

Footnote added 2024-08-31 11:18 by phil99
First Bug - MM.INFO(Pinno xx) is different on F4 to Pico. It gives the first pin of the Port, not the individual pin number.
By blind luck the pin I used was the first pin of that port so it worked.

For the F4 define IRpin this way:-
' "NECsend with option for Samsung32 variant.bas"
'Dim Integer IRpin = MM.Info(pinno GP0) 'for Picomite - set your output pin
Dim Integer IRpin = 23  '= PA0  for ArmMiteF4 - set your output pin
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3194
Posted: 01:28pm 30 Aug 2024
Copy link to clipboard 
Print this post

Excellent.

You should load this onto the Fruit Of The Shed (https://fruitoftheshed.com/wiki/).

Geoff
Geoff Graham - http://geoffg.net
 
Marcel27

Regular Member

Joined: 13/08/2024
Location: Netherlands
Posts: 53
Posted: 07:04pm 30 Aug 2024
Copy link to clipboard 
Print this post

Super! Just what I needed.
If you use AI, you lose your mind.
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 01:16am 31 Aug 2024
Copy link to clipboard 
Print this post

Thanks Geoff and Marcel, after any problems or improvements have been sorted out I will post it on FOTS.

If anyone has other variants of the NEC protocol post them here and I will try to add them to the Sub.

As I have only one Samsung device to test on I would like to know if these programs work on others.


First Bug - MM.INFO(Pinno xx) is different on F4 to Pico. It gives the first pin of the Port, not the individual pin number.
By blind luck the pin I used was the first pin of that port so it worked.

For the F4 define IRpin this way:-
' "NECsend with option for Samsung32 variant.bas"
'Dim Integer IRpin = MM.Info(pinno GP0) 'for Picomite - set your output pin
Dim Integer IRpin = 23  '= PA0  for ArmMiteF4 - set your output pin



The Samsung receiver program has now been tested on the ArmMiteF4 using this setup:-
> LIST
' "Samsung32 IR code receiver - F4.bas"
' tested on ArmMiteF4 v5.07.02
Dim Integer IRpin = 1 '= PE2 <- set your pin

Edited 2024-08-31 15:37 by phil99
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 08:00am 01 Sep 2024
Copy link to clipboard 
Print this post

An update for the IR Receiver program above.
It now also does standard NEC codes with 8 and 16 bit Device codes using NECs LSB first format.
It saves the results to a file, including the variant number in a format that can be copied and pasted into the NECsend program.
' "NEC and Samsung32 IR code receiver.bas"
' tested on PicoMite v5, v6 & ArmMiteF4 v5.07.02
Dim Integer Dev, Key, V, IRpin = MM.Info(PinNo GP1) '<- set your pin - Pico
'Dim Integer Dev, Key, V, IRpin = 1 '= PE2 <- set your pin - F4
Dim string KN
Print
Open "NEC_Key_Codes.txt" For append As #3
Pause 55
Print "To save the data (NEC_Key_Codes.txt) press any RC key"
Print " and type Quit at the 'Enter Key name ?' prompt." : Print
Print "Device, Key, Variant, 'Function"
Print #3, "'Device, Key, Variant, 'Function,,NEC_Key_Codes.txt"
SetPin IRpin, INTL, IR_Rx_NEC_S32

Sub IR_Rx_NEC_S32
 SetPin IRpin, off :SetPin IRpin, DIN 'stop interrupt and prepare to get data
 Local float T=Timer, T1, T2, Tmax=300, Z=T+Tmax
 Local Integer n, m
 dev = 0 : key = 0 : V = 0 : KN = ""

 Do :Loop Until Pin(IRpin)OR(Timer>Z):T2=Timer-T:Do While Pin(IRpin)AND(Timer<Z):Loop :T1=Timer-T
 'wait for start sequence to complete then get time, falling edge to falling edge
 For n=0 To 31
  T=Timer :Do :Loop Until Pin(IRpin):Do While Pin(IRpin):Loop :T1=Timer-T

  If T1>1.4 AND T1<2.4 Then 'measure bits, add to word, LSB first into MSB and shifting down
    m=(m>>1) + &H80000000 'add 1
   Else
    m=m>>1 'add 0
  EndIf
 Next

 SetPin IRpin, off
'  Print :Print "Start pulse";T2;"mS  ";Bin$(m,32); " Bit order reversed so MSB is on the left":Print

'  Print Bin$(m And &Hff,8), Bin$(m>>16 And &Hff,8) 'show assembled bytes 1 & 3 (m is in reverse order)
'  Print Bin$(m>>8 And &Hff,8), Bin$(255-(m>>24) And &Hff,8) 'show assembled bytes 2 & inverted 4
  'error check. compare byte 1 and byte 2
 If ((m AND 255) = ((m>>8) AND 255)) AND (T2 > 4) AND (T2 < 5) Then
  V = 1 'Samsung32, LSB first
  dev = m AND &Hff 'get device code
  key = m >> 16  AND &Hff 'get key code
 EndIf

 If ((m AND 255) = (255-((m>>8)) AND 255)) AND (T2 > 7) AND (T2 < 10) Then
  V = 4 'NEC 8 bit, LSB first
  dev = m AND &Hff 'get device code
  key = m >> 16  AND &Hff 'get key code
 EndIf

 If ((255-(m>>24) AND 255) = ((m>>16) AND 255)) AND (T2 > 7) AND (T2 < 10) AND (V = 0) Then
  V = 3 'NEC 16 bit, LSB first
  dev = m AND &Hffff 'get device code
  key = m >> 16  AND &Hff 'get key code
 EndIf

 If dev=0 Then GoTo NoData 'restart the interupt and end sub

 Print Dev;","; Key;","; V,
 Input "  Enter the Key name "; KN

 If (KN = "Quit") OR (KN = "quit") OR (KN = "QUIT") Then
  Print #3, : Print #3,"To use NECsend without the Variant number"
  Print #3,"replace the Device code:- ";Dev;" with:- ";Dev + (V<<16):Print #3,
  Pause 55
  Close #3
  Print
  List "NEC_Key_Codes.txt"
  End
 EndIf

 Print #3, Dev;","; Key;","; V; "  '"; KN

 NoData:
 Pause 300 'prevent re-triggering, Samsung remote always sends code twice
 SetPin IRpin, INTL, IR_Rx_NEC_S32 'prepare for next input

End Sub

Do : Loop

'Samsung32 specification:-
 'coding: Pulse Distance
 'Frame: 1 start + 32 Coding + 1 Stop bits
 'Data: 8 bit address + 8 bit address + 8 bit command + inverted 8 bit command all LSB first
 'Start Bit: 4500uS pulse 4500uS pause
 'Data: 0 bit = 550uS pulse + 550uS pause, 1 bit = 550uS pulse + 1650uS pause
 'Stop Bit 550uS pulse
 'Repetition after 47mS
 'on the remote control I have a button press always sends the code at least twice
End

When you Quit it lists the content of the file.
> RUN

To save the data (NEC_Key_codes.txt) type Quit at the 'Enter Key name ?' prompt.
Device, Key, Variant, 'Function
29185, 3, 3  Enter the Key name ? up
29185, 2, 3  Enter the Key name ? left
29185, 95, 3  Enter the Key name ? ok
29185, 12, 3  Enter the Key name ? info
5, 72, 1  Enter the Key name ? on
5, 29, 1  Enter the Key name ? return
5, 67, 1  Enter the Key name ? ok
64769, 206, 3  Enter the Key name ? list
64769, 193, 3  Enter the Key name ? vol+
1, 5, 4  Enter the Key name ? power
1, 19, 4  Enter the Key name ? enter
1, 91, 4  Enter the Key name ? pause
1, 4, 4  Enter the Key name ? stop
1, 4, 4  Enter the Key name ? quit

'Device, Key, Variant, 'Function
29185, 3, 3  'up
29185, 2, 3  'left
29185, 95, 3  'ok
29185, 12, 3  'info
5, 72, 1  'on
5, 29, 1  'return
5, 67, 1  'ok
64769, 206, 3  'list
64769, 193, 3  'vol+
1, 5, 4  'power
1, 19, 4  'enter
1, 91, 4  'pause
1, 4, 4  'stop
>


Edit.
Have edited the code above to improve the screen layout.

Edit 2
Same program but using PULSIN to get the data instead of waiting for the pin to change.
Benefits: nil
Disadvantages: nil
Reason: because you can
' "NEC JVC16 Samsung32 IR code receiver v3 - PicoMite & F4.bas"
' tested on PicoMite v6, 64MHz to 400MHz & ArmMiteF4 v5.07.02, 160MHz
Dim Integer Dev, Key, V, IRpin = MM.Info(PinNo GP1) '<- set your pin
'Dim Integer Dev, Key, V, IRpin = 1 '= PE2 <- set your pin

Sub IR_Rx_NEC_V
SetPin IRpin, off :SetPin IRpin, DIN 'stop interrupt and prepare to get data
Local float T=Timer, T1, T2, Tmax=300, Z=T+Tmax
Local Integer n, m
dev = 0 : key = 0 : V = 0 : KN = ""

Do :Loop Until Pin(IRpin)Or(Timer>Z):T2=Timer-T
'wait for start sequence to complete then get low pulses
For n=0 To 31
 T1=Pulsin(IRpin,1)
'  Print T1;

 If (T1 < 4000) And (T1 > 200) Then
   If T1>1000 And T1<2000 Then 'measure bits, add to word, LSB first into MSB and shifting down
     m=(m>>1) + &H80000000 'add 1
    Else
     m=m>>1 'add 0
   EndIf
  Else
   Exit For
 EndIf

Next
'  Print "m",Bin$(m>>16,16)

SetPin IRpin, off
'Print :Print "Start pulse";T2;"mS  ";Bin$(m,32); " Bit order reversed so MSB is on the left"
'Print T1;"uS last pulse"

'  Print Bin$(m And &Hff,8), Bin$(m>>16 And &Hff,8) 'show assembled bytes 1 & 3 (m is in reverse order)
'  Print Bin$(m>>8 And &Hff,8), Bin$(255-(m>>24) And &Hff,8) 'show assembled bytes 2 & inverted 4
 'error check. compare byte 1 and byte 2
If ((m And 255) = ((m>>8) And 255)) And (T2 > 4) And (T2 < 5) Then
 V = 1 'Samsung32, LSB first
 dev = m And &Hff 'get device code
 key = m >> 16  And &Hff 'get key code
EndIf

If ((m And 255) = (255-((m>>8)) And 255)) And (T2 > 7) And (T2 < 10) Then
 V = 4 'NEC 8 bit, LSB first
 dev = m And &Hff 'get device code
 key = m >> 16  And &Hff 'get key code
EndIf

If ((255-(m>>24) And 255) = ((m>>16) And 255)) And (T2 > 7) And (T2 < 10) And (V = 0) Then
 V = 3 'NEC 16 bit, LSB first
 dev = m And &Hffff 'get device code
 key = m >> 16  And &Hff 'get key code
EndIf

If ((m And &Hffff) = 0) And (T2 > 7) And (T2 < 10) Then
 V = 5 'JVC16, LSB first
 dev = (m >> 16) And &Hff 'get device code
 key = (m >> 24)  And &Hff 'get key code
EndIf

If dev<>0 And key<>0 Then 'output data

 Print Dev;","; Key;","; V,
 Input "  Enter the Key name "; KN

 If (KN = "Quit") Or (KN = "quit") Or (KN = "QUIT") Then
   Print #3, : Print #3,"To use NECsend without the Variant number"
   Print #3,"replace the Device code:- ";Dev;" with:- ";Dev + (V<<16):Print #3,
   Pause 55
   Close #3
   Print
   List "NEC_Key_Codes.txt"
   End
  Else
   Print #3, Dev;","; Key;","; V; "  '"; KN
 EndIf

EndIf
Pause 300 'prevent re-triggering, Samsung & JVC remotes always send code twice
SetPin IRpin, INTL, IR_Rx_NEC_V 'prepare for next input

End Sub

Dim string KN
Print
Open "NEC_Key_Codes.txt" For append As #3
Pause 55
Print "To save the data (NEC_Key_Codes.txt) press any RC key"
Print " and type Quit at the 'Enter Key name ?' prompt." : Print
Print "Device, Key, Variant, 'Function"
Print #3, "'Device, Key, Variant, 'Function,,NEC_Key_Codes.txt"
SetPin IRpin, INTL, IR_Rx_NEC_V
Do : Loop

End


Edit 3 9/9/2024
The code above has been edited again, adding the JVC 16 bit protocol. Close enough to NEC to count as Variant 5.

The received codes match the corresponding functions at the end of this document:-
JVC Protocol so I know it is working.
The main difference is it uses only 16 bits so there is no inherent error detection. The remote always sends the code at least twice so it would be possible to modify my code to read both copies and compare them.

Another difference is the remote control can have more than one Device Code to cater for multi function devices.
Edited 2024-09-10 11:55 by phil99
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 03:55am 10 Sep 2024
Copy link to clipboard 
Print this post

By overwhelming popular demand ;-)

Now added JVC 16 bit protocol as Variant 5 to the NECsend Sub.

The NEC_Rx program in the previous post has been edited to include this.
' "NECsend with JVC16 & Samsung32 variants.bas"
'Dim Integer IRpin = MM.Info(pinno GP1) 'pin 2 for PicoMite
Dim Integer IRpin = 23 '= PA0) 'for ArmMiteF4
Dim Integer dev, key, V 'for standard NEC V = 0, or omit
'for Samsung32, LSB first -  V = 1
'for 8 bit NEC Dev code - V = 2
'for 16 bit, LSB first NEC Dev code - V = 3
'for 8 bit, LSB first NEC Dev code - V = 4
'for JVC16  LSB first - V = 5

'Alternatively those variants can instead be denoted by adding them to Dev above bit 16
'eg. for S32 (V=1) Device 5 Dev = &H10005 = 65541
Do
'Your program here.
 Input "Enter Device, Key, Variant (NEC=0, S32=1) codes "; dev, key, V
 NECsend IRpin, dev, key, V
Loop

Sub NECsend IRpin As integer, Dev As integer, Key As integer, V As integer
Local Integer word, d(1390), m, n = 1
Local Float T
Pin(IRpin) = 0
Math set 14, d() 'fill array. 13=1000/(38*2) uS - duration of a half cycle @ 38kHz

If V = 0 Then V = (Dev >> 16) ' if V missing or 0 then look for V in Dev above bit 16
Dev = Dev AND &Hffff

If V = 1 Then
  dev = ((Dev AND 255) * &H0202020202 AND &H010884422010) MOD 1023 'ensure 8 bits only &
  key = ((Key AND 255) * &H0202020202 AND &H010884422010) MOD 1023 ' reverse bit order
  word = (dev<<24) + (dev<<16) + (key<<8) + 255-key 'assemble 32 bits
  BitBang bitstream IRpin, 330, d() 'send 4.5ms start 38kHz
 Else

  If (V=2) OR (V=4) Then dev = (Dev << 8) + 255-Dev  'convert 8 bit address to 16 if required
  If (V=3) OR (V=4) Then
    key = ((Key AND 255) * &H0202020202 AND &H010884422010) MOD 1023 ' reverse Key bit order, 8 bit
    dev16 = (((dev AND 255) * &H0202020202 AND &H010884422010) MOD 1023) << 8 ' reverse Dev bit order, low byte
    dev = dev16 + ((dev >> 8) * &H0202020202 AND &H010884422010) MOD 1023  'now reverse high byte & swap bytes
  EndIf
  word = (dev<<16) + (key<<8) + 255-key ':Print Bin$(word,32) 'assemble 32 bits '16 bit address only

  If V=5 Then
    dev = ((dev AND 255) * &H0202020202 AND &H010884422010) MOD 1023 ' reverse Key bit order, 8 bit
    key = ((Key AND 255) * &H0202020202 AND &H010884422010) MOD 1023 ' reverse Key bit order, 8 bit
    word = (key + (dev<<8))<<16
  EndIf

  BitBang bitstream IRpin, 620, d() 'send 9ms start 38kHz

EndIf

T = Timer' :Print t
For m = 42 To 1386 Step 42  'load data after start sequence, step 42 = 21 cycle IR pulse
 d(m) = (((word>>(32-n)) AND 1)*2 + 1) * 560  'convert bits to duration (short = 0, long = 1)
 Inc n ':Print d(m); 'step to next data bit
Next

Do : Loop Until Timer > T+4.3 ':Print Timer-T 'less than 4.5 due processing time, adjust for CPU speed

If V<>5 Then
  BitBang bitstream IRpin, 1386, d() 'send the data
 Else
  BitBang bitstream IRpin, 698, d() 'send V5 JVC data
  Pause 33
  BitBang bitstream IRpin, 698, d() 'repeat V5 JVC data
EndIf
Pin(IRpin) = 0
End Sub
End


Edit
Edited the code above to send the JVC 16 bits twice.
I think some JVC devices may require it.
Edited 2024-09-10 15:49 by phil99
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4222
Posted: 05:44am 10 Sep 2024
Copy link to clipboard 
Print this post

Hi Phil,

I think it is great what you are doing, but I do not have a real application for it, nor do I have compatible devices. My Philips TV is the only device I really use an RC with. The Sony DVD/Blueray player is never used anymore. Neither is the Harman Kardon radio since they removed all FM broacast from cable. And for 1 year (2026 is last year FM broadcast in the air in Netherlands) I am not putting up an antenna mast anymore.

Sorry, I can't use your RX and TX programs. But I do follow the series, if that is any comfort...

Volhout
PicomiteVGA PETSCII ROBOTS
 
phil99

Guru

Joined: 11/02/2018
Location: Australia
Posts: 2135
Posted: 05:57am 10 Sep 2024
Copy link to clipboard 
Print this post

Thanks, I plan to do the Philips protocol eventually but it is incompatible with any version the NEC Pulse-interval modulation. It uses bi-phase modulation and Manchester encoding.

Footnote added 2024-09-23 18:18 by phil99
Philips RC-5 protocol is now done.

Footnote added 2024-10-01 18:35 by phil99
Also RC-6 in the RC-5 thread.
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4222
Posted: 09:13am 10 Sep 2024
Copy link to clipboard 
Print this post

Hi Phil,

There is RC5 and RC6 code.

Volhout
PicomiteVGA PETSCII ROBOTS
 
Marcel27

Regular Member

Joined: 13/08/2024
Location: Netherlands
Posts: 53
Posted: 04:22pm 23 Sep 2024
Copy link to clipboard 
Print this post

I can appreciate this code. I repair amplifiers and not every amp has an original remote unit anymore.  If you want to setup these 5.1 or 7.1 devices you need a remote unit for the setup menu most of the time because certain menu options can't be accessed by front buttons. If I have an universal transmitter and when I know the codes I can access these menu's. A non-original remote cost me most of the times €19,95, therefore I welcome the effort of phil99.
If you use AI, you lose your mind.
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024