HELP ME Plz.........
I LOVE ROBOT
Posts: 22
hi!
···· I have a problem·with my robot and maybe·somebody can help me.·· I uses· analog distance finder (Sharp 2YOA21)·with·A/D converter (ADC0831). I want that··Sharp 2YOA21· scan from·L>CENTER>R>CENTER and then u-turn by both wheel (p12 and p13)about 1 sec·.· So·I··mount that sensor on the··Mounting Bracket Kit from parallax.·control with Parallax Servo Controller (Serial) by p15 and Standard Servo <!-- unit price -->connect with ch0··· (i use bs2e).···· That program·is· robot go forward· and when·<!-- unit price -->·Sharp·sensor detect object in front. the robot must stop running and scan the sharp sensor form L>CENTER>R>CENTER·and u-turn about 1 sec. after that go forward again.
··· EVERYTHING LOOK GOOD BUT THE PROBLEM IS WHY Standard Servo <!-- unit price -->connect with ch0(PSC)·DID NOT move from L>CENTER>R>CENTER . very headache· some body help me plz....
' {$Stamp BS2e}
CH VAR Byte
PW VAR Word
RA VAR Byte
SDAT CON 15
BAUD CON 396
RA = 7
CH = 0
CS······· CON·· 1········· ' ADC0831 chip select
CLK······ CON·· 3········ ' ADC0831 clock line
D0······· CON·· 5········· ' ADC0831 data line
adcbits·· VAR·· Byte· ··' Variable for A/D data
·pulse_count VAR Byte
·
' Main routine
Main:
· PULSOUT 12,650
· PULSOUT 13,850
· HIGH cs··········· '·· Deselect ADC0831
· LOW cs··········· '·· "Active low" select ADC0831.
· LOW clk··········· '·· Set ADC0831's clock pin low.
· PULSOUT CLK,210········· '·· Start pulse.
· SHIFTIN d0,clk,MSBPOST,[noparse][[/noparse]adcbits\8]· '·· Shift in valid data bits.
· IF adcbits > 100 THEN U_TURN
·GOTO MAIN
·
U_TURN:
GOSUB BOY
·FOR pulse_count = 0 TO· 42
· PULSOUT 12, 500
· PULSOUT 13, 500
· PAUSE 20
NEXT
GOTO main
·
BOY:
PW = 1250
SEROUT· SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
·PAUSE 1000
PW = 750
SEROUT· SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
PAUSE 1000
PW = 250
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
PAUSE 1000
PW = 750
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
PAUSE 1000
RETURN
···· I have a problem·with my robot and maybe·somebody can help me.·· I uses· analog distance finder (Sharp 2YOA21)·with·A/D converter (ADC0831). I want that··Sharp 2YOA21· scan from·L>CENTER>R>CENTER and then u-turn by both wheel (p12 and p13)about 1 sec·.· So·I··mount that sensor on the··Mounting Bracket Kit from parallax.·control with Parallax Servo Controller (Serial) by p15 and Standard Servo <!-- unit price -->connect with ch0··· (i use bs2e).···· That program·is· robot go forward· and when·<!-- unit price -->·Sharp·sensor detect object in front. the robot must stop running and scan the sharp sensor form L>CENTER>R>CENTER·and u-turn about 1 sec. after that go forward again.
··· EVERYTHING LOOK GOOD BUT THE PROBLEM IS WHY Standard Servo <!-- unit price -->connect with ch0(PSC)·DID NOT move from L>CENTER>R>CENTER . very headache· some body help me plz....
' {$Stamp BS2e}
CH VAR Byte
PW VAR Word
RA VAR Byte
SDAT CON 15
BAUD CON 396
RA = 7
CH = 0
CS······· CON·· 1········· ' ADC0831 chip select
CLK······ CON·· 3········ ' ADC0831 clock line
D0······· CON·· 5········· ' ADC0831 data line
adcbits·· VAR·· Byte· ··' Variable for A/D data
·pulse_count VAR Byte
·
' Main routine
Main:
· PULSOUT 12,650
· PULSOUT 13,850
· HIGH cs··········· '·· Deselect ADC0831
· LOW cs··········· '·· "Active low" select ADC0831.
· LOW clk··········· '·· Set ADC0831's clock pin low.
· PULSOUT CLK,210········· '·· Start pulse.
· SHIFTIN d0,clk,MSBPOST,[noparse][[/noparse]adcbits\8]· '·· Shift in valid data bits.
· IF adcbits > 100 THEN U_TURN
·GOTO MAIN
·
U_TURN:
GOSUB BOY
·FOR pulse_count = 0 TO· 42
· PULSOUT 12, 500
· PULSOUT 13, 500
· PAUSE 20
NEXT
GOTO main
·
BOY:
PW = 1250
SEROUT· SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
·PAUSE 1000
PW = 750
SEROUT· SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
PAUSE 1000
PW = 250
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
PAUSE 1000
PW = 750
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
PAUSE 1000
RETURN
Comments
have a "PAUSE 20" anywhere within the "Main:" routine. I would try this after your "PULSOUT"
commands within the "Main:" routine.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
love robot love Parallax
i will rewrite use 3 servo control with Parallax Servo Controller. I think maybe better
Standard Servo connect = ch0
left Continuous Rotation Servo connect = ch1
right Continuous Rotation Servo connect = ch2
i will try tonight
' {$Stamp BS2e}
PW1 VAR Word
PW2 VAR Word
CH VAR Byte
PW VAR Word
RA VAR Byte
SDAT CON 15
BAUD CON 396
RA = 1
CH = 0
CS CON 1 ' ADC0831 chip select
CLK CON 3 ' ADC0831 clock line
D0 CON 5 ' ADC0831 data line
adcbits VAR Byte ' Variable for A/D data
pulse_count VAR Nib
X VAR Nib
' Main routine
Main:
PW1 = 850
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",01,RA,PW1.LOWBYTE,PW1.HIGHBYTE,CR]
PW2 = 250
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",02,RA,PW2.LOWBYTE,PW2.HIGHBYTE,CR]
PAUSE 1000
HIGH cs ' Deselect ADC0831
LOW cs ' "Active low" select ADC0831.
LOW clk ' Set ADC0831's clock pin low.
PULSOUT CLK,210 ' Start pulse.
SHIFTIN d0,clk,MSBPOST,[noparse][[/noparse]adcbits\8] ' Shift in valid data bits.
IF adcbits > 50 THEN NOOPEE
GOTO MAIN
NOOPEE:
FOR pulse_count = 0 TO 0
PW1 = 750
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",01,RA,PW1.LOWBYTE,PW1.HIGHBYTE,CR]
PW2 = 750
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",02,RA,PW2.LOWBYTE,PW2.HIGHBYTE,CR]
PAUSE 1000
NEXT
GOSUB BOY
GOSUB U_TURN
GOTO main
BOY:
PW = 1250
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
PAUSE 500
PW = 750
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
PAUSE 500
PW = 250
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
PAUSE 500
PW = 750
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",CH,RA,PW.LOWBYTE,PW.HIGHBYTE,CR]
PAUSE 500
RETURN
U_TURN:
FOR X = 0 TO 0
PW1 = 850
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",01,RA,PW1.LOWBYTE,PW1.HIGHBYTE,CR]
PW2 = 850
SEROUT SDAT,BAUD+$8000,[noparse][[/noparse]"!SC",02,RA,PW2.LOWBYTE,PW2.HIGHBYTE,CR]
PAUSE 1000
NEXT
RETURN