bs2p and IR- remotcontrol with SFH 506
Archiver
Posts: 46,084
Hi,
I connect an SFH 506 (IC includes diode amp etc) to an Bs2p Pin
I would like to "record" 3 button of any standard Ir-remote control
and then to use the 3 bottom to change some parameter in the main
program but I don't find info how the Ir transmit is done (timing)
I have studied the Pc to Pc Ir-transmit of Trasy's homepage
Goggle search was not successful
Has anybody an link, info or sample project ?...........thanks
To get some ideas I tried to read the debug after pulsin
to see if there are useful counts by pressing button 1, 2, or 3 of the
remote control
but my result of debug is confusing, so I think I need background info
here is the debug result:
variable: b , c, d...... to v =
58 | 8 | 20 | 8 | 20 | 8 | 20 | 8 | 8 | 8 | 6 | 8 | 20 | 8 | 6 | 8 | 8 | 8 | 6 |
8 | 20
regards, Heinz Schwenk
The pgm I used:
'{$STAMP BS2p}
A var word
b var byte
c var byte
d var byte
.....and so on.....til v var byte
start:
if in 12=1 then start
pulsin 12,1,A: b=A/100
pulsin 12,0,A: c=A/100
pulsin 12,1,A: d=A/100
.....and so on.....til pulsin 12,1,A: v=A/10
after I debug from "a" til "v"
I connect an SFH 506 (IC includes diode amp etc) to an Bs2p Pin
I would like to "record" 3 button of any standard Ir-remote control
and then to use the 3 bottom to change some parameter in the main
program but I don't find info how the Ir transmit is done (timing)
I have studied the Pc to Pc Ir-transmit of Trasy's homepage
Goggle search was not successful
Has anybody an link, info or sample project ?...........thanks
To get some ideas I tried to read the debug after pulsin
to see if there are useful counts by pressing button 1, 2, or 3 of the
remote control
but my result of debug is confusing, so I think I need background info
here is the debug result:
variable: b , c, d...... to v =
58 | 8 | 20 | 8 | 20 | 8 | 20 | 8 | 8 | 8 | 6 | 8 | 20 | 8 | 6 | 8 | 8 | 8 | 6 |
8 | 20
regards, Heinz Schwenk
The pgm I used:
'{$STAMP BS2p}
A var word
b var byte
c var byte
d var byte
.....and so on.....til v var byte
start:
if in 12=1 then start
pulsin 12,1,A: b=A/100
pulsin 12,0,A: c=A/100
pulsin 12,1,A: d=A/100
.....and so on.....til pulsin 12,1,A: v=A/10
after I debug from "a" til "v"
Comments
programming skills but it will give you some ideas. The first
program is a little harder on the processor the second may work
on a slower processor.
The leader or start bit is 2.20mS, a highbit is 1.10mS, and a
lowbit
is .55mS, synch bit is also .55mS
' IR CODE READER SONY TYPE
' LARRY GAMINDE LGAMINDE@T...
'
' PIC16F84-10 USED IN THIS EXAMPLE AND TIMING IS DEPENDENT
' ON PROCESSOR SPEED 10MHZ
' I USED A SERIAL BACKPACK ON PORTB.3 FOR DISPLAY AND DEBUGGING
' INPUT FROM RADIO SHACK 40KHZ RECEIVER TO PORTB.1
'
DEFINE OSC 10
TRISB= %01000000
A VAR BYTE(16)
I VAR BYTE
LEADER VAR WORD
VALUE VAR WORD
PAUSE 500
SEROUT2 PORTB.3, $4054,[noparse][[/noparse]254,1]
PAUSE 100
SEROUT2 PORTB.3, $4054,[noparse][[/noparse]" IR CODE READER"]
PAUSE 2000
MAIN: LEADER = 0 'LOOK FOR LEADER OR START BIT
PULSIN PORTB.1, 0, LEADER
IF (LEADER < 310) THEN MAIN
IF (LEADER > 320) THEN MAIN
FOR I = 0 TO 11 'I USED 8 OF THE 12 BITS FOR DISPLAY
PULSIN PORTB.1, 0, A(I)
NEXT
FOR I = 0 TO 11
IF A(I) > 150 THEN ONE
IF A(I) < 130 THEN ZERO
'NEXT THREE LINES USED FOR DEBUGGING
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]254,1]
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]"A",DEC I,DEC A(I)]
PAUSE 2000
ONE:
A(I) = 1
GOTO ENDD
ZERO:
A(I) = 0
ENDD:
NEXT
VALUE1:
VALUE.BIT0 = A(0)
VALUE.BIT1 = A(1)
VALUE.BIT2 = A(2)
VALUE.BIT3 = A(3)
VALUE.BIT4 = A(4)
VALUE.BIT5 = A(5)
VALUE.BIT6 = A(6)
VALUE.BIT7 = A(7)
VALUE.BIT8 = A(8)
VALUE.BIT9 = A(9)
VALUE.BIT10 = A(10)
VALUE.BIT11 = A(11)
VALUE.BIT12 = 0
VALUE.BIT13 = 0
VALUE.BIT14 = 0
VALUE.BIT15 = 0
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]254,1]
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]" ",DEC VALUE]
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]254,192]
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]BIN VALUE]
PAUSE 2000
IF VALUE = 4074 THEN VALUE = 1
IF VALUE = 4042 THEN VALUE = 2
IF VALUE = 4010 THEN VALUE = 3
IF VALUE = 3978 THEN VALUE = 4
IF VALUE = 3946 THEN VALUE = 5
IF VALUE = 3914 THEN VALUE = 6
IF VALUE = 3882 THEN VALUE = 7
IF VALUE = 3850 THEN VALUE = 8
IF VALUE = 3818 THEN VALUE = 9
IF VALUE = 3786 THEN VALUE = 0
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]254,1]
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]" BUTTON # ",DEC VALUE]
LEADER = 0
VALUE = 0
PAUSE 500
GOTO MAIN
'second program starts here
DEFINE OSC 10
TRISB= %01000000
TOTAL VAR BYTE
LEADER VAR WORD
VALUE VAR WORD
A VAR BYTE(16)
PAUSE 500
SEROUT2 PORTB.3, $4054,[noparse][[/noparse]254,1]
PAUSE 100
SEROUT2 PORTB.3, $4054,[noparse][[/noparse]" IR CODE READER"]
PAUSE 2000
MAIN:
PULSIN PORTB.1, 0, LEADER
IF (LEADER < 310) THEN MAIN
IF (LEADER > 320) THEN MAIN
PULSIN PORTB.1, 0, A(0)
PULSIN PORTB.1, 0, A(1)
PULSIN PORTB.1, 0, A(2)
PULSIN PORTB.1, 0, A(3)
PULSIN PORTB.1, 0, A(4)
PULSIN PORTB.1, 0, A(5)
PULSIN PORTB.1, 0, A(6)
PULSIN PORTB.1, 0, A(7)
PULSIN PORTB.1, 0, A(8)
PULSIN PORTB.1, 0, A(9)
PULSIN PORTB.1, 0, A(10)
PULSIN PORTB.1, 0, A(11)
'PULSIN PORTB.1, 0, A(12)
'PULSIN PORTB.1, 0, A(13)
'PULSIN PORTB.1, 0, A(14)
'PULSIN PORTB.1, 0, A(15)
FOR TOTAL = 0 TO 11
IF A(TOTAL) > 150 THEN ONE
IF A(TOTAL) < 130 THEN ZERO
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]254,1]
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]"A",DEC TOTAL,DEC A(TOTAL)]
PAUSE 2000
ONE:
A(TOTAL) = 1
GOTO ENDD
ZERO:
A(TOTAL) = 0
ENDD:
NEXT
VALUE1:
VALUE.BIT0 = A(0)
VALUE.BIT1 = A(1)
VALUE.BIT2 = A(2)
VALUE.BIT3 = A(3)
VALUE.BIT4 = A(4)
VALUE.BIT5 = A(5)
VALUE.BIT6 = A(6)
VALUE.BIT7 = A(7)
VALUE.BIT8 = A(8)
VALUE.BIT9 = A(9)
VALUE.BIT10 = A(10)
VALUE.BIT11 = A(11)
VALUE.BIT12 = 0 'A(12)
VALUE.BIT13 = 0 'A(13)
VALUE.BIT14 = 0 'A(14)
VALUE.BIT15 = 0 'A(15)
DISPLAY:
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]254,1]
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]" ",DEC VALUE]
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]254,192]
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]BIN VALUE]
PAUSE 2000
IF VALUE = 4074 THEN VALUE = 1
IF VALUE = 4042 THEN VALUE = 2
IF VALUE = 4010 THEN VALUE = 3
IF VALUE = 3978 THEN VALUE = 4
IF VALUE = 3946 THEN VALUE = 5
IF VALUE = 3914 THEN VALUE = 6
IF VALUE = 3882 THEN VALUE = 7
IF VALUE = 3850 THEN VALUE = 8
IF VALUE = 3818 THEN VALUE = 9
IF VALUE = 3786 THEN VALUE = 0
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]254,1]
SEROUT2 PORTB.3,$4054,[noparse][[/noparse]" BUTTON # ",DEC VALUE]
LEADER = 0
VALUE = 0
PAUSE 500
DONE: GOTO MAIN
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the
Subject and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
for my robots and it work well on a bs2
ir con 14 'pin receiving data from IR
receiver
result var word 'vairable use to
store control word from remote
temp var word 'temp variable
a0 var word 'length of first logic 1
after the start bit
a1 var word 'length of the second logic 1
a2 var word 'length of the third logic 1
a3 var word 'length of the fourth logic 1
a4 var word 'length of the fifth logic 1
a5 var word 'length of the sixth logic 1
a6 var word 'length of the seventh logic 1
a7 var word 'length of the last recorded
logic bit
main:
pulsin ir,0,temp 'wait for valid start bit
if temp < 1000 then main 'valid start bit is > 2ms
pause 40 'pause to skip the first data
set. actual `measurements begin with second data set
pulsin ir,0,a0 'measure the length of the
first logic 1
pulsin ir,0,a1 'measure the length of the
second logic 1
pulsin ir,0,a2 'measure the length of the
third logic 1
pulsin ir,0,a3 'measure the length of the
fourth logic 1
pulsin ir,0,a4 'measure the length of the
fifthlogic 1
pulsin ir,0,a5 'measure the length of the
sixth logic 1
pulsin ir,0,a6 'measure the length of the
seventh logic 1
pulsin ir,0,a7 'measure the length of the
last recorded logic 1
pulsin ir,0,temp 'only the first eigh data
bits are useful to us.
pulsin ir,0,temp 'but each control word is
15bits in length. need to
pulsin ir,0,temp 'take into the account those
bits. therefore we `store them
pulsin ir,0,temp 'in a temp variable
pulsin ir,0,temp
result.bit0=a0/450 'PULSIN measures time in
2microsec increments. know `from
result.bit1=a1/450 'webpage that logic 1 is
1.2ms in length and logic 0 is 0.6ms
result.bit2=a2/450 'in length. therefore for a0-
a7 the values would be around 600 from
result.bit3=a3/450 'for logic 1 and around 300
for logic 0. dividing `a0-a7 with 450
result.bit4=a4/450 'would yield either 1 for
vaules greater than 450 or `0 for values
result.bit5=a5/450 'less that 450. we then fill
in the result variable `bit by bit to
result.bit6=a6/450 'reconstruct the control word
sent by the remote `control
result.bit7=a7/450
result.bit8=0
result.bit9=0
result.bit10=0
result.bit11=0
result.bit12=0
if result=%10010 then ZERO 'pressing different buttons
on the remote would `generate
if result=%0 then ONE 'different control words.
these are the control words received for
if result=%10 then TWO 'each button pressed. IF..THEN
statements compare the control word
if result=%100 then THREE 'received to those that can
be recogonized. If the `results match then
if result=%110 then FOUR 'we know which button was
pressed and can display `the name of that button
if result=%1000 then five 'on the LCD
if result=%1010 then SIX
if result=%1100 then SEVEN
if result=%1110 then EIGHT
if result=%10000 then NINE
if result=%100100 then VOLUP
if result=%100110 then VOLDOWN
if result=%100000 then CHUP
if result=%100010 then CHDOWN
goto main
ZERO:
'insert proper code here
goto main
ONE:
goto main
TWO:
goto main
THREE:
goto main
FOUR:
goto main
FIVE:
goto main
SIX:
goto main
SEVEN:
goto main
EIGHT:
goto main
NINE:
goto main
VOLUP:
goto main
VOLDOWN:
goto main
CHUP:
goto main
CHDOWN:
goto main