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.

PID Control using C Language (C18 Complier for MPLAB)

Status
Not open for further replies.

talhataj

Newbie level 3
Joined
Nov 22, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,327
Hi Guys,
I am implementing a Stepper motor control using PID control technique on PIC18F452........ My question is i have designed the PID controller using a small code below,

Code:
//Variables
float actual_error, error_previous, P, I, D, Kp, Ki, Kd ;
{
error_previous = actual_error;  //error_previous holds the previous error
actual_error = set_point - measured_value; 
// PID 
P  = actual_error;   //Current error
I += error_previous;  //Sum of previous errors
D  = actual_error - error_previous;  //Difference with previous error
 
return Kp*P + Ki*I + Kd*D;   //adjust Kp, Ki, Kd empirically or by using online method such as ZN

Then the PID controller gives a numerical number, i have to multilply this number to the motor Transfer function, now the transfer function is in s-domain, i m confused while calculations in C language, with what numeric number or numeric entity should i replace the 's' or the frequency domain representation to get a desired numeric speed output.

PID TF = Kp + Ki/s......... using above code gives a numeric number (time domain calculations)
motor TF = 1/(s+4+jsqrt(3))(a+4-jsqrt(3))

now what i should replace 's' from in motor TF to use it in my calculatons.......

Please help
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top