4 pings in a robin fashion
Robe
Posts: 13
GOOD MORNING EVERYONE,· I HAVE WRITTEN THIS CODE TO TRIGGER FOUR PINGS IN A RUBBING FASION BUT I HAVE TRIED A FEW DIFFERENT WAYS AND I CAN'T GET IT TO WORK. I AM NOT SURE WETHER OR NOT MY SUB ROUTINE IS WRIGHT OR IF I NEED 1 FOR EACH PING, OR IF SOMETHING IS MISSING. COULD·ANYONE HELP ME WITH REVIEWING THIS·CODE. I WOULD APPRECIATE THE HELP.
{$STANP BS2}
{$PBASIC 2.5}
ping1·· PIN 5
ping2·· PIN· 2
Ping3· ·PIN 15
Ping4 · PIN 4
trigger com 5
trigger· com 6
trigger· com 7
trigger· com 8
scale1· com $200
scale2· com $200
scale3· com $200
scale4· com $200
rawtoin· com 889
rawtoin· com 889
rawtoin· com 889
rawtoin· com 889
ishigh1· com 1
ishigh2· com 1
ishigh3· com 1
ishigh4· com 1
islow1· com 0
islow2· com 0
islow3· com 0
islow4· com0
rawdist1· var· word
rawdist2· var· word
rawdist3· var· word
rawdist4· var· word
inches1· var· word
inches2· var· word
inches3··var· word
inches4· var· word
pingnum· var bit
pulsecount· var byte
counter····· var·byte
pulseleft···· var word
pulseright·· var word
theping····· var byte
pingbase····var byte
ishigh······· var bit
rawdist····· var bit
scale········ var bit
DO
pingnum· = pingnum + 1 // 2
gosub get_sonar
inches1 = rawdist1**rawtion1
inches2 = rawdist2**rawtoin2
inches3 = rawdist3**rawtoin3
inches4 = rawdist4**rawtoin4
if (inches1·= 5 ) then
pulsout 13, 650
pulsout 12, 850
····· '· more navegation code goes here for ping #2 to #3
elseif ( inches4 = 5 )then
for counter 1 to 50
pulsout 13, 850
pulsout 12,· 850
next
pause 50
else
pulseleft··· = 850
pulseright· = 650
pulsout 13, pulseleft
pulsout 12, pulseright
loop
get_sonar:
theping = pingbase + pingnum
low theping
pulsout ·theping, trigger
pulsing·· theping, ishigh,rawdist (pingnum)
rawdist (pingnum ) = rawdist(pingnum)*/scasle1
rawdist (pingnum ) = rawdist(pingnum) / 2
RETURN
·
{$STANP BS2}
{$PBASIC 2.5}
ping1·· PIN 5
ping2·· PIN· 2
Ping3· ·PIN 15
Ping4 · PIN 4
trigger com 5
trigger· com 6
trigger· com 7
trigger· com 8
scale1· com $200
scale2· com $200
scale3· com $200
scale4· com $200
rawtoin· com 889
rawtoin· com 889
rawtoin· com 889
rawtoin· com 889
ishigh1· com 1
ishigh2· com 1
ishigh3· com 1
ishigh4· com 1
islow1· com 0
islow2· com 0
islow3· com 0
islow4· com0
rawdist1· var· word
rawdist2· var· word
rawdist3· var· word
rawdist4· var· word
inches1· var· word
inches2· var· word
inches3··var· word
inches4· var· word
pingnum· var bit
pulsecount· var byte
counter····· var·byte
pulseleft···· var word
pulseright·· var word
theping····· var byte
pingbase····var byte
ishigh······· var bit
rawdist····· var bit
scale········ var bit
DO
pingnum· = pingnum + 1 // 2
gosub get_sonar
inches1 = rawdist1**rawtion1
inches2 = rawdist2**rawtoin2
inches3 = rawdist3**rawtoin3
inches4 = rawdist4**rawtoin4
if (inches1·= 5 ) then
pulsout 13, 650
pulsout 12, 850
····· '· more navegation code goes here for ping #2 to #3
elseif ( inches4 = 5 )then
for counter 1 to 50
pulsout 13, 850
pulsout 12,· 850
next
pause 50
else
pulseleft··· = 850
pulseright· = 650
pulsout 13, pulseleft
pulsout 12, pulseright
loop
get_sonar:
theping = pingbase + pingnum
low theping
pulsout ·theping, trigger
pulsing·· theping, ishigh,rawdist (pingnum)
rawdist (pingnum ) = rawdist(pingnum)*/scasle1
rawdist (pingnum ) = rawdist(pingnum) / 2
RETURN
·
Comments
thats just a quick glance.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
DTQ
Good code, however, NO SHOUTING! It is very annoying to do that.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Buck Rogers
www.gregg.levine.name
bugg
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Boe-bot: $229
Toddler: $249
Learning Google is your friend: priceless
Note on my attachment: I've attached the program as a .TXT file so that it can be viewed online without downloading.· After downloading, simply remove the added .TXT extension to open in the BASIC Stamp IDE.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Let the loop run continuously while you check the operation of the sensor. I corrected some of the· syntax errors, but i did not check /alter any of the program logic.