Need Help!!
I LOVE ROBOT
Posts: 22
I TRY TO RENEW THAT PROGRAM. I· USE· TWO SHARP GP2Y0A21YK CONNECT WITH ADC0832 BUT SENSORS IT NOT WORK. AND BOE BOT JUST TURN AROUND ·ONLY.·SOMEBODY HELP ME··PLEASE
' {$Stamp bs2}
'{$PBASIC 2.0}
' This program·a Boe Bot with it's built on Two Sharp·GP2Y0A21YK IR sensor Connect· with ADC0832· (CH0 AND CH1)
·
' Variable declarations
pulse_count··· VAR· Byte····· ' For...next loop counter.
CS·· ······CON··· 0··········· ······' ADC0832 chip select
CLK····· CON··· 1················· ' ADC0832 clock line
D0··· ·····CON··· 2············· ····' ADC0832 data output
DI······ ··CON··· 3··········· ·······' ADC0832 data input
adcbits···· VAR· ·Byte········· ·· ' Variable for A/D data
' Main routine
Main:
· PULSOUT 12,500
· PULSOUT 13,1000
· HIGH cs
· LOW cs
· LOW CLK····································· '·· Set ADC0832's clock pin low.
· PULSOUT CLK,210····················· '·· Start pulse.
· SHIFTOUT DI,CLK,MSBFIRST,[noparse][[/noparse]adcbits]
· SHIFTIN D0,CLK,MSBPOST,[noparse][[/noparse]adcbits\8]··········· '·· Shift in valid data bits.
· IF adcbits > 100 THEN u_turn
·
· GOTO main
· '
Navigation Routines
· U_turn:
·FOR pulse_count = 0 TO 80
· PULSOUT 12, 500
· PULSOUT 13, 500
· PAUSE 20
· NEXT
· GOTO main
·
·
' {$Stamp bs2}
'{$PBASIC 2.0}
' This program·a Boe Bot with it's built on Two Sharp·GP2Y0A21YK IR sensor Connect· with ADC0832· (CH0 AND CH1)
·
' Variable declarations
pulse_count··· VAR· Byte····· ' For...next loop counter.
CS·· ······CON··· 0··········· ······' ADC0832 chip select
CLK····· CON··· 1················· ' ADC0832 clock line
D0··· ·····CON··· 2············· ····' ADC0832 data output
DI······ ··CON··· 3··········· ·······' ADC0832 data input
adcbits···· VAR· ·Byte········· ·· ' Variable for A/D data
' Main routine
Main:
· PULSOUT 12,500
· PULSOUT 13,1000
· HIGH cs
· LOW cs
· LOW CLK····································· '·· Set ADC0832's clock pin low.
· PULSOUT CLK,210····················· '·· Start pulse.
· SHIFTOUT DI,CLK,MSBFIRST,[noparse][[/noparse]adcbits]
· SHIFTIN D0,CLK,MSBPOST,[noparse][[/noparse]adcbits\8]··········· '·· Shift in valid data bits.
· IF adcbits > 100 THEN u_turn
·
· GOTO main
· '
Navigation Routines
· U_turn:
·FOR pulse_count = 0 TO 80
· PULSOUT 12, 500
· PULSOUT 13, 500
· PAUSE 20
· NEXT
· GOTO main
·
·
Comments
Your program is hard-coded to make the robot spin around in circles. That is exactly how you have it written. The pulse values for the servos are fixed and can never change in your program so the robot is doing exactly what you described and told it to.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
I want boe bot to move forward. But when sensors left or right detect something. Boe bot will turn around 2 second and then move forward again.
__________________________________________________________________________________________________
This program a Boe Bot with it's built on Two Sharp GP2Y0A21YK IR sensor Connect with ADC0832 (CH0 AND CH1)
' Variable declarations
pulse_count VAR Byte ' For...next loop counter.
CS CON 0 ' ADC0832 chip select
CLK CON 1 ' ADC0832 clock line
D0 CON 2 ' ADC0832 data output
DI CON 3 ' ADC0832 data input
LEFT VAR Byte
RIGHT VAR Byte
AD VAR Byte
' Main routine
Main:
PULSOUT 12,500
PULSOUT 13,1000
HIGH cs
LOW cs
LOW CLK ' Set ADC0832's clock pin low.
PULSOUT CLK,210 ' Start pulse.
SHIFTIN d0,clk,MSBPOST,[noparse][[/noparse]AD\8] ' Shift in valid data bits
SHIFTOUT DI,CLK,MSBFIRST,[noparse][[/noparse]AD]
IF (LEFT > 100)AND (RIGHT > 100) THEN U_turn
IF (LEFT > 100)THEN TURN_RIGHT
IF (RIGHT > 100)THEN TURN_LEFT
GOTO main
'
Navigation Routines
U_turn:
FOR pulse_count = 0 TO 80
PULSOUT 12, 500
PULSOUT 13, 500
PAUSE 20
NEXT
TURN_RIGHT:
FOR pulse_count = 0 TO 20
PULSOUT 13,850
PULSOUT 12,850
PAUSE 20
NEXT
TURN_LEFT:
FOR pulse_count = 0 TO 20
PULSOUT 13,650
PULSOUT 12,650
PAUSE 20
NEXT
GOTO main
These two lines causes it to go round and round and round and...
(Basically, you're telling the servos on 12 and 13 to rotate at different speeds)
Fix them first...
Then you can fix the 'u-turn' routine which seems to go straight ahead...
(In there, both servos always rotate at the same speed)
Anyway, you may want to SWITCH OFF THAT D@MN CAPS LOCK!
It is considered YELLING, and very rude...
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Don't visit my new website...
So i will renew
main:
Pulsout 12,650
pulaout 13,850
THIS PROGRAM· USE 2 SENSORS· 2 LED· 2 SERVO AND 1·SPEAKER.
'{$STAMP BS2}
'{$PBASIC 2.5}
PRO· VAR· Byte
FREQOUT 4,2000,3000
DO
IF(IN1=1)AND(IN0=1)THEN
HIGH 2
HIGH 3
GOSUB BACK_UP
GOSUB TURN_LEFT
GOSUB TURN_LEFT
ELSEIF (IN1=1)THEN
HIGH 3
GOSUB BACK_UP
GOSUB TURN_RIGHT
ELSEIF (IN0=1)THEN
HIGH 2
GOSUB BACK_UP
GOSUB TURN_LEFT
ELSE
LOW 2
LOW 3
GOSUB FORWARD
ENDIF
LOOP
FORWARD:
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
RETURN
TURN_LEFT:
FOR PRO = 0 TO 20
PULSOUT 13,650
PULSOUT 12,650
PAUSE 20
NEXT
RETURN
TURN_RIGHT:
FOR PRO = 0 TO 20
PULSOUT 13,850
PULSOUT 12,850
PAUSE 20
NEXT
RETURN
BACK_UP:
FOR PRO = 0 TO 20
PULSOUT 13,650
PULSOUT 12,850
PAUSE 20
NEXT
RETURN