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
|
#!/bin/bash
|
||||||
|
|
||||||
set -e
|
set -o pipefail
|
||||||
|
|
||||||
# first build the bootloader
|
# first build the bootloader
|
||||||
cd 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)
|
# compute the crc and write that to a file (in binary)
|
||||||
crc32 build/wideband_fullsize_nocrc.bin | xxd -r -p - > build/wideband_crc.bin
|
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
|
# Now glue the image and CRC together
|
||||||
cat build/wideband_fullsize_nocrc.bin build/wideband_crc.bin > build/wideband_image.bin
|
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_GPIOCODR, VAL_GPIOCCRL, VAL_GPIOCCRH},
|
||||||
{VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
|
{VAL_GPIODODR, VAL_GPIODCRL, VAL_GPIODCRH},
|
||||||
{VAL_GPIOEODR, VAL_GPIOECRL, VAL_GPIOECRH},
|
{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
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -146,6 +146,22 @@
|
||||||
#define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
|
#define VAL_GPIOECRH 0x88888888 /* PE15...PE8 */
|
||||||
#define VAL_GPIOEODR 0x0000FFFF
|
#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.
|
* USB bus activation macro, required by the USB driver.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -12,36 +12,34 @@
|
||||||
#include "can.h"
|
#include "can.h"
|
||||||
|
|
||||||
struct sensorHeaterParams {
|
struct sensorHeaterParams {
|
||||||
uint16_t closedLoopThresholdESR;
|
float targetTemp;
|
||||||
uint16_t targetESR;
|
float targetESR;
|
||||||
uint16_t overheatESR;
|
|
||||||
uint16_t underheatESR;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct sensorHeaterParams heaterParams49 = {
|
static const struct sensorHeaterParams heaterParams49 = {
|
||||||
.closedLoopThresholdESR = LSU49_HEATER_CLOSED_LOOP_THRESHOLD_ESR,
|
.targetTemp = 780,
|
||||||
.targetESR = LSU49_HEATER_TARGET_ESR,
|
.targetESR = 300,
|
||||||
.overheatESR = LSU49_HEATER_OVERHEAT_ESR,
|
};
|
||||||
.underheatESR = LSU49_HEATER_UNDERHEAT_ESR,
|
|
||||||
};
|
|
||||||
static const struct sensorHeaterParams heaterParams42 = {
|
static const struct sensorHeaterParams heaterParams42 = {
|
||||||
.closedLoopThresholdESR = LSU42_HEATER_CLOSED_LOOP_THRESHOLD_ESR,
|
.targetTemp = 730,
|
||||||
.targetESR = LSU42_HEATER_TARGET_ESR,
|
.targetESR = 80,
|
||||||
.overheatESR = LSU42_HEATER_OVERHEAT_ESR,
|
};
|
||||||
.underheatESR = LSU42_HEATER_UNDERHEAT_ESR,
|
|
||||||
};
|
|
||||||
static const struct sensorHeaterParams heaterParamsAdv = {
|
static const struct sensorHeaterParams heaterParamsAdv = {
|
||||||
//TODO
|
.targetTemp = 785,
|
||||||
};
|
.targetESR = 300,
|
||||||
|
};
|
||||||
|
|
||||||
static const sensorHeaterParams *getHeaterParams(SensorType type) {
|
static const sensorHeaterParams *getHeaterParams(SensorType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SensorType::LSU49:
|
|
||||||
return &heaterParams49;
|
|
||||||
case SensorType::LSU42:
|
case SensorType::LSU42:
|
||||||
return &heaterParams42;
|
return &heaterParams42;
|
||||||
case SensorType::LSUADV:
|
case SensorType::LSUADV:
|
||||||
return &heaterParamsAdv;
|
return &heaterParamsAdv;
|
||||||
|
case SensorType::LSU49:
|
||||||
|
default:
|
||||||
|
return &heaterParams49;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,7 +117,7 @@ static struct heater_state state[AFR_CHANNELS] =
|
||||||
#endif
|
#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;
|
bool heaterAllowed = heaterAllowState == HeaterAllow::Allowed;
|
||||||
|
|
||||||
|
@ -146,13 +144,17 @@ static HeaterState GetNextState(struct heater_state &s, HeaterAllow heaterAllowS
|
||||||
return HeaterState::Preheat;
|
return HeaterState::Preheat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float overheatTemp = heater->targetTemp + 100;
|
||||||
|
float closedLoopTemp = heater->targetTemp - 50;
|
||||||
|
float underheatTemp = heater->targetTemp - 100;
|
||||||
|
|
||||||
switch (s.heaterState)
|
switch (s.heaterState)
|
||||||
{
|
{
|
||||||
case HeaterState::Preheat:
|
case HeaterState::Preheat:
|
||||||
s.timeCounter--;
|
s.timeCounter--;
|
||||||
|
|
||||||
// If preheat timeout, or sensor is already hot (engine running?)
|
// 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
|
// If enough time has elapsed, start the ramp
|
||||||
// Start the ramp at 4 volts
|
// 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
|
// Stay in preheat - wait for time to elapse
|
||||||
break;
|
break;
|
||||||
case HeaterState::WarmupRamp:
|
case HeaterState::WarmupRamp:
|
||||||
if (sensorEsr < heater->closedLoopThresholdESR)
|
if (sensorTemp > closedLoopTemp)
|
||||||
{
|
{
|
||||||
return HeaterState::ClosedLoop;
|
return HeaterState::ClosedLoop;
|
||||||
}
|
}
|
||||||
|
@ -182,19 +184,22 @@ static HeaterState GetNextState(struct heater_state &s, HeaterAllow heaterAllowS
|
||||||
break;
|
break;
|
||||||
case HeaterState::ClosedLoop:
|
case HeaterState::ClosedLoop:
|
||||||
// Check that the sensor's ESR is acceptable for normal operation
|
// Check that the sensor's ESR is acceptable for normal operation
|
||||||
if (sensorEsr < heater->overheatESR)
|
if (sensorTemp > overheatTemp)
|
||||||
{
|
{
|
||||||
SetFault(s.ch, Fault::SensorOverheat);
|
SetFault(s.ch, Fault::SensorOverheat);
|
||||||
return HeaterState::Stopped;
|
return HeaterState::Stopped;
|
||||||
}
|
}
|
||||||
else if (sensorEsr > heater->underheatESR)
|
else if (sensorTemp < underheatTemp)
|
||||||
{
|
{
|
||||||
SetFault(s.ch, Fault::SensorUnderheat);
|
SetFault(s.ch, Fault::SensorUnderheat);
|
||||||
return HeaterState::Stopped;
|
return HeaterState::Stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case HeaterState::Stopped: break;
|
case HeaterState::Stopped:
|
||||||
|
case HeaterState::NoHeaterSupply:
|
||||||
|
/* nop */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s.heaterState;
|
return s.heaterState;
|
||||||
|
@ -220,6 +225,8 @@ static float GetVoltageForState(struct heater_state &s, float heaterEsr)
|
||||||
case HeaterState::ClosedLoop:
|
case HeaterState::ClosedLoop:
|
||||||
// "nominal" heater voltage is 7.5v, so apply correction around that point (instead of relying on integrator so much)
|
// "nominal" heater voltage is 7.5v, so apply correction around that point (instead of relying on integrator so much)
|
||||||
// Negated because lower resistance -> hotter
|
// Negated because lower resistance -> hotter
|
||||||
|
|
||||||
|
// TODO: heater PID should operate on temperature, not ESR
|
||||||
return 7.5f - s.heaterPid.GetOutput(heater->targetESR, heaterEsr);
|
return 7.5f - s.heaterPid.GetOutput(heater->targetESR, heaterEsr);
|
||||||
case HeaterState::Stopped:
|
case HeaterState::Stopped:
|
||||||
// Something has gone wrong, turn off the heater.
|
// Something has gone wrong, turn off the heater.
|
||||||
|
@ -253,6 +260,7 @@ static void HeaterThread(void*)
|
||||||
|
|
||||||
// Read sensor state
|
// Read sensor state
|
||||||
float heaterEsr = GetSensorInternalResistance(s.ch);
|
float heaterEsr = GetSensorInternalResistance(s.ch);
|
||||||
|
float sensorTemperature = GetSensorTemperature(s.ch);
|
||||||
|
|
||||||
// If we haven't heard from rusEFI, use the internally sensed
|
// If we haven't heard from rusEFI, use the internally sensed
|
||||||
// battery voltage instead of voltage over CAN.
|
// battery voltage instead of voltage over CAN.
|
||||||
|
@ -261,7 +269,7 @@ static void HeaterThread(void*)
|
||||||
: GetRemoteBatteryVoltage();
|
: GetRemoteBatteryVoltage();
|
||||||
|
|
||||||
// Run the state machine
|
// Run the state machine
|
||||||
s.heaterState = GetNextState(s, heaterAllowState, batteryVoltage, heaterEsr);
|
s.heaterState = GetNextState(s, heaterAllowState, batteryVoltage, sensorTemperature);
|
||||||
float heaterVoltage = GetVoltageForState(s, heaterEsr);
|
float heaterVoltage = GetVoltageForState(s, heaterEsr);
|
||||||
|
|
||||||
// Limit to 11 volts
|
// Limit to 11 volts
|
||||||
|
@ -337,6 +345,8 @@ const char* describeHeaterState(HeaterState state)
|
||||||
return "ClosedLoop";
|
return "ClosedLoop";
|
||||||
case HeaterState::Stopped:
|
case HeaterState::Stopped:
|
||||||
return "Stopped";
|
return "Stopped";
|
||||||
|
case HeaterState::NoHeaterSupply:
|
||||||
|
return "NoHeaterSupply";
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Unknown";
|
return "Unknown";
|
||||||
|
|
|
@ -49,19 +49,6 @@
|
||||||
// mininal battery voltage to continue heating
|
// mininal battery voltage to continue heating
|
||||||
#define HEATER_BATTETY_OFF_VOLTAGE 8.5
|
#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
|
// TunerStudio configuration
|
||||||
// *******************************
|
// *******************************
|
||||||
|
|
Loading…
Reference in New Issue