Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

instructables

DC Motor Speed Control PID

by AnnaMai

In this instruction, I will show how to control motor PID gain


speed with PID algorithm, by Arduino UNO
Let's go in detail
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,


//www.youtube.com/embed/Oai8qMH2yTU
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

DC Motor Speed Control PID: Page 1


Step 1: Hardware and Software Needed

To make this project, you will need following 3. Arduino UNO https://amzn.to/2P58O7s
hardware:
4. Motor base http://bit.ly/2DZJOZV
1. Motor with encoder https://amzn.to/2RHsCRj
The motor with encoder, you can choose any DC
2. H-bridge L298 https://amzn.to/2QS2FeI motor but you need to know how many pulse of

encoder per revolution. In case you don't know, you Arduino UNO, and Visual Studio to make HMI on
can make simple program with Arduino, then rotate computer In my case, I use Visual Studio 2008, you
motor shaft to know how many pulse of encoder per can use newest version if you can
revolution. In my case, it is 200 pulses per revolution.

About software, you will need Arduino IDE to program

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

DC Motor Speed Control PID: Page 2


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

DC Motor Speed Control PID: Page 3

You might also like