LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

coverting pid in to a c code

hi all ,

 

i have implemented a PI controller for my air heater controller using labview PID. 

 

The PID blocks input range is as follows

min  - 48300

max - 65000

 

With the Kc = 10 , Ki=8000 , the output is perfect . But now my question is how to implement the same using a c code.

 

Can some one suggest me whether the below program is right or not ?

 

loop {

error = sp_temp - actual_temp;

integral = integral + error*dt;

output = Kp*error + Ki*integral    (where Kc = kp =10 , Ki = Kp/Ti = 10/8000 = 1.25e-3)

}

 

how can i implement the min and max values in c implementation .

0 Kudos
Message 1 of 3
(2,375 Views)

It might be a bit long winded, but if you double click on the PID.vi and check out it's block diagram you'll see precisely how LabVIEW goes about performing PID Control.

 

From what I can see, the VI just uses an In Range and Coerce block to force values to a set window. I guess the equivalent in C would be an If Statement controlled by the maximum and minimum input parameters, and the current value to output.


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

0 Kudos
Message 2 of 3
(2,337 Views)

Hi john,

 

unfortunately there is no PID toolkit for LabWindows/CVI. You can either try to to search for a mathematic code,which representates your pid behaviour in c code or create a dll in LabVIEW. You told me that you have a working VI with LabVIEW PID, so if you have the application builder you can build a .dll out of your labview code and include this .dll in labwindows/CVI.

 

Regards,

Joaquin

0 Kudos
Message 3 of 3
(2,299 Views)