DC Motor Speed Control PID



Introduction: DC Motor Speed Control PID

About: just share what i have to make life funny see my page https://www.youtube.com/c/engineer2you

In this instruction, I will show how to control motor speed with PID algorithm, by Arduino UNO

With PID control, speed of motor can be archived exactly. This instruction mainly introduces about making program in Arduino UNO, and program in Computer (Visual Studio) to control motor speed by PID algorithm

Arduino UNO is used to store program motor control, PID algorithm, communicating with computer through COM Port Computer will have HMI made by Visual Studio to communicate with Arduino. HMI will show motor speed graph, change motor speed setting, and PID gain

Let's go in detail

Step 1: Hardware and Software Needed

To make this project, you will need following hardware:

1. Motor with encoder https://amzn.to/2RHsCRj

2. H-bridge L298 https://amzn.to/2QS2FeI

3. Arduino UNO https://amzn.to/2P58O7s

4. Motor base http://bit.ly/2DZJOZV

The motor with encoder, you can choose any DC motor but you need to know how many pulse of encoder per revolution. In case you don't know, you can make simple program with Arduino, then rotate motor shaft to know how many pulse of encoder per revolution. In my case, it is 200 pulses per revolution.

About software, you will need Arduino IDE to program Arduino UNO, and Visual Studio to make HMI on computer In my case, I use Visual Studio 2008, you can use newest version if you can

Step 2: Hardware Connection

Make circuit like this diagram, it's easy for Arduino fan: encoder from motor will connect to pin 2 and 3; H-bridge is used to control motor speed, then pin 4, 5 and 6 will connect to H-bridge. And, output of H-bridge is connected to motor

Then install the circuit to motor base like picture

Step 3: Arduino Code

Arduino code will do:

(1) Calculate motor speed

(2) Send motor speed to Computer

(3) Calculate PWM pulse (base on PID algorithm)

(4) Push result of PWM to H-brigde

The entire of code for Arduino UNO can be download at http://bit.ly/2P7CQbC

Step 4: Code Works at Computer

Visual Studio 2008 is used to make HMI program, in which:

(1) Send speed setting to Arduino

(2) Send PID gain to Arduino

(3) Receive motor speed, show on graph

Note that, communication between Arduino and Visual Studio by COM communication

The code can be download at http://bit.ly/2PqlYvQ

STEM Contest

Participated in the
STEM Contest

Be the First to Share


    • Robots Contest

      Robots Contest
    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Halloween Contest

      Halloween Contest