Assignments

Subject

For my final project I need to use a fan to regulate the soil moisture if it’s too wet (more than 90% ?). For our BadgeBot project we need to use 2 DC motor to rotate the eyes of our robot. So I want to make a board with one or two motor driver.

Fabrication process

Find DC motor:

In our FabLab we sometimes recover machines that no longer work including printers. We keep the functional components and make them available to the makers. That’s how I found 2 identical DC motors in our miracle box! I tested them with an electric load to know their consumption and choose the motor driver accordingly. Each does not consume more than 200mA (with 9V power supply).

I also try to use this mini DC gearbor motor. It consumes less than 200mA (with 9V power supply).

Check the Neil’s example:

hello.H-bridge.44 Neil uses only one external supply for the motor driver and for the ATTiny44. So he uses an 5V regulator (named “IC2 5V” on the board file).

Find the good voltage regulator:

I looked in the Fab component Eagle library to find the name of this component. From the footprint of the component I deduced that is SOT23 type.

Regulator SOT23 Regulator SOT223

Choose the components:

Maximum ratings Pinout Electrical diagram
Output voltage Input voltage Electrical diagram

Design on Eagle

Ground planes

For this board I used a function that I have never been try with Eagle, the ground plane. This avoids messing with the ground routing. After doing the schematic and the routing (leaving aside the ground):

Draw a polygon around the BOARD Define it as GND signal
Define the option in the supply tab in the DRC menu Use ratsnest tool

Final result

Eagle schematic Eagle board Bantam visualization

Output Eagle board

Output Eagle schematic

Soldering

The first board soldered The final board soldered

Programming

A4953 operation

The A4953 H-bridge must be connected to 2 PWM pins of the microcontroller. The PWM is useful for varying the rotation speed of the motors. For my board I use PA7 and PB2. The The A4953 feeds the motors in 9V (VBB) and also receives the reference voltage of the microcontroller (VCC = 5V).

From the datasheet we can know how to set the pin’s state do drive the motor:

Thus it is possible to turn the motor in one direction or another, or to stop the rotation.

Problem met with my first board soldered

I tried to program my board a first time. It was a very simple program, it was supposed to run the engine and turn it off after 5 seconds. The program was uploaded well, but the engine was not running. After several checks I realized that I had not connected the LSS pin driver A4953 to the ground as indicated in the datasheet. So I soldered a jumper and my program worked normally. After that I fix this error on my Eagle schematic and soldered a new board.

First program: reverse direction

The program rotates the motor in one direction then reverses the direction every 4 seconds. For that I use the function millis which allows to let the microcontroller to do other operations, unlike the delay function. I use the digitalWrite function and set the pins in1 and in2 in opposite state.

#define in1 2 // IN1
#define in2 3 // IN2

const unsigned long duration = 4000; ///duration time before to change direction
unsigned long previousMillis = 0; ///
byte statePinIn1 = LOW;
byte statePinIn2 = HIGH;

void setup() {
  Serial.begin(9600);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);

}

void loop() {


  // If duration or more milliseconds have elapsed
  if (millis() - previousMillis >= duration) {

    // record the current value of millis
    previousMillis = millis();

    // reverse the pin's state
    statePinIn1 = !statePinIn1;
    statePinIn2 = !statePinIn2;
    digitalWrite(in1, statePinIn1);
    digitalWrite(in2, statePinIn2);
  }
}

Current peak

A current peak occurs when the motor reverses. To avoid it I have to test with a low state of the both pins to cut the rotation of the engine before to reverse.

Second program: acceleration

The program gradually increases the RPM.

Downloads

ATTiny Core

Output Eagle board

Output Eagle schematic

Links

NCP1117ST Datasheet

A4952-3 Datasheet