Shop OBEX P1 Docs P2 Docs Learn Events
turn program — Parallax Forums

turn program

irkris77irkris77 Posts: 10
edited 2010-04-23 14:25 in BASIC Stamp
need a program to turn a servo motor using a hb25 and basic stamp to turn and go straing

Comments

  • FranklinFranklin Posts: 4,747
    edited 2010-04-20 22:06
    Check out the HB-25 product page for any sample code available.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • JDJD Posts: 570
    edited 2010-04-21 00:29
    irkris77,

    ·· Can you post the program that you sent me on the forums? Are you using 1 or 2 HB25 modules?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Respectfully,


    Joshua Donelson
    www.parallax.com
  • irkris77irkris77 Posts: 10
    edited 2010-04-22 23:33
    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-22 23:40
    We are using 2 HB25 motor controllers one for the drive motors and one for the steering motor . We followed the RC time circuit example and used a potentiometer to track steering position. The major difficulty we are having is trying to get the motor to turn to a center position( or any position for that matter) that corresponds with the potentiometer.
  • irkris77irkris77 Posts: 10
    edited 2010-04-22 23:41
    Please and thank youu for any assistance
  • NWCCTVNWCCTV Posts: 3,629
    edited 2010-04-23 01:26
    Might I inquire as to why you are using HB-25 controllers for Servo mtors? Seems to me a Servo PAL would serve the same purpose and are less expensive and you could use the H-25 for DC motors. Just curious!!!
  • irkris77irkris77 Posts: 10
    edited 2010-04-23 14:25
    I misspoke I am using a worm gear dc motor from a car seat. the reason for using it was it attaches easily to the shaft. However as the project has moved forward I am finding that there are better choices that make it easier to track position.
Sign In or Register to comment.