auto-sync
This commit is contained in:
parent
a0e4433d62
commit
24b7955c07
|
@ -363,11 +363,13 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
|
||||||
#endif
|
#endif
|
||||||
engineConfiguration->cylinderBore = 87.5;
|
engineConfiguration->cylinderBore = 87.5;
|
||||||
|
|
||||||
boardConfiguration->clutchDownPin = GPIOC_12;
|
// boardConfiguration->clutchDownPin = GPIOC_12;
|
||||||
boardConfiguration->clutchDownPinMode = PI_PULLUP;
|
boardConfiguration->clutchDownPinMode = PI_PULLUP;
|
||||||
engineConfiguration->clutchUpPin = GPIOD_3;
|
engineConfiguration->clutchUpPin = GPIOD_3;
|
||||||
engineConfiguration->clutchUpPinMode = PI_PULLUP;
|
engineConfiguration->clutchUpPinMode = PI_PULLUP;
|
||||||
|
|
||||||
|
// alt GPIOC_12
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set_fsio_setting 0 0.11
|
* set_fsio_setting 0 0.11
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,50 +12,53 @@
|
||||||
#include "pwm_generator.h"
|
#include "pwm_generator.h"
|
||||||
#include "alternatorController.h"
|
#include "alternatorController.h"
|
||||||
#include "pin_repository.h"
|
#include "pin_repository.h"
|
||||||
#include "engine_configuration.h"
|
#include "engine.h"
|
||||||
#include "voltage.h"
|
#include "voltage.h"
|
||||||
|
#include "pid.h"
|
||||||
|
|
||||||
#if 0
|
EXTERN_ENGINE
|
||||||
|
;
|
||||||
|
|
||||||
extern board_configuration_s *boardConfiguration;
|
static Logging *logger;
|
||||||
|
|
||||||
#define ALTERNATOR_VALVE_PWM_FREQUENCY 30000
|
#define ALTERNATOR_VALVE_PWM_FREQUENCY 300
|
||||||
|
|
||||||
static PwmConfig alternatorControl;
|
static SimplePwm alternatorControl;
|
||||||
|
static OutputPin alternatorPin;
|
||||||
|
static Pid altPid(10, 0, 0, 10, 90);
|
||||||
|
|
||||||
static THD_WORKING_AREA(ivThreadStack, UTILITY_THREAD_STACK_SIZE);
|
static THD_WORKING_AREA(ivThreadStack, UTILITY_THREAD_STACK_SIZE);
|
||||||
|
|
||||||
static msg_t AltCtrlThread(int param) {
|
static msg_t AltCtrlThread(int param) {
|
||||||
chRegSetThreadName("AlternatorController");
|
chRegSetThreadName("AlternatorController");
|
||||||
int alternatorDutyCycle = 500;
|
while (true) {
|
||||||
while (TRUE) {
|
chThdSleepMilliseconds(100);
|
||||||
chThdSleepMilliseconds(10);
|
|
||||||
|
|
||||||
if ( getVBatt() > 14.2 )
|
float result = altPid.getValue(14, getVBatt(engineConfiguration), 1);
|
||||||
alternatorDutyCycle = alternatorDutyCycle + 1 ;
|
scheduleMsg(logger, "alt duty: %f", result);
|
||||||
else
|
|
||||||
alternatorDutyCycle = alternatorDutyCycle - 1;
|
|
||||||
|
|
||||||
|
alternatorControl.setSimplePwmDutyCycle(result / 100);
|
||||||
if (alternatorDutyCycle < 150 )
|
|
||||||
alternatorDutyCycle = 150;
|
|
||||||
if (alternatorDutyCycle > 950)
|
|
||||||
alternatorDutyCycle = 950;
|
|
||||||
setSimplePwmDutyCycle(&alternatorControl, 0.001 * alternatorDutyCycle);
|
|
||||||
}
|
}
|
||||||
#if defined __GNUC__
|
#if defined __GNUC__
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void initAlternatorCtrl() {
|
static void setAltPid(float p) {
|
||||||
startSimplePwm(&alternatorControl, "Alternator control",
|
scheduleMsg(logger, "setAltPid: %f", p);
|
||||||
boardConfiguration->alternatorControlPin,
|
altPid.updateFactors(p, 0, 0);
|
||||||
0.5,
|
|
||||||
ALTERNATOR_VALVE_PWM_FREQUENCY,
|
|
||||||
ALTERNATOR_SWITCH
|
|
||||||
);
|
|
||||||
chThdCreateStatic(ivThreadStack, sizeof(ivThreadStack), LOWPRIO, (tfunc_t)AltCtrlThread, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
void initAlternatorCtrl(Logging *sharedLogger) {
|
||||||
|
logger = sharedLogger;
|
||||||
|
if (boardConfiguration->alternatorControlPin == GPIO_UNASSIGNED)
|
||||||
|
return;
|
||||||
|
|
||||||
|
startSimplePwmExt(&alternatorControl, "Alternator control", boardConfiguration->alternatorControlPin,
|
||||||
|
&alternatorPin,
|
||||||
|
ALTERNATOR_VALVE_PWM_FREQUENCY, 0.1, applyPinState);
|
||||||
|
chThdCreateStatic(ivThreadStack, sizeof(ivThreadStack), LOWPRIO, (tfunc_t) AltCtrlThread, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
addConsoleActionF("alt_pid", setAltPid);
|
||||||
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#ifndef ALTERNATORCONTROLLER_H_
|
#ifndef ALTERNATORCONTROLLER_H_
|
||||||
#define ALTERNATORCONTROLLER_H_
|
#define ALTERNATORCONTROLLER_H_
|
||||||
|
|
||||||
void initAlternatorCtrl(void);
|
#include "main.h"
|
||||||
|
void initAlternatorCtrl(Logging *sharedLogger);
|
||||||
|
|
||||||
#endif /* ALTERNATORCONTROLLER_H_ */
|
#endif /* ALTERNATORCONTROLLER_H_ */
|
||||||
|
|
Loading…
Reference in New Issue