mirror of
https://github.com/Ralim/IronOS.git
synced 2025-02-26 07:53:55 +00:00
Updated cold junction temp curve
* Disabled the hack off on temp as we dont need it for MHP30 * faster ADC on MHP30
This commit is contained in:
@@ -10,8 +10,6 @@
|
|||||||
#include "FreeRTOSConfig.h"
|
#include "FreeRTOSConfig.h"
|
||||||
enum Orientation { ORIENTATION_LEFT_HAND = 0, ORIENTATION_RIGHT_HAND = 1, ORIENTATION_FLAT = 3 };
|
enum Orientation { ORIENTATION_LEFT_HAND = 0, ORIENTATION_RIGHT_HAND = 1, ORIENTATION_FLAT = 3 };
|
||||||
|
|
||||||
// It is assumed that all hardware implements an 8Hz update period at this time
|
|
||||||
#define PID_TIM_HZ (8)
|
|
||||||
#define TICKS_SECOND configTICK_RATE_HZ
|
#define TICKS_SECOND configTICK_RATE_HZ
|
||||||
#define TICKS_MIN (60 * TICKS_SECOND)
|
#define TICKS_MIN (60 * TICKS_SECOND)
|
||||||
#define TICKS_100MS (TICKS_SECOND / 10)
|
#define TICKS_100MS (TICKS_SECOND / 10)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
#include "TipThermoModel.h"
|
#include "TipThermoModel.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
#include "configuration.h"
|
||||||
#include "history.hpp"
|
#include "history.hpp"
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
#include <IRQ.h>
|
#include <IRQ.h>
|
||||||
@@ -22,20 +23,167 @@ void resetWatchdog() { HAL_IWDG_Refresh(&hiwdg); }
|
|||||||
// Lookup table for the NTC
|
// Lookup table for the NTC
|
||||||
// Stored as ADCReading,Temp in degC
|
// Stored as ADCReading,Temp in degC
|
||||||
static const uint16_t NTCHandleLookup[] = {
|
static const uint16_t NTCHandleLookup[] = {
|
||||||
// ADC Reading , Temp in C
|
// ADC Reading , Temp in Cx10
|
||||||
11292, 600, //
|
808, 1600, //
|
||||||
12782, 550, //
|
832, 1590, //
|
||||||
14380, 500, //
|
848, 1580, //
|
||||||
16061, 450, //
|
872, 1570, //
|
||||||
17793, 400, //
|
888, 1560, //
|
||||||
19541, 350, //
|
912, 1550, //
|
||||||
21261, 300, //
|
936, 1540, //
|
||||||
22915, 250, //
|
960, 1530, //
|
||||||
24465, 200, //
|
984, 1520, //
|
||||||
25882, 150, //
|
1008, 1510, //
|
||||||
27146, 100, //
|
1032, 1500, //
|
||||||
28249, 50, //
|
1056, 1490, //
|
||||||
29189, 0, //
|
1080, 1480, //
|
||||||
|
1112, 1470, //
|
||||||
|
1136, 1460, //
|
||||||
|
1168, 1450, //
|
||||||
|
1200, 1440, //
|
||||||
|
1224, 1430, //
|
||||||
|
1256, 1420, //
|
||||||
|
1288, 1410, //
|
||||||
|
1328, 1400, //
|
||||||
|
1360, 1390, //
|
||||||
|
1392, 1380, //
|
||||||
|
1432, 1370, //
|
||||||
|
1464, 1360, //
|
||||||
|
1504, 1350, //
|
||||||
|
1544, 1340, //
|
||||||
|
1584, 1330, //
|
||||||
|
1632, 1320, //
|
||||||
|
1672, 1310, //
|
||||||
|
1720, 1300, //
|
||||||
|
1760, 1290, //
|
||||||
|
1808, 1280, //
|
||||||
|
1856, 1270, //
|
||||||
|
1912, 1260, //
|
||||||
|
1960, 1250, //
|
||||||
|
2016, 1240, //
|
||||||
|
2072, 1230, //
|
||||||
|
2128, 1220, //
|
||||||
|
2184, 1210, //
|
||||||
|
2248, 1200, //
|
||||||
|
2304, 1190, //
|
||||||
|
2368, 1180, //
|
||||||
|
2440, 1170, //
|
||||||
|
2504, 1160, //
|
||||||
|
2576, 1150, //
|
||||||
|
2648, 1140, //
|
||||||
|
2720, 1130, //
|
||||||
|
2792, 1120, //
|
||||||
|
2872, 1110, //
|
||||||
|
2952, 1100, //
|
||||||
|
3040, 1090, //
|
||||||
|
3128, 1080, //
|
||||||
|
3216, 1070, //
|
||||||
|
3304, 1060, //
|
||||||
|
3400, 1050, //
|
||||||
|
3496, 1040, //
|
||||||
|
3592, 1030, //
|
||||||
|
3696, 1020, //
|
||||||
|
3800, 1010, //
|
||||||
|
3912, 1000, //
|
||||||
|
4024, 990, //
|
||||||
|
4136, 980, //
|
||||||
|
4256, 970, //
|
||||||
|
4376, 960, //
|
||||||
|
4504, 950, //
|
||||||
|
4632, 940, //
|
||||||
|
4768, 930, //
|
||||||
|
4904, 920, //
|
||||||
|
5048, 910, //
|
||||||
|
5192, 900, //
|
||||||
|
5336, 890, //
|
||||||
|
5488, 880, //
|
||||||
|
5648, 870, //
|
||||||
|
5808, 860, //
|
||||||
|
5976, 850, //
|
||||||
|
6144, 840, //
|
||||||
|
6320, 830, //
|
||||||
|
6504, 820, //
|
||||||
|
6688, 810, //
|
||||||
|
6872, 800, //
|
||||||
|
7072, 790, //
|
||||||
|
7264, 780, //
|
||||||
|
7472, 770, //
|
||||||
|
7680, 760, //
|
||||||
|
7896, 750, //
|
||||||
|
8112, 740, //
|
||||||
|
8336, 730, //
|
||||||
|
8568, 720, //
|
||||||
|
8800, 710, //
|
||||||
|
9040, 700, //
|
||||||
|
9288, 690, //
|
||||||
|
9536, 680, //
|
||||||
|
9792, 670, //
|
||||||
|
10056, 660, //
|
||||||
|
10320, 650, //
|
||||||
|
10592, 640, //
|
||||||
|
10872, 630, //
|
||||||
|
11152, 620, //
|
||||||
|
11440, 610, //
|
||||||
|
11728, 600, //
|
||||||
|
12024, 590, //
|
||||||
|
12320, 580, //
|
||||||
|
12632, 570, //
|
||||||
|
12936, 560, //
|
||||||
|
13248, 550, //
|
||||||
|
13568, 540, //
|
||||||
|
13888, 530, //
|
||||||
|
14216, 520, //
|
||||||
|
14544, 510, //
|
||||||
|
14880, 500, //
|
||||||
|
15216, 490, //
|
||||||
|
15552, 480, //
|
||||||
|
15888, 470, //
|
||||||
|
16232, 460, //
|
||||||
|
16576, 450, //
|
||||||
|
16920, 440, //
|
||||||
|
17272, 430, //
|
||||||
|
17616, 420, //
|
||||||
|
17968, 410, //
|
||||||
|
18320, 400, //
|
||||||
|
18664, 390, //
|
||||||
|
19016, 380, //
|
||||||
|
19368, 370, //
|
||||||
|
19712, 360, //
|
||||||
|
20064, 350, //
|
||||||
|
20408, 340, //
|
||||||
|
20752, 330, //
|
||||||
|
21088, 320, //
|
||||||
|
21432, 310, //
|
||||||
|
21768, 300, //
|
||||||
|
22096, 290, //
|
||||||
|
22424, 280, //
|
||||||
|
22752, 270, //
|
||||||
|
23072, 260, //
|
||||||
|
23392, 250, //
|
||||||
|
23704, 240, //
|
||||||
|
24008, 230, //
|
||||||
|
24312, 220, //
|
||||||
|
24608, 210, //
|
||||||
|
24904, 200, //
|
||||||
|
25192, 190, //
|
||||||
|
25472, 180, //
|
||||||
|
25744, 170, //
|
||||||
|
26016, 160, //
|
||||||
|
26280, 150, //
|
||||||
|
26536, 140, //
|
||||||
|
26784, 130, //
|
||||||
|
27024, 120, //
|
||||||
|
27264, 110, //
|
||||||
|
27496, 100, //
|
||||||
|
27720, 90, //
|
||||||
|
27936, 80, //
|
||||||
|
28144, 70, //
|
||||||
|
28352, 60, //
|
||||||
|
28544, 50, //
|
||||||
|
28736, 40, //
|
||||||
|
28920, 30, //
|
||||||
|
29104, 20, //
|
||||||
|
29272, 10, //
|
||||||
};
|
};
|
||||||
const int NTCHandleLookupItems = sizeof(NTCHandleLookup) / (2 * sizeof(uint16_t));
|
const int NTCHandleLookupItems = sizeof(NTCHandleLookup) / (2 * sizeof(uint16_t));
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -15,12 +15,15 @@
|
|||||||
* runs again
|
* runs again
|
||||||
*/
|
*/
|
||||||
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) {
|
void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc) {
|
||||||
|
static uint8_t counter = 0;
|
||||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||||
if (hadc == &hadc1) {
|
if (hadc == &hadc1) {
|
||||||
if (pidTaskNotification) {
|
counter++;
|
||||||
vTaskNotifyGiveFromISR(pidTaskNotification, &xHigherPriorityTaskWoken);
|
if (counter % 4 == 0) {
|
||||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
if (pidTaskNotification) {
|
||||||
|
vTaskNotifyGiveFromISR(pidTaskNotification, &xHigherPriorityTaskWoken);
|
||||||
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "Pins.h"
|
#include "Pins.h"
|
||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
#include "TipThermoModel.h"
|
#include "TipThermoModel.h"
|
||||||
|
#include "configuration.h"
|
||||||
#include "history.hpp"
|
#include "history.hpp"
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
#include <IRQ.h>
|
#include <IRQ.h>
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
|
|
||||||
#include "BSP.h"
|
#include "BSP.h"
|
||||||
#include "I2C_Wrapper.hpp"
|
#include "I2C_Wrapper.hpp"
|
||||||
|
#include "IRQ.h"
|
||||||
#include "Pins.h"
|
#include "Pins.h"
|
||||||
#include "Setup.h"
|
#include "Setup.h"
|
||||||
#include "TipThermoModel.h"
|
#include "TipThermoModel.h"
|
||||||
|
#include "configuration.h"
|
||||||
#include "gd32vf103_timer.h"
|
#include "gd32vf103_timer.h"
|
||||||
#include "history.hpp"
|
#include "history.hpp"
|
||||||
#include "main.hpp"
|
#include "main.hpp"
|
||||||
#include <IRQ.h>
|
|
||||||
|
|
||||||
const uint16_t powerPWM = 255;
|
const uint16_t powerPWM = 255;
|
||||||
const uint8_t holdoffTicks = 25; // delay of 7 ms
|
const uint8_t holdoffTicks = 25; // delay of 7 ms
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#ifdef TEMP_uV_LOOKUP_HAKKO
|
#ifdef TEMP_uV_LOOKUP_HAKKO
|
||||||
const uint16_t uVtoDegC[] = {
|
const uint16_t uVtoDegC[] = {
|
||||||
//
|
//
|
||||||
//
|
// uv -> temp in C
|
||||||
0, 0, //
|
0, 0, //
|
||||||
266, 10, //
|
266, 10, //
|
||||||
522, 20, //
|
522, 20, //
|
||||||
|
|||||||
@@ -75,7 +75,9 @@ uint32_t TipThermoModel::getTipInC(bool sampleNow) {
|
|||||||
// Power usage indicates that our tip temp is lower than our thermocouple temp.
|
// Power usage indicates that our tip temp is lower than our thermocouple temp.
|
||||||
// I found a number that doesn't unbalance the existing PID, causing overshoot.
|
// I found a number that doesn't unbalance the existing PID, causing overshoot.
|
||||||
// This could be tuned in concert with PID parameters...
|
// This could be tuned in concert with PID parameters...
|
||||||
|
#ifndef NO_THERMAL_MASS_COMP
|
||||||
currentTipTempInC -= x10WattHistory.average() / 25;
|
currentTipTempInC -= x10WattHistory.average() / 25;
|
||||||
|
#endif
|
||||||
if (currentTipTempInC < 0)
|
if (currentTipTempInC < 0)
|
||||||
return 0;
|
return 0;
|
||||||
return currentTipTempInC;
|
return currentTipTempInC;
|
||||||
|
|||||||
@@ -129,6 +129,7 @@
|
|||||||
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100 //
|
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100 //
|
||||||
#define TEMP_uV_LOOKUP_HAKKO //
|
#define TEMP_uV_LOOKUP_HAKKO //
|
||||||
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
||||||
|
#define PID_TIM_HZ (8)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODEL_Pinecil
|
#ifdef MODEL_Pinecil
|
||||||
@@ -141,6 +142,7 @@
|
|||||||
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100 // Uses TS100 resistors
|
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS100 // Uses TS100 resistors
|
||||||
#define TEMP_uV_LOOKUP_HAKKO // Use Hakko lookup table
|
#define TEMP_uV_LOOKUP_HAKKO // Use Hakko lookup table
|
||||||
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
||||||
|
#define PID_TIM_HZ (8)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODEL_TS80
|
#ifdef MODEL_TS80
|
||||||
@@ -153,6 +155,7 @@
|
|||||||
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80 //
|
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80 //
|
||||||
#define TEMP_uV_LOOKUP_TS80 //
|
#define TEMP_uV_LOOKUP_TS80 //
|
||||||
#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate
|
#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate
|
||||||
|
#define PID_TIM_HZ (8)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODEL_TS80P
|
#ifdef MODEL_TS80P
|
||||||
@@ -165,17 +168,20 @@
|
|||||||
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80 //
|
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_TS80 //
|
||||||
#define TEMP_uV_LOOKUP_TS80 //
|
#define TEMP_uV_LOOKUP_TS80 //
|
||||||
#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate
|
#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate
|
||||||
|
#define PID_TIM_HZ (8)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODEL_MHP30
|
#ifdef MODEL_MHP30
|
||||||
#define VOLTAGE_DIV 355 // Default for MHP30
|
#define VOLTAGE_DIV 355 // Default for MHP30
|
||||||
#define PID_POWER_LIMIT 65 // Sets the max pwm power limit
|
#define PID_POWER_LIMIT 65 // Sets the max pwm power limit
|
||||||
#define CALIBRATION_OFFSET 0 // the adc offset in uV - MHP compensates automagically
|
#define CALIBRATION_OFFSET 0 // the adc offset in uV - MHP compensates automagically
|
||||||
#define POWER_LIMIT 65 // 65 watts default power limit
|
#define POWER_LIMIT 65 // 65 watts default power limit
|
||||||
#define MAX_POWER_LIMIT 65 //
|
#define MAX_POWER_LIMIT 65 //
|
||||||
#define POWER_LIMIT_STEPS 2 //
|
#define POWER_LIMIT_STEPS 2 //
|
||||||
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_MHP30 //
|
#define OP_AMP_GAIN_STAGE OP_AMP_GAIN_STAGE_MHP30 //
|
||||||
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
||||||
|
#define PID_TIM_HZ (32) // We run a faster update rate (ballpark no for now)
|
||||||
|
#define NO_THERMAL_MASS_COMP // The temp sensor is mounted seperate to the heater so we dont need this
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODEL_TS100
|
#ifdef MODEL_TS100
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
// Once we have feed-forward temp estimation we should be able to better tune this.
|
// Once we have feed-forward temp estimation we should be able to better tune this.
|
||||||
|
|
||||||
int32_t x10WattsNeeded = tempToX10Watts(tError);
|
int32_t x10WattsNeeded = tempToX10Watts(tError);
|
||||||
// tempError.average());
|
|
||||||
// note that milliWattsNeeded is sometimes negative, this counters overshoot
|
// note that milliWattsNeeded is sometimes negative, this counters overshoot
|
||||||
// from I term's inertia.
|
// from I term's inertia.
|
||||||
x10WattsOut += x10WattsNeeded;
|
x10WattsOut += x10WattsNeeded;
|
||||||
@@ -106,7 +105,7 @@ void startPIDTask(void const *argument __unused) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Secondary safety check to forcefully disable header when within ADC noise of top of ADC
|
// Secondary safety check to forcefully disable header when within ADC noise of top of ADC
|
||||||
if (getTipRawTemp(0) > (0x7FFF - 150)) {
|
if (getTipRawTemp(0) > (0x7FFF - 32)) {
|
||||||
x10WattsOut = 0;
|
x10WattsOut = 0;
|
||||||
}
|
}
|
||||||
if (systemSettings.powerLimit && x10WattsOut > (systemSettings.powerLimit * 10)) {
|
if (systemSettings.powerLimit && x10WattsOut > (systemSettings.powerLimit * 10)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user