ir decode using pulsin help needed!!!


Results 1 to 6 of 6

Threaded View

  1. #2
    Join Date
    Dec 2006
    Location
    Brasil, Sao Paulo, Campinas
    Posts
    54


    Did you find this post helpful? Yes | No

    Smile Re: ir decode using pulsin help needed!!!

    Engineer7,

    You need to use a Sony control!
    I use Sony IR protocol with sucess, and my rotine decode all key, then you only need to test the value and to do something...
    Code:
    @ DEVICE pic16F628a, INTRC_OSC_NOCLKOUT ' System Clock Options 
    @ DEVICE pic16F628a, WDT_OFF  ' Watchdog Timer
    @ DEVICE pic16F628a, PWRT_OFF  ' Power-On Timer
    @ DEVICE pic16F628a, BOD_OFF  ' Brown-Out Detect
    @ DEVICE pic16F628a, MCLR_ON  ' Master Clear Options (External)
    @ DEVICE pic16F628a, LVP_OFF  ' Low-Voltage Programming
    @ DEVICE pic16F628a, CPD_OFF  ' Data Memory Code Protect
    @ DEVICE pic16F628a, PROTECT_OFF ' Program Code Protection
    DEFINE OSC 4
    'Definição das variáveis e declarações
    INCLUDE "bs1defs.bas"   'inclui arquivo p/ compatibilizar com BS1
    'p/entender as variáveis b0...b3, w0...w6 e bit0...bit13
    CMCON = 7               'DEFINE PORTA COMO DIGITAL (COMPARADORES ANALÓGICOS:OFF)
    symbol ir = PORTB.7 'entrada do sinal de IR
    SYMBOL  LED = PORTB.4
    SYMBOL  RELE = PORTB.0
    TRISB = %10000000       
    '------------------------------------------------------------------
    'rotina principal
    LOOP:
     pulsin ir,0,w0       'aguarda start bit
     if w0 < 200 then LOOP  'start bit é > 200
     pause 20           'pula primeiro envio
     pulsin ir,0,b0       'aguarda 2º start bit
     pulsin ir,0,b1
     pulsin ir,0,b2       'lê cada bit do código IR.
     pulsin ir,0,b3   
     pulsin ir,0,b4   
     pulsin ir,0,b5
     pulsin ir,0,b6
     pulsin ir,0,b7
     
     bit0=b1/96   'extrai LSB
     bit1=b2/96   
     bit2=b3/96   
     bit3=b4/96
     bit4=b5/96
     bit5=b6/96
     bit6=b7/96   'extrai MSB
     bit7=0
     
     if b0=21 then COMANDO
        GOTO LOOP
        
     COMANDO:
        B0 = 0
        RELE = 1 
        LED = 1
        PAUSE 500
        RELE = 0
        LED = 0
     GOTO LOOP   
     
    '----------------------------------------------------------------
       end
    Last edited by Archangel; - 24th May 2011 at 05:18. Reason: code tags

Members who have read this thread : 0

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