Arduino is a very powerful hardware+software tool for rapid prototype development based on microcontrollers and embedded systems. It is very widely used nowadays for many different embedded applications. It is the first choice for hobbyists, trainers, teachers, students, scientists and even professionals for developing any embedded system application.
For given application of DC motor speed control, the Arduino can be the best choice because the Arduino microcontroller is AVR ATmega328 that has built in 8-bit PWM output that can be used to vary the speed of DC motor. Here in given application, the potentiometer is used to vary DC motor speed. The set speed and motor speed is displayed on LCD and Darlington transistor TIP122 is used to drive DC motor.
Fig. 1: Prototype of Arduino based DC Motor Speed Controller
The given project very accurately and linearly controls the speed of DC motor from minimum to maximum as the pot is varied from minimum to maximum and it displays set speed and motor speed as 0 – 100 % on LCD.
Circuit description:
1. Data pins D4, D5, D6 and D7 of LCD are connected to Arduino digital pins 5, 4, 3 and 2 respectively. En pin is connected to pin 11 and Rs pin to pin 12. RW pin is connected to ground.
2. A 10K pot is connected to 3rd pin VEE of LCD to vary its brightness. LED+ terminal and LED- terminal are connected to +5 V and ground to turn on LED backlight.
3. Connect pot to an analog input pin A0 as shown. Connect its sliding terminal to A0 and other two terminals to +5 V and ground.
4. Analog output pin 9 is connected to the base input of TIP22 through a current limiting resistor of 470E. The emitter of TIP122 is connected to ground.
5. DC motor is connected between the collector of TIP122 and 12 V external power supply.
Circuit operation:
• As the pot is varied, it will vary analog input voltage to A0 pin. When it is varied from min to max the analog input to pin varies from 0 to 5 V. Arduino will read this analog voltage and convert it into digital value from 0 to 1023.
• This value from 0 to 1023 is displayed as 0 to 100 % of set motor speed on LCD – means if the value is 1023 the set motor speed is displayed as 100% and vice versa.
• This analog input is used to vary the width of the output pulse on analog output pin 9. The pulse width is also varied from 0 to 100% as the pot is varied from min to max.
• As analog input varies from 0 to 1023 the analog output varies from 0 to 255 and it is also displayed on LCD as 0 to 100% of motor speed.
• Because this PWM output is given to DC motor through TIP122, the motor speed increases as pulse width increases and vice versa.
• The PWM output on pin 9 can be observed on CRO/DSO. One can see the increase in pulse width as the pot is turned CW and also observe an increase in speed of the motor. Similarly, as the pot is turned CCW the pulse width will be decreased and so does the speed of the motor.
Software program:
The program does the following tasks -:
• Reads the analog voltage on pin A0 and gives corresponding analog output value from 0 to 1023
• Maps this analog input value from 0 to 1023 into analog output from 0 to 255 to vary pulse width on pin
• Displays set speed and motor speed as 0 to 100% on LCD.
The program is edited and compiled in Arduino IDE software. Then it is uploaded into Arduino board microcontroller ATMega328.
Project Source Code
###
//Program to #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 5, 4, 3, 2); #define potpin A0 #define motor_pin 9 int set_speed,motor_speed,disp_speed;void setup() { lcd.begin(16, 2); // initialize LCD as 16x2 lcd.setCursor(0,0); // display message in 1st and 2nd line lcd.print("Set speed: "); lcd.setCursor(0,1); lcd.print("MotorSpeed:"); }void loop() { int set_speed = analogRead(potpin); // take input from pot lcd.setCursor(12,0); lcd.print(set_speed/10); // display set speed in % lcd.print('%'); motor_speed = set_speed/4; // set motor speed as PWM width analogWrite(motor_pin,motor_speed); disp_speed = (motor_speed*100)/255; // display motor speed(PWM width) in % lcd.setCursor(12,1); lcd.print(disp_speed); lcd.print('%'); delay(200); // delay for 0.2 sec }###
Circuit Diagrams
Project Video
Filed Under: Electronic Projects
Filed Under: Electronic Projects
Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.
Tell Us What You Think!!
You must be logged in to post a comment.