2022 | Project 1 | Cameron Wilson | Individual Research | DC Motors and Motor Drivers

What is a DC motor?
A DC motor is a component that uses energy from a Direct Current to produce mechanical energy. This is done by passing an electric current through a coil in a magnetic field producing a torque which turns the motor. It is possible to reverse the direction the motor turns be flipping the direction of the current through the coil.

Motor selection – DC motors have a range of uses from things from elevators to RC cars, However not all DC motors are right for certain applications. For this project we will be choosing smaller DC motors capable of higher torques as the aim is for the motor to move an object such as a wheel or cog.

Motor driver – A motor driver is a necessity as it allows us to change the direction of the motor thus the current without causing damage to the rest of the circuit. It also allows us to use a larger voltage motor as it will bridge the connection between motors, power and the Arduino.

The L293d that we will be using is capable of controlling two motors at the same time but for the purposes of this document we will just be exploring one motor.

Purpose of code –
Explore the capabilities of DC motors and the control of them using an Arduino and motor controller to control speed and direction. In doing so discovering possible options where this could be used.

Required components –
1x Arduino Uno (Alternative Arduino boards available)
1x Breadboard (Just for ease of development) 1x DC motor (12v)
1x Battery (12v) 1x 5v logic battery 1x L293d dual H bridge A selection of jumper wires

Flow Chart

https://imgur.com/a/KFxidzN

Code

/*
CameronJamesWilson - 18019750
DC Motor - Individual Design Research
*/

//Initialisation

int RPM = 2;     
int in1 = 3;
int in2 = 4;

void setup() {

pinMode(RPM,OUTPUT);     
pinMode(in1,OUTPUT);
pinMode(in2,OUTPUT);

}

void loop() {

analogWrite(RPM,255);     //Set motor to rotate clockwise for 5 seconds
digitalWrite(in1,HIGH);   
digitalWrite(in2,LOW);    

delay(5000);

digitalWrite(in1,HIGH);  //Motor Brakes 
digitalWrite(in2,HIGH);    

delay(1000);

analogWrite(RPM,255);     //Set motor to rotate anti-clockwise for 5 seconds
digitalWrite(in1,LOW);   
digitalWrite(in2,HIGH);    

delay(5000);

digitalWrite(in1,HIGH);  //Motor Brakes 
digitalWrite(in2,HIGH);    

delay(1000);
}

Fritzing Circuit

https://imgur.com/a/NmKo2h5

Further Development Options

From this code we can easily add a way in which the motor is controlled through direct user input such as a joystick or even automated control. We could also look at increasing the amount of motors and having them controlled both individually and together.

Component Specs and Workings

Working of L293d H Bridge

L293d H Bridge Pins

Additional Comments

Images added in form of links due to lack of space of word press drive