Shop OBEX P1 Docs P2 Docs Learn Events
HB25 speed — Parallax Forums

HB25 speed

StampyStampy Posts: 26
edited 2014-08-21 17:19 in Robotics
Hello,
I am trying to get my two drive motors ( the parallax aluminum cased ones) to operate at a very slow speed. Seems they are too fast and very dangerous to use while indoors.
I need them to operate at a "snails pace". I am use the motors with the HB25, and the controller is a BS2. I cant seem to find the right code using the pulsout command as in the
HB25 demo code to get it to always operate slow whether moving forward o backwards. Any help here would be great, thank you!

Comments

  • TtailspinTtailspin Posts: 1,326
    edited 2014-07-27 08:12
    Welcome Stampy,
    Can you post the code you are trying to use? it will help to see what is happening to your HB25.


    -Tommy
  • PublisonPublison Posts: 12,366
    edited 2014-07-27 08:24
    Welcome to the forum!

    I edited your title since I assume you wanted to say "Speed", not "Spped".
  • StampyStampy Posts: 26
    edited 2014-07-27 19:44
    Here is some test code I have been playing with. Its a very basic start, but...


    '
    [ Variables ]
    'index VAR Word ' Counter For Ramping

    '
    [ Initialization ]
    DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
    LOW HB25
    LOW HB25A ' 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 HB25A, 750 ' Stop Motor 2 (If Connected)
    ' The Above 2 Lines May Be Removed
    ' If You Are Using Single Mode
    '
    [ Program Code ]
    'Reverse motiom
    PULSOUT HB25, 650
    PAUSE 1
    PULSOUT HB25A, 650
    PAUSE 2000
    'Stop motion
    PULSOUT HB25, 750
    PAUSE 1
    PULSOUT HB25A, 750
    PAUSE 2000
    'Forward motion
    PULSOUT HB25, 850
    PAUSE 1
    PULSOUT HB25A, 850
    PAUSE 1000
    'STOP

    I plan on using a remote control to make the robot go forward, backwards, turns.....
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2014-07-27 21:23
    You get the motor to turn more slowly by choosing a speed very close to the 750 neutral setting. By very close, I mean a difference of 5-30, or so. Try values of 720 to 780, and adjust as needed.

    But bear in mind that at too slow of a PWM to the motors they just may not function. You will find that at certain very slow speeds there's not enough power to move the robot's weight.
  • StampyStampy Posts: 26
    edited 2014-07-28 17:07
    Hi Gordon, and thank you,
    I did some testing and found the best values t use are like 850 for a slow forward, 650 for a slow reverse and of curse 750 to stop. But when I run the forward and reverse, it only runs for a short time
    then stop. I'd need them to keep running until I tell them to stop . The idea is.. push a button to move forward or reverse (slowly) , and immediately stop when I release button.
  • TtailspinTtailspin Posts: 1,326
    edited 2014-07-28 19:04
    Is that code from the 'Whats a Microcontroller' text?

    We so seldom get stray BS2 questions in the Robot Forum,..Please, have some cookies...:)
    InaPinch2.JPG



    -Tommy
    800 x 600 - 414K
  • W9GFOW9GFO Posts: 4,010
    edited 2014-07-28 23:27
    Stampy wrote: »
    But when I run the forward and reverse, it only runs for a short time
    then stop. I'd need them to keep running until I tell them to stop.

    The HB25 should run indefinitely with a single pulse command. The exceptions are - if it receives an invalid pulse or if the timeout mode has been enabled. If it is stopping after four seconds then you have likely enabled the timeout mode.
  • StampyStampy Posts: 26
    edited 2014-07-29 16:34
    That timeout enable might be it. I did try to disable per the instructions, but still no luck. I may be looking into trying one of the Sabertooth RC Motor controllers instead of the HB25 I think.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-07-29 17:39
    I have code somewhere that will control 1 or 2 HB 25's using the standard Remote Control that Parallax sells. It also works with a couple of my Sony remotes. I know it works well as it is what I was using for my Wild Thumper when I was working on it. Let me know if you want it and I will post it here.
  • StampyStampy Posts: 26
    edited 2014-07-30 17:25
    Hi Andy, and thank you. Any help at this point would be greatfull. Id love to give it another try.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-07-30 21:36
    Attached is a .zip file of several BS2 programs that work with the HB-25. The one titled Working_Sony_Remote_IR is the one I used with a few different Sony remotes and also on the remote that Parallax sells. The others are just various tests, etc. that do work so give them a try also. Hope this helps. PM me if you have any issues.
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2014-07-31 09:24
    Stampy wrote: »
    But when I run the forward and reverse, it only runs for a short time then stop. I'd need them to keep running until I tell them to stop .

    The code you posted runs the motors in each direction for a few seconds. It's a demonstration.

    Post the code you're using that shows your problem.
  • StampyStampy Posts: 26
    edited 2014-08-01 12:15
    The code I posted earlier is basically the code I've been tinkering with. In short, a simple: Pulsout HB25, 650 command seems to run for a short period.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-01 15:41
    Did any of the code I sent you help? Although it is a bit sloppy, the code does work.
  • StampyStampy Posts: 26
    edited 2014-08-01 16:44
    Yes, thank you. I have been running little test with the code. I will keep plugging away at it, hopefully some good results. ans since I don't have a sony remote, Im using a simple RF TX/RX 433hz from Adafruit for my remote control needs.
  • StampyStampy Posts: 26
    edited 2014-08-03 07:35
    So, this is the basic code that I've been trying to get the BS2 to control the HB25 and Parallax motors. The code looks so basic yet the motors will either runs fast, runs slow, stops after a couple seconds, or only one side will run at a time, I just don't know what gives here, any other tried and true ideas? You will also note 0'Im trying to control it via a simple RF device.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    HB25 PIN 7 ' I/O Pin For HB-25
    HB25A PIN 6
    '
    [ Initialization ]
    DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
    LOW HB25 ' Make I/O Pin Output/Low
    LOW HB25A ' 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 HB25A, 750 ' Stop Motor 2
    PAUSE 1
    '---RF Dongle Inputs--
    RFKEYS: '4-channel RF TX/RX module
    IF IN12=1 THEN FWD:
    IF IN11=1 THEN RV:
    IF IN10=1 THEN LFT:
    IF IN9=1 THEN RT:
    GOTO RFKEYS
    '---Operation
    FWD: 'Foward motion
    PULSOUT HB25,850
    PAUSE 1
    PULSOUT HB25A,850
    PAUSE 1
    GOTO RFKEYS
    RV: 'Reverse motion
    PULSOUT HB25,650
    PAUSE 1
    PULSOUT HB25A,650
    PAUSE 1
    GOTO RFKEYS
    LFT: 'Left turn
    PULSOUT HB25,650
    PAUSE 1
    PULSOUT HB25A,850
    PAUSE 1
    GOTO RFKEYS
    RT: 'Right turn
    PULSOUT HB25,850
    PAUSE 1
    PULSOUT HB25A,650
    PAUSE 1
    GOTO RFKEYS
  • TtailspinTtailspin Posts: 1,326
    edited 2014-08-03 10:52
    Mode 2 Communication
    Independent control of both HB-25 units through a single I/O line is accomplished by sending two
    sequential pulses with a pause of 1.1 ms between them. When in Mode 2, the HB-25 looks for two
    sequential pulses and only responds to the second one. In reference to the diagram in Figure 4, Unit 1
    would respond to Pulse #1, and Unit 2 would respond to Pulse #2. Unit 2 looks for Pulse #1, pauses for
    a 1 ms hold-off time, then looks for Pulse #2. Therefore, the timing between Pulse #1 and Pulse #2 is
    important, and there should be a minimum of 1.1 ms between pulses.
    Only unit one should have its 'Mode' jumper pin installed, Unit two should not have its Mode jumper pin installed.

    Also note the pause of 1.1 ms between sequential pulses.

    But wait! there's more!,
    Just as in Mode 1, the HB-25 observes a 5 ms hold-ff time after the second pulse, so there should be a
    5.25 pause after the second pulse. If a pulse were to start before the end of this hold-off time it might
    be seen as a shorter pulse than it is since the first part was cut off...
    You might have to fiddle with your pause times, and see if that helps.

    I got that information from here: http://www.parallax.com/downloads/hb-25-motor-controller-product-documentation

    -Tommy
  • StampyStampy Posts: 26
    edited 2014-08-04 05:23
    Yes, thank you. That is why I put the two HB25's on seperate I/O pins. It does actually work too and have found that the jumper on each one does have to be installed. Guess I will have to keep tweeking the timing.
  • StampyStampy Posts: 26
    edited 2014-08-06 18:37
    Well, I think I've found my HB25 issue. I have two of them. One of them will run fine with the pulsout HB25 command. Its the second one that stops after a couple of seconds. I guess I may have damaged that second one. No matter what I send to it, it always stops after a couple of seconds.
  • garyggaryg Posts: 420
    edited 2014-08-07 09:38
    Hi Stampy
    The stopping after a couple of seconds thing really sounds like "Communication Timeout Mode" setting being not where you want it.
    This was mentioned in post #8, but it was pretty easy to miss.
    The link in Post #18 will get you the manual for the HB25. Please consider re-reading the Communication Timeout Mode portion of the document.
    It's near the end of the document.
    I had similar troubles with my HB-25's, but once I understood the Communication Timeout thing, I was able to have great success in controlling my
    motors.

    Just a couple of thoughts.
    Gary
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2014-08-07 12:08
    Stampy wrote: »
    the motors will either runs fast, runs slow, stops after a couple seconds, or only one side will run at a time,

    Apart from any other issues -- a bad HB25, etc. -- your program isn't helping much. If you just want to test the motor, just send ONE of them a single command, say

    PULSOUT HB25,850
    PAUSE 1

    and that's it. Don't try to read your RF input, don't try to handle multiple motors, and so on.

    The secret to troubleshooting is to simplify to the bare minimum. Who knows where the problem is with the motors. You're testing both motors at a time, and you trying to integrate a control interface that may also be an issue. To test a motor all you need is to set up an HB25, give it a pulse and a pause, and if the Mode jumper is set correctly, it should continue with that speed and direction until you tell it otherwise, or remove power.

    You don't mention how you're powering the motor(s). Trying to run largish motors off the same power supply as the one powering the BS2 is a good way to lose hair. Your motors could be drawing excessive current, and if the power supply can't handle it, and the BS2 is connected to the same one, the poor board will constantly get reset. You can check for this by connecting up an LED or little piezo speaker, and upon initial start of your program you run a little "tada!" routine -- blink the LED or sound a short tone. If that routine keeps re-running, you know the BS2 is going into brownout, and is resetting itself over and over.
  • StampyStampy Posts: 26
    edited 2014-08-07 14:10
    Hello,
    Thanks for all the input. Yes I am aware of the communication timeout feature already. I have unable to correct the issue with the one HB25, which I have also
    tested it by itself with a simple command as indicated above. This in turn proved to me that the other HB25 that I have is now working just fine. So now I have one
    fully working one and one no so. For power to these I have used either a 12V 7A battery as well as a hefty bench power supply. I still suspect that one faulty one is
    really bad because at one point during a test, I had the motors switching directions rather violently. No smoke, but I'm sure one of them got damaged somehow. At least I now have one good one to work with.
    Eventually, the next phase is to get the RF input connected again,and finally to add the sonar sensor for the forward motion safety sensor.
  • Matt GillilandMatt Gilliland Posts: 1,406
    edited 2014-08-08 11:04
    Hi Stampy - Let's get you up and running :thumb:
    Please send (to my attention) the one that isn't working, and email me your shipping address. My email is mattg@parallax.com.

    -MattG
  • StampyStampy Posts: 26
    edited 2014-08-20 17:26
    Hey Matt, I did receive the HB25 the other day, thank you. Now am back to trying to get the these HB25, motors and the 4-ch RF keyfob to work, and so far have had some success . Now am trying to figure out how to make the motors stop when I release a press button on my keyfob.
    Here is what Ive got working mostly... any other ideas will be great. You will note each HB25 is on a separate pin. This does seem to work fine.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    '
    HB25 PIN 7 ' I/O Pin For HB-25
    HB25A PIN 6
    '
    [ Initialization ]
    DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
    LOW HB25 ' Make I/O Pin Output/Low
    LOW HB25A ' 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 HB25A, 750 ' Stop Motor 2
    PAUSE 1
    '---RF Dongle Inputs--
    RFKEYS: '4-channel RF TX/RX module
    IF IN12=1 THEN FWD:
    IF IN11=1 THEN RV:
    IF IN10=1 THEN LFT:
    IF IN9=1 THEN RT:
    GOTO RFKEYS
    '---Operation
    FWD: 'Foward motion
    PULSOUT HB25,850
    PAUSE 1
    PULSOUT HB25A,850
    PAUSE 1
    GOTO RFKEYS
    RV: 'Reverse motion
    PULSOUT HB25,650
    PAUSE 1
    PULSOUT HB25A,650
    PAUSE 1
    GOTO RFKEYS
    LFT: 'Left turn
    PULSOUT HB25,650
    PAUSE 1
    PULSOUT HB25A,850
    PAUSE 1
    GOTO RFKEYS
    RT: 'Right turn
    PULSOUT HB25,850
    PAUSE 1
    PULSOUT HB25A,650
    PAUSE 1
    GOTO RFKEYS
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-20 18:28
    It is much easier to read if you use code tags when pasting cone in to your replies.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    '---------------------------------------------------------------------------
    HB25 PIN 7 ' I/O Pin For HB-25
    HB25A PIN 6
    ' -----[ Initialization ]--------------------------------------------------
    DO : LOOP UNTIL HB25 = 1 ' Wait For HB-25 Power Up
    LOW HB25 ' Make I/O Pin Output/Low
    LOW HB25A ' 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 HB25A, 750 ' Stop Motor 2
    PAUSE 1
    '---RF Dongle Inputs--
    RFKEYS: '4-channel RF TX/RX module
    IF IN12=1 THEN FWD:
    IF IN11=1 THEN RV:
    IF IN10=1 THEN LFT:
    IF IN9=1 THEN RT:
    GOTO RFKEYS
    '---Operation---------
    FWD: 'Foward motion
    PULSOUT HB25,850
    PAUSE 1
    PULSOUT HB25A,850
    PAUSE 1
    GOTO RFKEYS
    RV: 'Reverse motion
    PULSOUT HB25,650
    PAUSE 1
    PULSOUT HB25A,650
    PAUSE 1
    GOTO RFKEYS
    LFT: 'Left turn
    PULSOUT HB25,650
    PAUSE 1
    PULSOUT HB25A,850
    PAUSE 1
    GOTO RFKEYS
    RT: 'Right turn
    PULSOUT HB25,850
    PAUSE 1
    PULSOUT HB25A,650
    PAUSE 1
    GOTO RFKEYS
    
  • StampyStampy Posts: 26
    edited 2014-08-21 17:12
    code tags??
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-08-21 17:19
    Click Go Advanced, then highlight your code and select the #. For some reason my original was over written.
Sign In or Register to comment.