// ----------------------------------------------------------------------------- /// @file PIDParameters.c /// @brief 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) 2017 Micro-Key bv // ----------------------------------------------------------------------------- /// @file PIDParameters.c /// @ingroup {group_name} // ----------------------------------------------------------------------------- // Include files // ----------------------------------------------------------------------------- #include "PIDParameters.h" #include "PCBA.h" #include "PID.h" // ----------------------------------------------------------------------------- // Constant and macro definitions // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // Type definitions // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // File-scope variables // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // Function declarations // ----------------------------------------------------------------------------- // ----------------------------------------------------------------------------- // Function definitions // ----------------------------------------------------------------------------- void PIDParameters_generateDefaultParameters(struct PIDParameters* self) { // Differ between positive and negative regulation if (PCBA_getInstance()->pcba == PCBA_CathodeMCP) { // Negative regulation self->iMin = -100000000; self->iMax = 0; } else { // positive regulation self->iMin = 0; self->iMax = 100000000; } self->Kp = 3 * PID_FIXED_POINT_FACTOR / 10; self->Ki = 2 * PID_FIXED_POINT_FACTOR / 10; self->Kd = 0 * PID_FIXED_POINT_FACTOR / 10; } void PIDParameters_setKp(struct PIDParameters* self, int Kp) { self->Kp = Kp; } void PIDParameters_setKi(struct PIDParameters* self, int Ki) { self->Ki = Ki; } void PIDParameters_setKd(struct PIDParameters* self, int Kd) { self->Kd = Kd; } void PIDParameters_setiMin(struct PIDParameters* self, int iMin) { self->iMin = iMin; } void PIDParameters_setiMax(struct PIDParameters* self, int iMax) { self->iMax = iMax; }