Files
hsb/S - Software/0 - HSB MRTS Kathode-MCP/3 - Implementation/0 - Code/HAL/inc/PID.h
dvl 33bbbf4827 More doxygen documentation
git-svn-id: https://svn.vbchaos.nl/svn/hsb/trunk@418 05563f52-14a8-4384-a975-3d1654cca0fa
2018-01-11 14:20:29 +00:00

131 lines
4.1 KiB
C

// -----------------------------------------------------------------------------
/// @file PID.h
/// @brief File description
// -----------------------------------------------------------------------------
// Micro-Key bv
// Industrieweg 28, 9804 TG Noordhorn
// Postbus 92, 9800 AB Zuidhorn
// The Netherlands
// Tel: +31 594 503020
// Fax: +31 594 505825
// Email: support@microkey.nl
// Web: www.microkey.nl
// -----------------------------------------------------------------------------
/// $Revision$
/// $Author$
/// $Date$
// (c) 2015 Micro-Key bv
// -----------------------------------------------------------------------------
/**
* PID implementation
* \defgroup PID Package PID
* \ingroup HAL
* @{
*/
#ifndef INC_PID_H_
#define INC_PID_H_
// -----------------------------------------------------------------------------
// Include files
// -----------------------------------------------------------------------------
#include <stdbool.h>
#include "stm32f10x.h"
// -----------------------------------------------------------------------------
// Constant and macro definitions
// -----------------------------------------------------------------------------
#define PID_FIXED_POINT_FACTOR (10000)
// -----------------------------------------------------------------------------
// Type definitions.
// -----------------------------------------------------------------------------
struct Pid
{
int iTerm;
int Kp; // proportional constant
int Ki; // integration constant
int Kd; // differential constant
int input_d1; // Input t-1
int iMin;
int iMax;
bool initialized;
};
// -----------------------------------------------------------------------------
// Function declarations
// -----------------------------------------------------------------------------
/** ----------------------------------------------------------------------------
* PID_construct
* Constructor for a PID regulator
*
* @param self PID object to construct
* @param Kp proportional constant
* @param Ki integration constant
* @param Kd differential constant
* @param iMin Minimum value for integrator
* @param iMax Maximum value for integrator
*
* @return ErrorStatus SUCCESS if initialisation was successful
* ERRROR otherwise
*
* @todo
* -----------------------------------------------------------------------------
*/
extern ErrorStatus PID_construct(struct Pid* self, int Kp, int Ki, int Kd, int iMin, int iMax);
/** ----------------------------------------------------------------------------
* PID_destruct
* Destructor for a PID regulator
*
* @param self PID object to destruct
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void PID_destruct(struct Pid* self);
/** ----------------------------------------------------------------------------
* PID_reset
* Resets the pid regulator and cleans all history
*
* @param self PID object to reset
*
* @return void
*
* @todo
* -----------------------------------------------------------------------------
*/
extern void PID_reset(struct Pid* self);
/** ----------------------------------------------------------------------------
* PID_calculate
* Calculate
*
* @param self The PID object
* @param input The input
* @param error the error input to calculate
*
* @return int calculated value
*
* @todo
* -----------------------------------------------------------------------------
*/
extern int PID_calculate(struct Pid* self, int error);
#endif /* INC_PID_H_ */
/** @} */