chai98a
- 11th March 2006, 20:21
I have to try decode IR hitachi TV format but not work pls advise
We used pulsin for measure pulse with.
1. we measure head pulse and next pluse bit and keep it .
2. bring pulse bit to decode "0" or "1"
3. Prind data tp pc
Problem :
The decode pulse with not consitance not show all same time after we push in the same key on remote.
Hitachi =32 bit ,see attached picture
head +8800 -2200
Bit "0" +550 -1650
Bit "1" +550 -550
Here is my code:
'PIC 16F877
DEFINE LOADER_USED 1
DEFINE OSC 4
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 12 ' 19200 Bauds
Header Var Word ' Header pulse length
Packet Var Word ' 16-bit IR information
Packet1 Var Word ' 16-bit IR information
P_Val Var Byte[32] ' Record pluse width
IR_But Var Byte ' The BUTTON code returned
IR_Dev Var Byte ' The DEVICE code returned
Sony_LP Var Byte ' Temporary loop variable
Green_LED Var Portb.3 ' Assign the red LED to this pin
TRISA = 0
LOW Green_LED
START:
GOSUB IRIN
IF IR_But =255 THEN start 'HIGH Green_LED
For Sony_Lp=0 to 23 ' Do 12-bits
Pulsin PortB.0,0,P_Val[SONY_LP] ' Receive the IR bit pulse
HSEROUT ["B ",DEC P_VAL[SONY_LP],13,10]
NEXT
HSEROUT ["Bottom ",DEC IR_But,13,10]
HSEROUT ["Comand ",DEC IR_Dev,13,10]
Packet =0
Packet1 =1
intcon.1=0
GOTO START
IRIN:
IR_Dev=255:IR_But=255
Pulsin PortB.0,0,Header ' Measure the header length.
'HSEROUT ["H ",DEC Header,13,10]
If Header < 792 then Return ' Verify a good header
If Header > 968 then Return ' If not valid then exit
For Sony_Lp=0 to 23 ' Do command 8-bits
Pulsin PortB.0,1,P_Val[SONY_LP] ' Receive the IR bit pulse "0"
NEXT
For Sony_Lp=0 to 7 ' Do device 8-bits
If P_Val[SONY_LP] >= 120 then ' If it's >= 120 then we've received a 1
Packet.0[Sony_Lp] = 1 ' So set the appropriate bit of PACKET
Else
Packet.0[Sony_Lp] = 0
Endif
NEXT
For Sony_Lp=17 to 24 ' Do 12-bits
If P_Val[SONY_LP] >= 120 then ' If it's >= 120 then we've received a 1
Packet1.0[Sony_Lp] = 1 ' So set the appropriate bit of PACKET1
Else
Packet1.0[Sony_Lp] = 0
Endif
NEXT
' Split the 7-bit BUTTON code, and the 5-bit DEVICE code
'IR_But=Packet & %01111111 ' Mask the 7 BUTTON bits
IR_But=Packet
'IR_Dev=(Packet >>7) & %00011111 ' Move down and mask, the 5 DEVICE bits
IR_dEV=Packet1
Return
We used pulsin for measure pulse with.
1. we measure head pulse and next pluse bit and keep it .
2. bring pulse bit to decode "0" or "1"
3. Prind data tp pc
Problem :
The decode pulse with not consitance not show all same time after we push in the same key on remote.
Hitachi =32 bit ,see attached picture
head +8800 -2200
Bit "0" +550 -1650
Bit "1" +550 -550
Here is my code:
'PIC 16F877
DEFINE LOADER_USED 1
DEFINE OSC 4
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_SPBRG 12 ' 19200 Bauds
Header Var Word ' Header pulse length
Packet Var Word ' 16-bit IR information
Packet1 Var Word ' 16-bit IR information
P_Val Var Byte[32] ' Record pluse width
IR_But Var Byte ' The BUTTON code returned
IR_Dev Var Byte ' The DEVICE code returned
Sony_LP Var Byte ' Temporary loop variable
Green_LED Var Portb.3 ' Assign the red LED to this pin
TRISA = 0
LOW Green_LED
START:
GOSUB IRIN
IF IR_But =255 THEN start 'HIGH Green_LED
For Sony_Lp=0 to 23 ' Do 12-bits
Pulsin PortB.0,0,P_Val[SONY_LP] ' Receive the IR bit pulse
HSEROUT ["B ",DEC P_VAL[SONY_LP],13,10]
NEXT
HSEROUT ["Bottom ",DEC IR_But,13,10]
HSEROUT ["Comand ",DEC IR_Dev,13,10]
Packet =0
Packet1 =1
intcon.1=0
GOTO START
IRIN:
IR_Dev=255:IR_But=255
Pulsin PortB.0,0,Header ' Measure the header length.
'HSEROUT ["H ",DEC Header,13,10]
If Header < 792 then Return ' Verify a good header
If Header > 968 then Return ' If not valid then exit
For Sony_Lp=0 to 23 ' Do command 8-bits
Pulsin PortB.0,1,P_Val[SONY_LP] ' Receive the IR bit pulse "0"
NEXT
For Sony_Lp=0 to 7 ' Do device 8-bits
If P_Val[SONY_LP] >= 120 then ' If it's >= 120 then we've received a 1
Packet.0[Sony_Lp] = 1 ' So set the appropriate bit of PACKET
Else
Packet.0[Sony_Lp] = 0
Endif
NEXT
For Sony_Lp=17 to 24 ' Do 12-bits
If P_Val[SONY_LP] >= 120 then ' If it's >= 120 then we've received a 1
Packet1.0[Sony_Lp] = 1 ' So set the appropriate bit of PACKET1
Else
Packet1.0[Sony_Lp] = 0
Endif
NEXT
' Split the 7-bit BUTTON code, and the 5-bit DEVICE code
'IR_But=Packet & %01111111 ' Mask the 7 BUTTON bits
IR_But=Packet
'IR_Dev=(Packet >>7) & %00011111 ' Move down and mask, the 5 DEVICE bits
IR_dEV=Packet1
Return