Let's Make Robots!

The challenge of building a 1st bot..

08/07/09

I got my arduino mega in the post a few days back and having been playing around lighting up LEDs. Thought id get started with constructing my 1st bot. Hence i rigged up 2 motors, a dual mc33887 motor driver, a 6v supply and the mega board. Uploaded a sample code to see if it would turn the motors. Voila!! Nothing happens. Nothing whirring, no sound, no ecstasy. No nothing. 

Its quite obvious that my bot wont perform with stationary wheels.

Still trying to find a solution. Images of connection, mc33887 truth table and sample code below.


 

int motor1Input1 = 4 ;    // Motor1 inputs connected to pin 4 & 2
int motor1Input2 = 2;
int motor1Pwm= 9;         // Motor1 PWM pin
int motor2Input1= 7;      // Motor2 inputs connected to pin 7 & 5
int motor2Input2= 5;
int motor2Pwm= 11;        // Motor2 PWM pin
int ledPin = 13;          // LED on pin 13

void setup()                   
{
  pinMode(motor1Input1, OUTPUT);      // sets all pins as output
  pinMode(motor1Input2, OUTPUT);
  pinMode(motor2Input1, OUTPUT);
  pinMode(motor2Input2, OUTPUT);
  pinMode(ledPin, OUTPUT);
//  pinMode(motor2Pwm, OUTPUT); > Disabled this line as analogWrite doesnt need pinMode to be defined
//  pinMode(motor1Pwm, OUTPUT); > Same as above

}

void loop()
{
  digitalWrite(motor1Input1, HIGH);   // Motor1 on
  digitalWrite(motor1Input2,LOW);
  analogWrite(motor1Pwm,255);  // Motor1 PWM Pulse

 
  digitalWrite(motor2Input1, HIGH);   // Motor2 on
  digitalWrite(motor2Input2,LOW);
  analogWrite(motor2Pwm,255);  // Motor2 PWM Pulse
  digitalWrite(ledPin,HIGH); // LED test 
}
 

MC33887 connection to Arduino Mega

 

Truth Table for MC33887

 

 

 


Update:

 

Reference from MC33887 datasheet:

 

IN1 = Logic input control of OUT1 (i.e., IN1 logic HIGH = OUT1 HIGH)

IN2 = Logic input control of OUT2 (i.e., IN2 logic HIGH = OUT2 HIGH)

EN = Enable control of device (i.e., EN logic HIGH = full operation, EN logic LOW = Sleep Mode)

OUT1, OUT2 = Output 1 and Output 2 of H-Bridge

D2 = Active LOW input used to simultaneously tri-state disable both H-Bridge outputs. When D2 is Logic LOW, both outputs are tri-stated.

D1 = Active HIGH input used to simultaneously tri-state disable both H-Bridge outputs. When D1 is Logic HIGH, both outputs are tri-stated.

 

LOGIC INPUT CONTROL AND DISABLE  (IN1, IN2, D1, AND D2):
These pins are input control pins used to control the outputs. These pins are 5.0 V CMOS-compatible inputs with hysteresis. The IN1 and IN2  independently control OUT1 and OUT2, respectively. D1 and D2 are complementary inputs used to tri-state disable the H-Bridge outputs. When either D1 or D2 is SET (D1 = logic HIGH or D2 = logic LOW) in the disable state, outputs OUT1 and OUT2 are both tri-state disabled; however, the rest of the circuitry is fully operational and the supply IQ  (standby) current is reduced to a few milliamperes.

 

Update:

 

Again, from the MC33887 datasheet:

For a DC motor to run, the input conditions need be as follows:
Enable input logic HIGH, D1 input logic LOW, D2 input logic HIGH, FS flag cleared (logic HIGH), one IN logic LOW and the other IN logic HIGH (to define output polarity). An external pull-up resistor is required at the FS pin for fault status reporting.

Two independent inputs (IN1 and IN2) provide control of the two totem-pole half-bridge outputs. Two disable inputs (D1 and D2) provide the means to force the H-Bridge outputs to a high-impedance state (all H-Bridge switches OFF). An undervoltage shutdown, output short-circuit latch-OFF, or overtemperature latch-OFF fault condition will cause the outputs to turn OFF (i.e., become high impedance or tri-stated) and the fault output flag to be set LOW. Either of the Disable inputs or V+ must be “toggled” to clear the fault flag.

If an output short circuit condition is detected, the power outputs tri-state (latch-OFF) independent of the input (IN1
and IN2) states, and the fault status output flag is SET logic LOW. If the D1 input changes from logic HIGH to logic LOW,
or if the D2 input changes from logic LOW to logic HIGH, the output bridge will become operational again and the fault
status flag will be reset (cleared) to a logic HIGH state.

--------------------------------------------------------------

 

Just to be doubly sure, I've connected the FS pin to a digital output and set it to HIGH. This doesnt seem needed though, as the datasheet states that if D2 changes from LOW to HIGH, FS is automatically reset.  

Still no joy!! 

 

--------------------------------------------------------------

 

Update:

 

Its spinning now!! and im mighty glad :)

Reconnected all pins with the following config >

D2 > PWM

IN1 > Digital Pin, HIGH or LOW

IN2 > Digital Pi, HIGH or LOW

EN > +5V

GND > Ground

D1 > GND

 

Now, onto attaching two photoresistors and get it seeking light :)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Did some of the red/green LEDs on the motor controller show anything? If you disconnect the motors, the LEDs should light up and show the motor direction & speed.

Reduce the PWM speed to a lower level, try a half speed PWM value of 127 or lower. Or make a sweep from 0 to maximum in the loop function.

Are the motors have some noise filtering? At least one capacitor 100nF between the motor connectors are needed. For bigger motors 3 capapcitors (1 between motor connectors and from each motor connector to the motor chassis) are better and the motor wires should be short as possible.

Check the FS motor false state signals.

 

Ok, Im not sure if this is supposed to mean anything, but when I disconnected one output wire of the motor and connected it directly to +6v terminal, the green LED on the controller lit up. The other output was still plugged in. When i tried the same thing vice versa, the red LED lit up.

 

I tried 127 on the PWM pin, but still no movement on the motors. Have also connected a 1uF capacitor between the terminals of each motor, which are 12V, 1Amp btw. 

 

Going to try the loop from 1 to 255 now. Im not sure how to check the FS signal though. 

 

Thank you very much for all the suggestions!

You have let D1 unconnected. It needs to be connected to GND, as shown in the truthtable.
Just tried that > Connected D1 of motor1 and motor2 to GND on arduino..No joy!! :(