1
0
forked from me/IronOS

Merge pull request #1046 from Ralim/adjustable-qc

Make QC3 voltages adjustable
This commit is contained in:
Ben V. Brown
2021-09-19 09:31:06 +10:00
committed by GitHub
8 changed files with 20 additions and 48 deletions

View File

@@ -71,7 +71,6 @@ uint8_t QC_DM_PulledDown() { return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO
#endif
void QC_resync() {
#ifdef POW_QC
seekQC((systemSettings.QCIdealVoltage) ? 120 : 90,
systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
seekQC(systemSettings.QCIdealVoltage, systemSettings.voltageDiv); // Run the QC seek again if we have drifted too much
#endif
}

View File

@@ -71,7 +71,6 @@ uint8_t QC_DM_PulledDown() { return HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_11) == GPIO
#endif
void QC_resync() {
#ifdef POW_QC
seekQC((getSettingValue(SettingsOptions::QCIdealVoltage)) ? 120 : 90,
getSettingValue(SettingsOptions::VoltageDiv)); // Run the QC seek again if we have drifted too much
seekQC(getSettingValue(SettingsOptions::QCIdealVoltage), getSettingValue(SettingsOptions::VoltageDiv)); // Run the QC seek again if we have drifted too much
#endif
}

View File

@@ -130,7 +130,7 @@
#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV
#define PID_POWER_LIMIT 70 // Sets the max pwm power limit
#define POWER_LIMIT 0 // 0 watts default limit
#define MAX_POWER_LIMIT 65 //
#define MAX_POWER_LIMIT 70 //
#define POWER_LIMIT_STEPS 5 //
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100 //
#define TEMP_uV_LOOKUP_HAKKO //
@@ -154,7 +154,7 @@
#define PID_POWER_LIMIT 24 // Sets the max pwm power limit
#define CALIBRATION_OFFSET 900 // the adc offset in uV
#define POWER_LIMIT 24 // 24 watts default power limit
#define MAX_POWER_LIMIT 30 //
#define MAX_POWER_LIMIT 40 //
#define POWER_LIMIT_STEPS 2 //
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80 //
#define TEMP_uV_LOOKUP_TS80 //
@@ -179,7 +179,7 @@
#define PID_POWER_LIMIT 35 // Sets the max pwm power limit
#define CALIBRATION_OFFSET 1500 // the adc offset in uV
#define POWER_LIMIT 30 // 30 watts default power limit
#define MAX_POWER_LIMIT 35 //
#define MAX_POWER_LIMIT 40 //
#define POWER_LIMIT_STEPS 2 //
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80 //
#define TEMP_uV_LOOKUP_TS80 //

View File

@@ -46,13 +46,6 @@ uint8_t QC_DM_PulledDown() { return gpio_input_bit_get(USB_DM_LOW_GPIO_Port, USB
#endif
void QC_resync() {
#ifdef POW_QC
uint8_t targetvoltage = 90;
if (getSettingValue(SettingsOptions::QCIdealVoltage) == 1) {
targetvoltage = 120;
} else if (getSettingValue(SettingsOptions::QCIdealVoltage) == 2) {
targetvoltage = 200;
}
seekQC(targetvoltage, getSettingValue(SettingsOptions::VoltageDiv)); // Run the QC seek again if we have drifted too much
seekQC(getSettingValue(SettingsOptions::QCIdealVoltage), getSettingValue(SettingsOptions::VoltageDiv)); // Run the QC seek again if we have drifted too much
#endif
}

View File

@@ -119,9 +119,9 @@
#define CALIBRATION_OFFSET 900 // 900 - Default adc offset in uV
#define PID_POWER_LIMIT 70 // Sets the max pwm power limit
#define POWER_LIMIT 0 // 0 watts default limit
#define MAX_POWER_LIMIT 65 //
#define MAX_POWER_LIMIT 70 //
#define POWER_LIMIT_STEPS 5 //
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_PINECIL // Uses Pinecil resistors
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_PINECIL // Uses TS100 resistors
#define TEMP_uV_LOOKUP_HAKKO // Use Hakko lookup table
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
#define PID_TIM_HZ (8) // Tick rate of the PID loop

View File

@@ -54,18 +54,12 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
if (QCMode == QCState::NOT_STARTED)
startQC(divisor);
if (Vx10 < 45)
if (Vx10 < 40) // Bail out if less than 4V
return;
if (xTaskGetTickCount() < TICKS_SECOND)
return;
#ifdef POW_QC_20V
if (Vx10 > 200)
Vx10 = 200; // Cap max value at 20V
#else
if (Vx10 > 130)
Vx10 = 130; // Cap max value at 13V
#endif
// Seek the QC to the Voltage given if this adapter supports continuous mode
// try and step towards the wanted value
@@ -77,8 +71,6 @@ void seekQC(int16_t Vx10, uint16_t divisor) {
int steps = difference / 2;
if (QCMode == QCState::QC_3) {
if (steps > -2 && steps < 2)
return; // dont bother with small steps
while (steps < 0) {
QC_SeekContNeg();
vTaskDelay(3 * TICKS_10MS);

View File

@@ -16,9 +16,9 @@
bool sanitiseSettings();
#ifdef POW_QC_20V
#define QC_SETTINGS_MAX 3
#define QC_VOLTAGE_MAX 222
#else
#define QC_SETTINGS_MAX 2
#define QC_VOLTAGE_MAX 142
#endif
/*
@@ -53,7 +53,7 @@ static const SettingConstants settingsConstants[(int)SettingsOptions::SettingsOp
{0, 16, 1, SLEEP_TIME}, // SleepTime
{0, 5, 1, CUT_OUT_SETTING}, // MinDCVoltageCells
{24, 38, 1, RECOM_VOL_CELL}, // MinVoltageCells
{0, QC_SETTINGS_MAX, 1, 0}, // QCIdealVoltage
{90, QC_VOLTAGE_MAX, 2, 90}, // QCIdealVoltage
{0, 3, 1, ORIENTATION_MODE}, // OrientationMode
{0, 10, 1, SENSITIVITY}, // Sensitivity
{0, 2, 1, ANIMATION_LOOP}, // AnimationLoop

View File

@@ -324,25 +324,14 @@ static bool settings_displayInputMinVRange(void) {
#ifdef POW_QC
static bool settings_displayQCInputV(void) {
printShortDescription(SettingsItemIndex::QCMaxVoltage, 5);
// 0 = 9V, 1=12V, 2=20V (Fixed Voltages)
printShortDescription(SettingsItemIndex::QCMaxVoltage, 4);
// These are only used in QC modes
switch (getSettingValue(SettingsOptions::QCIdealVoltage)) {
case 0:
OLED::printNumber(9, 2, FontStyle::LARGE);
OLED::print(SymbolVolts, FontStyle::LARGE);
break;
case 1:
OLED::printNumber(12, 2, FontStyle::LARGE);
OLED::print(SymbolVolts, FontStyle::LARGE);
break;
case 2:
OLED::printNumber(20, 2, FontStyle::LARGE);
OLED::print(SymbolVolts, FontStyle::LARGE);
break;
default:
break;
}
// Allows setting the voltage negotiated for QC
auto voltage = getSettingValue(SettingsOptions::QCIdealVoltage);
OLED::printNumber(voltage / 10, 2, FontStyle::LARGE);
OLED::print(SymbolDot, FontStyle::LARGE);
OLED::printNumber(voltage % 10, 1, FontStyle::LARGE);
OLED::print(SymbolVolts, FontStyle::LARGE);
return false;
}