You have unsaved changes. If you choose to leave all changes will be discarded.
Author: Stevan Tosic
Last Updated: 2012-05-12
Category: Other Codes
Downloaded: 605 times
Followed by: 1 user
Typical control system with PID controller is simulated and variables (input, error, output, control) are drawn on GLCD screen using PID and Bars libraries.
Do you want to subscribe in order to receive notifications regarding "PID control simulation on GLCD" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "PID control simulation on GLCD" changes.
Do you want to report abuse regarding "PID control simulation on GLCD".
|DOWNLOAD LINK||RELATED COMPILER||CONTAINS|
|1336827552_pid_control_simu_mikroc_pic.zip [205.72KB]||mikroC PRO for PIC||
This is just simulation of PID control on GLCD with typical dynamic process. There are three (same) control loops which variables are drawn on GLCD as bars. It seems as animation of 4*3 variables (input-Xi,output-Yi, error-Ei, control-Ui ; i=0,1,2). Variables values is not scaled and tested in all. In source code (bar.c) it can be changed by user needs. Calculation are made in integer arithmetic for optimization purpose.
Project contains five files (glcd.c with main function and libraries pid.c/pid.h and bar.c/bar.h). Bar functions work as progress bar.
Files pid.c and bar.c are pure C code so there are no limitation using them by any microcontroller. Only specific pins must be adapted to ucontrollers( // Glcd module connections ...). Project was tested on BIGPIC5 with mikroC PRO 5.0.1. User should change parameters closely that is defined in code and try to adapt scale by needs. For example, control variable "u" is scaled by dividing with 5 (u/5). Program with pure PID control also works without bar functions.
A litle bit of theory of control systems to explain program simulation (PID CONTROLLER -> PROCESS):
Analog: G(s) = K * exp(-s*Tau) / (1 + s*T1)
Digital: G(z) = Z [ ( (1-exp(-s*T)/s) * G(s) ], (DAC + Process).
Process parameters set in program:
a) Sampling time (rate): T=1
b) Tau (process delay): Tau=N*T=2*1=2
c) Time constant: T1=10
d) Process gain: K=0.7.
For example, "i"-th process is set:
process_set(&processes[i], 1, 2, 10, 0.7);
PID parameters set in program:
pid_set(&pids[i], &processes[i], 3, 2, 3); // Kp,Ti,Td
But optimal parameters should be obtained from Ziegler-Nichols formulas (using process parameters from mathematic model as here or from open-loop experiment):
Kp = 1.2 * T1 / Tau; // 6
Ti = 2 * Tau; // 4
Td = 0.5 * Tau; // 1
Ziegler-Nichols parameters tunning in closed-loop with oscillations is not considered here, but also can be used efficiently.