Shop OBEX P1 Docs P2 Docs Learn Events
Help on implementing servo positioning with HB25 — Parallax Forums

Help on implementing servo positioning with HB25

Tronic (Greece)Tronic (Greece) Posts: 130
edited 2007-01-04 10:19 in BASIC Stamp
Hello to all.

I have hard time coding·feedback control·from my motor that is driven by a HB25. What I currently do is to have the BS2 send a position pulse to HB25 and read the angle of the shaft of the motor with a pot aligned to it with the help of a ADC0831. The problem is that the motor keeps rotating before the feedback can correct the angle of the shaft by reducing its speed or stops it when the right angle reached. It overshoots and its osclillating. I gets even more bad when it has to react on faster transitions of angles. When I tried to set a debug print to monitor what happens, the extra delay almost destroyed the potentiometer by tearing it off from the motor shaft!

I intend to use two HB25 controllers doing the·such positioning job in one BS2 and plus some·other fuctions like RS232 data input·and·this behavior·worries me...

Any ideas?

Rgrds Thanos


▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


Greekbotics: Greek Robotics Forum

(Translate it using Babelfish)
·

Comments

  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2007-01-03 12:15
    This is the code I use:


    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    HB25 PIN 13 ' I/O Pin For HB-25
    Clk············ PIN···· 1······················ ' ADC0831.7 (both)
    Dio············ PIN···· 0······················ ' ADC0831.6 (both)
    CS0············ CON···· 2······················ ' ADC0831.1 (ADC 0)
    CS1············ CON···· 3······················ ' ADC0831.1 (ADC 1)

    '
    [noparse][[/noparse] Variables ]
    idx············ VAR···· Nib···················· ' ADC identifier
    adc············ VAR···· Byte(2)················ ' raw adc value
    shaftpot VAR Byte
    userpot VAR Word
    servovalue VAR Word
    centerpos CON 623

    '
    [noparse][[/noparse] Initialization ]
    DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
    LOW HB25 ' Make I/O Pin Output/Low
    PAUSE 5 ' Wait For HB-25 To Initialize
    PULSOUT HB25, 750 ' Stop Motor 1
    '
    [noparse][[/noparse] Program Code ]
    Main:

    DO
    · idx = 0
    · GOSUB Read_0831
    · userpot = adc(idx)
    · userpot = userpot * 2
    · idx = 1
    · GOSUB Read_0831
    · shaftpot = adc(idx)
    · servovalue = centerpos + (userpot - shaftpot)
    · PULSOUT HB25, servovalue···· 'set to 0 degrees before FS gaining control.
    ·· ' DEBUG DEC userpot, " ", DEC shaftpot, " ", DEC servovalue ,CR
    LOOP

    STOP ' Use STOP To Prevent State Change

    '
    [noparse][[/noparse] Subroutines ]
    ' Reads selected ADC0831
    ' -- pass unit in 'idx' (0 or 1)
    Read_0831:
    · LOW (CS0 + idx)
    · SHIFTIN Dio, Clk, MSBPOST, [noparse][[/noparse]adc(idx)\9]
    · HIGH (CS0 + idx)
    · RETURN





    Thanos


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Greekbotics: Greek Robotics Forum

    (Translate it using Babelfish)
    ·
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-01-03 15:16
    Tronic,
    ·
    ·· I don’t see how you’ll be able to do this…If you’re using a standard DC Motor it would be inclined to turn continuously whereas it seems like you want standard servo positioning.· DC Motors aren’t set up like that.· If the output shaft is not highly geared you can expect overshoot.· The HB-25 is trying to set the speed of the motor while you’re trying to set the position.· High gear ratio may help, but I don’t think it will solve your problem.· Remember too that the HB-25 requires a single pulse for a given speed.· Your loop monitoring the angle would be faster if not refreshing the HB-25 unnecessarily.· I hope this helps.· Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • Tronic (Greece)Tronic (Greece) Posts: 130
    edited 2007-01-04 10:19
    Ok, I understand what the problem is... With the 5ms gap between pulse updates that HB25 requires its going to be somehow tough to have it·work the way I want with BS2. I already have some high rate grearing on the motors output shaft.

    The only thing that remains now is to·try to make a custom feedback controller to handle the math and just let BS2 output simple servo pulses.

    Thanks anyway, Thanos


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Greekbotics: Greek Robotics Forum

    (Translate it using Babelfish)
    ·
Sign In or Register to comment.