Controling DC Motors using HB-25 Motor Controller.
Jay007
Posts: 5
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?·
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
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?
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?
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··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