Updated 6/8/15 - I've now confirmed this was a hardware issue
Hi all,
I have been using variuos codes (most recently the code from here: IBT-2 H-Bridge with Arduino – Dr Rainer Hessmer) to test out my new motor driver with my UNO clone.
I connected it to my motor (B+ and B- to 12v SMPS - M+ and M- to the Motor).
I also connected it to the Arduino as per isntructions (VCC, R_EN and L_EN to Arduino 5v - Pin 8 (GND) to Arduino GND, and LPWM + RPWM pins to Arduino D5 and D6).
The only hardware difference is that I used an LDR instead of a 10k pot for the analog input, because that's what I had handy. I took that out of the code and used the value 127 to simplify.
At firs, with any test code, I could only get it to rotate the motor one way (let's call this forwards) - by experimentation, I could achieve reverse rotation if I unplugged the wire connecting pin 8 (GND) with Arduino GND, however, with the GND wire disconnected it would then blow the motor fuse on the next FW cycle.
I realised that if I set the PWM values to 0 between direction switches, then no fuse is blown. So now I have rotation both ways, but the GND cannot be connected or I lose REV rotation.
I'm now using the code below (a heavily cut down version of the Dr Rainer code) to get rotation both ways (only works with GND disconnected).
/*
IBT-2 Motor Control Board driven by Arduino.
Speed and direction controlled by a potentiometer attached to analog input 0.
One side pin of the potentiometer (either one) to ground; the other side pin to +5V
Connection to the IBT-2 board:
IBT-2 pin 1 (RPWM) to Arduino pin 5(PWM)
IBT-2 pin 2 (LPWM) to Arduino pin 6(PWM)
IBT-2 pins 3 (R_EN), 4 (L_EN), 7 (VCC) to Arduino 5V pin
IBT-2 pin 8 (GND) to Arduino GND
IBT-2 pins 5 (R_IS) and 6 (L_IS) not connected
*/
int SENSOR_PIN = 0; // center pin of the potentiometer
int RPWM_Output = 5; // Arduino PWM output pin 5; connect to IBT-2 pin 1 (RPWM)
int LPWM_Output = 6; // Arduino PWM output pin 6; connect to IBT-2 pin 2 (LPWM)
void setup()
{
pinMode(RPWM_Output, OUTPUT);
pinMode(LPWM_Output, OUTPUT);
Serial.begin (9600);
}
void loop()
{
int sensorValue = analogRead(SENSOR_PIN);
// sensor value is in the range 0 to 1023
// the lower half of it we use for reverse rotation; the upper half for forward rotation
Serial.println (sensorValue);
//if (sensorValue > 511)
// reverse rotation
int reversePWM = 127;
analogWrite(RPWM_Output, 0);
analogWrite(LPWM_Output, reversePWM);
delay(5000);
analogWrite(RPWM_Output, 0);
analogWrite(LPWM_Output, 0);
//forward rotation
int forwardPWM = (127);
analogWrite(LPWM_Output, 0);
analogWrite(RPWM_Output, forwardPWM);
delay(5000);
analogWrite(RPWM_Output, 0);
analogWrite(LPWM_Output, 0);
}
Is there anything obvious I'm doing wrong - I'm very confused as to why:
(a) it works perfectly with the IBT_2 GND disconnected from the Arduino GND and
(b) it would not work in both directions when GND was connected.
Thanks for any help you can give me.
Steve