HB-25 Motor Controller Issues

Hi i got a HB-25 Motor Controller (#29144) however i'm having a hard time getting it to work (The documentation is http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/HB-25MotorController-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

Nathan, I don't know if you fixed this problem. Part of the problem could be that your function pulseOut calls delay in microseconds, but as i understand it the HB25 is looking for a pulse between 0.8 and 2.2 milliseconds. So in my program below, i use "delay" instead of "delayMicroseconds".

My program is below.


#define PulsePort 11
#define Switch 8
#define LED 13

int val = 0;

void setup() {
pinMode(PulsePort, OUTPUT);
pinMode(Switch, INPUT);
}

void loop(){
val = digitalRead(Switch);

if(val == HIGH) {
digitalWrite(LED, LOW);
digitalWrite(PulsePort, HIGH);
delay(1);
digitalWrite(PulsePort, LOW);
delay(20);
}

else {
digitalWrite(LED, HIGH);
}
}


What i've found is that basically when the pulse width is above zero (0.05) and below 1, the motor turns counterclockwise at basically full power. When the pulse width is 1 up to 2, the motor turns clockwise at full power. So i'm getting direction (although it's not changing at 1.5 ms), but no change in power.

Any ideas?