Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Implementing digital PID control

Status
Not open for further replies.

coolchip

Full Member level 2
Joined
Nov 17, 2003
Messages
125
Helped
1
Reputation
2
Reaction score
2
Trophy points
1,298
Activity points
1,109
digital pid

I want to control the rpm of a brushless motor with ESC(Electronic speed controller) using PID codes in PIC.
Suppose my motor is rotating at 2000 rpm detecting using hall sensor setup.Now I want it to run at 5000 rpm.The speed will be controlled by PWM signals generated by PWM module( 16-bit) in PIC hardware which is fed to ESC.
How am I gonna use the PID parameters Kp, Ki and Kd to drive the motor to desired rpm?
desired rpm = 5000
measured rpm = 2000
error = desired - measured = + 3000
C(t) = Kp*e + Ki*∫e.dt + Kd*de/dt in digital form
 

digital pid controller design

coolchip

Generate the motor speed term by either of the following methods:
~
. Take the reciprocal of the interval between pulses.
. This number is proportional to the motor speed. Measureing
. the number of pulses in a fixed time interval is more straighforward,
. but usually introduces too much lag for a real-time control application.
. This is your Speed variable ea. The Error (e) term is the difference
. The desired speed es and the speed variable ea. e = es - ea.
~
The "P" component is just a straightforward implementation of the 1st term of your equation.
~
The "Integral" I can be an up-down counter, the count rate being proportional to the speed error term.
~
The "Derivative" component is the difference between the current speed [ea(i)] and the previous speed [ea(i-1)]. de/dt = ea(i) - ea(i-1).
~
The scale factors of the variables e, I, de/dt can be absorbed into the scale
factors Kp, Ki, Kd.
Regards,
Kral

Added after 2 hours 23 minutes:

coolchip

Generate the motor speed term by either of the following methods:
~
. Take the reciprocal of the interval between pulses.
. This number is proportional to the motor speed. Measuring
. the number of pulses in a fixed time interval is more straighforward,
. but usually introduces too much lag for a real-time control application.
. This is your Speed variable ea. The Error (e) term is the difference
. The desired speed es and the speed variable ea. e = es - ea.
~
The "P" component is just a straightforward implementation of the 1st term of your equation.
~
The "Integral" I can be an up-down counter, the count rate being proportional to the speed error term.
~
The "Derivative" component is the difference between the current speed [ea(i)] and the previous speed [ea(i-1)]. de/dt = ea(i) - ea(i-1).
~
The scale factors of the variables e, I, de/dt can be absorbed into the scale
factors Kp, Ki, Kd.
Regards,
Kral
 

pwm pid rpm

Thanks Kral.
Suppose I calculate C(t) digitally, then what 16-bit value of pwm should I put in the register? The error has units of rpm and the control signal is in PWM.

As in the diagram below the error signal going into controller is in rpm and the outgoing signal should be in pwm.
Is the outgoig PWM control signal = C(t)*error or C(t)+error or C(t)[1+error] ?
 

implementing digital pid in c

i have a simpler query now : Suppose I use a proportional control to drive a motor. Measured rpm = 2000, Required rpm = 5000, Error = +3000. Control signal = K * Error. Now how should I apply this control signal to increase in voltage so as to attain the required rpm ?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top