Sequre T55 Support (#1928)
Some checks are pending
Docs / deploy-docs (push) Waiting to run
CI / build (MHP30) (push) Waiting to run
CI / build (Pinecil) (push) Waiting to run
CI / build (Pinecilv2) (push) Waiting to run
CI / build (S60) (push) Waiting to run
CI / build (S60P) (push) Waiting to run
CI / build (T55) (push) Waiting to run
CI / build (TS100) (push) Waiting to run
CI / build (TS101) (push) Waiting to run
CI / build (TS80) (push) Waiting to run
CI / build (TS80P) (push) Waiting to run
CI / build_multi-lang (Pinecil) (push) Waiting to run
CI / build_multi-lang (Pinecilv2) (push) Waiting to run
CI / upload_metadata (push) Blocked by required conditions
CI / tests (push) Waiting to run
CI / check_c-cpp (push) Waiting to run
CI / check_python (push) Waiting to run
CI / check_shell (push) Waiting to run
CI / check_readme (push) Waiting to run

* Add T55 to build

* Approx in T55

* Update ThermoModel.cpp

* use PT1000 lookup logic

* Handle no accelerometer

* Setup for temp reading

* Lock max temp

* No movement pin

* Compensate for heater coil resistance change

* Fix min offset for T55

* Fixup font for T55

* Update draw_profile_advanced.cpp

* Update draw_temperature_change.cpp

---------

Co-authored-by: discip <53649486+discip@users.noreply.github.com>
This commit is contained in:
Ben V. Brown
2024-07-24 19:06:26 +10:00
committed by GitHub
parent 84e53e11e0
commit d9c88c9e71
17 changed files with 283 additions and 34 deletions

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) {
@@ -242,7 +246,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; }
@@ -252,3 +274,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

@@ -69,5 +69,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_MINIWARE_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,4 +8,78 @@
#include "Utils.h"
#include "configuration.h"
#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; }
#endif // TEMP_uV_LOOKUP_S60

View File

@@ -100,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
@@ -120,22 +117,12 @@
// Vin_max = (3.3*(r1+r2))/(r2)
// vdiv = (32768*4)/(vin_max*10)
#if defined(MODEL_S60) + defined(MODEL_S60P) == 0
#if defined(MODEL_S60) + defined(MODEL_S60P) + defined(MODEL_T55) == 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
@@ -145,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 HARDWARE_MAX_WATTAGE_X10 600
@@ -177,7 +166,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 HARDWARE_MAX_WATTAGE_X10 600
@@ -200,7 +191,86 @@
#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 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 */
#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);