problem with ir code.using pulsin


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

    Default problem with ir code.using pulsin

    TRISA= %00000100





    Set_Defaults PROTON_4
    Device 16F877A
    DEFINE LOADER_USED 1
    DEFINE OSC 20

    'dim VARIABLE AS WORD
    dim HEADER as word ' Header pulse length
    dim PACKET as Word ' 12-bit IR information
    dim P_VAL as Byte ' The bit length 60us = 0, 120us = 1
    dim IR_BUT as Byte ' The BUTTON code returned
    dim IR_DEV as Byte ' The DEVICE code returned
    dim SONY_LP as Byte ' Temporary loop variable
    symbol GREENLED= Porta.5 ' Assign the red LED to this pin
    symbol REDLED = Porta.0


    'VARIABLE=PULSIN PORTA.2,LOW

    IRIN:
    PACKET=0
    IR_DEV=255
    IR_BUT=255

    HEADER=PULSIN PORTA.2,LOW
    IF HEADER<1000 THEN RETURN
    IF HEADER>1350 THEN RETURN

    for SONY_LP=0 TO SONY_LP=11

    P_VAL=PULSIN PORTA.2,LOW

    IF P_VAL>=600 THEN PACKET.11=1 ENDIF

    PACKET=PACKET>>1
    'INC SONY_LP
    'UNTIL SONY_LP=11111
    NEXT

    IR_BUT =PACKET& 01111111

    IR_DEV=%00011111 & (PACKET >>7)

    AGAIN:
    LOW GREENLED
    LOW REDLED
    IF IR_DEV=255 THEN AGAIN
    IF IR_DEV<>0 THEN AGAIN
    IF IR_DEV =116 THEN HIGH GREENLED
    IF IR_DEV=117 THEN HIGH REDLED
    PAUSE 300
    GOTO IRIN





    im very new to the world of pics and new to the forum as well. i dont know why the above code is not working.im using pic16f877a and tsop 1238 and trying to decode sony 12 bit signals.if any one can point any mistake in the code it will be greatly appreciated....

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: problem with ir code.using pulsin

    Hello engineer7,
    I think you are looking for the other Crownhill Basic compiler forum.
    http://www.protonbasic.co.uk/forum.php
    It is there where they speak Proton.
    If you are actually using PBP then let us know so we can help you.
    IN PBPro variables are not declared this way:
    dim HEADER as word ' Header pulse length
    that variable would be declared as:
    HEADER VAR WORD ' Header pulse length

    Now after saying all that . . . P Basic (the cheap version, you know the forum you actually posted in) syntax absolutely alludes me as I only have the PRO version, but I felt pretty safe due to your define proton_4 . . .
    Last edited by Archangel; - 20th May 2011 at 07:58. Reason: CMA
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: problem with ir code.using pulsin

    thanku so much sir.i think this may be the problem coz i have checked and rechecked many a times my logic.i'll look again n let u know.by the way this is the first time any person has actually helped me out on forums so thanks v much again!

  4. #4
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: problem with ir code.using pulsin

    n i am using PICBASIC PLUS COMPILER

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: problem with ir code.using pulsin

    I am sorry, I am not familar with PICBASIC Plus or with:
    Set_Defaults PROTON_4
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Default Re: problem with ir code.using pulsin

    archangel sir i checked.there is no problem with the declarations.in this compiler one can declare the variables both ways.may be something wrong with the logic....


    IF P_VAL>=600 THEN PACKET.11=1 ENDIF

    maybe something wrong in this line.maybe my calculations are abit off???

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,520


    Did you find this post helpful? Yes | No

    Default Re: problem with ir code.using pulsin

    Hi,
    You really should visit the forum for the compiler you are using. I know it's confusing but there are several different BASIC-compilers for PICs and they are all slightly different from each other in syntax etc so you'll get much better help on a forum where everybody else is using the same compiler as you are - which isn't the case here. There's a link to the PROTON forum in second post in the thread.

    With that said the line...
    Code:
    for SONY_LP=0 TO SONY_LP=11
    ...looks a bit odd to me. I'd try FOR SONY_LP = 0 to 11 instead. But then again your syntax may be perfectly valid for the PROTON compiler you're using, I don't know since I'm not using it.

    /Henrik.

  8. #8
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: problem with ir code.using pulsin

    Quote Originally Posted by engineer7 View Post
    archangel sir i checked.there is no problem with the declarations.in this compiler one can declare the variables both ways.may be something wrong with the logic....


    IF P_VAL>=600 THEN PACKET.11=1 ENDIF

    maybe something wrong in this line.maybe my calculations are abit off???
    I never really thought there was, I am pretty sure you are using Proton, THIS IS NOT THE PROTON FORUM. I did not want to just blow you off if you are using M E Labs P Basic.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  9. #9
    Join Date
    Mar 2011
    Posts
    30


    Did you find this post helpful? Yes | No

    Smile Re: problem with ir code.using pulsin

    ok thanks everyone.4 pointing me in the right direction!

Members who have read this thread : 1

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

Tags for this Thread

Posting Permissions

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