Shop OBEX P1 Docs P2 Docs Learn Events
Nec IR Transmitter — Parallax Forums

Nec IR Transmitter

LegonigelLegonigel Posts: 12
edited 2010-10-06 19:26 in Propeller 1
Hey,
Would it be possible to build a transmitter to send the hex value 43 for the data. I don't really seem to understand how to program the timing.

Thanks,
Nigel

Comments

  • bill190bill190 Posts: 769
    edited 2010-10-06 18:29
    Well I understand the sending part and following is a propeller program to send multiple Sony volume down's via an IR LED. That is all it does is send the volume down command.

    As to the receiving part, I've not worked on that, but I would expect someone will come along and discuss that. Also there is an IR Kit on the Propeller Object exchange and I think that has a receiving program?
    http://obex.parallax.com/objects/category/9/?n=100

    Here is my Sony volume down transmitting code as an example...
    'SendSonyVolumeDown.spin Sends volume down IR signal to Sony receiver
    'manufactured in 2007. Uses 38 kHz carrier.
    'IR LED on pins 21(-) and 22(+).
    'Red indicator LED on pin 0.
    CON
     
      _clkmode = xtal1 + pll16x      'System clock settings
      _xinfreq = 5_000_000           'External 5 MHz crystal
    VAR
      long StackSpaceSendBits[6]     'Stack space for SendBits cog
      byte Cog                       'To store cog number of SonyBits cog 
    PUB SonyReceiverVolumeDown
      'Start new cog SonyBits - lower volume
      Cog := (cognew (@SonyBits, @StackSpaceSendBits)) 
      dira[0] := 1                    'Turn on red LED (Sending signal)
      outa[0] := 1                    'Turn on red LED
      waitcnt(200_000_000 + cnt)      'Wait - Amount of time to send volume down
      cogstop(Cog)                    'Turn off SonyBits (Stops sending volume down)
      dira[0] := 0                    'Turn off red LED
      outa[0] := 0                    'Turn off red LED
    repeat
     
      dira[1] := 1                    'Flash green LED (No longer sending signal)
      outa[1] := 1
      waitcnt(cnt + 10_000_000)
      dira[1] := 0
      outa[1] := 0
      waitcnt(cnt + 100_000_000)
     
    DAT
    ORG 0         'Begin at Cog RAM addr 0
    SonyBits      or dira, Pin               'Set IR LED - pin to output
                  or outa, Pin               'Set IR LED - pin high to turn off
                  'Turn on 38 kHz carrier frequency
                  or dira, PinFreq            'IR LED high pin set to output 
                  mov ctra, CtraNCOp22        'Set ctra for NCO single-ended output to Pin 22"
                  mov frqa, CarrierFrequency  'Set frequency to 38 kHz
                  'Send start bit
    :loop1        mov Delay, Start_Bit_Mark_On 'Copy timing to Delay 
                  xor outa, Pin                'IR LED on 
    :loop2        sub Delay, #1                'Subtract 1 from Delay
                  djnz Delay,#:loop2           'When Delay = 0, goto next line
                  xor outa, Pin                'IR LED off
                  mov Delay, Space_Off         'Copy timing to Delay
    :loop3        sub Delay, #1                'Subtract 1 from Delay
                  djnz Delay,#:loop3           'When Delay = 0, goto next line
                  'Send Volume Down 19 (1100100) LSB first
                  call #OneBit
                  call #OneBit
                  call #ZeroBit
                  call #ZeroBit
                  call #OneBit
                  call #ZeroBit
                  call #ZeroBit
                  'Send audio device 16 (00001) LSB first
                  call #ZeroBit
                  call #ZeroBit
                  call #ZeroBit
                  call #ZeroBit
                  call #OneBit
                  'Send two additional bits (10) unknown
                  call #OneBit
                  call #ZeroBit
                  'Send stop bit
                  mov Delay, Zero_Bit_Mark_On
                  xor outa, Pin                   'IR LED on 
    :loop4        sub Delay, #1
                  djnz Delay,#:loop4
                  xor outa, Pin                   'IR LED off
                  mov Delay, Stop_Bit_Space_Off
    :loop5        sub Delay, #1
                  djnz Delay,#:loop5
                  jmp #:loop1
     
                  'Send one bit subroutine
    OneBit        mov Delay, One_Bit_Mark_On
                  xor outa, Pin                   'IR LED on 
    :loop6        sub Delay, #1
                  djnz Delay,#:loop6
                  xor outa, Pin                   'IR LED off
                  mov Delay, Space_Off
    :loop7        sub Delay, #1
                  djnz Delay,#:loop7
    OneBit_Ret    ret
                  'Send zero bit subroutine
    ZeroBit       mov Delay, Zero_Bit_Mark_On
                  xor outa, Pin                   'IR LED on 
    :loop8        sub Delay, #1
                  djnz Delay,#:loop8
                  xor outa, Pin                   'IR LED off
                  mov Delay, Space_Off
    :loop9        sub Delay, #1
                  djnz Delay,#:loop9
    ZeroBit_Ret   ret
     
    PinFreq            long  |< 22          '+ Frequency Pin number
    Pin                long  |< 21          '- Pin number
    CtraNCOp22         long  %00010000_00000000__00000000_00010110 '%00100 and pin 22
    CarrierFrequency   long 2039184   'A little under 38kHz 
    Start_Bit_Mark_On  long 24000*2   '2.4 ms milliseconds 2,400 µs microseconds
    One_Bit_Mark_On    long 12000*2   '1.2 ms milliseconds 1,200 µs microseconds
    Zero_Bit_Mark_On   long 6000*2    '0.6 ms milliseconds 600 µs microseconds
    Space_Off          long 6000*2    '0.6 ms milliseconds 600 µs microseconds
    Stop_Bit_Space_Off long 213750*2
    Delay res 1
     
    
  • LegonigelLegonigel Posts: 12
    edited 2010-10-06 18:50
    Sony does not use the NEC style code, and I can't figure out how to make the IR kit to transmit the hex value 43.

    ~Nigel~
  • bill190bill190 Posts: 769
    edited 2010-10-06 19:04
    Here are a couple of "pictures" of what is going on with an IR transmission. The first of following is for a Technics volume down on another processor. That has a start bit, then 48 bits, then a stop bit.

    Anyway 2 signals are shown. 38 kHz is RC2 and the bits are RC1. The same amount of time on/off (up/down) on RC1 is a zero bit. But a longer off period is a one bit. Sony is opposite and a longer on time is a one bit.

    The second picture shows a closeup of a zero and one bit. With this you can see the 38 kHz below.

    Anyway that is what the program above is doing. Sending 38 kHz out one pin and turning another pin on/off to send the bits.
    572 x 263 - 42K
    572 x 262 - 46K
  • bill190bill190 Posts: 769
    edited 2010-10-06 19:26
    Legonigel wrote: »
    Sony does not use the NEC style code, and I can't figure out how to make the IR kit to transmit the hex value 43.

    As for a specific protocol, following is a LIRC database and there is an NEC folder there. These give the "specifications" of each IR signal for each manufacturer. Here is that link...
    http://lirc.sourceforge.net/remotes/

    Then here is all about LIRC...
    http://www.lirc.org

    Here it explains what the various settings in each LIRC specification are for...
    http://winlirc.sourceforge.net/technicaldetails.html

    As for sending Hex 43, the calculator in the programs/accessories which are on Microsoft OS computers has a View/Scientific mode. And this has binary, hex, decimal, etc.

    So easy to convert that Hex 43!

    That would be 1000011 in binary.

    So that is what you would send. Some IR protocols send the least significant bit first. Others the most significant bit first.

    So MSB would be sent as it is... 1000011
    LSB would be sent backwards... 1100001

    This is difficult stuff to work on! The problem is being able to "see" what is going on.

    I use a Basic Stamp to measure the 38 kHz frequency. It helps to be sure you have that working OK.

    Then I use IR capture on the Propeller to see the "bits". Following is the output of IR capture for the above pictures! Notice the larger numbers on some of the following? Those are 1 bits as shown in the pictures above for the Technics...

    1,100
    2,3455,1640
    2,362,535
    2,359,1356
    2,362,513
    2,352,540
    2,362,513
    2,352,540
    2,362,513
    2,352,540
    2,362,513
    2,352,540
    2,362,513
    2,434,458
    2,362,513
    2,416,1320
    2,362,511
    2,432,462
    2,362,512
    2,457,437
    2,362,511
    2,430,463
    2,362,510
    2,360,1379
    2,361,510
    2,362,1359
    2,352,539
    2,362,514
    2,352,539
    2,362,513
    2,352,539
    2,362,513
    2,353,539
    2,362,513
    2,406,1331
    2,362,512
    2,460,433
    2,362,512
    2,459,434
    2,362,1355
    2,360,534
    2,362,510
    2,361,1359
    2,377,514
    2,362,514
    2,352,538
    2,362,514
    2,352,539
    2,362,514
    2,352,1383
    2,362,1093780
    3
Sign In or Register to comment.