TTK4155 Ping-pong project
pi.c File Reference

General PID implementation for AVR. More...

#include "general_header_node2.h"
#include "pi.h"
#include "stdint.h"
Include dependency graph for pi.c:

Functions

void pi_init (int16_t Kp_set, int16_t Ki_set, struct pi_t *regulator_p)
 Initialization of PID controller parameters. More...
 
int16_t pi_controller (int16_t set_point, int16_t measurement, struct pi_t *regulator_p)
 PID control algorithm. More...
 
void pi_reset_integrator (struct pi_t *regulator_p)
 Resets the integrator. More...
 

Detailed Description

General PID implementation for AVR.

Discrete PID controller implementation. Set up by giving P/I/D terms to Init_PID(), and uses a struct PID_DATA to store internal values.

Function Documentation

◆ pi_controller()

int16_t pi_controller ( int16_t  set_point,
int16_t  measurement,
struct pi_t regulator_p 
)

PID control algorithm.

Calculates output from setpoint, process value and PID status.

Parameters
set_pointDesired value.
measurementMeasured value.
pi_stPI status struct.
Here is the caller graph for this function:

◆ pi_init()

void pi_init ( int16_t  Kp_set,
int16_t  Ki_set,
struct pi_t regulator_p 
)

Initialization of PID controller parameters.

Initialize the variables used by the PID algorithm.

Parameters
KpProportional term.
KiIntegral term.
regulator_pStruct with PI status.
Here is the caller graph for this function:

◆ pi_reset_integrator()

void pi_reset_integrator ( struct pi_t regulator_p)

Resets the integrator.

Calling this function will reset the integrator in the PID regulator.