HB-25 Moter Control Issues
Hi i got a HB-25 Motor Controller (#29144) however i'm having a hard time getting it to work (The documentation is www.parallax.com/Portals/0/Downloads/docs/prod/motors/HB-25MotorControlle r-V1.2.pdf ). I have M1 & M2 hooked up to the two motor leads. then i have a 9v power supply hooked up to the HB-25's two power leads. then i have the W connector hooked up to my Arduino with the following code:
void setup() {
// make pin 10 an output pin.
// Pin 10 goes to the HB-25
pinMode(10, OUTPUT);
}
void loop() {
pulseOut(10, 2, HIGH);
}
void pulseOut(int pinNumber, int pulseWidth, int state) {
// only pulse if the pulseWidth value
// is greater than 0:
if (pulseWidth > 0) {
// if the pulse should be high, go high then low:
if (state == HIGH) {
digitalWrite(pinNumber, HIGH);
delayMicroseconds(pulseWidth);
digitalWrite(pinNumber, LOW);
delayMicroseconds(pulseWidth + 5.25);
}
// if the pulse should be low, go low then high:
else {
digitalWrite(pinNumber, LOW);
delayMicroseconds(pulseWidth);
digitalWrite(pinNumber, HIGH);
delayMicroseconds(pulseWidth + 5.25);
}
}
}
Any help you could send me would be fantastic.
Thanks,
Nathan
void setup() {
// make pin 10 an output pin.
// Pin 10 goes to the HB-25
pinMode(10, OUTPUT);
}
void loop() {
pulseOut(10, 2, HIGH);
}
void pulseOut(int pinNumber, int pulseWidth, int state) {
// only pulse if the pulseWidth value
// is greater than 0:
if (pulseWidth > 0) {
// if the pulse should be high, go high then low:
if (state == HIGH) {
digitalWrite(pinNumber, HIGH);
delayMicroseconds(pulseWidth);
digitalWrite(pinNumber, LOW);
delayMicroseconds(pulseWidth + 5.25);
}
// if the pulse should be low, go low then high:
else {
digitalWrite(pinNumber, LOW);
delayMicroseconds(pulseWidth);
digitalWrite(pinNumber, HIGH);
delayMicroseconds(pulseWidth + 5.25);
}
}
}
Any help you could send me would be fantastic.
Thanks,
Nathan
Comments
The HB-25 requires a control pulse from 1000 to 2000 microseconds in width.
It looks like you're supplying a 2 microsecond pulse which will be ignored.