Shop OBEX P1 Docs P2 Docs Learn Events
hb25 motor in fwd and reverse — Parallax Forums

hb25 motor in fwd and reverse

Let's Go!Let's Go! Posts: 124
edited 2009-04-02 20:38 in BASIC Stamp
how does one make the motor go in reverse?. i can only get fwd. any ideas? thanks

' =========================================================================
' File...... HB-25 Motor Test.bs2
' Purpose... Tests One Or Two HB-25's Connected To P15
' Author.... Parallax, Inc.
' E-mail.... support@parallax.com
' Updated... 01-18-2006
'
' {$STAMP BS2}
' {$PBASIC 2.5}
'
[noparse][[/noparse] Program Description ]
' This program tests the HB-25 by waiting for it to power up, then pulsing
' the output to ramp the motors up in opposite directions, wait 3 seconds
' then ramp them back down to a stopped position. While the code is
' written for two HB-25/motors you can use it with just one by commenting
' out or removing the lines for the second motor, commented below. If you
' have two HB-25/motors connected, remember to remove the jumper block from
' the second HB-25.
'
[noparse][[/noparse] I/O Definitions ]
HB25 PIN 15 ' I/O Pin For HB-25
'
[noparse][[/noparse] Variables ]
index VAR Word ' Counter For Ramping
'
[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
PAUSE 1 ' 1 mS Delay
PULSOUT HB25, 750 ' Stop Motor 2 (If Connected)
' The Above 2 Lines May Be Removed
' If You Are Using Single Mode
'
[noparse][[/noparse] Program Code ]
Main:
PAUSE 20 ' Wait 20 mS Before Ramping
FOR index = 0 TO 250 ' Ramp Up To Full Speed
PULSOUT HB25, 750 + index ' Motor 1 Forward
PAUSE 1 ' 1 mS Delay For Motor 2 Pulse
PULSOUT HB25, 750 - index ' Motor 2 Reverse
PAUSE 20 ' 20 mS Smoothing Delay
NEXT
PAUSE 3000 ' Wait 3 Seconds
FOR index = 250 TO 0 ' Ramp Back Down
PULSOUT HB25, 750 + index ' Motor 1 Forward Slowing
PAUSE 1 ' 1 mS Delay For Motor 2
PULSOUT HB25, 750 - index ' Motor 2 Reverse Slowing
PAUSE 20 ' 20 mS Smoothing Delay
NEXT

STOP

Comments

  • JDJD Posts: 570
    edited 2008-11-26 22:25
    Shirkey9,

    The test program should turn the motor(s) one way, pause for 3 seconds, and then turn the motor(s) in the other direction. Depending on the pulse you provide the HB-25 will determine how the motor will rotate.

    In the future, please use the attachment manager for sample code; as that makes it easier to load into the BASIC Stamp Editor. Thank you

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Joshua Donelson

    www.parallax.com
  • Let's Go!Let's Go! Posts: 124
    edited 2008-11-26 22:30
    that's what i thought, but the motor went in fwd, 2 times. can you enlighten me on the code that will reverse it or at least the tech on it. thanks
  • Mike GreenMike Green Posts: 23,101
    edited 2008-11-26 22:34
    The speed and direction of the motor is specified by the width of the control pulse received. Pulses of 1.5ms width stop the motor. Pulses shorter than 1.5ms (1.0-1.5ms) cause rotation in one direction. Pulses longer than 1.5ms (1.5-2.0ms) cause rotation in the other direction. The PULSOUT statement provides the control pulses in 2us units, so 750 produces a 1.5ms pulse.
  • SRLMSRLM Posts: 5,045
    edited 2008-11-27 00:05
    As a side note, I've found the HB-25 to be very accurate on pulse length. For a regular servo, the center might be off as much as 250 uS, but not so with the HB-25: it's exactly in the middle, at 1500 uS.
  • be80bebe80be Posts: 56
    edited 2008-11-27 03:39
    the part of the code that tills it to
    PULSOUT HB25, 750 - index ' Motor 2 Reverse
    

    make sure its a - after the 750 -
  • FranklinFranklin Posts: 4,747
    edited 2008-11-28 04:11
    And that you are actually using a BS2 not a stamp that has a different clock rate.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2008-11-28 06:49
    shirkey9,

    What is the power source for your HB25, and what is the current demand of your motors? I have seen what you describe if the HB25 was inadequately powered.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • halfblinddadohalfblinddado Posts: 59
    edited 2009-03-31 22:11
    Hi,

    What do you mean by "inadequately powered"? Are you refering to the power to the motors "posts" or the power to the pins?

    I am having problems with inconsistancy whereas the same code produces different results.

    I have read the documentation and can't figure out how to troubleshoot this.

    Thanks,

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Everything is working so why do we pay him?"


    "Nothing is working so why do we pay him?"
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-03-31 22:29
    Mike--

    I had a long wire running from a BS2p40 pin to the HB-25 control pin. It worked fine. Eventually, I changed robot brains (five Stamps for one SX48) and hooked everything back up. The HB-25 did not respond. I remembered reading about bypass capacitors. So, I stuck one between each HB25 control line, I have two·HB-25s·on my machine·(the wire from the SX48 to the HB-25 control pin), and ground.

    All problems disappeared.

    Now, I am dedicated to using bypass capacitors. Many folks say it is good practice. Here is a nice, short article on their use.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2009-04-01 05:42
    halfblinddado,

    What I meant was... The HB25 is designed to handle a decent amount of current. Don't feed it something like a 9V battery and expect it to perform, it needs more oomph than that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • halfblinddadohalfblinddado Posts: 59
    edited 2009-04-01 13:41
    Beau,

    I thought it could handle 6-16Volts? I am using the Parallax 7.2v power plug and connecting the input side of the HB25 to VIN. Is that not enough.

    I did notice that the HB25 worked better at higher speed.

    Thanks,

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Everything is working so why do we pay him?"


    "Nothing is working so why do we pay him?"
  • Beau SchwabeBeau Schwabe Posts: 6,559
    edited 2009-04-01 18:46
    halfblinddado,

    "I thought it could handle 6-16Volts?" - It can, I'm talking current here... if your current is not adequate then the HB25 might have a difficult time doing what you tell it to do.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • halfblinddadohalfblinddado Posts: 59
    edited 2009-04-02 19:01
    Hello,

    Obviously I don't have a lot of experience with this so could you tell me what the voltage and current should be to make tis work?

    I have attached a schematic of my setup.

    The voltage applied to the HB25(s) is 6-12V at 2Amps

    The motors I am driving are small hobby motors.

    Tamiya FA-130

    Voltage: 1.5-3V (1.5V Recommended) (4.5 V max)<!--mstheme--><!--msthemelist-->

    RPM: 6990-9100 (6990 Max. Efficiency)

    Amperage: .66A

    Thanks,

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Everything is working so why do we pay him?"


    "Nothing is working so why do we pay him?"
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-04-02 19:24
    Mike--

    Nice schematic.

    Do you have the HB-25s set up in "Mode 1?" (Page 2.) That is the mode necessary for one HB-25 to control one motor. The jumper "J", must be in place. See the data.pdf, as I'm sure you have a thousand times, by now.

    I use a lot of HB-25s. I cannot say I know a lot about them because they are so easy to use. You might disconnect one of the HB-25/motor sets and work with a single set until you get everything ironed out. Cut the test code down so that it just runs a single HB-25. Forget about ramping (for now). Use something like this: PULSOUT HB25, 870 after the HB-25 is "ready."

    On the off-chance that one of your HB-25s is bad, try the other one.

    I run mine off a 12 volt, lead-acid battery. I have never tried anything else.

    When you get the bug(s) out of your setup, you will like these motor controllers.

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • halfblinddadohalfblinddado Posts: 59
    edited 2009-04-02 19:46
    Bill,

    Thanks, I have the jumper on both and am currently trying to use them seperately. I have tried what you said about disconnecting them and only using one then the other with very simple code but I still can't predict the behavior.

    Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "Everything is working so why do we pay him?"


    "Nothing is working so why do we pay him?"
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2009-04-02 20:38
    Your motors are 4.5V Max, but the HB-25 is designed to run motors from 6-16V. the minimum voltage you’re going to get is whatever your supply voltage. This is because the HB-25 controls speed by varying the duty cycle of the input voltage, not by varying the output voltage directly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Engineering
Sign In or Register to comment.