mirror of https://github.com/rusefi/wideband.git
Merge branch 'master' of https://github.com/mck1117/wideband
This commit is contained in:
commit
0b27e6a8e7
|
@ -1,6 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
# first build the bootloader
|
||||
cd bootloader
|
||||
|
@ -31,6 +31,7 @@ arm-none-eabi-objcopy -I binary -O binary --gap-fill 0xFF --pad-to 0x63FC build/
|
|||
|
||||
# compute the crc and write that to a file (in binary)
|
||||
crc32 build/wideband_fullsize_nocrc.bin | xxd -r -p - > build/wideband_crc.bin
|
||||
[ $? -eq 0 ] || { echo "crc32 computation failed"; exit 1; }
|
||||
|
||||
# Now glue the image and CRC together
|
||||
cat build/wideband_fullsize_nocrc.bin build/wideband_crc.bin > build/wideband_image.bin
|
||||
|
|
|
@ -30,6 +30,9 @@ const PALConfig pal_default_config =
|
|||
{VAL_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
|
||||
{VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
|
||||
{VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH},
|
||||
/* Following GPIO ports are not balled out on 64 pin package, but still needs to be set to safe state */
|
||||
{VAL_GPIOFODR, VAL_GPIOFCRL, VAL_GPIOFCRH},
|
||||
{VAL_GPIOGODR, VAL_GPIOGCRL, VAL_GPIOGCRH},
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -146,6 +146,22 @@
|
|||
#define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
|
||||
#define VAL_GPIOEODR 0x0000FFFF
|
||||
|
||||
/*
|
||||
* Port F setup.
|
||||
* Everything input with pull-up expect:
|
||||
*/
|
||||
#define VAL_GPIOFCRL 0x88888888 /* PF7...PF0 */
|
||||
#define VAL_GPIOFCRH 0x88888888 /* PF15...PF8 */
|
||||
#define VAL_GPIOFODR 0xFFFFFFFF
|
||||
|
||||
/*
|
||||
* Port G setup.
|
||||
* Everything input with pull-up expect:
|
||||
*/
|
||||
#define VAL_GPIOGCRL 0x88888888 /* PG7...PG0 */
|
||||
#define VAL_GPIOGCRH 0x88888888 /* PG15...PG8 */
|
||||
#define VAL_GPIOGODR 0xFFFFFFFF
|
||||
|
||||
/*
|
||||
* USB bus activation macro, required by the USB driver.
|
||||
*/
|
||||
|
|
|
@ -12,36 +12,34 @@
|
|||
#include "can.h"
|
||||
|
||||
struct sensorHeaterParams {
|
||||
uint16_t closedLoopThresholdESR;
|
||||
uint16_t targetESR;
|
||||
uint16_t overheatESR;
|
||||
uint16_t underheatESR;
|
||||
float targetTemp;
|
||||
float targetESR;
|
||||
};
|
||||
|
||||
static const struct sensorHeaterParams heaterParams49 = {
|
||||
.closedLoopThresholdESR = LSU49_HEATER_CLOSED_LOOP_THRESHOLD_ESR,
|
||||
.targetESR = LSU49_HEATER_TARGET_ESR,
|
||||
.overheatESR = LSU49_HEATER_OVERHEAT_ESR,
|
||||
.underheatESR = LSU49_HEATER_UNDERHEAT_ESR,
|
||||
};
|
||||
.targetTemp = 780,
|
||||
.targetESR = 300,
|
||||
};
|
||||
|
||||
static const struct sensorHeaterParams heaterParams42 = {
|
||||
.closedLoopThresholdESR = LSU42_HEATER_CLOSED_LOOP_THRESHOLD_ESR,
|
||||
.targetESR = LSU42_HEATER_TARGET_ESR,
|
||||
.overheatESR = LSU42_HEATER_OVERHEAT_ESR,
|
||||
.underheatESR = LSU42_HEATER_UNDERHEAT_ESR,
|
||||
};
|
||||
.targetTemp = 730,
|
||||
.targetESR = 80,
|
||||
};
|
||||
|
||||
static const struct sensorHeaterParams heaterParamsAdv = {
|
||||
//TODO
|
||||
};
|
||||
.targetTemp = 785,
|
||||
.targetESR = 300,
|
||||
};
|
||||
|
||||
static const sensorHeaterParams *getHeaterParams(SensorType type) {
|
||||
switch (type) {
|
||||
case SensorType::LSU49:
|
||||
return &heaterParams49;
|
||||
case SensorType::LSU42:
|
||||
return &heaterParams42;
|
||||
case SensorType::LSUADV:
|
||||
return &heaterParamsAdv;
|
||||
case SensorType::LSU49:
|
||||
default:
|
||||
return &heaterParams49;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -119,7 +117,7 @@ static struct heater_state state[AFR_CHANNELS] =
|
|||
#endif
|
||||
};
|
||||
|
||||
static HeaterState GetNextState(struct heater_state &s, HeaterAllow heaterAllowState, float batteryVoltage, float sensorEsr)
|
||||
static HeaterState GetNextState(struct heater_state &s, HeaterAllow heaterAllowState, float batteryVoltage, float sensorTemp)
|
||||
{
|
||||
bool heaterAllowed = heaterAllowState == HeaterAllow::Allowed;
|
||||
|
||||
|
@ -146,13 +144,17 @@ static HeaterState GetNextState(struct heater_state &s, HeaterAllow heaterAllowS
|
|||
return HeaterState::Preheat;
|
||||
}
|
||||
|
||||
float overheatTemp = heater->targetTemp + 100;
|
||||
float closedLoopTemp = heater->targetTemp - 50;
|
||||
float underheatTemp = heater->targetTemp - 100;
|
||||
|
||||
switch (s.heaterState)
|
||||
{
|
||||
case HeaterState::Preheat:
|
||||
s.timeCounter--;
|
||||
|
||||
// If preheat timeout, or sensor is already hot (engine running?)
|
||||
if (s.timeCounter <= 0 || sensorEsr < heater->closedLoopThresholdESR)
|
||||
if (s.timeCounter <= 0 || sensorTemp > closedLoopTemp)
|
||||
{
|
||||
// If enough time has elapsed, start the ramp
|
||||
// Start the ramp at 4 volts
|
||||
|
@ -167,7 +169,7 @@ static HeaterState GetNextState(struct heater_state &s, HeaterAllow heaterAllowS
|
|||
// Stay in preheat - wait for time to elapse
|
||||
break;
|
||||
case HeaterState::WarmupRamp:
|
||||
if (sensorEsr < heater->closedLoopThresholdESR)
|
||||
if (sensorTemp > closedLoopTemp)
|
||||
{
|
||||
return HeaterState::ClosedLoop;
|
||||
}
|
||||
|
@ -182,19 +184,22 @@ static HeaterState GetNextState(struct heater_state &s, HeaterAllow heaterAllowS
|
|||
break;
|
||||
case HeaterState::ClosedLoop:
|
||||
// Check that the sensor's ESR is acceptable for normal operation
|
||||
if (sensorEsr < heater->overheatESR)
|
||||
if (sensorTemp > overheatTemp)
|
||||
{
|
||||
SetFault(s.ch, Fault::SensorOverheat);
|
||||
return HeaterState::Stopped;
|
||||
}
|
||||
else if (sensorEsr > heater->underheatESR)
|
||||
else if (sensorTemp < underheatTemp)
|
||||
{
|
||||
SetFault(s.ch, Fault::SensorUnderheat);
|
||||
return HeaterState::Stopped;
|
||||
}
|
||||
|
||||
break;
|
||||
case HeaterState::Stopped: break;
|
||||
case HeaterState::Stopped:
|
||||
case HeaterState::NoHeaterSupply:
|
||||
/* nop */
|
||||
break;
|
||||
}
|
||||
|
||||
return s.heaterState;
|
||||
|
@ -220,6 +225,8 @@ static float GetVoltageForState(struct heater_state &s, float heaterEsr)
|
|||
case HeaterState::ClosedLoop:
|
||||
// "nominal" heater voltage is 7.5v, so apply correction around that point (instead of relying on integrator so much)
|
||||
// Negated because lower resistance -> hotter
|
||||
|
||||
// TODO: heater PID should operate on temperature, not ESR
|
||||
return 7.5f - s.heaterPid.GetOutput(heater->targetESR, heaterEsr);
|
||||
case HeaterState::Stopped:
|
||||
// Something has gone wrong, turn off the heater.
|
||||
|
@ -253,6 +260,7 @@ static void HeaterThread(void*)
|
|||
|
||||
// Read sensor state
|
||||
float heaterEsr = GetSensorInternalResistance(s.ch);
|
||||
float sensorTemperature = GetSensorTemperature(s.ch);
|
||||
|
||||
// If we haven't heard from rusEFI, use the internally sensed
|
||||
// battery voltage instead of voltage over CAN.
|
||||
|
@ -261,7 +269,7 @@ static void HeaterThread(void*)
|
|||
: GetRemoteBatteryVoltage();
|
||||
|
||||
// Run the state machine
|
||||
s.heaterState = GetNextState(s, heaterAllowState, batteryVoltage, heaterEsr);
|
||||
s.heaterState = GetNextState(s, heaterAllowState, batteryVoltage, sensorTemperature);
|
||||
float heaterVoltage = GetVoltageForState(s, heaterEsr);
|
||||
|
||||
// Limit to 11 volts
|
||||
|
@ -337,6 +345,8 @@ const char* describeHeaterState(HeaterState state)
|
|||
return "ClosedLoop";
|
||||
case HeaterState::Stopped:
|
||||
return "Stopped";
|
||||
case HeaterState::NoHeaterSupply:
|
||||
return "NoHeaterSupply";
|
||||
}
|
||||
|
||||
return "Unknown";
|
||||
|
|
|
@ -49,19 +49,6 @@
|
|||
// mininal battery voltage to continue heating
|
||||
#define HEATER_BATTETY_OFF_VOLTAGE 8.5
|
||||
|
||||
//LSU 4.9
|
||||
#define LSU49_HEATER_CLOSED_LOOP_THRESHOLD_ESR 500
|
||||
#define LSU49_HEATER_TARGET_ESR 300
|
||||
#define LSU49_HEATER_OVERHEAT_ESR 150
|
||||
#define LSU49_HEATER_UNDERHEAT_ESR 700
|
||||
|
||||
//LSU 4.2
|
||||
// TODO: check this!!!
|
||||
#define LSU42_HEATER_CLOSED_LOOP_THRESHOLD_ESR 150
|
||||
#define LSU42_HEATER_TARGET_ESR 90
|
||||
#define LSU42_HEATER_OVERHEAT_ESR 45
|
||||
#define LSU42_HEATER_UNDERHEAT_ESR 250
|
||||
|
||||
// *******************************
|
||||
// TunerStudio configuration
|
||||
// *******************************
|
||||
|
|
Loading…
Reference in New Issue