yarf 0.1
Yet Another RepRap Firmware
Functions
src/temperature/pid.c File Reference

The proportional–integral–derivative algorithm controls the amount of power delivered to the nozzle and printbed heaters, in order to keep them at their required temperature, without too much fluctuation. This file is based on the Marlin v0.9 firmware. More...

#include "pid.h"
#include "yarf.h"
#include "util/math.h"
#include <stdint.h>

Go to the source code of this file.

Functions

static void reset_state (pid_t *pid)
 Resets the state of a PID algorithm instance.
void pid_init (pid_t *pid, uint8_t envelope, uint8_t p, uint8_t i, uint8_t d)
 Initializes an instance of the PID algorithm.
void pid_set_target (pid_t *pid, float target_temp)
 Sets the target temperature for a given PID algorithm instance.
uint8_t pid_next (pid_t *pid, float current_temp)
 Returns the next result of a given PID algorithm instance, given the current measured temperature.

Detailed Description

The proportional–integral–derivative algorithm controls the amount of power delivered to the nozzle and printbed heaters, in order to keep them at their required temperature, without too much fluctuation. This file is based on the Marlin v0.9 firmware.

Author:
Pieter Agten (pieter.agten@gmail.com)
Date:
28 okt 2011

Definition in file pid.c.


Function Documentation

void pid_init ( pid_t pid,
uint8_t  envelope,
uint8_t  p,
uint8_t  i,
uint8_t  d 
)

Initializes an instance of the PID algorithm.

Parameters:
pidpointer to the instance of the PID algorithm to initialize
envelopenumber of degrees above or below the target temperature, at which the PID algorithm kicks in. Outside of this temperature range, pid_next returns 0 if the temperature is too high and 255 if it is too low.
pgain of the proportional component for the given PID instance
igain of the integral component for the given PID instance
dgain of the derivative component for the given PID instance

Definition at line 52 of file pid.c.

uint8_t pid_next ( pid_t pid,
float  current_temp 
)

Returns the next result of a given PID algorithm instance, given the current measured temperature.

The result indicates the amount of power to apply to heater belonging to the given PID instance. This function should be called at short periodic intervals.

Parameters:
pidpointer to the PID instance for which to return the next result
current_tempthe current measured temperature in degrees celsius
Returns:
An integer between 0 and 255, indicating the relative amount of power to apply to the heater belonging to the given PID instance, in order to reach the instance's target temperature.

Definition at line 74 of file pid.c.

void pid_set_target ( pid_t pid,
float  target_temp 
)

Sets the target temperature for a given PID algorithm instance.

Parameters:
pidpointer to the PID instance of which to set the target temperature
target_temptarget temperature in degrees celcius

Definition at line 66 of file pid.c.

static void reset_state ( pid_t pid) [inline, static]

Resets the state of a PID algorithm instance.

Parameters:
pidpointer to the PID instance to reset

Definition at line 47 of file pid.c.

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines