TOP Contributors

  1. MIKROE (2653 codes)
  2. Alcides Ramos (351 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 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 (136706 times)
  2. FAT32 Library (69916 times)
  3. Network Ethernet Library (55929 times)
  4. USB Device Library (46255 times)
  5. Network WiFi Library (41882 times)
  6. FT800 Library (41142 times)
  7. GSM click (28976 times)
  8. PID Library (26407 times)
  9. mikroSDK (26354 times)
  10. microSD click (25351 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: 1942 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

GLCD parallel programming with events and timers

0

This is really old project for BigPIC5 (PIC 18F8520). Event library used here is written in pure C code which means that can be ported to any processor with minimal effort. Parallelism is achieved by event driven programming (timers is special kind of events). See on https://www.youtube.com/watch?v=YCW8Hi3Fmok

[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]