Macros | Functions
PID-control

Functions which handle the PID-control. More...

Macros

#define RAMP
 ramp for speed [tics/s^2]
 

Functions

uint8_t pid_control_init (float Kp, float Ki, float Kd, int freq)
 
void pid_control_use_ramp (uint8_t ramp)
 
void pid_control_set_sp (int16_t v_desired)
 
int16_t pid_control_sp (void)
 
void pid_control_set_Kp (float Kp)
 
void pid_control_set_Ki (float Ki)
 
void pid_control_set_Kd (float Kd)
 
float pid_control_Kp (void)
 
float pid_control_Ki (void)
 
float pid_control_Kd (void)
 
void pid_control_reset (void)
 
void pid_control_stop (void)
 

Detailed Description

Functions which handle the PID-control.

This additional module is designed for simple pid-controller tests. It is only supposed to be a starting point for your own code. Therefore, all functions are not optimized at all. To underline the only supportive idea, the function have a slightly different API compared to the rest of the TUC-Bot library.

In order to use any of these functions, include tucbot_additionals/control.h into your code.

Some points you might keep in mind, while programming your own and better version of the controller:

The folowin data packet is published via XBee: "%li %d %d %d %d %d\n"

Function Documentation

◆ pid_control_init()

uint8_t pid_control_init ( float  Kp,
float  Ki,
float  Kd,
int  freq 
)

Activate the control loop. This adds the control loop to the queue which is processed each time a systick interrupt occures.

Parameters
Kpproportional constant
Kiintegral constant
Kddifferential constant
freq16-bit integer (1..100)
The frequency is measured in Hz.
Since the systick is internally used to cyclic call the controller, only multiple intervals of 10ms can be used. Therefore, the frequency should be choosen wisely.
E.g. 17, 18, 19 and 20 will all result to an interval of 50ms.

◆ pid_control_Kd()

float pid_control_Kd ( void  )

Get differential constant of the PID controller.

◆ pid_control_Ki()

float pid_control_Ki ( void  )

Get integral constant of the PID controller.

◆ pid_control_Kp()

float pid_control_Kp ( void  )

Get proportional constant of the PID controller.

◆ pid_control_reset()

void pid_control_reset ( void  )

Reset the internal variables of the controller.

◆ pid_control_set_Kd()

void pid_control_set_Kd ( float  Kd)

Set differential constant of the PID controller.

◆ pid_control_set_Ki()

void pid_control_set_Ki ( float  Ki)

Set integral constant of the PID controller.

◆ pid_control_set_Kp()

void pid_control_set_Kp ( float  Kp)

Set proportional constant of the PID controller.

◆ pid_control_set_sp()

void pid_control_set_sp ( int16_t  v_desired)

Set a new setpoint for the velocity control in tics/s.

◆ pid_control_sp()

int16_t pid_control_sp ( void  )

Get the current setpoint for the velocity control in tics/s..

◆ pid_control_stop()

void pid_control_stop ( void  )

Deactivate the control loop. This removes the control loop from the queue which is processed each time a systick interrupt occures.

◆ pid_control_use_ramp()

void pid_control_use_ramp ( uint8_t  ramp)

If use_ramp is active, the internal setpoint will change smoothly.
The stepsize is set by the constant RAMP.