ir decode using pulsin help needed!!!


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2011
    Posts
    30

    Default ir decode using pulsin help needed!!!

    here is my code:
    Code:
    '****************************************************************
    '*  Name    : UNTITLED.BAS                                      *
    '*  Author  : [select VIEW...EDITOR OPTIONS]                    *
    '*  Notice  : Copyright (c) 2011 [select VIEW...EDITOR OPTIONS] *
    '*          : All Rights Reserved                               *
    '*  Date    : 5/23/2011                                         *
    '*  Version : 1.0                                               *
    '*  Notes   :                                                   *
    '*          :                                                   *
    '****************************************************************
    Define OSC 20 
    Header var word
    Body var word
    i var byte
    tmp var Byte
    irButton var byte
    irDevice var byte 
    irIN var PortA.2 
    SonyLED var PortB.2 
    
    TrisA = %00000100 
    TrisB = 0 
    Start:
    LOW SONYLED 
    IRBUTTON=255: IRDEVICE=255
    
    Pulsin irin,0,header 
    if header > 1000 or header < 1350 then goto Start
     
    for i =0 to 11
    pulsin irin,0,tmp 
    if tmp >= 480 then
    Body.0[i]=1 'Sony Logic 1 is 120
    else
    Body.0[i]=0 ' Sony Logic 0 is 60
    endif
    next
    IRBUTTON = Body & %01111111 'Mask 7 bit 
    IRDEVICE = (Body >>7) & %00011111 'Mask 5 bit 
    If IRDEVICE=255 then goto start
     
    if IRBUTTON >=0 and IRBUTTON < 255 then
    high Sonyled
    pause 300
    low Sonyled
    endif
    pause 100
    goto start
    i am using pic16f877a n i am definitely using picbasic pro now.
    but the pin portb.2 never gets high on pushing any button of my sony remote.can anyone plz plz help me out with this.i really need to make it work plz!
    Last edited by Archangel; - 24th May 2011 at 05:17.

  2. #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

  3. #3
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

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

    I can not help much on th decoding but there is a problem with your setup. PORT.A is analog so you will need to turn the ADC off.
    http://www.picbasic.co.uk/forum/showthread.php?t=561
    Dave
    Always wear safety glasses while programming.

  4. #4
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

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

    sir i have gone through the link which you have given. but i cant seem to find the command for which to turn the ADC off. plz help in this regard.im using picbasic pro.
    n secondly
    if i take my sensor output to some other port lets portb.2 then i m guessing that there wont be any problem of ADC etc.?????

  5. #5
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,802


    Did you find this post helpful? Yes | No

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

    If I remeber right, your PIC has comparators and ADC. So, read for me the DS and find the appropriate registers to setup.

    Alternatively use the include file from Darrel and get over with.

    http://www.picbasic.co.uk/forum/show...ht=all_digital

    Ioannis

  6. #6
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

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

    ok thanks a lot

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