Importing Miniware's alg for tip temperature for the MHP
Love to @g3gg0
This commit is contained in:
@@ -4,54 +4,19 @@
|
|||||||
* Created on: 1 May 2021
|
* Created on: 1 May 2021
|
||||||
* Author: Ralim
|
* Author: Ralim
|
||||||
*/
|
*/
|
||||||
|
#include "Setup.h"
|
||||||
#include "TipThermoModel.h"
|
#include "TipThermoModel.h"
|
||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
extern uint16_t tipSenseResistancex10Ohms;
|
||||||
#ifdef TEMP_uV_LOOKUP_MHP30
|
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) {
|
||||||
const uint16_t uVtoDegC[] = {
|
// For the MHP30, we are mimicing the original code and using the resistor fitted to the base of the heater head, this is measured in the isTipDisconnected() function
|
||||||
//
|
if (tipSenseResistancex10Ohms > 900 && tipSenseResistancex10Ohms <= 1100) {
|
||||||
//
|
int32_t a = ((tipSenseResistancex10Ohms / 10) + 300) * (3300000 - tipuVDelta);
|
||||||
0, 0, //
|
int32_t b = a / 1000000;
|
||||||
397, 10, //
|
int32_t c = tipuVDelta - b;
|
||||||
798, 20, ///
|
int32_t d = c * 243 / 1000;
|
||||||
1203, 30, //
|
return d / 10;
|
||||||
1612, 40, //
|
}
|
||||||
2023, 50, //
|
return 0xFFFF;
|
||||||
2436, 60, //
|
|
||||||
3225, 79, //
|
|
||||||
4013, 98, //
|
|
||||||
4756, 116, //
|
|
||||||
5491, 134, //
|
|
||||||
5694, 139, //
|
|
||||||
6339, 155, //
|
|
||||||
7021, 172, //
|
|
||||||
7859, 193, //
|
|
||||||
8619, 212, //
|
|
||||||
9383, 231, //
|
|
||||||
10153, 250, //
|
|
||||||
10930, 269, //
|
|
||||||
11712, 288, //
|
|
||||||
12499, 307, //
|
|
||||||
13290, 326, //
|
|
||||||
14084, 345, //
|
|
||||||
14881, 364, //
|
|
||||||
15680, 383, //
|
|
||||||
16482, 402, //
|
|
||||||
17285, 421, //
|
|
||||||
18091, 440, //
|
|
||||||
18898, 459, //
|
|
||||||
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const int uVtoDegCItems = sizeof(uVtoDegC) / (2 * sizeof(uint16_t));
|
|
||||||
|
|
||||||
uint32_t TipThermoModel::convertuVToDegC(uint32_t tipuVDelta) {
|
|
||||||
// For the MHP30, we are mimicing the original code and using the resistor fitted to the base of the heater head
|
|
||||||
// As such, we need to use the ADC and some pin toggling to measure this resistor
|
|
||||||
// We want to cache the value as it takes time to measure, but we also need to re-measure when the tip is inserted / removed
|
|
||||||
// We can detect the tip being inserted / removed by using the reading of that channel, as if its reporting max (0xFFFF) then the heater is not connected
|
|
||||||
|
|
||||||
return Utils::InterpolateLookupTable(uVtoDegC, uVtoDegCItems, tipuVDelta);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -168,15 +168,14 @@
|
|||||||
#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 700 // the adc offset in uV
|
#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 TEMP_uV_LOOKUP_MHP30 //
|
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
||||||
#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODEL_TS100
|
#ifdef MODEL_TS100
|
||||||
@@ -200,6 +199,6 @@ const uint8_t tipResistance = 45; // x10 ohms, 4.5 typical for ts80 tips
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MODEL_MHP30
|
#ifdef MODEL_MHP30
|
||||||
const uint32_t tipMass = 100; // TODO
|
const uint32_t tipMass = 45; // TODO
|
||||||
const uint8_t tipResistance = 75; // x10 ohms, ~6 typical
|
const uint8_t tipResistance = 75; // x10 ohms, ~6 typical
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user