TOP Contributors

  1. MIKROE (2784 codes)
  2. Alcides Ramos (387 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (120 codes)
  5. Bugz Bensce (97 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (140168 times)
  2. FAT32 Library (72621 times)
  3. Network Ethernet Library (57641 times)
  4. USB Device Library (47955 times)
  5. Network WiFi Library (43553 times)
  6. FT800 Library (42942 times)
  7. GSM click (30140 times)
  8. mikroSDK (28669 times)
  9. PID Library (27057 times)
  10. microSD click (26552 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
Project

PID control simulation on GLCD

Rating:

0

Author: Stevan Tosic

Last Updated: 2012-05-15

Package Version: 1.0.0.0

Category: Other Codes

Downloaded: 1982 times

Followed by: 1 user

License: MIT license  

Typical control system with PID controller is simulated and variables (input, error, output, control) are drawn on GLCD screen using PID and Bars libraries.

No Abuse Reported

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".

  • Information
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

Project Blog

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):

PROCESS model(s):

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 CONTROLLER

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.

ALSO FROM THIS AUTHOR

RTOS for PIC 18F

4

Simple RTOS working in round-robin way with 1ms task switching. Number of tasks is five. Stacks size are configurable. Semaphores and timers examples are presented. Tasks progress is indicated by led blinking,

[Learn More]

Multi Timers using Event driven programming for PIC 18F8520

9

How to use Multi Timers for PIC 18F8520 in easy and user friendly way with additional library.

[Learn More]

Simple multitasking driven by state machine

0

State machine programming style and task functions are used to implement tasks running through their states. There are versions of code with or without timer interrupt (Multitasking.c and MultitaskingNoInterrupts.c). Code is portable to any uC.

[Learn More]