Вы находитесь на странице: 1из 3

DC geared motor speed controlling using PWM

technique
Muhammad Abdul Hadi Muhammad Ahmad Muhammad Ahsan Ali Muhammad Huzefa
UG-Student Saleem UG-Student UG-Student
SMME, NUST UG-Student SMME, NUST SMME, NUST
Islamabad, Pakistan SMME, NUST Islamabad, Pakistan Islamabad, Pakistan
muhammadabdulhadi.20@ Islamabad, Pakistan ahsan.a12374@gmail.com
gmail.com ichauhdryahmad@gmail.c Huzefasalfi1032@gmail.co
om m

Abstract signal consists of two main components that define its


behavior: a duty cycle and a frequency. The duty cycle
In this project, we were supposed to design a code on describes the amount of time the signal is in a high (on) state
Arduino Software and make a circuit such that it analog input as a percentage of the total time of it takes to complete one
for the Arduino Board. The key technique used here is Pulse cycle. The frequency determines how fast the PWM
Wave Modulation. The circuit is designed as to process completes a cycle (i.e. 1000 Hz would be 1000 cycles per
incoming signals and consequently controls the speed of the second), and therefore how fast it switches between high and
motor as well as change the direction of rotation of motor. low states. By cycling a digital signal off and on at a fast-
The code we design in the Arduino Software performs the enough rate, and with a certain duty cycle, the output will
instructions provided and reads the input. We define 0-255 as appear to behave like a constant voltage analog signal when
active duty cycle. The purpose of the code we designed is to providing power to devices. The DC voltage is converted to
provide analog write for Arduino Board to read. After the a square wave signal, alternating between fully on
Arduino executes the code, it varies the speed of motor (approximately 12v) and zero. PWM for motor speed control
through H-bridge network and we use potentiometer in the works in a very similar way. Instead of supplying a varying
circuit. The active duty cycle for the motor is taken to be 0- voltage to a motor, it is supplied with a fixed voltage value
255). (such as 12v) which starts it spinning immediately. The
voltage is then removed and the motor runs for a short period
Keywords—Arduino, Pulse Wave Modulation, H- of time due to its inertia. By continuing this voltage on/off
bridge, Potentiometer, speed analog write. cycle with a varying duty cycle, the motor speed can be
controlled.
I. INTRODUCTION III. NECESSARY COMPONENTS
Arduino[1] is an open-source hardware and software
company, project and user community that designs and A. L298N Module (H-Bridge)
manufactures single-board microcontrollers and An H-bridge, if used with DC motor, lets us change its
microcontroller kits for building digital devices and rotation. We implement it with Arduino to control
interactive objects that can sense and control both physically motors. The term H bridge is derived from the typical
and digitally[1]. Arduino does not need a separate piece of graphical representation of such a circuit. An H bridge is
hardware (called a programmer) in order to load new code built with four switches (solid-state or mechanical).
onto the board – you can simply use a USB cable.
When the switches S1 and S4 (according to the first
Additionally, the Arduino IDE uses a simplified version of
figure) are closed (and S2 and S3 are open) a positive
C++, making it easier to learn to program. Arduino can
interact with buttons, LEDs, motors, speakers, GPS units, voltage will be applied across the motor. By opening S1
cameras, the internet, smartphones etc. Here it is used to vary and S4 switches and closing S2 and S3 switches, this
the speed of the motor by varying the pulse width of the signal voltage is reversed, allowing reverse operation of the
going in. motor.

In this experiment, we shall be implementing Arduino for our


cause which is to control speed of a DC geared motor using
PWM technique. The circuit here is the most basic Arduino
circuit.

II. BASIC CONCEPTS


PWM Technique[2]
A Pulse Width Modulation (PWM) Signal is a method for
generating an analog signal using a digital source. A PWM Fig. Two States of an H-Bridge
Here, we use L298N DC Motor Driver which has many
features such as presence of dual H-Bridges, speed and
direction control of motor, can afford a DC Motor of voltage
range between 5V-35V and have peak current of 2A. A typical IV. CODE
L298N module is shown below:
#define enA 9
#define in1 6
#define in2 7
#define button 4

boolean buttonState = LOW;


int rotDirection = 0;
int pressed = false;

void setup(){
pinMode (enA ,OUTPUT);
pinMode (in1, INPUT);
Fig. L298N Module pinMode (in2, INPUT);
pinMode (button, INPUT);
B. Arduino // Set initial rotation direction
Arduino consists of two parts. One is a physical digitalWrite (in1, LOW);
programmable circuit board often referred to as a digitalWrite (in2, HIGH);
microcontroller and the other is a piece of software. Software }
runs on computer, used to write and upload computer code to void loop(){
the physical board. int potValue = analogRead(A0); //Read Potentiometer
value
C. Potentiometer int pwmOutput = map (potValue , 0 ,1023, 0, 255); //Map
A potentiometer is an electronic device that is act as the potentiometer
variable resistor. It consists of a three-terminal resistor with a analogWrite(enA, pwmOutput); //Send PWM signal to
sliding or rotating contact that forms an adjustable voltage L298N Enable pin
divider. If only two terminals are used, one end and the wiper,
it acts as a variable resistor or rheostat. // Read button - Debounce
if (digitalRead(button) ==true){
D. Resistor pressed = !pressed;
A resistor is used with potentiometer to limit the current }
flowing through the DC geared motors so that motor does while (digitalRead(button)==true);
not burn up. delay(20);

E. Push Button //if button is pressed - Change direction


The switch that is used to connect or disconnect the flow of if (pressed == true & rotDirection == 0){
current through the circuit. We used it to alter the direction digitalWrite (in1 , HIGH);
of current and hence the direction of motor. digitalWrite (in2, LOW);
rotDirection = 1;
F. A bunch of Jump Wires delay(20);
A jump wire is used to interconnect the components of a }
breadboard test circuit, without soldering. Individual jump //if button pressed - Change Direction
wires are fitted by inserting their "end connectors" into the if (pressed == false & rotDirection == 1){
slots provided in a breadboard, the header connector of a digitalWrite (in1 , LOW);
circuit board, or a piece of test equipment. In our project, digitalWrite (in2, HIGH);
jump wire is used to connect circuit component. rotDirection = 0 ;
delay(20);
G. 12 V DC motor }
A DC motor is an electrical device that uses direct current to }
change electrical power to mechanical power. A 12v DC
motor is a type of DC motor that uses 12V to operate it. In
our project, the motor acts as a channel to visualize the
output of the Arduino and the H-Bridge combined and their
processing.
VI. OUTPUT
V. CIRCUIT [3] The code is processed by the Arduino and we use the
potentiometer to vary the speed of the DC motor. According
to the input, the resulting speed of the motor increases or
decreases. The H-Bridge can control the rotational direction
of the motor on the push of the “push-button”. We see that the
motor not only vary its speed according to the potentiometer
but also changes its direction whenever commanded. This
surely proves that Arduino is very useful and makes our work
smooth and manageable.

ACKNOWLEDGMENT
We are grateful to Engr. Faisal Mehmood for providing us
this opportunity to make our knowledge that he gave us
applicable in real life and we sure did learn a lot new things
from it.

REFERENCES

[1] https://en.wikipedia.org/wiki/Arduino
Fig. A complete schematic circuit of this project [2] https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z00000
19OkFSAU
[3] https://howtomechatronics.com/tutorials/arduino/arduino-dc-motor-
control-tutorial-l298n-pwm-h-bridge/

Вам также может понравиться