Shop OBEX P1 Docs P2 Docs Learn Events
hb25 mode 2 help — Parallax Forums

hb25 mode 2 help

Let's Go!Let's Go! Posts: 124
edited 2009-11-16 18:25 in BASIC Stamp
i want to control 2 motors with 1 bs2 and 2 hb25's in mode 2. the example given for the hb25 is very convenient and simple as it has both motors doing the same routine, just in reverse.

but i want one motor to ramp up, coast, and then ramp down.·i want the other motor to go fwd and rev independently of the first motor, e.g. the motor 2 will go back and forth(fwd and rev) more frequently than motor 1. the code given by hb25 is as follows:

pause 20
for index = 0 to 250
pulsout hb25, 15, 750 + index···· 'mot 1 fwd ramp up
pause 1
pulsout hb25, 750 - index···· 'mot 2 rev ramp up
pause 20
next

Question is: can i put a subroutine in the place of pulsout hb25, 750 - index above to move mot 2 around differently, and yet continue to have mot 1 operate as shown above?

Question: can i use a "for.... next" loop above hb25, 750 - index to give a different mot 2 control than mot 1, and still have mot 1 continue its routine?

thanks, jim

Comments

  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-11-15 17:29
    Jim--

    The HB-25 is my favorite motor controller .·. . until Parallax releases the HB-50!

    I believe what you want to is use one pin to control two motors that do different things. The HB-25 documentation explains this beginning on page 2, "Modes of Operation." You are interested in Mode 2.

    I have a bunch of HB-25s, but have never used them in anything other than Mode 1 due to the high current draw of the motors in my machines.

    Good luck!

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Let's Go!Let's Go! Posts: 124
    edited 2009-11-15 18:44
    thanks bill,



    i suspect that is what i will do due to the different routine of each of the 2 motors.but if i use 2 hb25 routines, does one routine have to finish before the other, second, hb25 kicks in.



    jim
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-11-15 20:59
    Jim--

    Once you send the proper command sequence to an HB-25, you can forget it. It will continue the execution of the last command you sent until you change it or power it off. Therefore, after the first proper command sequence is sent to the first HB-25, you can then do anything you want, including giving the second HB-25 a command.

    What I have just described is a Mode 1 scenario. I have never driven an HB-25 in Mode 2, but the instructions are clear. For example, Mode 2 will allow you to send a "dual" command using a single pin. Let's say you want HB-25#1 to continue doing whatever it is doing. You would send it·the appropriate·PULSOUT--identical to the first one you sent it--and then pause 1.1ms and send another PULSOUT command on the same pin. HB-25#1 will ignore the second command. HB-25#2 will execute it. The recommended "settle down" times you see in the Parallax sample code seem trivial, but they·are vital.

    It is important to remember that most of the PULSOUT "timing" charts you see are for the BS2. Faster (or slower) microcontrollers will use different numbers. Those ranges are available, but they are also easy to discover experimentally. (I don't know where you find them online; Google is your friend, though! [noparse]:)[/noparse] )

    Have fun and help me beat Parallax up to produce that HB-50!

    My application uses DEDICATED BS2s. One is dedicated to each HB-25. Other than sit in a very tight loop awaiting commands from a "master" microcontroller, all it does is send the appropriate PULSOUT command to a single HB-25. The other HB-25 has its own dedicated BS2. Both are controlled by a single, faster Stamp.

    (By the way, I ain't one of the smart guys in any of this.)

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Let's Go!Let's Go! Posts: 124
    edited 2009-11-16 13:08
    bill, you say you aren't one of the smart guys in this, but you sure eloquently answered my question regarding using 2 single mode hb25's, which is what i'll set up. thanks a lot for your time. i have 2 hb25's in my setup and will try to run them both off 1 bs2.



    jim
  • Bill ChennaultBill Chennault Posts: 1,198
    edited 2009-11-16 14:49
    Jim--

    You are gracious. Thank you.

    Follow the HB-25 setup instructions carefully. They are simple.

    In Mode 1, you can control·ONE HB-25 with a single output pin.

    In Mode 2, you can control TWO HB-25s with a single output pin by removing the jumper on the SECOND unit, only. (The jumper on the first remains in place.) While in Mode 2, you ALWAYS send two PULSOUT commands separated by a 1.1ms pause. The first command is grabbed by HB-25#1. The second command is grabbed by HB-25#2.

    On a previous machine, I dedicated BS2s to each HB-25. I also dedicated separate BS2s to each motor optical encoder. The only thing the BS2s counting optical encoder pulses did was to send them via a single BS2 pin to another pin on the master processor, which was a BS2p40. So, the four dedicated BS2s had very little to do and never missed a beat doing it. (That was the plan.) The BS2p40 received raw encoder events from the "encoder" BS2s, implemented that data into its very simple world model, and sent commands to the two BS2s controlling the tracks, via separate HB-25s, using separate output pins.

    I never implemented handshaking of any kind due to the fact that no single processor was ever burdened in the least. This scheme worked very well. I dedicated a total of 20 pins on the master BS2p40 .·. . five for each of the BS2 devices. In reality, I am sure I could have done it using only six pins. And, if I had ever implemented Mode 2 to control the HB-25s, then that would have been reduced to three pins. (I think!)

    The reason I keep harping on the fact that Parallax needs to produce a higher current motor controller is that many people use larger motors today. The two on my tracked machine each are capable of drawing 85 amps apiece. Now, something is going to break long, long before that happens! I doubt that either one has drawn more than 10 amps.

    But, what if I wanted to pull my car with it? [noparse]:)[/noparse]

    --Bill

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    You are what you write.
  • Let's Go!Let's Go! Posts: 124
    edited 2009-11-16 16:28
    bill, are you saying that if i want to run 2 motors "simultaneously" with 2 different routines, via 1-
    bs2, 2 pins, and 2 hb25's in single mode, that i can simply power up the hb25's and run the programs, one after the other.

    i.e. one program doesn't have to complete before the other starts.

    thanks, jim
  • JDJD Posts: 570
    edited 2009-11-16 18:25
    Shirkey,

    The HB25 have a mode that Bill spoke about that enables them to be used with a single pulse; enabling a controller to send a single pulse on an I/O pin to control the speed and direction of the motor. If you used this function with 2 I/O pins you could run each motor in their respective routines and they would be controlled accordingly. However, what you would want to remember; is that the HB25 will continue to send a pulse until updated.

    Code snippet for example only

    ·· PULSOUT HB25#1, 1000
    ·· PULSOUT HB25#2, 500
    ·· PAUSE 1000

    ·· PULSOUT HB1, 750

    In the example above, the program will send a·2 and·1 ms pulse to HB25 #1 and #2 respectfully, wait 1 second, and send a stop pulse to the HB25 #1. If the HB25s were set to a single pulse mode, then HB25 #2 will continue to send a 1 ms pulse until otherwise commanded.

    I hope this helps to clarify.



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


    Joshua Donelson
    www.parallax.com

    Post Edited (Joshua Donelson (Parallax)) : 11/16/2009 6:30:20 PM GMT
Sign In or Register to comment.