Use your forum account to login.

LOGIN

TOP Contributors

  1. MikroElektronika Team (99 codes)
  2. Dany (44 codes)
  3. NART SCHINACKOW (34 codes)
  4. Alcides Ramos (33 codes)
  5. Agent Wolfz (14 codes)
  6. Andrew Hazelden (13 codes)
  7. Roman Black (11 codes)
  8. Alberto Trasimeni (11 codes)
  9. Roman Toropov (9 codes)
  10. Simon Platten (8 codes)

Most Downloaded

  1. Network Ethernet Library (11743 times)
  2. FAT32 Library (8591 times)
  3. Timer Calculator (6518 times)
  4. PID Library (5236 times)
  5. Network WiFi Library (5188 times)
  6. SMS home alarm system (4414 times)
  7. External Memory (4104 times)
  8. mikromedia for PIC18FJ - Examples (3564 times)
  9. microSD click - Example (3486 times)
  10. GPS click - Example (3246 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:

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.

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

Download Project [199.83KB]

Version 1.0.0.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

Multi Timers using Event driven programming for PIC 18F8520

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

[Learn More]

RTOS for PIC 18F

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]