mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
QC code does not get control of vin filter
This commit is contained in:
@@ -20,7 +20,7 @@ DMA_HandleTypeDef hdma_i2c1_tx;
|
|||||||
IWDG_HandleTypeDef hiwdg;
|
IWDG_HandleTypeDef hiwdg;
|
||||||
TIM_HandleTypeDef htim2;
|
TIM_HandleTypeDef htim2;
|
||||||
TIM_HandleTypeDef htim3;
|
TIM_HandleTypeDef htim3;
|
||||||
#define ADC_FILTER_LEN 32
|
#define ADC_FILTER_LEN 4
|
||||||
#define ADC_SAMPLES 16
|
#define ADC_SAMPLES 16
|
||||||
uint16_t ADCReadings[ADC_SAMPLES]; // Used to store the adc readings for the handle cold junction temp
|
uint16_t ADCReadings[ADC_SAMPLES]; // Used to store the adc readings for the handle cold junction temp
|
||||||
|
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
// try and step towards the wanted value
|
// try and step towards the wanted value
|
||||||
|
|
||||||
// 1. Measure current voltage
|
// 1. Measure current voltage
|
||||||
int16_t vStart = getInputVoltageX10(divisor, 1);
|
int16_t vStart = getInputVoltageX10(divisor, 0);
|
||||||
int difference = Vx10 - vStart;
|
int difference = Vx10 - vStart;
|
||||||
|
|
||||||
// 2. calculate ideal steps (0.2V changes)
|
// 2. calculate ideal steps (0.2V changes)
|
||||||
@@ -94,7 +94,7 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
#ifdef ENABLE_QC2
|
#ifdef ENABLE_QC2
|
||||||
// Re-measure
|
// Re-measure
|
||||||
/* Disabled due to nothing to test and code space of around 1k*/
|
/* Disabled due to nothing to test and code space of around 1k*/
|
||||||
steps = vStart - getInputVoltageX10(divisor, 1);
|
steps = vStart - getInputVoltageX10(divisor, 0);
|
||||||
if (steps < 0)
|
if (steps < 0)
|
||||||
steps = -steps;
|
steps = -steps;
|
||||||
if (steps > 4) {
|
if (steps > 4) {
|
||||||
@@ -118,7 +118,7 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
|
|||||||
void startQC(uint16_t divisor) {
|
void startQC(uint16_t divisor) {
|
||||||
// Pre check that the input could be >5V already, and if so, dont both
|
// Pre check that the input could be >5V already, and if so, dont both
|
||||||
// negotiating as someone is feeding in hv
|
// negotiating as someone is feeding in hv
|
||||||
if (getInputVoltageX10(divisor, 1) > 80) {
|
if (getInputVoltageX10(divisor, 0) > 80) {
|
||||||
QCTries = 11;
|
QCTries = 11;
|
||||||
QCMode = QCState::NO_QC;
|
QCMode = QCState::NO_QC;
|
||||||
return;
|
return;
|
||||||
@@ -160,7 +160,7 @@ void startQC(uint16_t divisor) {
|
|||||||
// Wait for frontend ADC to stabilise
|
// Wait for frontend ADC to stabilise
|
||||||
QCMode = QCState::QC_2;
|
QCMode = QCState::QC_2;
|
||||||
for (uint8_t i = 0; i < 10; i++) {
|
for (uint8_t i = 0; i < 10; i++) {
|
||||||
if (getInputVoltageX10(divisor, 1) > 80) {
|
if (getInputVoltageX10(divisor, 0) > 80) {
|
||||||
// yay we have at least QC2.0 or QC3.0
|
// yay we have at least QC2.0 or QC3.0
|
||||||
QCMode = QCState::QC_3; // We have at least QC2, pray for 3
|
QCMode = QCState::QC_3; // We have at least QC2, pray for 3
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
PIDTempTarget = TipThermoModel::getTipMaxInC();
|
PIDTempTarget = TipThermoModel::getTipMaxInC();
|
||||||
}
|
}
|
||||||
int32_t tError = PIDTempTarget - currentTipTempInC;
|
int32_t tError = PIDTempTarget - currentTipTempInC;
|
||||||
tError = tError > INT16_MAX ? INT16_MAX : tError;
|
// tError = tError > INT16_MAX ? INT16_MAX : tError;
|
||||||
tError = tError < INT16_MIN ? INT16_MIN : tError;
|
// tError = tError < INT16_MIN ? INT16_MIN : tError;
|
||||||
|
|
||||||
detectThermalRunaway(currentTipTempInC, tError);
|
detectThermalRunaway(currentTipTempInC, tError);
|
||||||
x10WattsOut = getPIDResultX10Watts(tError);
|
x10WattsOut = getPIDResultX10Watts(tError);
|
||||||
@@ -138,7 +138,7 @@ int32_t getPIDResultX10Watts(int32_t setpointDelta) {
|
|||||||
// so we basically double the need (gain = 2) to get what we want.
|
// so we basically double the need (gain = 2) to get what we want.
|
||||||
return powerStore.update(TIP_THERMAL_MASS * setpointDelta, // the required power
|
return powerStore.update(TIP_THERMAL_MASS * setpointDelta, // the required power
|
||||||
TIP_THERMAL_MASS, // inertia factor
|
TIP_THERMAL_MASS, // inertia factor
|
||||||
2, // gain
|
1, // gain
|
||||||
rate, // PID cycle frequency
|
rate, // PID cycle frequency
|
||||||
getX10WattageLimits());
|
getX10WattageLimits());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user