IMPORTANT PROBLEM... About PING))) Ultrosonic.. Help Us.
fatihsatir
Posts: 3
Hi Everybody,
·Last weeks I bought ping))) ultrasonic sensors for making sumo robot and I use 3 ping ultrasonic sensors but..
problem:
my sumo robot have to wait 5 second· then it must work.
At the beginning of the source code:
·"pause 5000
·goto main
·main:
·............
·............"
but in this situation my ultrasonic sensor work after 5 second and not work continual. firstly work then wait 5 sn then work..[noparse]:([/noparse]
this is big problem and I have no time because competition will start a few days later.
my sumo robot must wait 5 sn please interest my problem and I wait your answer immediatly..
Your Sincerely
SOURCE FOR SUMO ROBOT
________________________________________________________
' {$STAMP BS2}
' {$PBASIC 2.5}
' 23.24 ||31.01.07
' sonicmania
'
(pin yerleþimi)
ULTRA1·· PIN······ 13·················· 'ultrasonic pini········· (sol)· yeþil- beyaz
ULTRA2·· PIN······ 12·················· '·· "······· "··········· (orta) mavi beyaz
ULTRA3·· PIN······ 14·················· '·· "······· "··········· (sag)· mavi
OUTPUT 7······························· 'sag ileri motor
OUTPUT 6······························· 'sag geri motor
OUTPUT 5······························· 'sol ileri motor
OUTPUT 4······························· 'sol geri motor
INPUT 1································ 'ön sol···· cny
INPUT 2································ 'ön sað···· cny
INPUT 0································ 'arka sol·· cny
INPUT 15······························· 'arka sað·· cny
'
[noparse][[/noparse] Program baþlanhýcý]
'
[noparse][[/noparse]ultrasonic· sabitler ]
Trigger········ CON···· 5··············· ' trigger pulse = 10 uS
Scale·········· CON···· $200············ ' raw x 2.00 = uS
RawToIn········ CON···· 889············· ' 1 / 73.746 (with **)
RawToCm········ CON···· 2257············ ' 1 / 29.034 (with **)
IsHigh········· CON···· 1··············· ' for PULSOUT
IsLow·········· CON···· 0
'
[noparse][[/noparse]ultrasonic degiskenler ]
rawDist1········ VAR···· Word
inches1········· VAR···· Word
cm1············· VAR···· Word
rawDist2········ VAR···· Word
inches2········· VAR···· Word
cm2············· VAR···· Word
rawDist3········ VAR···· Word
inches3········· VAR···· Word
cm3············· VAR···· Word
PAUSE 5000··· "Problem ih here........................................"
· main:
··· LOW 14······························· ' her tarama icin ultrasonicleri önce temizle
··· LOW 12
··· LOW 13
··· GOSUB Get_Sonar1······················ ' get sensor value
··· inches1 = rawDist1 ** RawToIn········ ' inch'e dönüþtür
··· cm1 = rawDist1 ** RawToCm
··············· ' cm'ye dönüþtür
··· GOSUB Get_Sonar2
··· inches2 = rawDist2 ** RawToIn········ ' inch'e dönüþtür
··· cm2 = rawDist2 ** RawToCm
··· GOSUB Get_Sonar3
··· inches3 = rawDist3 ** RawToIn········ ' inch'e dönüþtür
··· cm3 = rawDist3 ** RawToCm·········· ' cm'ye dönüþtür····· '
·· DO
··· IF ((cm1>130) & (cm2>130) & (cm3>130)) THEN bul· 'hepsi pasif iken , dohyo dýþý
··· IF cm1 < (cm2 & cm3) THEN· kara········ 'ultrasonicler ... sol· yakýnsa
··· IF cm2 < (cm1 & cm3) THEN· de··············· '············· ... orta yakýnsa
··· IF cm3 < (cm2 & cm1) THEN· niz········· '············· ... sag yakýnsa
··· IF ((cm1=cm2) OR (cm1=cm3) OR (cm2=cm3)) THEN· ileri '...ikisinin esitlik durumu
··· IF (IN1=1 OR IN2=1)THEN kesme1······ 'cnyler ... ön cnyler çizgide ise kesme1
··· IF (IN0=1 OR IN15=1)THEN kesme2
···· LOOP
···· kara:
·· DO· WHILE·· cm1 <( cm2 & cm3)
··· GOTO sag
···· GOSUB Get_Sonar1
······ GOSUB Get_Sonar2
········ GOSUB Get_Sonar3
····· LOOP
····· GOTO main
·· de:
··· DO· WHILE·· cm2 < (cm1 & cm3)
··· GOTO ileri
···· GOSUB Get_Sonar1
······ GOSUB Get_Sonar2
········ GOSUB Get_Sonar3
····· LOOP
····· GOTO main
·· niz:
···· DO WHILE· cm3 < (cm2 & cm1)
··· GOTO sol
···· GOSUB Get_Sonar1
······ GOSUB Get_Sonar2
········ GOSUB Get_Sonar3
···· LOOP
···· GOTO main
· bul:
···· DO· WHILE·· (cm1>130 & cm2>130 & cm3>130)·· ' bu durum yokolana kadar saga don
··· GOTO sag
···· GOSUB Get_Sonar1
······ GOSUB Get_Sonar2
········ GOSUB Get_Sonar3
····· LOOP
····· GOTO main
ileri:
·· HIGH 5
·· HIGH 7·································· 'ileri git .....
·· LOW· 4
·· LOW· 6
·· RETURN
·sag:
··· HIGH 7
··· LOW 4································ ' sag ileri motor aktif .....
··· LOW 5
··· LOW 6
··· RETURN
·sol:
··· HIGH 5
··· LOW 4································ 'sol ileri motor aktif ....
··· LOW 6
··· LOW 7
··· RETURN
kesme1:
IF cm1 <( cm2 & cm3) THEN dal1····· ' rakip solda·········· , on cnyler icin
IF cm3 <( cm2 & cm1) THEN dal2····· ' rakip sagda
LOW 5
LOW 7······························ ' bu þartlar saglanmýyorsa 1.5sn. geri gel
HIGH 4
HIGH 6
PAUSE 1000
IF (IN1=0 OR IN2=0) THEN
LOW 1
LOW 2
ENDIF
RETURN
kesme2:
IF cm1 <( cm2 & cm3) THEN dal3····· ' rakip solda········· ,arka cnyler icin
IF cm3 <( cm2 & cm1) THEN dal4····· ' rakip sagda
LOW 4
LOW 6······························ 'bu þartlar saglanmýyorsa 1.5sn. ileri git
HIGH 5
HIGH 7
PAUSE 1000
IF (IN0=0 OR IN15=0) THEN
LOW 0
LOW 15
ENDIF
RETURN
dal1:
LOW 5············· '
sadece sol geri aktif
LOW 6
LOW 7
HIGH 4
PAUSE 1000
RETURN
dal2:
LOW 4············· '
sadece sag geri aktif
LOW 5
LOW 7
HIGH 6
PAUSE 1000
RETURN
dal3:
LOW 4
LOW 6············· '
sadece sol ileri aktif
LOW 7
HIGH 5
PAUSE 1000
RETURN
dal4:
LOW 4
LOW 5
LOW 6············· '
sadece· sag ileri aktif
HIGH 7
PAUSE 1000
RETURN
Get_Sonar1:··································· ' make trigger 0-1-0
· ULTRA1 = IsLow
· PULSOUT ULTRA1, Trigger···················· ' sensörü aktifle
· PULSIN· ULTRA1, IsHigh, rawDist1··········· ' measure echo pulse
· rawDist1 = rawDist1 */ Scale··············· ' convert to uS
· rawDist1 = rawDist1 / 2
·· RETURN···································· ' remove return trip
··· Get_Sonar2:
··· ULTRA2 = Islow
· PULSOUT ULTRA2, Trigger···················· ' sensörü aktifle
· PULSIN· ULTRA2, IsHigh, rawDist2··········· ' measure echo pulse
· rawDist2 = rawDist2 */ Scale··············· ' convert to uS
· rawDist2 = rawDist2 / 2
· RETURN················ ' remove return trip
·· Get_Sonar3:
·· ULTRA3 = IsLow
· PULSOUT ULTRA3, Trigger···················· ' sensörü aktifle
· PULSIN· ULTRA3, IsHigh, rawDist3··········· ' measure echo pulse
· rawDist3 = rawDist3 */ Scale··············· ' convert to uS
· rawDist3 = rawDist3 / 2
RETURN
· END
________________________________________________
·
·Last weeks I bought ping))) ultrasonic sensors for making sumo robot and I use 3 ping ultrasonic sensors but..
problem:
my sumo robot have to wait 5 second· then it must work.
At the beginning of the source code:
·"pause 5000
·goto main
·main:
·............
·............"
but in this situation my ultrasonic sensor work after 5 second and not work continual. firstly work then wait 5 sn then work..[noparse]:([/noparse]
this is big problem and I have no time because competition will start a few days later.
my sumo robot must wait 5 sn please interest my problem and I wait your answer immediatly..
Your Sincerely
SOURCE FOR SUMO ROBOT
________________________________________________________
' {$STAMP BS2}
' {$PBASIC 2.5}
' 23.24 ||31.01.07
' sonicmania
'
(pin yerleþimi)
ULTRA1·· PIN······ 13·················· 'ultrasonic pini········· (sol)· yeþil- beyaz
ULTRA2·· PIN······ 12·················· '·· "······· "··········· (orta) mavi beyaz
ULTRA3·· PIN······ 14·················· '·· "······· "··········· (sag)· mavi
OUTPUT 7······························· 'sag ileri motor
OUTPUT 6······························· 'sag geri motor
OUTPUT 5······························· 'sol ileri motor
OUTPUT 4······························· 'sol geri motor
INPUT 1································ 'ön sol···· cny
INPUT 2································ 'ön sað···· cny
INPUT 0································ 'arka sol·· cny
INPUT 15······························· 'arka sað·· cny
'
[noparse][[/noparse] Program baþlanhýcý]
'
[noparse][[/noparse]ultrasonic· sabitler ]
Trigger········ CON···· 5··············· ' trigger pulse = 10 uS
Scale·········· CON···· $200············ ' raw x 2.00 = uS
RawToIn········ CON···· 889············· ' 1 / 73.746 (with **)
RawToCm········ CON···· 2257············ ' 1 / 29.034 (with **)
IsHigh········· CON···· 1··············· ' for PULSOUT
IsLow·········· CON···· 0
'
[noparse][[/noparse]ultrasonic degiskenler ]
rawDist1········ VAR···· Word
inches1········· VAR···· Word
cm1············· VAR···· Word
rawDist2········ VAR···· Word
inches2········· VAR···· Word
cm2············· VAR···· Word
rawDist3········ VAR···· Word
inches3········· VAR···· Word
cm3············· VAR···· Word
PAUSE 5000··· "Problem ih here........................................"
· main:
··· LOW 14······························· ' her tarama icin ultrasonicleri önce temizle
··· LOW 12
··· LOW 13
··· GOSUB Get_Sonar1······················ ' get sensor value
··· inches1 = rawDist1 ** RawToIn········ ' inch'e dönüþtür
··· cm1 = rawDist1 ** RawToCm
··············· ' cm'ye dönüþtür
··· GOSUB Get_Sonar2
··· inches2 = rawDist2 ** RawToIn········ ' inch'e dönüþtür
··· cm2 = rawDist2 ** RawToCm
··· GOSUB Get_Sonar3
··· inches3 = rawDist3 ** RawToIn········ ' inch'e dönüþtür
··· cm3 = rawDist3 ** RawToCm·········· ' cm'ye dönüþtür····· '
·· DO
··· IF ((cm1>130) & (cm2>130) & (cm3>130)) THEN bul· 'hepsi pasif iken , dohyo dýþý
··· IF cm1 < (cm2 & cm3) THEN· kara········ 'ultrasonicler ... sol· yakýnsa
··· IF cm2 < (cm1 & cm3) THEN· de··············· '············· ... orta yakýnsa
··· IF cm3 < (cm2 & cm1) THEN· niz········· '············· ... sag yakýnsa
··· IF ((cm1=cm2) OR (cm1=cm3) OR (cm2=cm3)) THEN· ileri '...ikisinin esitlik durumu
··· IF (IN1=1 OR IN2=1)THEN kesme1······ 'cnyler ... ön cnyler çizgide ise kesme1
··· IF (IN0=1 OR IN15=1)THEN kesme2
···· LOOP
···· kara:
·· DO· WHILE·· cm1 <( cm2 & cm3)
··· GOTO sag
···· GOSUB Get_Sonar1
······ GOSUB Get_Sonar2
········ GOSUB Get_Sonar3
····· LOOP
····· GOTO main
·· de:
··· DO· WHILE·· cm2 < (cm1 & cm3)
··· GOTO ileri
···· GOSUB Get_Sonar1
······ GOSUB Get_Sonar2
········ GOSUB Get_Sonar3
····· LOOP
····· GOTO main
·· niz:
···· DO WHILE· cm3 < (cm2 & cm1)
··· GOTO sol
···· GOSUB Get_Sonar1
······ GOSUB Get_Sonar2
········ GOSUB Get_Sonar3
···· LOOP
···· GOTO main
· bul:
···· DO· WHILE·· (cm1>130 & cm2>130 & cm3>130)·· ' bu durum yokolana kadar saga don
··· GOTO sag
···· GOSUB Get_Sonar1
······ GOSUB Get_Sonar2
········ GOSUB Get_Sonar3
····· LOOP
····· GOTO main
ileri:
·· HIGH 5
·· HIGH 7·································· 'ileri git .....
·· LOW· 4
·· LOW· 6
·· RETURN
·sag:
··· HIGH 7
··· LOW 4································ ' sag ileri motor aktif .....
··· LOW 5
··· LOW 6
··· RETURN
·sol:
··· HIGH 5
··· LOW 4································ 'sol ileri motor aktif ....
··· LOW 6
··· LOW 7
··· RETURN
kesme1:
IF cm1 <( cm2 & cm3) THEN dal1····· ' rakip solda·········· , on cnyler icin
IF cm3 <( cm2 & cm1) THEN dal2····· ' rakip sagda
LOW 5
LOW 7······························ ' bu þartlar saglanmýyorsa 1.5sn. geri gel
HIGH 4
HIGH 6
PAUSE 1000
IF (IN1=0 OR IN2=0) THEN
LOW 1
LOW 2
ENDIF
RETURN
kesme2:
IF cm1 <( cm2 & cm3) THEN dal3····· ' rakip solda········· ,arka cnyler icin
IF cm3 <( cm2 & cm1) THEN dal4····· ' rakip sagda
LOW 4
LOW 6······························ 'bu þartlar saglanmýyorsa 1.5sn. ileri git
HIGH 5
HIGH 7
PAUSE 1000
IF (IN0=0 OR IN15=0) THEN
LOW 0
LOW 15
ENDIF
RETURN
dal1:
LOW 5············· '
sadece sol geri aktif
LOW 6
LOW 7
HIGH 4
PAUSE 1000
RETURN
dal2:
LOW 4············· '
sadece sag geri aktif
LOW 5
LOW 7
HIGH 6
PAUSE 1000
RETURN
dal3:
LOW 4
LOW 6············· '
sadece sol ileri aktif
LOW 7
HIGH 5
PAUSE 1000
RETURN
dal4:
LOW 4
LOW 5
LOW 6············· '
sadece· sag ileri aktif
HIGH 7
PAUSE 1000
RETURN
Get_Sonar1:··································· ' make trigger 0-1-0
· ULTRA1 = IsLow
· PULSOUT ULTRA1, Trigger···················· ' sensörü aktifle
· PULSIN· ULTRA1, IsHigh, rawDist1··········· ' measure echo pulse
· rawDist1 = rawDist1 */ Scale··············· ' convert to uS
· rawDist1 = rawDist1 / 2
·· RETURN···································· ' remove return trip
··· Get_Sonar2:
··· ULTRA2 = Islow
· PULSOUT ULTRA2, Trigger···················· ' sensörü aktifle
· PULSIN· ULTRA2, IsHigh, rawDist2··········· ' measure echo pulse
· rawDist2 = rawDist2 */ Scale··············· ' convert to uS
· rawDist2 = rawDist2 / 2
· RETURN················ ' remove return trip
·· Get_Sonar3:
·· ULTRA3 = IsLow
· PULSOUT ULTRA3, Trigger···················· ' sensörü aktifle
· PULSIN· ULTRA3, IsHigh, rawDist3··········· ' measure echo pulse
· rawDist3 = rawDist3 */ Scale··············· ' convert to uS
· rawDist3 = rawDist3 / 2
RETURN
· END
________________________________________________
·
Comments
You clearly have taken the sample code from the PING documentation and that should work. There's nothing obvious
in your program that should cause problems with reading the PING values.
I am a little confused in your statements "IF cm1 < (cm2 & cm3) THEN". I don't think they will do what you want.
Do you mean "IF cm1 < cm2 AND cm1 < cm3 THEN"? If so, you need to change all of those IF statements.
The "&" operator is a bit-wise and operation.
pause 5000
high led
pause 50
low led
....
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
I am sure that batteries or another things is not causing the stamp to reset.. Because motors don't stop... Always running.
We changed all of "IF" statements and tested again but.... same problem... Firstly wait 5 second after measure distance than wait 5 second again and measure. If we use only one ultrasonic, there is no problem. It work... But 3 ultrasonic sensors, every time wait 5 second.
If there is any question about whether the Stamp is resetting or not, just add the following line as the first line in your program, before any labels or anything else:
DEBUG "Stamp resetting"
That should only display once during any iteration of the program.
Regards,
Bruce Bates
Post Edited (Bruce Bates) : 2/19/2007 11:23:56 AM GMT
At the beginning of the source code:
"pause 5000
goto main
main:
if we put this lines of the begining, ping))'s led low 5sn -work--low 5sn.....
but they must continual....
for examample this program work very well: firstly wait 3 sn then work..
Ping PIN 14
'
[noparse][[/noparse] Constants ]
#SELECT $STAMP
#CASE BS2, BS2E
Trigger CON 5 ' trigger pulse = 10 uS
Scale CON $200 ' raw x 2.00 = uS
#CASE BS2SX, BS2P, BS2PX
Trigger CON 13
Scale CON $0CD ' raw x 0.80 = uS
#CASE BS2PE
Trigger CON 5
Scale CON $1E1 ' raw x 1.88 = uS
#ENDSELECT
RawToIn CON 889 ' 1 / 73.746 (with **)
RawToCm CON 2257 ' 1 / 29.034 (with **)
IsHigh CON 1 ' for PULSOUT
IsLow CON 0
'
[noparse][[/noparse] Variables ]
rawDist VAR Word ' raw measurement
inches VAR Word
cm VAR Word
'
[noparse][[/noparse] EEPROM Data ]
'
[noparse][[/noparse] Initialization ]
Reset:
DEBUG CLS, ' setup report screen
"Parallax Ping Sonar ", CR,
"=====================", CR,
CR,
"Time (uS)..... ", CR,
"Inches........ ", CR,
"Centimeters... "
'
[noparse][[/noparse] Program Code ]
PAUSE 3000
Main:
DO
GOSUB Get_Sonar ' get sensor value
inches = rawDist ** RawToIn ' convert to inches
cm = rawDist ** RawToCm ' convert to centimeters
DEBUG CRSRXY, 15, 3, ' update report screen
DEC rawDist, CLREOL,
CRSRXY, 15, 4,
DEC inches, CLREOL,
CRSRXY, 15, 5,
DEC cm, CLREOL
IF cm<30 THEN
GOTO k
PAUSE 100
ENDIF
LOOP
k:
HIGH 7
PAUSE 1000
LOW 7
GOTO main
'
[noparse][[/noparse] Subroutines ]
' This subroutine triggers the Ping sonar sensor and measures
' the echo pulse. The raw value from the sensor is converted to
' microseconds based on the Stamp module in use. This value is
' divided by two to remove the return trip -- the result value is
' the distance from the sensor to the target in microseconds.
Get_Sonar:
Ping = IsLow ' make trigger 0-1-0
PULSOUT Ping, Trigger ' activate sensor
PULSIN Ping, IsHigh, rawDist ' measure echo pulse
rawDist = rawDist */ Scale ' convert to uS
rawDist = rawDist / 2 ' remove return trip
RETURN