Sony IR Remote


Closed Thread
Results 1 to 40 of 41

Thread: Sony IR Remote

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Thank You for repply ! Since I have on my car Radio-SD card Blaupunkt and I have the sensor (TSOP 34838) too, I intend to try to build one remote (using 12F675 ?!) ; Your code it's a good point to start !
    Attached Images Attached Images  

  2. #2
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Hope don't disturb if I continue here with "code" for RC10 remote...If necessary please move in separate topic. Thanks.
    It's my (pseudo)code...Any advice it's wellcome !
    Code:
    ' First variant for RC 10 Blaupunkt remote 
    
    ;           PIC12F675:                    +--U--+                                         
    ;                                    +5V  [     ]  GND                                    
    ;                         key 5 |---/--- >[     ]< ---/---| key 1     
    ;                         key 4 |---/--- >[     ]< ---/---| key 2                   
    ;       pull-up!          key 3 |---/--- >[     ]>--[4K7]-- NPN Transistor, IR LED  
    
    @ DEVICE PIC12F675, intrc_osc_noclkout, wdt_off, pwrt_on, mclr_off, bod_off
    
    DEFINE OSC  4
    CMCON=7
    OPTION_REG  = %00000111
    TRISIO  = %00111110
    WPU=%00110111
    ANSEL=0
    
    but1 var gpio.1
    but2 var gpio.2
    but3 var gpio.3
    but4 var gpio.4
    but5 var gpio.5
    LED  var gpio.0
    
    GIE  var intcon.7 ' global interrupt enable 1=on ; 0=off
    gpie var intcon.3 'port change interrupt enable 1=0n ; 0=off
    gpif var intcon.0 'port change interrupt flag bit
    
    GIE=0
    GPIE=1
    
    IOC.1=1   ' int-on-change for GPIO.1 enabled
    IOC.2=1   ' int-on-change for GPIO.2 enabled
    IOC.3=1   ' int-on-change for GPIO.3 enabled
    IOC.4=1   ' int-on-change for GPIO.4 enabled
    IOC.5=1   ' int-on-change for GPIO.5 enabled
    
    LED=1
    delay var word
    i var byte
    
    
    main:
     @ sleep
     pause 100
    
    if but1=1 then  vol_up
    if but2=1 then  vol_down
    if but3=1 then  btn_up
    if but4=1 then  btn_down
    if but5=1 then  mute 
    
    vol_up:
        delay = 2600
        gosub ir_out
    
    
    vol_down:
        delay = 3200
        gosub ir_out
    
    
    btn_up:
        delay = 3800
        gosub ir_out
    
    
    btn_down:
        delay = 4400
        gosub ir_out
    
    
    mute:
        delay = 5000
        gosub ir_out
    
    
    GPIF=0  'Clear port change interrupt flag
    Goto Main
    
    
    ir_out:
        for i = 1 to 10 'sends out command 10 times
            led=0
            pauseus delay
            led=1
            pauseus delay
            led=0
            pauseus 660
            led=1
            pause 10    'wait 10ms before repeating
        next i
    return
    
    END         ' of program

  3. #3
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default I think I made some mistakes...

    ...because with the code posted up, ISIS show me this results for "vol_up" like in picture attached ; it's something wrong ?! Thanks for your attention & cooperation !
    Attached Images Attached Images  

  4. #4
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default ...me again...

    ...with some modification ; the results are now OK (in simulation, hope in real-world too !).
    Code:
    TRISIO  = %00111110
    ANSEL=0
    OPTION_REG.7=0
    IOCB=%00111110
    ...and (of course !) ...
    Code:
    if but1=0 then  vol_up
    if but2=0 then  vol_down
    if but3=0 then  btn_up
    if but4=0 then  btn_down
    if but5=0 then  mute
    ...and at last...
    Code:
    vol_up:
        delay = 970 '(970 us low + 970 us high + 660 us low = 2600 us pulse total time)
        gosub ir_out
    The results are like in picture; hope testing "in vivo" tomorrow...
    Attached Images Attached Images  

  5. #5
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    You should modulate your signal on a carrier of about 38 kHz. You can generate this with assembly or use a pic12f683 and use the internal pwm generator. Then you can modulate this signal by switching the trisio pin.

    I once did it this way:
    It sends a Sony DVD play command every five seconds (as an example)

    Code:
    @ device  pic12F683, intrc_osc_noclkout, wdt_off, pwrt_on, mclr_off, protect_off, bod_off
    
    INCLUDE "MODEDEFS.BAS" 
    DEFINE PULSIN_MAX 5000 
    
    GPIO      =       %00100000
    TRISIO    =       %00001100
    CCP1CON   =       %00001100  ' Mode select = PWM
    T2CON     =       %00000100  ' Timer2 ON + 1:1 prescale (last two bits)
    CCPR1L	  =       %00001101  ' pwm duty 50%
    PR2       =       %00011001  ' Set PWM frequency to +/- 40kHz, set to 26 for 38kHz or 28 for 36kHz
    ANSEL     =       %00000000
    CMCON0    =       %00000111
    
    led       var     GPIO.5
    counter   VAR     BYTE 
    counter2  VAR     BYTE
    command   VAR     WORD		                            'IR command to send
    temp      VAR     WORD
    bitcount  VAR     WORD
    bitselector var   word
    
    rewind    CON     $79A	                                'sony DVD codes for testing
    play      CON     $59A 
    postdata  con     $36   
    
    clear
    
    loop:   
       command =  play
       gosub sendIR 
       pause 5000  
    goto loop
    
    sendIR:								' send IR code					
        for counter = 1 to 5            ' five times
            TRISIO.2 = 0					
            PauseUs 2450	            ' Lead_in pulse
        	TRISIO.2 = 1	
        	pauseus 450                 ' (space)
            bitcount = 11               ' send first 11 bits
            temp = command
            GoSub transmit
            bitcount = 8                ' send remaining 8 bits
            temp = postdata
            GoSub transmit
            TRISIO.2 = 0					
            PauseUs 650	                ' ptrail (pulse)
            TRISIO.2 = 1				
            Pauseus 13080
        next counter
        Return
    
    transmit:	
    	bitselector = 1 << (bitcount - 1)
            For counter2 = 1 TO bitcount	        'number of bits
    		TRISIO.2 = 0				'make output (pin active, led on)
    		PauseUs 540			        'first part of bit, pulse
                    IF (temp & bitselector) = 0 Then 'if bit is 0		
    			PauseUs 580			'send second part of bit ,pulse
    		EndIF
    		TRISIO.2 = 1				'make input (pin inactive, led off)
    		PauseUs 560                              'space (no pulse)
                    temp = temp << 1			'shift one bit
    	Next counter2	
    	Return

  6. #6
    Join Date
    Feb 2010
    Location
    Albuquerque
    Posts
    19


    Did you find this post helpful? Yes | No

    Smile Got it working

    I finally got the code working but it is very ineffecient. I am only 17 and I came up with the code with only a little help so give me some credit. Its not the best but if any of you have other ways to compress the code and make it more effecient please reply. Thanks

    Code:
    DEFINE OSC 4
    ANSEL = %00000000
    
    IR_PULSE    var word(11)
    SIGNAL      var word
    START_PULSE var word
    INDEX       var byte
    X           var byte
    
    Main:
    
        Pulsin PORTC.3, 0, start_pulse
        if (start_pulse < 220) or (start_pulse > 260) then main
    
        
        for index = 0 to 11
            pulsin PORTC.3, 0, ir_pulse(index)
        next index
        
    Convert:
    
    x = 1
    signal = 0
        
        for index = 0 to 11
            if (ir_pulse(index) > 90) then ADD_X
            READ_IR:
            x = x * 2
        next index
        
        serout PORTC.2, 2, [#signal, 9]
        
        clear      
                 
    goto main
    
    ADD_X:
        signal = signal + x
        goto read_ir
    
    
        end

  7. #7
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by eggman View Post
    You should modulate your signal on a carrier of about 38 kHz. You can generate this with assembly or use a pic12f683 and use the internal pwm generator. Then you can modulate this signal by switching the trisio pin.
    I intend to build remote using 12F675 (I have a lot...and none of 12F683). How generating a carrier of 39 kHz with assembly ? I found something about 40 kHz pulse on Mr.Bruce site, but...
    Please, one clue ?!
    ?!?
    Pulse: '// Emits # of 39kHz bursts held in variable Cycles
    ASM ;// with auto delay between bursts
    bsf gpio, 0 ;// 1uS, LED=on [need 25uS total ???????
    goto $+1 ;// 3uS (2uS per goto $+1)
    goto $+1 ;// 5uS
    goto $+1 ;// 7uS
    goto $+1 ;// 9uS
    goto $+1 ;// 11uS
    ' goto $+1 ;// 13uS 'comment this for 39 kHz ???
    bcf gpio, 0 ;// 14uS, LED=off
    goto $+1 ;// 16uS
    goto $+1 ;// 18uS
    goto $+1 ;// 20uS
    goto $+1 ;// 22uS
    decfsz _Cycles,F ;// 23uS
    goto _Pulse ;// 25us
    ENDASM
    PAUSEUS 500 '// 500uS delay between each data bit
    RETURN '// Return to Main

    ...and next ?
    Last edited by fratello; - 15th May 2010 at 18:55.

  8. #8
    Join Date
    Dec 2008
    Location
    Ploiesti, ROMANIA
    Posts
    582


    Did you find this post helpful? Yes | No

    Unhappy ?!?

    I try to simulate this remote using 12F683 (because of PWM) :
    Code:
    @ device  pic12F683, intrc_osc_noclkout, wdt_off, pwrt_on, mclr_off, protect_off, bod_off
    
    INCLUDE "MODEDEFS.BAS" 
    
    
    GPIO      =       %00000010
    TRISIO    =       %00000010
    CCP1CON   =       %00001100  ' Mode select = PWM
    T2CON     =       %00000100  ' Timer2 ON + 1:1 prescale (last two bits)
    CCPR1L    =       %00001101  ' pwm duty 50%
    PR2       =       %00011001  ' Set PWM frequency to +/- 40kHz, set to 26 for 38kHz or 28 for 36kHz
    ANSEL     =       %00000000
    CMCON0    =       %00000111
    
    led   var GPIO.5
    but1 	var GPIO.1
    
    LED=0
    
    delay		var word
    i 		var byte
    timeX       var byte
    '=========================================
    main:
     pause 100
    
    if but1=0 then  vol_up
    vol_up:
        delay = 970 '(970 us low + 970 us high + 660 us low = 2600 us pulse total time)
    	while but1=0
    		gosub ir_out
    		gosub debounce
    	wend
    PAUSE 50
    
    Goto Main
    '=========================================
    ir_out:
            led=1
            pauseus delay
    
            led=0
            pauseus delay
    
            led=1
            pauseus 660
    
            led=0
            pause 10    'wait 10ms before repeating
    return
    '=========================================
    Debounce :
    For timeX= 1 to 50
    Pause 5
    next timeX
    Return
    '=========================================
    
    END         ' of program
    But the results are similarly ; I really don't understand what I do wrong ...
    Attached Images Attached Images  

  9. #9
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    Instead of led = 1 or led = 0 use this: TRISIO.2 = 0 or TRISIO.2 = 1
    You have to connect your IR led to GPIO.2, not GPIO.5
    Toggling TRISIO.2 will modulate your IR led

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts