Let's Make Robots!

The challenge of building a 1st bot..


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
  analogWrite(motor1Pwm,255);  // Motor1 PWM Pulse

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

MC33887 connection to Arduino Mega


Truth Table for MC33887






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.


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.




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!! 






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.

I wouldn not think that the FS pin is needed, as it is an output to monitor operation, but the wording in the datasheet is a bit cryptic saying that operation depends upon it being cleared, almost implying it feedsback into the internal control circuitry. Seems weird, but I guess possible. There is one h-bridge, the Infineon TLE-5206, that requires a cycling of inputs to clear an error flag to allow the h-bridge to restart operation, so it could be something similar. Disconnectiong and reconnecting is a sort of "reset" to the system that could clear any faults that occur.

You could just pull it up and not monitor it.

If you did want to check it, wire a micro pin to the connection between the FS pin and the resistor. It will read 5 volts whe evevrything is ok, and drop to near 0 if a problem occurs.

Ok, thanks for the suggestiong robologist. Btw, i came across this article regarding pull up resistors, from the arduino site:

Pullup resistors

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.

pinMode(pin, INPUT);           // set pin to input
digitalWrite(pin, HIGH);       // turn on pullup resistors


So im guessing what needs to be done to monitor FS, would be to connect it to a digital input, and read the value that comes out of it.



That's pretty much it, just read it, and can have that reading trigger something in your program if needed.
Thank you :)