Dual-Control DC Motor System

by DP - 987636 in Circuits > Arduino

65 Views, 1 Favorites, 0 Comments

Dual-Control DC Motor System

FJ97LFKLXIZK755.png

The Dual-Control DC Motor System project is a complex project involving the integration of speed and direction for a DC motor, combining a 555 timer and an L293D H-bridge to do so. This project is divided into two major parts: a speed control portion and a direction control portion. The speed of the DC motor is directly manager by the 555 timer in PWM mode, which adjusts the motor speed via user input on a potentiometer and a MOSFET transistor. The direction circuit is handled by an Arduino Uno and the H-bridge, which use a pushbutton to receive user input to toggle the direction of the motor's spin. The 555 timer's output controls the motor speed by controlling the voltage applied while on the other hand, the H-bridge works with managing current flow to switch directions. This versatile project shows the fundamental principles of motor control and has various real life applications; from robotics to automation systems, in which it can be used when dealing with precise motor control.

Supplies

1x DC Motor: $9:49

1x 9V Battery and Cap: $6.99

1x Arduino Uno 3 and connecting cable: $8:39

Several lengths of multi-coloured jumper cables: $3.34

1x P30N06LE MOSFET N-Channel Transistor: $2.75

1x 555 Timer: $0.99

1x L293D H-Bridge: $0.48

1x 10K Ohms Potentiometer: $1.49

2x 4148 Diodes: $1.98

1x 10 nF ceramic capacitor - C1: $2.05

1x 100 nF ceramic capacitor - C2: $2.05

1x 10K Ohms Resistor - R1: $2.18

1x 1K Ohms Resistor - R2: $1.46

1x 330 Ohms Resistor - R3: $0.99

1x Pushbutton: $1.18

Computer or Device with Arduino IDE Capabilities

Soldering Station access


Total Cost: $44


Note:

  1. Any MOSFET N-Channel Transistor works in this project, as long as it is appropriate size and strength to control a small DC Motor
  2. Resistor and Capacitors used for the 555 timer connection can be changed and modified in strength depending on the needs

Theory and Explanation

How does the project work?

  • Here, three main components that require further explanation are discussed more in-depth.

555 timer:

  • In this project, to achieve a constant PWM signal, the 555 timer has been wired in a somewhat astable configuration. In astable mode, the 555 timer acts as an oscillator that generates a square wave. The frequency of the wave can be adjusted by changing the values of two resistors and a capacitor connected to the chip. 
  • In astable mode, the output cycles on and off continuously. In the schematic below, notice that the threshold pin and the trigger pin are connected to C1. This makes the voltage the same at the trigger pin, threshold pin, and C1.
  • At the beginning of an on/off cycle, the voltage is low at C1, the trigger pin, and the threshold pin. Whenever the trigger pin voltage is low, the output is on, and the discharge pin is off. Since the discharge pin is off, current can flow through resistors R1 and R2, charging capacitor C1.
  • Once C1 charges to 2/3 Vcc, the output is switched off by the threshold pin. When the output goes off, the discharge pin switches on. This allows the charge accumulated on capacitor C1 to drain to ground.
  • Once the voltage across C1 drops to 1/3 Vcc, the trigger pin turns off the discharge pin, so C1 can start charging again.
  • The output of the 555 timer, taken from output, is fed into the Gate of the MOSFET transistor, as discussed later on.

Mosfet Transistor:

  • Unlike traditional transistors, which contain Base, Emitter and Collector legs; the MOSFET transistos are larger in their capabilities and contain different legs: Drain, Source and Gate.
  • In normal transistors, when a current flows from the base to the emitter, the transistor turns on so that a larger current can flow from the collector to the emitter.
  • In the MOSFET transistor, the voltage between gate and source decides how much current can flow from drain to source, unlike traditionals in which the transistor deals with current.
  • A voltage between gate and source that is higher than the threshold voltage is required to turn the transistor on. The threshold voltage of a MOSFET transistor is the voltage where it turns off.
  • However, the voltage stays there when it is applied to the gate and the source until it is discharged.

DC Motor and H-Bridge:

  • In this project, an H-Bridge is used along side an Arduino to switch the direction of the motor.
  • Firstly, since the first portion of the project, the 555 timer part, allows the DC Motor to operate as it receives ground from Drain via Source.
  • Drain is now re-directed to the Ground pins of 4 and 5. Meaning when the DC Motor is now connected to the H-Bridge, it is able to operate with ground being fed from the 555 timer portion of the porject. Allowing it have both functions.
  • Other than that, the Arduino takes user input from the button and controls the two inputs on the Bridge. Doing so allows the Arduino to set either terminal of the DC Motor High/Low to reverse the direction of the motor spin.

Schematic

comp eng final tinkercad schematic.png
Comp Eng Final Schematic-1.png

Here is detailed schematic of the project, showcasing all the connections made for every single component. Following this schematic will be helpful during the entire wiring procedure. Along with the schematic, a neat and detailed TinkerCAD simulation diagram has been provided to further aid with the wiring process.

Wiring Part 1

IMG_2180.png

Note: Before wiring, make sure that the top and bottom power rails of the breadboard are not connected during the procedure. The top rail will operate power to components from the battery, while bottom rail is from Arduino.


555 Timer Circuit (Speed Control):


555 Timer Setup:

  • Pin 1 (GND) → Ground rail on the breadboard
  • Pin 2 (Trigger) → Connected to Pin 6 (Threshold)
  • Pin 3 (Output) → Gate of the MOSFET AND to ground through 330 Ohms Resistor
  • Pin 4 (Reset) → 9V (the 9v Battery rail NOT Arduino 5v rail)
  • Pin 5 (Control Voltage) → Ground rail through a 10 microfarad Ceramic Capacitor
  • Pin 6 (Threshold) → Connected to Pin 2 (Trigger) AND Middle pin of the Potentiometer
  • Pin 7 (Discharge) → Ground rail on the breadboard through 1K Ohms Resistor AND to both terminals of Potentiometer (further explained)
  • Pin 8 (Vcc) → 9V (the 9v Battery rail NOT Arduino 5v rail)


Diodes:

  • Diode 1: Anode to Pin 6 (Threshold) and Cathode to the Potentiometer
  • Diode 2: Cathode to Pin 6 (Threshold) and Anode to the Potentiometer (reversed direction)


Capacitor:

  • Connect a 100 microfarad Ceramic Capacitor between Pin 6 and Ground
  • Connect a 10 microfarad Ceramic Capacitor between Pin 5 and Ground


MOSFET (Speed Control Interface):


  • Gate → Output of 555 Timer
  • Drain → Ground pins of the H-Bridge (Pins 4 and 5)
  • Source → Ground rail on the breadboard

Wiring Part 2

IMG_2181.png

H-Bridge Circuit (Direction Control):


H-Bridge Power:

  • Pin 8 (Vcc2) → Positive rail of the breadboard (the 9v Battery rail NOT Arduino 5v rail)
  • Pin 16 (Vcc1) → Arduino 5V (the 5v Arduino rail NOT Battery 9v rail)
  • Pin 4 (GND) → Drain of MOSFET
  • Pin 5 (GND) → Drain of MOSFET

Motor Connections:

  • Pin 3 (Output 1) → One terminal of the DC Motor
  • Pin 6 (Output 2) → Other terminal of the DC Motor

Control Inputs:

  • Pin 1 (Enable 1,2) → Arduino 5V
  • Pin 2 (Input 1) → Arduino digital pin D3
  • Pin 7 (Input 2) → Arduino digital pin D2

Pushbutton:

  • Top-right terminal → Common GND with a 10K Ohms resistor
  • Bottom-right terminal → Arduino digital pin D5
  • Bottom-left terminal → Power rail (the 5v Arduino rail NOT Battery 9v rail)

Common Grounds:


  • Connect the ground rail on the breadboard (connected to Source of MOSFET) to Arduino GND
  • Ensure all grounds are connected together (9V Battery, Arduino GND, MOSFET Source, H-Bridge GND pins)

Coding Component

Comp eng final code 2.png
Comp eng final code 1.png

Here is step by step guide to the coding component of the project, used to switch direction.

  1. Declaring all the pins connected to the Arduino, the pushbutton and the bridge inputs
  2. Adding three variables: Direction, Last button state and Current button state
  3. Declaring the three pins as either input or output and giving the motor a default direction to spin
  4. Current button state is set to whatever signal is read from the pushbutton by the Arduino
  5. Since the button initially will not be pressed, current state and last state will differ, causing the if statement to activate
  6. We switch motor direction by using the not or ! operator, and the direction is now a numeric value that is not 0
  7. Another if-else statement now controls the direction of the motors by using the motor direction value as a condition. If the direction was changed, then the power supplied to either terminal of the motor is switched
  8. Lastly, last button state is set to the current button state for the loop to cycle again properly.

Results

Here is the fully finish prototype of the project working, as shown in the video here.