fome-fw/firmware/controllers/math/pid.h

48 lines
1015 B
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file pid.h
*
* @date Sep 16, 2014
2017-01-03 03:05:22 -08:00
* @author Andrey Belomutskiy, (c) 2012-2017
2015-07-10 06:01:56 -07:00
*/
#ifndef PID_H_
#define PID_H_
2016-02-06 09:02:24 -08:00
#include "global.h"
2016-01-20 20:03:03 -08:00
#include "engine_configuration_generated_structures.h"
2016-02-06 09:02:24 -08:00
#if EFI_PROD_CODE || EFI_SIMULATOR
#include "tunerstudio_configuration.h"
#endif
2016-01-20 20:03:03 -08:00
2015-07-10 06:01:56 -07:00
class Pid {
public:
2016-02-06 09:02:24 -08:00
Pid();
2016-01-20 20:03:03 -08:00
Pid(pid_s *pid, float minResult, float maxResult);
2016-02-06 09:02:24 -08:00
void init(pid_s *pid, float minResult, float maxResult);
2016-09-15 20:01:48 -07:00
bool isSame(pid_s *pid);
2016-02-06 09:02:24 -08:00
2015-07-10 06:01:56 -07:00
float getValue(float target, float input, float dTime);
void updateFactors(float pFactor, float iFactor, float dFactor);
void reset(void);
float getP(void);
float getI(void);
float getD(void);
2016-02-06 09:02:24 -08:00
float getOffset(void);
2016-01-24 13:01:28 -08:00
float getIntegration(void);
float getPrevError(void);
2016-02-06 09:02:24 -08:00
#if EFI_PROD_CODE || EFI_SIMULATOR
void postState(TunerStudioOutputChannels *tsOutputChannels);
#endif
2015-07-10 06:01:56 -07:00
private:
2016-01-20 20:03:03 -08:00
pid_s *pid;
2015-07-10 06:01:56 -07:00
float minResult;
float maxResult;
float iTerm;
2016-09-20 18:02:46 -07:00
float dTerm; // we are remembering this only for debugging purposes
2015-07-10 06:01:56 -07:00
float prevError;
};
#endif /* PID_H_ */