Skip to content

Commit

Permalink
Merge branch 'dev' into enum-lockingmode
Browse files Browse the repository at this point in the history
  • Loading branch information
ia committed Jul 24, 2024
2 parents b17cf69 + d9c88c9 commit d1c30e2
Show file tree
Hide file tree
Showing 17 changed files with 283 additions and 34 deletions.
1 change: 1 addition & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
"Pinecilv2",
"S60",
"S60P",
"T55",
"TS101",
]
fail-fast: true
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ DOCKER_CMD=$(DOCKER_BIN) -f $(DOCKER_YML) run --rm builder
MKDOCS_YML=$(CURDIR)/scripts/IronOS-mkdocs.yml

# supported models
MODELS=TS100 TS80 TS80P Pinecil MHP30 Pinecilv2 S60 TS101 S60P # target names & dir names
MODELS=TS100 TS80 TS80P Pinecil MHP30 Pinecilv2 S60 TS101 S60P T55 # target names & dir names
MODELS_ML=Pinecil Pinecilv2 # target names
MODELS_MULTILANG=Pinecil_multi-lang Pinecilv2_multi-lang # dir names

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ _This firmware does **NOT** support the USB port while running for changing sett
| Miniware TS101 | ✔️ || ✔️ | ✔️ || ✔️ | ✔️ | Full OLED resolution not yet supported. |
| Sequre S60 ||| ✔️ |||| ✔️ | Full OLED resolution not yet supported. |
| Sequre S60P ||| ✔️ |||| ✔️ | Full OLED resolution not yet supported. |
| Sequre T55 ||| ✔️ ||| N/A | ✔️ | Full OLED resolution not yet supported. |
| Miniware TS80P || ✔️ | ✔️ ||| N/A | ✔️ | |
| Miniware TS100 | ✔️ ||||||\*\* | |
| Miniware TS80 || ✔️ |||| N/A |\*\*\* | |
Expand Down
28 changes: 27 additions & 1 deletion source/Core/BSP/Sequre/BSP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down Expand Up @@ -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; }

Expand All @@ -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
30 changes: 29 additions & 1 deletion source/Core/BSP/Sequre/Pins.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_ */
20 changes: 16 additions & 4 deletions source/Core/BSP/Sequre/Setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
74 changes: 74 additions & 0 deletions source/Core/BSP/Sequre/ThermoModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
102 changes: 86 additions & 16 deletions source/Core/BSP/Sequre/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand All @@ -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_ */
Loading

0 comments on commit d1c30e2

Please sign in to comment.