irout to control dvd player not possible?

go10000

New Member
I've been trying to use the infraout command to control a dvd player. I have successfully used this command to control VCRs but have not been able to do the same with DVDs.

Following some internet research I understand that Sony DVDs use a 20 bit protocol and so cannot be controlled using infraout which can only relay the 12 bit protocol.
p82 of the picaxe manual http://www.rev-ed.co.uk/docs/picaxe_manual2.pdf states that the device code for a dvd is 26 but I believe this has to be accompanied by a sub device code (hence 20 bit rather than 12).

Hopefully I am wrong and hopefully there are in fact a number of Sony DVDs which can be operated by the PIC (I assume somebody did successfully control a dvd player before the manual was written?). If this is so could someone please tell me the specific model numbers which were controlled.
 

hippy

Technical Support
Staff member
If the Sony 20-bit IR Codes are sent using a similar protocol as the 12-bit codes with the same sort of slow timing it should be possible to bit-bang those codes out, and no extra hardware ( beyond an IR LED plus R ) for a PICAXE which has PWMOUT command suppport.

Point us to a Sony IR protocol specification for 20-bit codes and you'll get your answer as to whether it's possble or not.

The use of device code 26 to control Sony DVD's is what Sony specified for controlling DVD's at the time and INFRAOUT will/should control those DVD's which use 12-bit codes, but won't work with those DVD's which need 15 or 20 bit codes.
 

go10000

New Member
If the Sony 20-bit IR Codes are sent using a similar protocol as the 12-bit codes with the same sort of slow timing it should be possible to bit-bang those codes out, and no extra hardware ( beyond an IR LED plus R ) for a PICAXE which has PWMOUT command suppport.

Point us to a Sony IR protocol specification for 20-bit codes and you'll get your answer as to whether it's possble or not.

The use of device code 26 to control Sony DVD's is what Sony specified for controlling DVD's at the time and INFRAOUT will/should control those DVD's which use 12-bit codes, but won't work with those DVD's which need 15 or 20 bit codes.
This is the site I referred to when looking for device codes
http://www.hifi-remote.com/sony/Sony_dvd.htm
Apparently 26 is the correct device code but you the way I understand it is: you always have to use a sub device code in addition to this device code.
 

crazymatt

New Member
Hi go1000 , for my recent Alevel project i needed to control a SONY Hard-Drive Recorder the SVR-S500. I found out that it was also a 20bit SIRC code. There is practically no information anywhere on the protocol so i had to work the whole thing out by experimenting with a pc oscilloscope. I did in the end manage to control the video recorder but it took many hours so heres what i did.



(I filtered out the pulses that were being modulated, so this just shows the structure.)

This is one of the signal traces i took from the video recorder. The timings for the start bit, logical 1 and logical 0 are the same as SIRC 12 and SIRC15. The device ID section is 12 bits rather than 4 bits. That is the only diffrence.(I also mapped every single function code of the remote)

So now knowing exactly the structure the difficulty was actually replicating the code so that it could control any function. I tried using the picaxe and PWM to bit bash a code but the picaxe is not fast enough even when overclocked to 20mhz (28x1) to be accurate enough. (to be with in the 10% tolerance sony IR recievers accept).

My final solution was to learn a basic ammount of machine code. I programmed a standard pic to act as a binary to SIRC 20 encoder. taking a set of 8 inputs (binary) from a picaxe and converting it into the SIRC 20 signal timing. This method is extremely reliable and worked every time. I used direct connection to the IR receiver so i just had to invert the signal and i didnt need to modulate the 38Khz. But i imagine u could use the output of my binary to SIRC 20 encoder to modulate a frequency generator and an IR LED :)

You might find an easier way but i hope this helps. I have lots more infomation and the program from my SIRC 20bit encoder PIC.
Hope this Helps
 

go10000

New Member
That's really useful, do you think you could send me some more information.

If anybody has managed to do this with the PICAXE I would appreciate any info.
 

crazymatt

New Member
Right well i had a PICAXE receiving a serial signal from a XBEE. Once i had a decimal value in serial like 21 which in my case was the on/off command. I used let pins = b0 where b0 was the value of 21. Causing the outputs to 0 to 7 to go high or low to give the value of 21 in binary. This is then converted directly to the signal in the pic. See source code attached. This is a chart of the functions of the remote and each binary code it might help:



The main things u need to know are yr Device ID which is unique for your model. And Device Commands which are Unique to your model remote. If you have an osciloscope to hand connect it up to a IR receiver and u can work it out from my previous post's diagram.

This is a photo of the breadboard of the whole section:



PIC to the left and Picaxe to the right, the oscilator is 4MHZ and the 100K pull down is needed on pin 6. Orange wire is the output signal.

Anything else? Oh and also the PIC programming is probably horrendous but i had to teach myself in an hour and it works reliably.
 

Attachments

go10000

New Member
Hmmmm I don't seem to be able to access the attached file. I am logged in but I keep getting the message:
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
You are not logged in. Fill in the form at the bottom of this page and try again.
You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Any suggestions?
 

hippy

Technical Support
Staff member
@ crazymatt : Thanks for the details of the 20-bit code and its timing. It's also interesting to see you used the Programming Editor PICAXE to Assembler conversion utility to get your PICmicro code; I think this might be the first published program created that way. Good to see it worked out for you.

With the fairly slow speeds of the 20-bit code it is possible to bit-bang this in software so, instead of using INFRAOUT, the command and data is placed in variables and a GOSUB to the bit-banging routine would be used.

For a PICAXE which supports PWMOUT the IR LED + R can have one end connected to the PWM output and the other to an I/O line which can then turn the modulated IR signal on and off at the appropriate times. With the right choice of I/O pins it should be possible to support both INFRAOUT 12-bit code and bit-banged 20-bit code sending with no additional hardware required.

I'm not sure why it wasn't possible to get the timing right with just a PICAXE because it should be possible but does involve some trickery ( using PULSOUT on a dummy pin to get accurate timing ). There has been previous discussion on bit-banging Sony IR codes and I'll also look to see if I can find any appropriate PICAXE code.

@ go10000 : Which PICAXE are you hoping to use and do you have access to an oscilloscope ? I'm not sure why you cannot access the attachment so cannot help there.
 

hippy

Technical Support
Staff member
Untested and needs timing tweaking but here's how I'd go about it ....

Code:
' *****************************************************************************
' *                                                                           *
' *     Sony 20-Bit IR Control Code transmission                SIRC20.BAS    *
' *                                                                           *
' *****************************************************************************
'
'       This code is untested. It will need to be changed to work.
'       The START_OFF, BIT0_OFF and BIT1_OFF values will need reducing.
'       Additional time tweaking may be necessary.
'       Assumes sends lsb first for id and command.
'       Hardware supports INFRAOUT and bit-banging ( 08M/14M )
'       Can be used with any PICAXE which supports PWMOUT
'       Do not move SendStartPulse etc routines from the beginning of program
'
'       08M/14M : 86 bytes of 256 used
'
' *****************************************************************************
'
'       PICAXE-08M/14M
'        .----------.    220R
'        |          |    ____
'        |       O0 |---|____|---.
'        |          |           _|_
'        |       O1 |- N/C     _\./_  IR LED
'        |          |            |
'        |       O2 |------------'
'        |          |
'        `----------'

Symbol IR_PIN    = 0            ' IR Control - Pin 0 also used by INFRAOUT
Symbol XX_PIN    = 1            ' Dummy pin used for timing
Symbol PWM_PIN   = 2            ' PWM output

Symbol START_ON  = 480          ' 2400us                ( 2400 * 2 / 10 )
Symbol START_OFF = 120          '  600us                (  600 * 2 / 10 )

Symbol BIT1_ON   = 240          ' 1200us                ( 1200 * 2 / 10 )
Symbol BIT1_OFF  = 120          '  600us                (  600 * 2 / 10 )

Symbol BIT0_ON   = 120          '  600us                (  600 * 2 / 10 )
Symbol BIT0_OFF  = 120          '  600us                (  600 * 2 / 10 )

Symbol reserved  = w0 ' b1:b0   ' Used for bit-banging
Symbol id        = w1 ' b3:b2   ' Device ID             ( 8-bit,  0..255  )
Symbol cmd       = b4           ' Command code          ( 12-Bit, 0..4095 )
Symbol bitNumber = b5           ' Bit counter

' *****************************************************************************

Goto StartProgram:

SendStartPulse:
  PulsOut IR_PIN, START_ON
  PulsOut XX_PIN, START_OFF
  Return

SendBitPulse:
  If bit0 = 1 Then SendBit1Pulse

SendBit0Pulse:
  PulsOut IR_PIN, BIT0_ON
  PulsOut XX_PIN, BIT0_OFF
  Return

SendBit1Pulse:
  PulsOut IR_PIN, BIT1_ON
  PulsOut XX_PIN, BIT1_OFF
  Return

StartProgram:
  SetFreq M8                    ' Run as fast as possible, 8MHz
  PwmOut PWM_PIN, 52, 105       ' 38kHz, 50:50, signal at 8MHz

  Do
    id  = %101010101010
    cmd = %10101
    Gosub SendCommand
    Pause 50
  Loop

SendCommand:
  w0 = cmd
  Gosub SendStartPulse
  For bitNumber = 0 To 7
    Gosub SendBitPulse
    w0 = w0 / 2
  Next
  w0 = id
  For bitNumber = 0 To 11
    Gosub SendBitPulse
    w0 = w0 / 2
  Next
  Return
If timing were not achievable it would be necessary to unroll the send loop, put timing values in SFR, then bit-bang in sequence with something like ...

Code:
  Peek Word $50,w0 : PulsOut IR_PIN,w0 : PulsOut XX_PIN, w1
  Peek Word $52,w0 : PulsOut IR_PIN,w0 : PulsOut XX_PIN, w1
  :
 
Last edited:

crazymatt

New Member
Ahhhhhh! using pulsout on a dummy pin, that was like the only thing i didnt try! i was using pause which i know is very basic, but the the pause varied massivly and when at 20mhz pause 1 didnt multiply out well. Yeah i used the automatic conversion but there was quite alot it didnt do/work so bits of it i had to change. Anyway glad my experimenting helped.
 
Last edited:

Texy

Senior Member
Hmmmm I don't seem to be able to access the attached file. I am logged in but I keep getting the message:
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
You are not logged in. Fill in the form at the bottom of this page and try again.
You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Any suggestions?
Sound like you haven't actually activated your account. Are you sure you received the email and clicked on the activation link?
note that you can still log in and post without clicking the activation link!
Texy
 

go10000

New Member
Unfortunately I don't have access to an oscilloscope though if necessary I could look into it. I was intending to use the picaxe 08M, this is the one I used to control the video player and I know it supports pwmout (though I've not so far used this command), but I would be happy to use any picaxe.
Managed to download file ok now... looks a bit beyond me though.
 

hippy

Technical Support
Staff member
It can be hard getting timing right without an oscilloscope but I wouldn't suggest buying one just for this one project unless extremely cheap. One alternative would be to run the PWM slower and view the signal with a PC sound card oscilloscope ( needs a simple interface, don't put 5V into the sound card ! ), may not even require the modulation but it probably helps. You might have to add some extra hardware to get the LED signal into something useful for a sound card; an opto isolator would be a good bet for taking the combined PWM and LED control signal into giving a single 0V/+V signal, and the output from a suitable IR reciever will show what's being sent out.

Another PICAXE and PULSIN can be used to measure the length of pulses quite accurately.

Without any appropriate tools I'd go for building up a list of how long each pulse should be then use 21 sequential PULSOUT's. The code will take up more space but it should be easier to guesstimate the time for each PULSOUT value then use a 'try it and see' approach. Once you have something working at least some of the time, sending a repeated command you can wind pulse times up and down until it stops working at each extreme. Whatever the middle value is should be close to the optimal value. It's a lot more work than simply looking at it on a scope.

If you can borrow one from a school or college or convince one to let you tune your program there or find a friend who has a scope that's you're best bet.

Alternatively, try and convince someone like crazymatt who has the experience, the tools, an interest in this, and a DVD player to test the results with to work with you on the project.
 
Last edited:

hippy

Technical Support
Staff member
This is the most optimised code I can create. The command and id are sent lsb first which may be wrong, the BIT_OFF time will likely need adjusting.

Code:
' *****************************************************************************
' *                                                                           *
' *     Sony 20-Bit IR Control Code transmission                SIRC20.BAS    *
' *                                                                           *
' *****************************************************************************
'
'       This code is untested. It may need to be changed to work.
'       The START_ON, BIT0_ON and BIT1_ON times should not need changing.
'       The BIT_OFF value may need changing up or down.
'       Assumes id and command are sent lsb first.
'       Hardware supports INFRAOUT and bit-banging ( 08M/14M )
'       Can be used with any PICAXE which supports PWMOUT
'
'       08M/14M : 206 bytes of 256 used
'
' *****************************************************************************
'
'       PICAXE-08M/14M
'        .----------.    220R
'        |          |    ____
'        |       O0 |---|____|---.
'        |          |           _|_
'        |       O1 |- N/C     _\./_  IR LED
'        |          |            |
'        |       O2 |------------'
'        |          |
'        `----------'

Symbol IR_PIN    = 0            ' IR Control - Pin 0 also used by INFRAOUT
Symbol XX_PIN    = 1            ' Dummy pin used for timing
Symbol PWM_PIN   = 2            ' PWM output

Symbol START_ON  = 480          ' 2400us start pulse
Symbol BIT1_ON   = 240          ' 1200us bit 1 pulse
Symbol BIT0_ON   = 120          '  600us bit 0 pulse

Symbol BIT_OFF   = 80           '  600us off period

Symbol cmd       = w0 ' b1:b0   ' Command code          ( 8-bit,  0..255  )
Symbol id        = w1 ' b3:b2   ' Device ID             ( 12-Bit, 0..4095 )
Symbol pokePtr   = b4           ' Ptr to poke into SFR

' *****************************************************************************

StartProgram:
  SetFreq M8                    ' Run as fast as possible, 8MHz
  PwmOut PWM_PIN, 52, 105       ' 38kHz, 50:50, signal at 8MHz

  Do
    id  = %101010101010
    cmd = %10101
    Gosub SendCommand
    Pause 50
  Loop

SendCommand:
  
  For PokePtr = $50 To $63
    If bit0 = 0 Then
      Poke pokePtr, BIT0_ON
    Else
      Poke pokePtr, BIT1_ON
    End If
    cmd = cmd / 2
    If pokePtr = $58 Then
      cmd = id
    End If
  Next
  
  PulsOut IR_PIN,START_ON         : PulsOut XX_PIN,BIT_OFF ' S
  
  Peek $50,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 1
  Peek $51,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 2
  Peek $52,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 3
  Peek $53,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 4
  Peek $54,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 5
  Peek $55,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 6
  Peek $56,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 7
  Peek $57,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 8
  
  Peek $58,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 1
  Peek $59,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 2
  Peek $5A,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 3
  Peek $5B,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 4
  Peek $5C,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 5
  Peek $5D,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 6
  Peek $5E,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 7
  Peek $5F,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 8
  Peek $60,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 9
  Peek $61,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 10
  Peek $62,b0 : PulsOut IR_PIN,b0 : PulsOut XX_PIN,BIT_OFF ' 11
  Peek $63,b0 : PulsOut IR_PIN,b0                          ' 12
  
  Return
 
Last edited:

inglewoodpete

Senior Member
A soundcard oscilloscope is all that is needed to debug Infrared signals. I use a 4-decade (external) opamp/attenuator front-end on my soundcard setup, which is overkill for logic work. For 5v and 12v logic work like this, you only need a simple 10:1 attenuator.

Use a 43k and 4k7 voltage divider pair for each channel.
 
Top