auto-sync

This commit is contained in:
rusEfi 2015-03-02 22:05:27 -06:00
parent a0e4433d62
commit 24b7955c07
3 changed files with 35 additions and 29 deletions

View File

@ -363,11 +363,13 @@ void setDodgeNeonNGCEngineConfiguration(DECLARE_ENGINE_PARAMETER_F) {
#endif
engineConfiguration->cylinderBore = 87.5;
boardConfiguration->clutchDownPin = GPIOC_12;
// boardConfiguration->clutchDownPin = GPIOC_12;
boardConfiguration->clutchDownPinMode = PI_PULLUP;
engineConfiguration->clutchUpPin = GPIOD_3;
engineConfiguration->clutchUpPinMode = PI_PULLUP;
// alt GPIOC_12
/**
* set_fsio_setting 0 0.11
*/

View File

@ -12,50 +12,53 @@
#include "pwm_generator.h"
#include "alternatorController.h"
#include "pin_repository.h"
#include "engine_configuration.h"
#include "engine.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 msg_t AltCtrlThread(int param) {
chRegSetThreadName("AlternatorController");
int alternatorDutyCycle = 500;
while (TRUE) {
chThdSleepMilliseconds(10);
while (true) {
chThdSleepMilliseconds(100);
if ( getVBatt() > 14.2 )
alternatorDutyCycle = alternatorDutyCycle + 1 ;
else
alternatorDutyCycle = alternatorDutyCycle - 1;
float result = altPid.getValue(14, getVBatt(engineConfiguration), 1);
scheduleMsg(logger, "alt duty: %f", result);
if (alternatorDutyCycle < 150 )
alternatorDutyCycle = 150;
if (alternatorDutyCycle > 950)
alternatorDutyCycle = 950;
setSimplePwmDutyCycle(&alternatorControl, 0.001 * alternatorDutyCycle);
alternatorControl.setSimplePwmDutyCycle(result / 100);
}
#if defined __GNUC__
return -1;
#endif
}
void initAlternatorCtrl() {
startSimplePwm(&alternatorControl, "Alternator control",
boardConfiguration->alternatorControlPin,
0.5,
ALTERNATOR_VALVE_PWM_FREQUENCY,
ALTERNATOR_SWITCH
);
chThdCreateStatic(ivThreadStack, sizeof(ivThreadStack), LOWPRIO, (tfunc_t)AltCtrlThread, NULL);
static void setAltPid(float p) {
scheduleMsg(logger, "setAltPid: %f", p);
altPid.updateFactors(p, 0, 0);
}
#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);
}

View File

@ -10,6 +10,7 @@
#ifndef ALTERNATORCONTROLLER_H_
#define ALTERNATORCONTROLLER_H_
void initAlternatorCtrl(void);
#include "main.h"
void initAlternatorCtrl(Logging *sharedLogger);
#endif /* ALTERNATORCONTROLLER_H_ */