sony ir and bs2
Hello Pieter-Jan:
You might want to compare your approach with the Sony/BS2 code that is posted
in the Code Bank section at:
http://www.personalrobotics.net
There is no problem with slow response in this code -- in fact, there is a
PAUSE command at the end of the main loop to debounce incoming signals. Hope
this helps.
Regards...Don
Pieter-Jan van Diepen wrote:
> hello all,
>
> I've written some code to receive signals from a sony ir-remote. It works,
> but is very slow. The start bit of the sony protocol is very sometimes
> recognized, so i have to send my ir signal many times. Is there something
> wrong in the code, is it normal, or has anyone tips/trics?
>
[noparse][[/noparse]snip]
--
__________________________________________________________________________
FirstBOT(tm) Robot Kits & Components - http://www.FirstBotStore.com
Personal Robotics News - http://www.personalrobotics.net
You might want to compare your approach with the Sony/BS2 code that is posted
in the Code Bank section at:
http://www.personalrobotics.net
There is no problem with slow response in this code -- in fact, there is a
PAUSE command at the end of the main loop to debounce incoming signals. Hope
this helps.
Regards...Don
Pieter-Jan van Diepen wrote:
> hello all,
>
> I've written some code to receive signals from a sony ir-remote. It works,
> but is very slow. The start bit of the sony protocol is very sometimes
> recognized, so i have to send my ir signal many times. Is there something
> wrong in the code, is it normal, or has anyone tips/trics?
>
[noparse][[/noparse]snip]
--
__________________________________________________________________________
FirstBOT(tm) Robot Kits & Components - http://www.FirstBotStore.com
Personal Robotics News - http://www.personalrobotics.net
Comments
I've written some code to receive signals from a sony ir-remote. It works,
but is very slow. The start bit of the sony protocol is very sometimes
recognized, so i have to send my ir signal many times. Is there something
wrong in the code, is it normal, or has anyone tips/trics?
here is my code
irsense con 15
irinput var in15
irthreshold con 500
irstartlow con 1100
irstarthi con 1400
value var byte
raw var word(7)
start var word
dummy var word
output 1
out1 = 1
output 5
out5 = 1
output 9
out9 = 1
top:
debug "tp"
gosub read_ir
if value =1 then do_1
if value =5 then do_5
if value =9 then do_9
goto top
do_1:
low 1
pause 1000
high 1
pause 1000
goto top
do_5:
low 5
pause 1000
high 5
pause 1000
goto top
do_9:
low 9
pause 1000
high 9
pause 1000
goto top
read_ir:
debug ? irinput
if irinput = 0 then noir
pulsin irsense,0,start
pulsin irsense,0,raw(0)
pulsin irsense,0,raw(1)
pulsin irsense,0,raw(2)
pulsin irsense,0,raw(3)
pulsin irsense,0,raw(4)
pulsin irsense,0,raw(5)
pulsin irsense,0,raw(6)
pulsin irsense,0,dummy
pulsin irsense,0,dummy
pulsin irsense,0,dummy
pulsin irsense,0,dummy
pulsin irsense,0,dummy
if (start <irstartlow) or (start > irstarthi) then noir
value = 0
for dummy = 6 to 0
value = value *2
if raw(dummy) < irthreshold then ir0
value = value +1
debug ? value
ir0:
next
return
noir:
debug "noir"
value=-1
return
many thanks pieter-jan
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
well as I wanted though, just like yours i would have to press the button
several times. Then I wrote some code in picbasic and have never had any
trouble. The faster speed of the pics help A LOT. I could pass it on to
you if you like, assuming you can program PICs.
>From: "Pieter-Jan van Diepen" <diepenpj@h...>
>Reply-To: basicstamps@egroups.com
>To: basicstamps@egroups.com
>Subject: [noparse][[/noparse]basicstamps] sony ir and bs2
>Date: Tue, 18 Jul 2000 08:34:03 CEST
>
>hello all,
>
>I've written some code to receive signals from a sony ir-remote. It works,
>but is very slow. The start bit of the sony protocol is very sometimes
>recognized, so i have to send my ir signal many times. Is there something
>wrong in the code, is it normal, or has anyone tips/trics?
>
>here is my code
>
>irsense con 15
>irinput var in15
>irthreshold con 500
>irstartlow con 1100
>irstarthi con 1400
>value var byte
>raw var word(7)
>start var word
>dummy var word
>output 1
>out1 = 1
>output 5
>out5 = 1
>output 9
>out9 = 1
>top:
>debug "tp"
>gosub read_ir
>if value =1 then do_1
>if value =5 then do_5
>if value =9 then do_9
>goto top
>
>do_1:
>low 1
>pause 1000
>high 1
>pause 1000
>goto top
>
>do_5:
>low 5
>pause 1000
>high 5
>pause 1000
>goto top
>
>do_9:
>low 9
>pause 1000
>high 9
>pause 1000
>goto top
>
>read_ir:
>debug ? irinput
>if irinput = 0 then noir
>pulsin irsense,0,start
>pulsin irsense,0,raw(0)
>pulsin irsense,0,raw(1)
>pulsin irsense,0,raw(2)
>pulsin irsense,0,raw(3)
>pulsin irsense,0,raw(4)
>pulsin irsense,0,raw(5)
>pulsin irsense,0,raw(6)
>pulsin irsense,0,dummy
>pulsin irsense,0,dummy
>pulsin irsense,0,dummy
>pulsin irsense,0,dummy
>pulsin irsense,0,dummy
>
>if (start <irstartlow) or (start > irstarthi) then noir
>
>value = 0
>for dummy = 6 to 0
> value = value *2
>
>if raw(dummy) < irthreshold then ir0
>value = value +1
>debug ? value
>
>ir0:
>next
>return
>
>noir:
>debug "noir"
>value=-1
>return
>
>many thanks pieter-jan
>________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
>
>
>
>
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
Do you mind if you email the Picbasic code to me at
Gary.Chung@d... ??
Thanks
Gary
Original Message
From: "ED Ward" <punk__rocker@h...>
To: <basicstamps@egroups.com>
Sent: Wednesday, July 19, 2000 9:22 AM
Subject: Re: [noparse][[/noparse]basicstamps] sony ir and bs2
> I wrote some code for the BS@ to do this same thing. It never worked as
> well as I wanted though, just like yours i would have to press the button
> several times. Then I wrote some code in picbasic and have never had any
> trouble. The faster speed of the pics help A LOT. I could pass it on to
> you if you like, assuming you can program PICs.
>
>
> >From: "Pieter-Jan van Diepen" <diepenpj@h...>
> >Reply-To: basicstamps@egroups.com
> >To: basicstamps@egroups.com
> >Subject: [noparse][[/noparse]basicstamps] sony ir and bs2
> >Date: Tue, 18 Jul 2000 08:34:03 CEST
> >
> >hello all,
> >
> >I've written some code to receive signals from a sony ir-remote. It works,
> >but is very slow. The start bit of the sony protocol is very sometimes
> >recognized, so i have to send my ir signal many times. Is there something
> >wrong in the code, is it normal, or has anyone tips/trics?
> >
> >here is my code
> >
> >irsense con 15
> >irinput var in15
> >irthreshold con 500
> >irstartlow con 1100
> >irstarthi con 1400
> >value var byte
> >raw var word(7)
> >start var word
> >dummy var word
> >output 1
> >out1 = 1
> >output 5
> >out5 = 1
> >output 9
> >out9 = 1
> >top:
> >debug "tp"
> >gosub read_ir
> >if value =1 then do_1
> >if value =5 then do_5
> >if value =9 then do_9
> >goto top
> >
> >do_1:
> >low 1
> >pause 1000
> >high 1
> >pause 1000
> >goto top
> >
> >do_5:
> >low 5
> >pause 1000
> >high 5
> >pause 1000
> >goto top
> >
> >do_9:
> >low 9
> >pause 1000
> >high 9
> >pause 1000
> >goto top
> >
> >read_ir:
> >debug ? irinput
> >if irinput = 0 then noir
> >pulsin irsense,0,start
> >pulsin irsense,0,raw(0)
> >pulsin irsense,0,raw(1)
> >pulsin irsense,0,raw(2)
> >pulsin irsense,0,raw(3)
> >pulsin irsense,0,raw(4)
> >pulsin irsense,0,raw(5)
> >pulsin irsense,0,raw(6)
> >pulsin irsense,0,dummy
> >pulsin irsense,0,dummy
> >pulsin irsense,0,dummy
> >pulsin irsense,0,dummy
> >pulsin irsense,0,dummy
> >
> >if (start <irstartlow) or (start > irstarthi) then noir
> >
> >value = 0
> >for dummy = 6 to 0
> > value = value *2
> >
> >if raw(dummy) < irthreshold then ir0
> >value = value +1
> >debug ? value
> >
> >ir0:
> >next
> >return
> >
> >noir:
> >debug "noir"
> >value=-1
> >return
> >
> >many thanks pieter-jan
> >________________________________________________________________________
> >Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
> >
> >
> >
> >
> >
>
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
>
>
>
>
>
>
to comment it much, but it should be easy to figure out.
'decodes sony IR remote signals
symbol loop = b16
symbol start = W7
top:
b13=0
b2=0
b3=0
b4=0
b5=0
b6=0
b7=0
b8=0
b9=0
b12=0
pulsin 0, 0, start
if start > 240 then get
goto top
get:
if start < 1000 then getbits
goto top
getbits:
pulsin 0, 0, B13
pulsin 0, 0, B2
pulsin 0, 0, B3
pulsin 0, 0, B4
pulsin 0, 0, B5
pulsin 0, 0, B6
pulsin 0, 0, B7
pulsin 0, 0, B8
pulsin 0, 0, B9
pulsin 0, 0, B10
pulsin 0, 0, B11
pulsin 0, 0, B12
if b13=0 or b2=0 or b3=0 or b4=0 or b5=0 or b6=0 or b7=0 or b8=0 or
b9=0 or b10=0 or b11=0 or b12=0 then top
gosub setvalue
w8=b0+b1
serout 2, n9600, ("total = ", #w8, $0A, $0D) 'send data to LCD
low 1
pause 10
dir1=0
serout 1, t9600, (w8) 'send data to basic stamp
goto top:
setvalue:
bit0 = b13/96
bit1 = b2/96
bit2 = b3/96
bit3 = b4/96
bit4 = b5/96
bit5 = b6/96
bit6 = b7/96
bit7 = b8/96
bit8 = b9/96
bit9 = b10/96
bit10 = b11/96
bit11 = b12/96
return
>From: "Gary Chung" <gary.chung@d...>
>Reply-To: basicstamps@egroups.com
>To: <basicstamps@egroups.com>
>Subject: Re: [noparse][[/noparse]basicstamps] sony ir and bs2
>Date: Thu, 20 Jul 2000 00:19:17 +0800
>
>Ed,
>
>Do you mind if you email the Picbasic code to me at
>Gary.Chung@d... ??
>
>Thanks
>Gary
>
>
Original Message
>From: "ED Ward" <punk__rocker@h...>
>To: <basicstamps@egroups.com>
>Sent: Wednesday, July 19, 2000 9:22 AM
>Subject: Re: [noparse][[/noparse]basicstamps] sony ir and bs2
>
>
> > I wrote some code for the BS@ to do this same thing. It never worked as
> > well as I wanted though, just like yours i would have to press the
>button
> > several times. Then I wrote some code in picbasic and have never had any
> > trouble. The faster speed of the pics help A LOT. I could pass it on
>to
> > you if you like, assuming you can program PICs.
> >
> >
> > >From: "Pieter-Jan van Diepen" <diepenpj@h...>
> > >Reply-To: basicstamps@egroups.com
> > >To: basicstamps@egroups.com
> > >Subject: [noparse][[/noparse]basicstamps] sony ir and bs2
> > >Date: Tue, 18 Jul 2000 08:34:03 CEST
> > >
> > >hello all,
> > >
> > >I've written some code to receive signals from a sony ir-remote. It
>works,
> > >but is very slow. The start bit of the sony protocol is very sometimes
> > >recognized, so i have to send my ir signal many times. Is there
>something
> > >wrong in the code, is it normal, or has anyone tips/trics?
> > >
> > >here is my code
> > >
> > >irsense con 15
> > >irinput var in15
> > >irthreshold con 500
> > >irstartlow con 1100
> > >irstarthi con 1400
> > >value var byte
> > >raw var word(7)
> > >start var word
> > >dummy var word
> > >output 1
> > >out1 = 1
> > >output 5
> > >out5 = 1
> > >output 9
> > >out9 = 1
> > >top:
> > >debug "tp"
> > >gosub read_ir
> > >if value =1 then do_1
> > >if value =5 then do_5
> > >if value =9 then do_9
> > >goto top
> > >
> > >do_1:
> > >low 1
> > >pause 1000
> > >high 1
> > >pause 1000
> > >goto top
> > >
> > >do_5:
> > >low 5
> > >pause 1000
> > >high 5
> > >pause 1000
> > >goto top
> > >
> > >do_9:
> > >low 9
> > >pause 1000
> > >high 9
> > >pause 1000
> > >goto top
> > >
> > >read_ir:
> > >debug ? irinput
> > >if irinput = 0 then noir
> > >pulsin irsense,0,start
> > >pulsin irsense,0,raw(0)
> > >pulsin irsense,0,raw(1)
> > >pulsin irsense,0,raw(2)
> > >pulsin irsense,0,raw(3)
> > >pulsin irsense,0,raw(4)
> > >pulsin irsense,0,raw(5)
> > >pulsin irsense,0,raw(6)
> > >pulsin irsense,0,dummy
> > >pulsin irsense,0,dummy
> > >pulsin irsense,0,dummy
> > >pulsin irsense,0,dummy
> > >pulsin irsense,0,dummy
> > >
> > >if (start <irstartlow) or (start > irstarthi) then noir
> > >
> > >value = 0
> > >for dummy = 6 to 0
> > > value = value *2
> > >
> > >if raw(dummy) < irthreshold then ir0
> > >value = value +1
> > >debug ? value
> > >
> > >ir0:
> > >next
> > >return
> > >
> > >noir:
> > >debug "noir"
> > >value=-1
> > >return
> > >
> > >many thanks pieter-jan
> >
> >________________________________________________________________________
> > >Get Your Private, Free E-mail from MSN Hotmail at
>http://www.hotmail.com
> > >
> > >
> > >
> > >
> > >
> >
> > ________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com
> >
> >
> >
> >
> >
> >
>
>
>
>
>
________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com