Shop OBEX P1 Docs P2 Docs Learn Events
Enquiry on hb25 programming — Parallax Forums

Enquiry on hb25 programming

b0ib0i07b0ib0i07 Posts: 33
edited 2010-09-26 23:30 in BASIC Stamp
I m currently using bs2 to program hb25 to drive a 12v dc motor.
From what i know : pulsout, pin number,duration can signal a motor to move.
I will like to know why do i need to loop this statement and how does the duration affect the movement of the motor. Like 750 is stop.
And how do i set the motor to lets say move 20 degree clockwise?

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2010-09-25 05:13
    The hb25 is designed to operate the motor at various speeds forward or backwards based on a single PULSOUT command.
    To position at 20 degrees clockwise, you'll need to provide some form of feedback so the controller knows whether to move fwd or rev to get to the desired position.
    You don't give much in the way of detail of what your aims are, but a servo may be better suited to your needs.
    Based on the pulse-width of the PULSOUT command a servo WILL move to a particular position and hold there as long as you keep refreshing the PULSOUT command several times a second.
    Cheers,
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-09-25 07:28
    I hope that I am not hi jacking this post by asking this question

    I want to ask about this comment about the PULSOUT command several times a second.

    Then would I be able to run a routine using a optic sensor to keep track how far the motor has moved


  • b0ib0i07b0ib0i07 Posts: 33
    edited 2010-09-25 07:55
    stamptrol wrote: »
    The hb25 is designed to operate the motor at various speeds forward or backwards based on a single PULSOUT command.
    To position at 20 degrees clockwise, you'll need to provide some form of feedback so the controller knows whether to move fwd or rev to get to the desired position.
    You don't give much in the way of detail of what your aims are, but a servo may be better suited to your needs.
    Based on the pulse-width of the PULSOUT command a servo WILL move to a particular position and hold there as long as you keep refreshing the PULSOUT command several times a second.
    Cheers,

    So lets say : "pulsout, pin14, 850" is use to move e motor 20 degree clockwise. So if i want to hold it in the 20 degree position, do i just simply loop this single command?

    Or can i use "pulsout, pin14, 750" to stop the motor after it reaches that position?
  • stamptrolstamptrol Posts: 1,731
    edited 2010-09-25 12:09
    Again, the hb25 is for controlling motor speed and direction, not position.

    So, your code would make the motor run slowly in one direction until you told it to stop. Without independently measuring position, the Stamp will not know when to tell the hb25 to stop the motor. If you measure the position by some method, as Sam has asked, you have just made a servo.

    On the other hand, those commands fed to a packaged servo would make the servo move to some definite position and stop as long as the signal was repeated a few times a second. When you send "pulsout, pin14, 750" it would return to zero as long as you kept sending that value. The feedback is built into the servo unit.
  • W9GFOW9GFO Posts: 4,010
    edited 2010-09-25 12:48
    b0ib0i07 wrote: »
    So if i want to hold it in the 20 degree position, do i just simply loop this single command?

    Or can i use "pulsout, pin14, 750" to stop the motor after it reaches that position?

    For a standard servo you would repeat the PULSOUT 850 command 20 times a second to hold that position.

    If you want the HB-25 to perform like a servo you must add an encoder of some form to whatever it is you are moving. You would command the HB-25 to move in a direction and then monitor that encoder. When the time comes to stop the HB-25 base upon the feedback you have received from the encoder, you would send a PULSOUT 750 command to stop the HB-25.

    Like stamptrol says, a servo may be a better fit for your need. If you were to give more detail about your project we could be more helpful.

    Rich H
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2010-09-25 13:21
    W9GFO wrote: »
    When the time comes to stop the HB-25 base upon the feedback you have received from the encoder, you would send a PULSOUT 750 command to stop the HB-25.
    Rich H

    That the most IMPORTANT part of what I need to know
  • b0ib0i07b0ib0i07 Posts: 33
    edited 2010-09-25 23:31
    :smilewinkgrin:thanks all for the help. i will try figure out that.
  • b0ib0i07b0ib0i07 Posts: 33
    edited 2010-09-26 07:56
    Sorry to disturb again.. To double confirm. Hb 25 will move with single pulse command. Means that a "pulsout pin14, 900" command will make the motor keep moving without looping the command or?
  • ercoerco Posts: 20,256
    edited 2010-09-26 08:41
    Why not just try it and see? Experimentation breeds familiarity and builds Xperts.
  • b0ib0i07b0ib0i07 Posts: 33
    edited 2010-09-26 10:08
    erco wrote: »
    Why not just try it and see? Experimentation breeds familiarity and builds Xperts.

    I tried. It didnt move.

    for index = 0 to 250
    pulsout pin14, 750 + index.

    The above 2 command made it move..
    But i dont understand it o.o
  • ercoerco Posts: 20,256
    edited 2010-09-26 10:41
    ' {$stamp bs2}
    ' {$pbasic 2.5}
    for w0 = 750 to 1000
    pulsout 14,w0
    pause 1000
    next
  • b0ib0i07b0ib0i07 Posts: 33
    edited 2010-09-26 17:57
    erco wrote: »
    ' {$stamp bs2}
    ' {$pbasic 2.5}
    for w0 = 750 to 1000
    pulsout 14,w0
    pause 1000
    next

    *correct me if i am wrong.

    The above program do move the motor. However i noticed that the motor move in increasing speed. Is there any way to move the motor at constant speed?
  • ercoerco Posts: 20,256
    edited 2010-09-26 18:17
    You're VERY welcome! Keep up the XLNT work!

    Best,

    erco
  • W9GFOW9GFO Posts: 4,010
    edited 2010-09-26 18:24
    You can drive the HB-25 just like a continuous rotation servo. Depending upon which mode the HB-25 is in you may or may not need to refresh the signal to keep it going.
    DO
    Pulsout 14, 800
    Pause 20     
    Loop
    

    Rich H
  • b0ib0i07b0ib0i07 Posts: 33
    edited 2010-09-26 19:10
    Thanks all for the help.
  • b0ib0i07b0ib0i07 Posts: 33
    edited 2010-09-26 19:55
    W9GFO wrote: »
    You can drive the HB-25 just like a continuous rotation servo. Depending upon which mode the HB-25 is in you may or may not need to refresh the signal to keep it going.
    DO
    Pulsout 14, 800
    Pause 20     
    Loop
    

    Rich H

    The above program didnt move my motor :confused:
    What are the possibilities that cause it to didnt move?
    * I am very sure nothing wrong with the wire connections..*
  • FranklinFranklin Posts: 4,747
    edited 2010-09-26 20:04
    Take a look at the two pieces of code and see what is different then play with the code until you can answer your question. That is called learning.
  • W9GFOW9GFO Posts: 4,010
    edited 2010-09-26 20:07
    Are you powering up the Basic Stamp at the same time as the HB-25? Can you power up the HB-25 a few seconds before the Stamp? Or a few seconds after?

    Rich H
  • b0ib0i07b0ib0i07 Posts: 33
    edited 2010-09-26 20:08
    OK:lol:
    I got it.
    think something wrong with the particular port.
    THANKS ALL:smilewinkgrin:
  • b0ib0i07b0ib0i07 Posts: 33
    edited 2010-09-26 20:11
    W9GFO wrote: »
    Are you powering up the Basic Stamp at the same time as the HB-25? Can you power up the HB-25 a few seconds before the Stamp? Or a few seconds after?

    Rich H

    I did tried.
    But i miss out the pause 20 i think.
    Anw, thanks for the help.
  • b0ib0i07b0ib0i07 Posts: 33
    edited 2010-09-26 23:30
    Btw, starting, my I/O 15 spoiled.
    Now is I/O 7 spoiled.
    Anyone gt any idea whats going on?

    * I just built a particular pulsout program. The program works fine on all I/O ports initially. However port 7 and 15 suddenly stop working.... *
Sign In or Register to comment.