100% found this document useful (1 vote)
170 views

PID Speed Controller For DC Motor - Arduino Project Hub

This document describes a PID speed controller for a DC motor. It discusses: 1. Using Arduino, MATLAB, and C# to program and model the controller. 2. Tuning the PID controller using system identification tools. 3. Estimating motor parameters like inertia and friction using nonlinear least squares. 4. Designing a GUI to monitor and control the motor speed from a computer.

Uploaded by

Šarra Mk
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
170 views

PID Speed Controller For DC Motor - Arduino Project Hub

This document describes a PID speed controller for a DC motor. It discusses: 1. Using Arduino, MATLAB, and C# to program and model the controller. 2. Tuning the PID controller using system identification tools. 3. Estimating motor parameters like inertia and friction using nonlinear least squares. 4. Designing a GUI to monitor and control the motor speed from a computer.

Uploaded by

Šarra Mk
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

Arduino c programming ( program arduino uno )


Matlab & Simulink ( T.f & parameter estimation & tuning PID )
C# programming ( build GUI )

Algorithms
kalman filter algorithm ( filter the speed sensor from noise)
Non-linearleast squares algorithm ( parameter estimation)

DC Motor Speed Control


The physical parameters for the DC motor “MY6812” are: ( from parameter
estimation)
(J) moment of inertia of therotor 1.2130e-05 kg.m^2
(b) motor viscous frictionconstant 1.5319e-04 N.m.s
(Ke) electromotive forceconstant 0.0034 V/rad/sec
(Kt) motor torque constant 0.0034 N.m/Amp
(R) electric resistance 0.0710 Ohm
(L) electric inductance 0.0127 H

free-body diagram of the dc motor.

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 23/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

1.Transfer Function.

2.State-Space.
the armature voltage is treated as the input and the rotational speed is chosen as the
output.

3.Simulink Modeling.

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 24/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

Simulink Modeling of The DC Motor.

subsystem of DC Motor.

some configuration of dc motor.

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 25/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

4.PID (http://4.pid/) control.


The speed of the dc motor can be controlled using a different controller. In this
project,speed is controlled by the PID controller.
A PID controller produces an output signal consisting of three terms- one proportional
to error signal, another one proportional to integral of error signal and third one
proportional to the derivative of the error signal.
The proportional controller stabilizes the gain but produces a steady state error.
The integral controller reduces or eliminates the steady state error.
The derivative controller reduces the rate of change of error.
PIDcontrollers have higher stability , no offset and reduced overshoot .

 PREVIOUS • •
NEXT 

5.Tuning PID
There are many different ways to tune PID control of any system like ZIEGLER
NICHOLS methods or even TRY AND ERROR method to get the required performance.

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 26/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

In this section, PID tuner toolbox is used to tune PID depends on response time
[slower– faster] and the transient behavior [aggressive – robust] that you give.

 PREVIOUS • •
NEXT 

6.Parameters (http://6.parameters/) Estimation.

Parameter estimation plays a criticalrole in accurately describing system behavior


through mathematical models suchas statistical probability distribution functions,
parametric dynamic models.

Common tasks for parameter estimation:


Importing and analysis input-output data, like the applied voltage as input and
rotor speed as the output of a DC motor.
Determine which model parameters and initial conditions to estimate, such as
motor inductance and friction, and other parameters.
Non-linearleast squares method is used to estimate the unknown parameters.

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 27/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

It compares between two data:


measured data
simulation data.

measured data ( step input 24v == 3600rpm)

Measured data comes from real system while simulation data comes from
mathematical model with initial assumption as shown below :
J=0.01;
B=0.1;
K=0.01;
R=1;

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 28/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

L=0.5;
And after a number of iteration, the simulation data try to follow the measured data
by changing these parameters to match measured data and give us realistic model
result.

iteration of estimation progress.

 PREVIOUS • •
NEXT 

result of estimation

GUI

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 29/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

For displaying results by PC a GUI is designed by a c sharp windows form application


using visual studio2015 text editor. by the designed GUI the power, voltage, current
draws by the motor will be displayed in this application. Also, the desired speed and
the value of speed sensor & error & output PWM will be shown.
Login Form.
When opening the application, a login form will be shown and you have to enter the
user name and password.
· User name: user
· Password: 1234
Control Unit Panel.
· Setpoint : desired speed that user need.
· Sampletime : default 20 milli seconds.
· Disturbance: [0 -500 ], effect the value of speed sensor.
· Setmode : either “auto” or “manual”, where “manual” turn off the PID
algorithm.
· Open loop configuration : activate open loop instead of closed loop [0 – 255],
where “0” turn off the motor while “255” max speed can handle.
· Controltype : “PID”, “PI “, “P”, “I “.

GUI app

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 30/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

Open the connect button for making a connection between ARDUINO and the PC.
· Com ports: choose what available.
· Baud rate: 9600
Then press open button from port control panel.

bluetooth / usb

The GUI have also both serial monitor and serial plotter for better visualization data
incoming from ARDUINO.
For serial monitor, you can copy the data and analysis it by either Microsoft excel or
Matlab.

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 31/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

you can also save the data as txt or csv.

save data

Difficulties And Challenges.


1.How to filter the reading of speed sensor: Using kalman filter algorithm,
Excellent filtering but it delay the signal a little bit.
https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 32/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

2.How to estimate the parameters of the motor: Using non-linear least squares
method.Good estimate but it have some error.
3.How to send and receive command from a computer :Make a GUI using c sharp
windows form application.
4.How to build mathematical model of the motor:Using Simulink and create
subsystem.
5.How to tune PID control: Using system identification toolbox from Matlab Very
good result.

Design

2D part : box.

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 33/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

Schematic Diagram.

Applications of PID controller.


Cruise control system in cars.
to regulate flow, temperature, pressure, level, etc.

Features And Improvements.


you can improve the system by doing the following : [@version2]

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 34/58
18/05/2022 00:32 PID Speed Controller for DC Motor - Arduino Project Hub

· Implement PID loop on faster microcontroller.


· Instead of using Bluetooth to make a connection between the interface and
Arduino, a Wi-Fi model is better to change the speed and monitor the system
from any place of the world.
· Add features that make the application automatically calculate the rise time
and overshoot also settling time.
· Auto tuning option.

Videos

PID speed controller for DC motor using ard…


ard…

part1 : hardware.

PID speed controller for DC motor using arduino part (2/2)

https://create.arduino.cc/projecthub/tareqwaleed1996/pid-speed-controller-for-dc-motor-74e735 35/58

You might also like