Shop OBEX P1 Docs P2 Docs Learn Events
HELP ME Plz......... — Parallax Forums

HELP ME Plz.........

I LOVE ROBOTI LOVE ROBOT Posts: 22
edited 2006-07-22 04:57 in Robotics
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

Comments

  • I LOVE ROBOTI LOVE ROBOT Posts: 22
    edited 2006-07-20 00:08
    HELP ME Plz.........
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2006-07-20 04:37
    It's hard to follow exactly what you are asking, but from the looks of your program, you don't
    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.
  • I LOVE ROBOTI LOVE ROBOT Posts: 22
    edited 2006-07-20 18:05
    hi Beau Schwabe Thankyou for your help.

    love robot love Parallax
  • I LOVE ROBOTI LOVE ROBOT Posts: 22
    edited 2006-07-20 19:10
    i review my program and i think i do someing wrong. because that program i use 3 servo motor control separate. 2 Continuous Rotation Servo (p12,p13) control by PULSOUT command. and 1 Standard Servo control by Parallax Servo Controller(p15,ch0)because i want to control position left>center>right>center for Sharp sensor.

    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
  • I LOVE ROBOTI LOVE ROBOT Posts: 22
    edited 2006-07-22 04:57
    Done !!!!!!!!!!55555555555+++++ I CAN DO

    ' {$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
Sign In or Register to comment.