2015-07-10 06:01:56 -07:00
|
|
|
/**
|
2019-03-31 13:56:13 -07:00
|
|
|
* @file alternator_controller.h
|
2015-07-10 06:01:56 -07:00
|
|
|
* @brief alternator controller
|
|
|
|
*
|
|
|
|
* @date Apr 6, 2014
|
|
|
|
* @author Dmitry Sidin
|
2020-01-13 18:57:43 -08:00
|
|
|
* @author Andrey Belomutskiy, (c) 2012-2020
|
2015-07-10 06:01:56 -07:00
|
|
|
*
|
|
|
|
*/
|
2020-03-23 19:31:24 -07:00
|
|
|
|
|
|
|
#pragma once
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2021-04-21 11:28:48 -07:00
|
|
|
void initAlternatorCtrl();
|
2022-09-07 21:20:56 -07:00
|
|
|
|
2015-07-10 06:01:56 -07:00
|
|
|
void setAltPFactor(float p);
|
2017-05-22 19:31:41 -07:00
|
|
|
void setAltIFactor(float p);
|
|
|
|
void setAltDFactor(float p);
|
2015-07-10 06:01:56 -07:00
|
|
|
|
2023-11-10 10:12:01 -08:00
|
|
|
class AlternatorController : public EngineModule, public ClosedLoopController<float, percent_t> {
|
2021-12-05 15:33:50 -08:00
|
|
|
public:
|
2023-11-13 01:22:08 -08:00
|
|
|
void init();
|
2023-11-10 10:12:01 -08:00
|
|
|
void pidReset();
|
|
|
|
|
|
|
|
// EngineModule implementation
|
2021-12-05 15:33:50 -08:00
|
|
|
void onFastCallback() override;
|
2023-11-10 10:12:01 -08:00
|
|
|
void onConfigurationChange(engine_configuration_s const * previousConfiguration) override;
|
|
|
|
|
|
|
|
// ClosedLoopController implementation
|
|
|
|
expected<float> getSetpoint() override;
|
|
|
|
expected<float> observePlant() override;
|
|
|
|
expected<percent_t> getOpenLoop(float setpoint) override;
|
|
|
|
expected<percent_t> getClosedLoop(float targetVoltage, float vBattVoltage) override;
|
|
|
|
void setOutput(expected<percent_t> outputValue) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
Pid alternatorPid;
|
2021-12-05 15:33:50 -08:00
|
|
|
};
|
|
|
|
|