Merge remote-tracking branch 'upstream/dev' into dev

This commit is contained in:
jonasius
2024-08-07 20:39:30 +02:00
91 changed files with 2413 additions and 1654 deletions

View File

@@ -57,6 +57,7 @@
*
*/
#define ORIENTATION_MODE 0 // 0: Right 1:Left 2:Automatic - Default right
#define MAX_ORIENTATION_MODE 1 // Unlikely to ever change
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change
/**
@@ -151,7 +152,7 @@
#define ACCEL_MSA
#define PROFILE_SUPPORT
#define OLED_96x16 1
#define POW_PD 1
#define USB_PD_TIMEOUT 20 // Default Timeout for USB-PD Protocol negotiation in x100ms
#define POW_PD_EXT 0

View File

@@ -57,6 +57,7 @@
*
*/
#define ORIENTATION_MODE 2 // 0: Right 1:Left 2:Automatic - Default Automatic
#define MAX_ORIENTATION_MODE 2 // Up to auto
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change
/**
@@ -194,7 +195,7 @@
#define POWER_LIMIT_STEPS 5
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100
#define TEMP_uV_LOOKUP_HAKKO
#define ACCEL_LIS_CLONE 1
#define HARDWARE_MAX_WATTAGE_X10 1000
#define TIP_THERMAL_MASS 65 // X10 watts to raise 1 deg C in 1 second
#define TIP_RESISTANCE 75 // x10 ohms, 7.5 typical for ts100 tips
@@ -277,6 +278,7 @@
#else
#define FLASH_LOGOADDR (0x08000000 + (62 * 1024))
#define SETTINGS_START_PAGE (0x08000000 + (63 * 1024))
#define OLED_96x16 1
#endif /* TS101 */
#endif /* CONFIGURATION_H_ */

View File

@@ -57,6 +57,7 @@
*
*/
#define ORIENTATION_MODE 2 // 0: Right 1:Left 2:Automatic - Default Automatic
#define MAX_ORIENTATION_MODE 2 // Up to auto
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change
/**
@@ -145,15 +146,16 @@
#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C
#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F
#define OLED_96x16 1
#define POW_PD 1
#define USB_PD_EPR_WATTAGE 0 /*No EPR (Yet?) */
#define POW_PD_EXT 0
#define POW_PD_EXT 0
#define USB_PD_TIMEOUT 20 // Default Timeout for USB-PD Protocol negotiation in x100ms
#define POW_QC 1
#define POW_DC 1
#define POW_QC_20V 1
#define ENABLE_QC2 1
#define MAG_SLEEP_SUPPORT 1
#define POW_QC 1
#define POW_DC 1
#define POW_QC_20V 1
#define ENABLE_QC2 1
#define MAG_SLEEP_SUPPORT 1
#define TEMP_TMP36
#define ACCEL_BMA
#define ACCEL_SC7

View File

@@ -57,6 +57,7 @@
*
*/
#define ORIENTATION_MODE 2 // 0: Right 1:Left 2:Automatic - Default Automatic
#define MAX_ORIENTATION_MODE 2 // Up to auto
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change
/**
@@ -156,6 +157,7 @@
#define ENABLE_QC2 1
#define MAG_SLEEP_SUPPORT 1
#define DEVICE_HAS_VALIDATION_SUPPORT
#define OLED_96x16 1
#define TEMP_NTC
#define ACCEL_BMA
#define CUSTOM_MAX_TEMP_C 1 // Uses custom max temp lookup
@@ -169,8 +171,8 @@
#define NEEDS_VBUS_PROBE 0 // No vbus probe, its not connected in pcb
#define CANT_DIRECT_READ_SETTINGS // We cant memcpy settings due to flash cache
#define TIP_CONTROL_PID // We use PID rather than integrator
#define TIP_PID_KP 45 // Reasonable compromise for most tips so far
#define TIP_PID_KI 9 // About as high for stability across tips
#define TIP_PID_KP 40 // Reasonable compromise for most tips so far
#define TIP_PID_KI 6 // About as high for stability across tips
#define TIP_PID_KD 200 // Helps dampen smaller tips; ~= nothing for larger tips
#define FILTER_DISPLAYED_TIP_TEMP 8 // Filtering for GUI display

View File

@@ -53,6 +53,7 @@ static const uint16_t NTCHandleLookup[] = {
};
uint16_t getHandleTemperature(uint8_t sample) {
#ifdef TMP36_ADC1_CHANNEL
int32_t result = getADCHandleTemp(sample);
// S60 uses 10k NTC resistor
// For now not doing interpolation
@@ -62,6 +63,9 @@ uint16_t getHandleTemperature(uint8_t sample) {
}
}
return 45 * 10;
#else
return 0; // Not implemented
#endif
}
uint16_t getInputVoltageX10(uint16_t divisor, uint8_t sample) {
@@ -172,7 +176,25 @@ uint64_t getDeviceID() {
return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32);
}
uint8_t getTipResistanceX10() { return TIP_RESISTANCE; }
uint8_t getTipResistanceX10() {
#ifdef COPPER_HEATER_COIL
// TODO
//! Warning, must never return 0.
TemperatureType_t measuredTemperature = TipThermoModel::getTipInC(false);
if (measuredTemperature < 25) {
return 50; // Start assuming under spec to soft-start
}
// Assuming a temperature rise of 0.00393 per deg c over 20C
uint32_t scaler = 393 * (measuredTemperature - 20);
return TIP_RESISTANCE + ((TIP_RESISTANCE * scaler) / 100000);
#else
return TIP_RESISTANCE;
#endif
}
bool isTipShorted() { return false; }
uint8_t preStartChecksDone() { return 1; }
@@ -182,3 +204,7 @@ uint16_t getTipInertia() { return TIP_THERMAL_INERTIA; }
void setBuzzer(bool on) {}
void showBootLogo(void) { BootLogo::handleShowingLogo((uint8_t *)FLASH_LOGOADDR); }
#ifdef CUSTOM_MAX_TEMP_C
TemperatureType_t getCustomTipMaxInC() { return MAX_TEMP_C; }
#endif

View File

@@ -108,5 +108,33 @@
#define MOVEMENT_Pin GPIO_PIN_3
#define MOVEMENT_GPIO_Port GPIOA
#endif
#endif // MODEL_S60P
#ifdef MODEL_T55
#define KEY_A_Pin GPIO_PIN_1
#define KEY_A_GPIO_Port GPIOB
// No cold junction compensation as its a PT1000
#define TIP_TEMP_Pin GPIO_PIN_5
#define TIP_TEMP_GPIO_Port GPIOA
#define TIP_TEMP_ADC1_CHANNEL ADC_CHANNEL_5
#define TIP_TEMP_ADC2_CHANNEL ADC_CHANNEL_5
#define VIN_Pin GPIO_PIN_4
#define VIN_GPIO_Port GPIOA
#define VIN_ADC1_CHANNEL ADC_CHANNEL_4
#define VIN_ADC2_CHANNEL ADC_CHANNEL_4
#define KEY_B_Pin GPIO_PIN_0
#define KEY_B_GPIO_Port GPIOB
#define PWM_Out_Pin GPIO_PIN_8
#define PWM_Out_GPIO_Port GPIOB
#define PWM_Out_CHANNEL TIM_CHANNEL_3 // Timer 4; channel 3
#define SCL2_Pin GPIO_PIN_6
#define SCL2_GPIO_Port GPIOB
#define SDA2_Pin GPIO_PIN_7
#define SDA2_GPIO_Port GPIOB
#endif // MODEL_T55
#endif /* BSP_SEQURE_PINS_H_ */

View File

@@ -51,7 +51,8 @@ void Setup_HAL() {
HAL_ADCEx_InjectedStart(&hadc1); // enable injected readings
HAL_ADCEx_InjectedStart(&hadc2); // enable injected readings
// Setup movement pin
// Setup movement pin
#ifdef MOVEMENT_Pin
{
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Pin = MOVEMENT_Pin;
@@ -60,9 +61,11 @@ void Setup_HAL() {
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(MOVEMENT_GPIO_Port, &GPIO_InitStruct);
}
#endif
}
uint16_t getADCHandleTemp(uint8_t sample) {
#ifdef TMP36_ADC1_CHANNEL
static history<uint16_t, ADC_FILTER_LEN> filter = {{0}, 0, 0};
if (sample) {
uint32_t sum = 0;
@@ -72,6 +75,9 @@ uint16_t getADCHandleTemp(uint8_t sample) {
filter.update(sum);
}
return filter.average() >> 1;
#else
return 0;
#endif
}
uint16_t getADCVin(uint8_t sample) {
@@ -165,13 +171,19 @@ static void MX_ADC1_Init(void) {
hadc1.Init.NbrOfConversion = 1;
HAL_ADC_Init(&hadc1);
/**Configure Regular Channel
*/
/**Configure Regular Channel
*/
#ifdef TMP36_ADC1_CHANNEL
sConfig.Channel = TMP36_ADC1_CHANNEL;
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_71CYCLES_5;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
#else
sConfig.Channel = VIN_ADC1_CHANNEL; // Filler
sConfig.Rank = ADC_REGULAR_RANK_1;
sConfig.SamplingTime = ADC_SAMPLETIME_71CYCLES_5;
HAL_ADC_ConfigChannel(&hadc1, &sConfig);
#endif
/**Configure Injected Channel
*/
// F in = 10.66 MHz

View File

@@ -8,11 +8,85 @@
#include "Utils.h"
#include "configuration.h"
#if defined(TEMP_uV_LOOKUP_S60)
#ifdef TEMP_uV_LOOKUP_PT1000
// Use https://br.flukecal.com/pt100-table-generator to make table for resistance to temp
const int32_t ohmsToDegC[] = {
//
// Resistance (ohms x10) Temperature (Celsius)
10000, 0, //
10390, 10, //
10779, 20, //
11167, 30, //
11554, 40, //
11940, 50, //
12324, 60, //
12708, 70, //
13090, 80, //
13471, 90, //
13851, 100, //
14229, 110, //
14607, 120, //
14983, 130, //
15358, 140, //
15733, 150, //
16105, 160, //
16477, 170, //
16848, 180, //
17217, 190, //
17586, 200, //
17953, 210, //
18319, 220, //
18684, 230, //
19047, 240, //
19410, 250, //
19771, 260, //
20131, 270, //
20490, 280, //
20848, 290, //
21205, 300, //
21561, 310, //
21915, 320, //
22268, 330, //
22621, 340, //
22972, 350, //
23321, 360, //
23670, 370, //
24018, 380, //
24364, 390, //
24709, 400, //
25053, 410, //
25396, 420, //
25738, 430, //
26078, 440, //
26418, 450, //
26756, 460, //
27093, 470, //
27429, 480, //
27764, 490, //
28098, 500, //
};
TemperatureType_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) {
// 3.3V -> 1K ->(ADC) <- PT1000 <- GND
// PT100 = (adc*r1)/(3.3V-adc)
uint32_t reading_mv = tipuVDelta / 1000;
uint32_t resistance_x10 = (reading_mv * 10000) / (3300 - reading_mv);
return Utils::InterpolateLookupTable(ohmsToDegC, sizeof(ohmsToDegC) / (2 * sizeof(int32_t)), resistance_x10);
}
#endif // TEMP_uV_LOOKUP_PT1000
#ifdef TEMP_uV_LOOKUP_S60
TemperatureType_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return (tipuVDelta * 50) / 485; }
#elif defined(TEMP_uV_LOOKUP_S99)
#endif // TEMP_uV_LOOKUP_S60
#ifdef TEMP_uV_LOOKUP_S99
// 42.85 uV / K -> 1/42.85 K/uV = 20/857
// TemperatureType_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return (tipuVDelta * 20) / 857; }
// Measurement is probably with heating element in series, thats why the reading differs from the approx 42.85 uV/K
TemperatureType_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) { return (tipuVDelta * 1) / 30; }
#endif
#endif // TEMP_uV_LOOKUP_S99

View File

@@ -65,7 +65,8 @@
* OLED Orientation
*
*/
#define ORIENTATION_MODE 0 // 0: Right 1:Left 2:Automatic - Default Automatic
#define ORIENTATION_MODE 0 // 0: Right 1:Left (2:Automatic N/A)
#define MAX_ORIENTATION_MODE 1 // Disable auto mode
#define REVERSE_BUTTON_TEMP_CHANGE 0 // 0:Default 1:Reverse - Reverse the plus and minus button assigment for temperature change
/**
@@ -99,9 +100,6 @@
#define DETAILED_SOLDERING 0 // 0: Disable 1: Enable - Default 0
#define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0
#define THERMAL_RUNAWAY_TIME_SEC 20
#define THERMAL_RUNAWAY_TEMP_C 10
#define CUT_OUT_SETTING 0 // default to no cut-off voltage
#define RECOM_VOL_CELL 33 // Minimum voltage per cell (Recommended 3.3V (33))
#define TEMPERATURE_INF 0 // default to 0
@@ -119,22 +117,12 @@
// Vin_max = (3.3*(r1+r2))/(r2)
// vdiv = (32768*4)/(vin_max*10)
#if defined(MODEL_S60) + defined(MODEL_S60P) + defined(MODEL_S99) == 0
#if defined(MODEL_S60) + defined(MODEL_S60P) + defined(MODEL_T55) + defined(MODEL_S99) == 0
#error "No model defined!"
#endif
#define NEEDS_VBUS_PROBE 0
#define MIN_CALIBRATION_OFFSET 100 // Min value for calibration
#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C
#define PID_TIM_HZ (8) // Tick rate of the PID loop
#define MAX_TEMP_C 450 // Max soldering temp selectable °C
#define MAX_TEMP_F 850 // Max soldering temp selectable °F
#define MIN_TEMP_C 10 // Min soldering temp selectable °C
#define MIN_TEMP_F 60 // Min soldering temp selectable °F
#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C
#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F
#ifdef MODEL_S60
#define VOLTAGE_DIV 460 // Default divider scaler
#define CALIBRATION_OFFSET 200 // Default adc offset in uV
@@ -144,7 +132,9 @@
#define POWER_LIMIT_STEPS 5
#define OP_AMP_GAIN_STAGE 536
#define TEMP_uV_LOOKUP_S60
#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate
#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate
#define THERMAL_RUNAWAY_TIME_SEC 20
#define THERMAL_RUNAWAY_TEMP_C 10
#define USB_PD_TIMEOUT 1 // Default Timeout for USB-PD Protocol negotiation in x100ms
#define HARDWARE_MAX_WATTAGE_X10 600
@@ -177,7 +167,9 @@
#define POWER_LIMIT_STEPS 5
#define OP_AMP_GAIN_STAGE 536
#define TEMP_uV_LOOKUP_S60
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
#define THERMAL_RUNAWAY_TIME_SEC 20
#define THERMAL_RUNAWAY_TEMP_C 10
#define USB_PD_TIMEOUT 1 // Default Timeout for USB-PD Protocol negotiation in x100ms
#define HARDWARE_MAX_WATTAGE_X10 600
@@ -204,6 +196,57 @@
#define MODEL_HAS_DCDC // We dont have DC/DC but have reallly fast PWM that gets us roughly the same place
#endif /* S60P */
#ifdef MODEL_T55
// T55 Hotplate is similar to Project-Argon, PCB heater + PT100 sensor but no current rolloff compensation
// Uses a HUB238 for PD negotiation like the S60, also has a buzzer. Feels like designed to share with S60
// Hold back left button for "DFU"
#define SOLDERING_TEMP 200 // Default soldering temp is 200.0 °C
#define VOLTAGE_DIV 460 // Default divider scaler
#define MIN_CALIBRATION_OFFSET 0 // Should be 0
#define CALIBRATION_OFFSET 0 // 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 70
#define POWER_LIMIT_STEPS 5
#define OP_AMP_GAIN_STAGE 1
#define TEMP_uV_LOOKUP_PT1000
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
#define USB_PD_TIMEOUT 1 // Default Timeout for USB-PD Protocol negotiation in x100ms
#define NO_DISPLAY_ROTATE // Disable OLED rotation by accel
#define MAX_TEMP_C 350 // Max soldering temp selectable °C
#define MAX_TEMP_F 660 // Max soldering temp selectable °F
#define MIN_TEMP_C 10 // Min soldering temp selectable °C
#define MIN_TEMP_F 50 // Min soldering temp selectable °F
#define MIN_BOOST_TEMP_C 150 // The min settable temp for boost mode °C
#define MIN_BOOST_TEMP_F 300 // The min settable temp for boost mode °F
#define NO_SLEEP_MODE
#define HARDWARE_MAX_WATTAGE_X10 850
#define TIP_THERMAL_MASS 30 // X10 watts to raise 1 deg C in 1 second
#define TIP_THERMAL_INERTIA 10 // We use a large inertia value to smooth out the drive to the tip since its stupidly sensitive
#define THERMAL_RUNAWAY_TIME_SEC 60
#define THERMAL_RUNAWAY_TEMP_C 3
#define COPPER_HEATER_COIL 1 // Have a heater coil that changes resistance on us
#define TIP_RESISTANCE 52 // PCB heater, measured at ~19C. Will shift by temp a decent amount
#define CUSTOM_MAX_TEMP_C
#define PROFILE_SUPPORT 1 // Soldering Profiles
#define OLED_128x32 1 // Larger OLED
#define OLED_FLIP 1 // Mounted upside down
#define POW_PD_EXT 1 // Older HUB238
#define USB_PD_EPR_WATTAGE 0 /*No EPR*/
#define DEBUG_POWER_MENU_BUTTON_B 1
#define HAS_POWER_DEBUG_MENU
#define NO_ACCEL 1
#define I2C_SOFT_BUS_2 // For now we are doing software I2C to get around hardware chip issues
#define OLED_I2CBB2
#define FILTER_DISPLAYED_TIP_TEMP 16 // Filtering for GUI display
#define MODEL_HAS_DCDC // We dont have DC/DC but have reallly fast PWM that gets us roughly the same place
#endif /* T55 */
#ifdef MODEL_S99
#define VOLTAGE_DIV 460 // Default divider scaler
#define CALIBRATION_OFFSET 200 // Default adc offset in uV
@@ -243,4 +286,34 @@
#define FLASH_LOGOADDR (0x08000000 + (62 * 1024))
#define SETTINGS_START_PAGE (0x08000000 + (63 * 1024))
// Defaults
#ifndef MIN_CALIBRATION_OFFSET
#define MIN_CALIBRATION_OFFSET 100 // Min value for calibration
#endif
#ifndef SOLDERING_TEMP
#define SOLDERING_TEMP 320 // Default soldering temp is 320.0 °C
#endif
#ifndef PID_TIM_HZ
#define PID_TIM_HZ (8) // Tick rate of the PID loop
#endif
#ifndef MAX_TEMP_C
#define MAX_TEMP_C 450 // Max soldering temp selectable °C
#endif
#ifndef MAX_TEMP_F
#define MAX_TEMP_F 850 // Max soldering temp selectable °F
#endif
#ifndef MIN_TEMP_C
#define MIN_TEMP_C 10 // Min soldering temp selectable °C
#endif
#ifndef MIN_TEMP_F
#define MIN_TEMP_F 60 // Min soldering temp selectable °F
#endif
#ifndef MIN_BOOST_TEMP_C
#define MIN_BOOST_TEMP_C 250 // The min settable temp for boost mode °C
#endif
#ifndef MIN_BOOST_TEMP_F
#define MIN_BOOST_TEMP_F 480 // The min settable temp for boost mode °F
#endif
#endif /* CONFIGURATION_H_ */

View File

@@ -56,12 +56,15 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef *hadc) {
PB0 ------> ADC2_IN8
PB1 ------> ADC2_IN9
*/
GPIO_InitStruct.Pin = TIP_TEMP_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(TIP_TEMP_GPIO_Port, &GPIO_InitStruct);
#ifdef TMP36_INPUT_Pin
GPIO_InitStruct.Pin = TMP36_INPUT_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(TMP36_INPUT_GPIO_Port, &GPIO_InitStruct);
#endif
GPIO_InitStruct.Pin = VIN_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
HAL_GPIO_Init(VIN_GPIO_Port, &GPIO_InitStruct);