Shop OBEX P1 Docs P2 Docs Learn Events
Need Help!! — Parallax Forums

Need Help!!

I LOVE ROBOTI LOVE ROBOT Posts: 22
edited 2007-01-23 21:38 in Robotics
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
·
·

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-20 04:17
    Hello,

    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 LOVE ROBOTI LOVE ROBOT Posts: 22
    edited 2007-01-20 04:39
    Thank chris!!

    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.
  • I LOVE ROBOTI LOVE ROBOT Posts: 22
    edited 2007-01-20 19:20
    LAST NIGHT I TRY TO RENEW THIS PROGRAM AGAIN. BUT IT STILL NOT WORK . HAVE SOMETHING WRONG WITH MY CODE. MY GOD!!!!! ***** HELP ME PLEASE ****


    __________________________________________________________________________________________________
    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
  • GadgetmanGadgetman Posts: 2,436
    edited 2007-01-20 19:53
    This is your problem:
    Main:
    PULSOUT 12,500
    PULSOUT 13,1000
    
    



    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...
  • I LOVE ROBOTI LOVE ROBOT Posts: 22
    edited 2007-01-20 21:36
    Thank guy!!!!

    So i will renew

    main:
    Pulsout 12,650
    pulaout 13,850
  • I LOVE ROBOTI LOVE ROBOT Posts: 22
    edited 2007-01-23 21:38
    !!!!!!DONE!!!!!!!·· I REPLACE SENSORS· GP2Y0D02YK· NO NEED TO USE ADC0832.· BECAUSE OUTPUT IS DIGITAL SIGNAL ALREADY. (GP2Y0A21YK ·IS ANALOG OUTPUT)

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