Showing results for 
Search instead for 
Did you mean: 

Program Structure for PID temperature Controller

Hi everybody,
I built a PID temperature controller VI for a third party DAQ board, based on a very basic knowledge in programming.
Now the VI works fine in both ends "i/ps & o/ps", the problem is that i cant get the response that I'm looking for from the PID controller. Since the system is time critical, I wounder if the structure of the VI is cosing this problem. please if you have any idea, hint or suggestion.
0 Kudos
Message 1 of 2

You say that time is critical. The timeout is set to 1 second in the main loop. You will only get one update per second with this setting.

Several comments:
1. I have never seen the event structure used soley to control loop timing like this. No reason it should not work, but that is not its primary purpose. If you were to use the event structure to also handle user events (as it is designed to do), then things could get complicated. The Wait (ms) functions and Elapsed Time Express VIs can perform the timing for you without the risk of unintended consequences.
2. Generally it is recommended to use only one event structure in a program, unless you have very specific reasons for using more than one. Since you are using them only as timers, the interaction potential is minimal.
3. Right to left wiring and avoidance of wires hidden behind other objects make code much easier to read and to debug.
4. Putting the user controls and displays and the write to file functions in independent loops allows the PID function to run at different rates from the user interface and file save functions. Look at examples of Producer/consumer architecture.
5. Precalculating things which do not change from iteration to iteration can save time. For example multiply by 2.55 rather than multiply by 255 and divide by 100. Also make the datatypes consistent to avoid type coercion (indicated by little dots at the input connections such as the 255 input to the mutliply. Changing the datatype of the 255 constant to Double eliminates the coercion.

0 Kudos
Message 2 of 2