Shop OBEX P1 Docs P2 Docs Learn Events
Controling DC Motors using HB-25 Motor Controller. — Parallax Forums

Controling DC Motors using HB-25 Motor Controller.

Jay007Jay007 Posts: 5
edited 2007-10-31 13:49 in BASIC Stamp
Hi guys,
I'm newbie and I was searching how to control two independent DC motors (Brushed) attched to HB-25 motor controllers which is conneted to the BS2 homework board. What I'm trying to do is make both motors spin at same time at a set·voltage and after about 5-10sec later make one motor spin faster then the other by increasing the voltage? Can you please assist by showing me how the programming code would like for something like this?·

Comments

  • Steve JoblinSteve Joblin Posts: 784
    edited 2007-10-29 13:39
    Have you read the documentation? You don't control the motor speed by changing the voltage, you change it by using PWM.
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-29 13:53
    The HB-25 already has the capability of changing the motor speed by using PWM (pulse width modulation) which changes the average amount of power applied to the motor. The HB-25 looks to the BS2 like a servo motor and the descriptions of motor control of continuous motion servos in the "Robotics with the BoeBot" tutorial apply. You can download this from Parallax's website. Basically, a control pulse of 1.5ms is "off". A control pulse longer than that (up to 2.0ms) causes rotation in one direction and a control pulse shorter than that (down to 1.0ms) causes rotation in the other direction. The further the pulse width is from the "off" time, the faster the motor moves in that direction. With the Homework board, a "PULSOUT <pin>,<value>" statement will produce the pulse. A <value> of 750 is the "off" position. A <value> of 500 (roughly) is full speed in one direction while a <value> of 1000 (roughly) is full speed in the other direction. With the HB-25, you don't have to send continuous (every 20ms) pulses like you would with a conventional servo motor, you just send a pulse when the speed changes. There is a "timeout" mode with the HB-25 where you have to send a pulse every so often ... see the documentation for details.
  • Jay007Jay007 Posts: 5
    edited 2007-10-29 14:48
    hi Guys,

    You are right controlling the PWM will allow me to control the motors, but I'm not understanding the source code and how it would work. The sample souce code which was on the H-25 documentation that I downloaded from the parallax website is written in BS1 Ver 1, I m using BS2 Ver 2.5. I wans't able to find any other doumenation on HB-25, any adivse?
  • Mike GreenMike Green Posts: 23,101
    edited 2007-10-29 14:56
    What don't you understand?

    You do need to look at the tutorial www.parallax.com/detail.asp?product_id=28154.

    Have you looked at the PAUSE statement in the PBasic manual?
  • Steve JoblinSteve Joblin Posts: 784
    edited 2007-10-29 17:12
    Jay007 - I don't know what you are talking about... there is an example of using the HB-25 with a BS2 on page 8 of the HB-25 manual... http://www.parallax.com/dl/docs/prod/motors/HB-25MotorController-V1.2.pdf
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2007-10-29 20:35
    Jay007

    I'm newbie and I was searching how to control two independent DC motors (Brushed) attched to HB-25 motor controllers which is conneted to the BS2 homework board. What I'm trying to do is make both motors spin at same time at a set·voltage and after about 5-10sec later make one motor spin faster then the other by increasing the voltage? Can you please assist by showing me how the programming code would like for something like this?·

    I hope this Helps in what you want to do·

    I·have point out some of what is need
    ·
    Here is the Demo Code for the· HB-25

    This what i do would is run Part 1 until you understand how HB-25· hardware works with part 1 of the code then add part two

    The parts that are in green tell you what that line dose


    '
    [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 ]
    ·'Demo Code Part 1
    Main:
    PAUSE 20···································· ·' Wait 20 mS Before Ramping

    ·'·What I'm trying to do is make both motors spin at same time at a set·voltage and after about 5-10sec later make one motor spin faster then the other by increasing the voltage?

    FOR index = 0 TO 250·················· ·' Ramp Up To Full Speed
    ·' This line is what you change to change FOR index = 0 TO 250· (0) would = Stop
    ······················································································' (250 would = Full ON
    ·'·Any thing that is in from 1 to 249 would be your speed control
    PULSOUT HB25, 750 + index········ · ·' Motor 1 Forward
    ·' This would· make the motor run Foward ( + ) and would run ( - ) Reverse
    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
    ···················· ' Take this line out when you add Part 2

    STOP··········································' Use STOP To Prevent State Change




    '........................................................................................................................
    ················ ' Add this once you understand how the frist part works
    ···· ' Part 2

    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··········································' Use STOP To Prevent State Change

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 10/29/2007 9:12:27 PM GMT
  • Jay007Jay007 Posts: 5
    edited 2007-10-31 13:49
    Hey guys thank you for all the help, I m starting to understand the motor controller, I will be workgin on this a few days and see how it goes.
Sign In or Register to comment.