Shop OBEX P1 Docs P2 Docs Learn Events
(Untitled) — Parallax Forums

(Untitled)

irkris77irkris77 Posts: 10
edited 2010-04-27 01:21 in Robotics
I am currently converting a power wheels jeep into an autonomous vehicle. I am using 2 HB25 motor controllers and a BS2 Bot . 1 controller is used for steering and 1 for the drive motor. I have most of the code written but I am stuck on the steering. I am using a potentiometer to track position, but, I can not get the motor to go to a given position on the pot. Any help anyone can give would be greatly appreciated. I am also posting the code i have

Comments

  • irkris77irkris77 Posts: 10
    edited 2010-04-23 00:25
    Posted Today 4:33 PM (GMT -7) Edit post Delete post
    HB25 PIN 14 ' I/O Pin For HB-25


    '
    [noparse][[/noparse] Variables ]
    result VAR Word
    true CON 1
    false CON 0

    index VAR Word ' Counter For Ramping
    counter VAR Word
    DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
    LOW HB25 ' Make I/O Pin Output/Low
    PAUSE 6 ' Wait For HB-25 To Initialize
    PULSOUT HB25, 750 ' Stop Motor 1
    PAUSE 1 ' 1 mS Delay
    PULSOUT HB25, 750











    Main:
    DO


    GOSUB POT_READING
    DEBUG DEC result, LF

    'ruleFired = false
    Rule1:
    IF (result < 2112) THEN'AND (ruleFired = false) THEN
    PULSOUT 12, 650
    GOSUB RIGHT
    'ruleFired = True
    DEBUG "rule 1 ",CR,LF
    ENDIF
    PAUSE 200



    'Rule2:

    ' IF (result > 2112) THEN'AND (ruleFired = false) THEN

    ' GOSUB Rightcenter
    'ruleFired = True
    ' DEBUG "rule 2 ", CR, LF
    ' ENDIF
    ' PAUSE 200


    Rule3:
    IF (result > 2112) THEN'AND (ruleFired = false) THEN
    PULSOUT 12, 650
    GOSUB left
    'ruleFired = True
    DEBUG "rule 3 ", CR, LF

    ENDIF

    LOOP



    'SUB POT READING'''''''''''''''''''''

    POT_READING:
    HIGH 7
    PAUSE 200
    RCTIME 7,1,RESULT
    DEBUG ? RESULT
    'GOTO POT_READIN
    RETURN


    'SUB TURNE RIGHT

    Right:
    FOR counter = 1 TO 100

    PULSOUT 14, 650

    PAUSE 20
    NEXT
    GOTO MAIN


    Left:

    FOR counter = 1 TO 100

    PULSOUT 14, 850

    PAUSE 2
    NEXT
    GOTO Main

    forward:
    DO
    PULSOUT 12, 650
    PAUSE 20
    LOOP
    END



    Rightcenter:
    FOR counter = 1 TO 100

    PULSOUT 14, 760
    PAUSE 2
    NEXT
  • irkris77irkris77 Posts: 10
    edited 2010-04-23 00:25
    Posted Today 4:33 PM (GMT -7) Edit post Delete post
    HB25 PIN 14 ' I/O Pin For HB-25


    '
    [noparse][[/noparse] Variables ]
    result VAR Word
    true CON 1
    false CON 0

    index VAR Word ' Counter For Ramping
    counter VAR Word
    DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
    LOW HB25 ' Make I/O Pin Output/Low
    PAUSE 6 ' Wait For HB-25 To Initialize
    PULSOUT HB25, 750 ' Stop Motor 1
    PAUSE 1 ' 1 mS Delay
    PULSOUT HB25, 750











    Main:
    DO


    GOSUB POT_READING
    DEBUG DEC result, LF

    'ruleFired = false
    Rule1:
    IF (result < 2112) THEN'AND (ruleFired = false) THEN
    PULSOUT 12, 650
    GOSUB RIGHT
    'ruleFired = True
    DEBUG "rule 1 ",CR,LF
    ENDIF
    PAUSE 200



    'Rule2:

    ' IF (result > 2112) THEN'AND (ruleFired = false) THEN

    ' GOSUB Rightcenter
    'ruleFired = True
    ' DEBUG "rule 2 ", CR, LF
    ' ENDIF
    ' PAUSE 200


    Rule3:
    IF (result > 2112) THEN'AND (ruleFired = false) THEN
    PULSOUT 12, 650
    GOSUB left
    'ruleFired = True
    DEBUG "rule 3 ", CR, LF

    ENDIF

    LOOP



    'SUB POT READING'''''''''''''''''''''

    POT_READING:
    HIGH 7
    PAUSE 200
    RCTIME 7,1,RESULT
    DEBUG ? RESULT
    'GOTO POT_READIN
    RETURN


    'SUB TURNE RIGHT

    Right:
    FOR counter = 1 TO 100

    PULSOUT 14, 650

    PAUSE 20
    NEXT
    GOTO MAIN


    Left:

    FOR counter = 1 TO 100

    PULSOUT 14, 850

    PAUSE 2
    NEXT
    GOTO Main

    forward:
    DO
    PULSOUT 12, 650
    PAUSE 20
    LOOP
    END



    Rightcenter:
    FOR counter = 1 TO 100

    PULSOUT 14, 760
    PAUSE 2
    NEXT
  • rpdbrpdb Posts: 101
    edited 2010-04-27 01:21
    irkris77

    If you edit your original post with a descriptive "subject", you will probably get some feedback.

    rpdb
Sign In or Register to comment.