1
0
forked from me/IronOS

QC code does not get control of vin filter

This commit is contained in:
Ben V. Brown
2021-09-14 22:01:10 +10:00
parent 0f3aff6619
commit ad857a08ab
3 changed files with 8 additions and 8 deletions

View File

@@ -20,7 +20,7 @@ DMA_HandleTypeDef hdma_i2c1_tx;
IWDG_HandleTypeDef hiwdg;
TIM_HandleTypeDef htim2;
TIM_HandleTypeDef htim3;
#define ADC_FILTER_LEN 32
#define ADC_FILTER_LEN 4
#define ADC_SAMPLES 16
uint16_t ADCReadings[ADC_SAMPLES]; // Used to store the adc readings for the handle cold junction temp

View File

@@ -70,7 +70,7 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
// try and step towards the wanted value
// 1. Measure current voltage
int16_t vStart = getInputVoltageX10(divisor, 1);
int16_t vStart = getInputVoltageX10(divisor, 0);
int difference = Vx10 - vStart;
// 2. calculate ideal steps (0.2V changes)
@@ -94,7 +94,7 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
#ifdef ENABLE_QC2
// Re-measure
/* 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)
steps = -steps;
if (steps > 4) {
@@ -118,7 +118,7 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
void startQC(uint16_t divisor) {
// Pre check that the input could be >5V already, and if so, dont both
// negotiating as someone is feeding in hv
if (getInputVoltageX10(divisor, 1) > 80) {
if (getInputVoltageX10(divisor, 0) > 80) {
QCTries = 11;
QCMode = QCState::NO_QC;
return;
@@ -160,7 +160,7 @@ void startQC(uint16_t divisor) {
// Wait for frontend ADC to stabilise
QCMode = QCState::QC_2;
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
QCMode = QCState::QC_3; // We have at least QC2, pray for 3
return;

View File

@@ -64,8 +64,8 @@ void startPIDTask(void const *argument __unused) {
PIDTempTarget = TipThermoModel::getTipMaxInC();
}
int32_t tError = PIDTempTarget - currentTipTempInC;
tError = tError > INT16_MAX ? INT16_MAX : tError;
tError = tError < INT16_MIN ? INT16_MIN : tError;
// tError = tError > INT16_MAX ? INT16_MAX : tError;
// tError = tError < INT16_MIN ? INT16_MIN : tError;
detectThermalRunaway(currentTipTempInC, 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.
return powerStore.update(TIP_THERMAL_MASS * setpointDelta, // the required power
TIP_THERMAL_MASS, // inertia factor
2, // gain
1, // gain
rate, // PID cycle frequency
getX10WattageLimits());
}