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.

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 :)
Robotfreak/Robologist, thank you very much for the tip. I had to disconnect everything and rig it up again to get it running. There did seem to be a bad capacitor. I really dont have much of an idea how to use FS, so like you said i could perhaps connect it to an input pin and let it notify if it turns LOW. Could you suggest a sample code just for this part? Or maybe a reference somewhere on the net? Thanks again.

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.

Pulling FS to HIGH isn't a good idea. These pin should be connected to an Arduino input pin or to a LED (with resistor) connected to VCC for signaling the error condition. Or reading the input pin and give out an error message when it is LOW.

When the motor controller LEDS light up, when no motor is connected, the motor controller works, so the problem is the motor, or the wiring of the motor, or motor noise (worng or no filtering capacitors). You said that you have wired a 1µF Capacitor on the motor connectors. That is not a good value, 100nF is better. Be sure not to use a polarized capacitor like an elctrolyte or tantal type. You need a bipolar type like a ceramic or polyester capacitor. Otherwise the capacitor will explode when you change the motor direction.

The datasheet states that the FS pins are open drain and should be pulled to +5 volts. Probably an 18K or better resistor would be appropriate (Ifs= 300 uA, page 10 Fault status table notes). The Fault Status pins are presented as outputs, however it states that these must be cleared (high) for operation of the h-bridge (page 23).

Open Drain and open collector outputs generally always read low unless pulled up. 

THe motor could still be a problem, but not for the reasons stated. It is possible that the motor is drtawing enough current to lower the voltage below the undervoltage lockout rating of the chip, since power is only starting at 6 volts to start with (4.4 volts is relatively close).

Yes you're right, robologist. I didn't take look in the datasheet before. The motor controller schematic  http://www.pololu.com/picture/view/0J404 shows no pullup resistors on the FS pins. They must be connected externally or the internal pullup of the Arduino inputs can be used.

 

 

After going through the datasheet again, I've connected the following pins and set them as such :

FS > HIGH

EN > HIGH

D2 > HIGH

IN1 > HIGH

IN2 > LOW

D1 > LOW

 Nothing turning yet...

AT LAST!!!

Got it turning!! ... I removed all connections, reconnected and tested it on one output. It works!! :)