DC Motor Controller

Date:

February-June, 2014

General Description:

The PID is one of popular control algorithms widely used in almost every devices, from industrial to educational purposes. I will show you a simple PID algorithm in motor control system. Motor controller can be made by using open loop control, the user actively control the motor and if there is an error the system can not compensate it. By using close loop control, the system can compensate the error automatically in microseconds, and it can hold the motor position at desired set point. This project used PID algorithm to control the DC motor speed.

Tools:

-Soldering iron
-Cutter
-Solder wire
-Proteus
-Multisim
-Altium Designer
-Wires

Materials and Components:

-PCB
-ATMega8535
-X-TAL 4 Mhz
-LCD HD44780
-Motor driver L298N
-Trimpot/Potensiometer
-Motor DC 6V
-Rotary Encoder with 22 holes
-LEDs
-Push Buttons
-9V Battery
-and some capacitors and resistors

The value of set point is controlled using trimpot. The output values from trimpot are converted into digital form by ATMega8535's ADC. LCD is used to display the set point value and rotary encoder value (measured DC motor speed). Therefore, I set the change of 1 RPM is equal to 1 bit of the trimpot output value. L298N is a commonly used dual H-bridge to control 2 DC motors. PWM signals to control the DC motor speed are generated from output timer 2 (8 bit) on Port D.7. Push button is connected to Port D.2 to change the motor direction. You can see the schematic of this DC motor controller on the left side.

The Schematic

The Flow Chart

After initializing all the necessary variables, the microcontroller convert the trimpot output value using its ADC feature. Rotary encoder pulses will trigger the interrupt 0. IN ISR 0 (Interrupt Service Routine 0) the pulses will be counted. It is used to measure sensed RPM of the DC motor which will be done in ISR timer 1 every 0.1 second. PID output value will be determined in another subroutine. The output will be converted to PWM signals by using timer 2. The last thing to do is display set point value and sensed RPM value on LCD, and then repeat all of steps from beginning, it goes on and on until the machine is turned off. The codes are developed in AVR Studio.

The Rotary Encoder

The LCD

Originally published in my previous blog on 30/06/14

Share this post to the world:
Facebooktwittergoogle_pluspinterestlinkedinFacebooktwittergoogle_pluspinterestlinkedin

5 Comments on “DC Motor Controller

  1. Excellent blog! Do you have any hints for aspiring writers?
    I’m hoping to start my own website soon but I’m a little lost on everything.
    Would you advise starting with a free platform like WordPress or go for a paid option? There are so many choices out
    there that I’m completely overwhelmed .. Any tips? Thanks!

    1. For beginner just use free platform such as wordpress, it already has all the things you need to start blogging. After that, make a decision for the blog theme, it could be one strict theme or general theme like mine. One last important thing, is to start writing the content of your new blog, get inspirations from various articles, books, events, podcasts, etc. Good luck on your blog!

Leave a Reply

Your email address will not be published. Required fields are marked *