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

Cookies are required to use this site. You must accept them to continue using the site. Learn more…