PDA

View Full Version : problem with ir code.using pulsin



engineer7
- 20th May 2011, 07:42
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....

Archangel
- 20th May 2011, 07:53
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 . . .

engineer7
- 20th May 2011, 12:26
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!

engineer7
- 20th May 2011, 12:30
n i am using PICBASIC PLUS COMPILER

cncmachineguy
- 20th May 2011, 13:19
I am sorry, I am not familar with PICBASIC Plus or with:
Set_Defaults PROTON_4

engineer7
- 20th May 2011, 14:36
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??? :confused:

HenrikOlsson
- 20th May 2011, 16:57
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...

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.

Archangel
- 21st May 2011, 01:23
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??? :confused:

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.

engineer7
- 21st May 2011, 07:37
ok thanks everyone.4 pointing me in the right direction!