PID Speed Controller for DC Motor

[@version 1 ] PID loop is used in this project to control the speed of a permanent magnet DC motor.

Jul 22, 2020

94365 views

21 respects

Components and supplies

1

INA219 I2C POWER MONITOR SENSOR

1

Voltage regulator 5v

1

wire

1

Dc motor 24v/150w

1

Voltage regulator 9v

1

Gt2 pulley 20 teeth 8mm (for motor)

1

Gt2 closed loop belt

1

Gt2 pulley 20 teeth 6mm (for encoder)

1

Bread board 830 tie

1

Arduino UNO

2

On –off switch

2

Cooling fan

1

Encoder 600ppr incremental

1

IRF540 Power MOSFET

1

SERIAL I2C TO LCD

1

Push button

1

Power supply 300w - 24/12 v

1

Bluetooth hc-05

1

LCD

Tools and machines

1

3D Printer (generic)

1

digital multimeter

1

cnc machine

Apps and platforms

1

Arduino IDE

1

MATLAB

1

Visual Studio 2015

Project description

Code

results of parameters estimation.

markdown

this is estimation values of our dc motor after applied nonlinear least square method from matlab.

step input data

matlab

this is a step input data from arduino after applied 24v to the motor. step1: convert freqency to rps then to rpm. step2:convert time from us to s. step3: time start from zero.

all libraries

markdown

all libraries you need to import it.

final code

arduino

step input response

arduino

just apply 24v to the motor terminal and copy the result that appears in the serial monitor of Arduino ide. this is for parameter estimation of the transfer function.

GUI code

markdown

download it as (.exe)

step input response

arduino

just apply 24v to the motor terminal and copy the result that appears in the serial monitor of Arduino ide. this is for parameter estimation of the transfer function.

final code

arduino

step input data

matlab

this is a step input data from arduino after applied 24v to the motor. step1: convert freqency to rps then to rpm. step2:convert time from us to s. step3: time start from zero.

all libraries

markdown

all libraries you need to import it.

results of parameters estimation.

markdown

this is estimation values of our dc motor after applied nonlinear least square method from matlab.

Downloadable files

Image of Circuit diagram

Image of Circuit diagram

Circuit diagram

Circuit diagram

Image of Circuit diagram

Image of Circuit diagram

Circuit diagram

Circuit diagram

Documentation

motor base

motor base

2D enclosure box

Acrylic 5mm thick

2D enclosure box

encoder base

encoder base

2D enclosure box

Acrylic 5mm thick

2D enclosure box

encoder base

encoder base

motor base

motor base

Comments

Only logged in users can leave comments

Anonymous user

2 years ago

Excellent,if you dont mind can i use your project for my practice ? Thank you so much

tareqwaleed1996

2 years ago

absolutely , do whatever you want.

Anonymous user

2 years ago

I'm about to start my first project on a DC motor. Any advice on gathering the physical parameters for the DC motor? Looks like the data sheet I have on the motor I'm using doesn't supply these constants. Thanks!

tareqwaleed1996

2 years ago

to find physical parameters for the dc motor you have, you need to apply step input(as max voltage of dc motor) and save the result(as matrix) this is called (step input response). for example, let us say that you have a 5v dc motor and u don't know the parameters (J),(b),(Ke),(Kt),(R),(L). what do you do? first step: figure out what is the maximum voltage that dc motor can handle it ( look it from datasheet). for the example above the max voltage is 6 volt. second step: apply step input ( 6 v max voltage ) to the terminal of dc motor. and using the speed sensor and Arduino to get result from serial monitor as (real-time vs frequency). third step: because we use frequency and micros() function. we need to copy the result and open Matlab page and put the data as matrix and do the following below step1: convert frequency to rps then to rpm. step2: convert time from us to s. step3: time start from zero. look at @step input data finally, you get what I called it measured data. for the simulation data you need to use Matlab >> look @Simulink Modeling. when you get both data, apply the Non-linear least-squares method from the Matlab toolbox. and after a number of iteration, u get all the parameters that u need. and I know it's hard for a beginner to do all this stuff together. good luck!

korte65

2 years ago

Nice project really you work hard.

Anonymous user

2 years ago

Great Project, do you have the code for the GUI?

tareqwaleed1996

2 years ago

u can download the GUI as (*.exe) from the link below under name ( lm35.exe ) : http://www.mediafire.com/file/jtulkoftuhqhbd0/lm35.exe/file and I think there is a way to extract the code from .exe file just google it.

Anonymous user

2 years ago

Excellent, but can you share the link of matlab that you do for this project? Thank you so much

whitebank

2 years ago

Nice project, i also made same project like this, you can prefer at my channel https://www.youtube.com/watch?v=Oai8qMH2yTU

tareqwaleed1996

2 years ago

Thank u

Anonymous user

2 years ago

Nice job! I need GUI`s code too.

tareqwaleed1996

2 years ago

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

tareqwaleed1996

2 years ago

u can download the GUI as (*.exe) from the link below under name ( lm35.exe ) : http://www.mediafire.com/file/jtulkoftuhqhbd0/lm35.exe/file and I think there is a way to extract the code from .exe file just google it.

tareqwaleed1996

2 years ago

yes, you right. I fixed it. gt2. 20teeth>[8mm]>motor diameter gt2. 20teeth>[6mm]>encoder diameter

Anonymous user

2 years ago

If somebody needs the GUI`s code from this .exe you can use this application: https://github.com/dnSpy/dnSpy It works. If you don`t need the code and you just want to see or use interface then you have to login as "user" with password "1234".

Anonymous user

2 years ago

Thanks a lot! You have a little mistake in Hardware components. There we can see Gt2 pulley 20 teeth 5mm, but you have used 6mm.

Anonymous user

2 years ago

Thank you Tareq for this amazing project. Tareq can you help to build one, i need the matlab part and the block diagram of project thanks

Anonymous user

2 years ago

Sir this simulation will support hardware ??

project235

2 years ago

Thank you Tareq for this amazing project. Tareq can you help to build one, i need the matlab part and the block diagram of project thanks

Anonymous user

3 years ago

Excellent, but can you share the link of matlab that you do for this project? Thank you so much

whitebank

3 years ago

Nice project, i also made same project like this, you can prefer at my channel https://www.youtube.com/watch?v=Oai8qMH2yTU

tareqwaleed1996

2 years ago

Thank u

Anonymous user

4 years ago

This project has been a great help thank you. Can you give me some direction on how to get a step response from the dc motor using the arduino?

Anonymous user

2 years ago

Thank you very much!

tareqwaleed1996

2 years ago

I think u need to watch this playlist in order to understand how we get step input response from any dc motor. this playlist helped me too when I was building this project. it's done by Matt Bilsky. https://www.youtube.com/playlist?list=PLcbUil_vzklIYGVIAsn2fKxZ8dD_PafBP

Anonymous user

4 years ago

I'm about to start my first project on a DC motor. Any advice on gathering the physical parameters for the DC motor? Looks like the data sheet I have on the motor I'm using doesn't supply these constants. Thanks!

tareqwaleed1996

2 years ago

to find physical parameters for the dc motor you have, you need to apply step input(as max voltage of dc motor) and save the result(as matrix) this is called (step input response). for example, let us say that you have a 5v dc motor and u don't know the parameters (J),(b),(Ke),(Kt),(R),(L). what do you do? first step: figure out what is the maximum voltage that dc motor can handle it ( look it from datasheet). for the example above the max voltage is 6 volt. second step: apply step input ( 6 v max voltage ) to the terminal of dc motor. and using the speed sensor and Arduino to get result from serial monitor as (real-time vs frequency). third step: because we use frequency and micros() function. we need to copy the result and open Matlab page and put the data as matrix and do the following below step1: convert frequency to rps then to rpm. step2: convert time from us to s. step3: time start from zero. look at @step input data finally, you get what I called it measured data. for the simulation data you need to use Matlab >> look @Simulink Modeling. when you get both data, apply the Non-linear least-squares method from the Matlab toolbox. and after a number of iteration, u get all the parameters that u need. and I know it's hard for a beginner to do all this stuff together. good luck!

Anonymous user

4 years ago

Nice job! I need GUI`s code too.

tareqwaleed1996

2 years ago

yes, you right. I fixed it. gt2. 20teeth>[8mm]>motor diameter gt2. 20teeth>[6mm]>encoder diameter

Anonymous user

2 years ago

If somebody needs the GUI`s code from this .exe you can use this application: https://github.com/dnSpy/dnSpy It works. If you don`t need the code and you just want to see or use interface then you have to login as "user" with password "1234".

Anonymous user

2 years ago

Thanks a lot! You have a little mistake in Hardware components. There we can see Gt2 pulley 20 teeth 5mm, but you have used 6mm.

tareqwaleed1996

2 years ago

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

tareqwaleed1996

2 years ago

u can download the GUI as (*.exe) from the link below under name ( lm35.exe ) : http://www.mediafire.com/file/jtulkoftuhqhbd0/lm35.exe/file and I think there is a way to extract the code from .exe file just google it.

Anonymous user

4 years ago

Great Project, do you have the code for the GUI?

tareqwaleed1996

2 years ago

u can download the GUI as (*.exe) from the link below under name ( lm35.exe ) : http://www.mediafire.com/file/jtulkoftuhqhbd0/lm35.exe/file and I think there is a way to extract the code from .exe file just google it.

Anonymous user

4 years ago

Excellent,if you dont mind can i use your project for my practice ? Thank you so much

tareqwaleed1996

2 years ago

absolutely , do whatever you want.