Example of how to setup and use the general PID implementation in pid.c.
Definition in file main.c.
#include <inavr.h>
#include <ioavr.h>
#include "stdint.h"
#include "pid.h"
Include dependency graph for main.c:
Go to the source code of this file.
Data Structures | |
struct | GLOBAL_FLAGS |
Flags for status information. More... | |
Defines | |
#define | K_D 0.00 |
#define | K_I 0.00 |
#define | K_P 1.00 |
#define | TIME_INTERVAL 157 |
Functions | |
int16_t | Get_Measurement (void) |
Read system process value. | |
int16_t | Get_Reference (void) |
Read reference value. | |
void | Init (void) |
Init of PID controller demo. | |
void | main (void) |
Demo of PID controller. | |
void | Set_Input (int16_t inputValue) |
Set control input to system. | |
__interrupt void | TIMER0_OVF_ISR (void) |
Timer interrupt to control the sampling interval. | |
Variables | |
GLOBAL_FLAGS | gFlags |
Flags for status information. | |
PID_DATA | pidData |
Parameters for regulator. |
|
Definition at line 37 of file main.c. Referenced by Init(). |
|
Definition at line 35 of file main.c. Referenced by Init(). |
|
The K_P, K_I and K_D values (P, I and D gains) need to be modified to adapt to the application at hand
Definition at line 33 of file main.c. Referenced by Init(). |
|
Specify the desired PID sample time interval With a 8-bit counter (255 cylces to overflow), the time interval value is calculated as follows: TIME_INTERVAL = ( desired interval [sec] ) * ( frequency [Hz] ) / 255
Definition at line 57 of file main.c. Referenced by TIMER0_OVF_ISR(). |
|
Read system process value. This function must return the measured data Definition at line 99 of file main.c. References int16_t. Referenced by main().
|
|
Read reference value. This function must return the reference value. May be constant or varying Definition at line 90 of file main.c. References int16_t. Referenced by main().
|
|
Init of PID controller demo.
Definition at line 75 of file main.c. References K_D, K_I, K_P, pid_Init(), pidData, and SCALING_FACTOR. Referenced by main().
Here is the call graph for this function: ![]() |
|
Demo of PID controller.
Definition at line 117 of file main.c. References FALSE, Get_Measurement(), Get_Reference(), gFlags, Init(), int16_t, pid_Controller(), pidData, GLOBAL_FLAGS::pidTimer, and Set_Input().
Here is the call graph for this function: ![]() |
|
Set control input to system. Set the output from the controller as input to system. Definition at line 109 of file main.c. Referenced by main().
|
|
Timer interrupt to control the sampling interval.
Definition at line 62 of file main.c. References gFlags, GLOBAL_FLAGS::pidTimer, TIME_INTERVAL, TRUE, and uint16_t.
|
|
Flags for status information.
Referenced by main(), and TIMER0_OVF_ISR(). |
|
Parameters for regulator.
|