The challenge of building a 1st bot..
July 8, 2009
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
pinMode(motor1Input1, OUTPUT); // sets all pins as output
// pinMode(motor2Pwm, OUTPUT); > Disabled this line as analogWrite doesnt need pinMode to be defined
// pinMode(motor1Pwm, OUTPUT); > Same as above
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
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.
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 :)