mirror of
https://github.com/arwidcool/Solder-Plate.git
synced 2025-02-17 19:09:23 +01:00
Fixed menu for Thermistor resistence made it show Kohm with 2 decimal points
This commit is contained in:
parent
e117d72f53
commit
2590724561
@ -92,9 +92,9 @@ void OledDisplay::handleDrawThermistorMenu(OledMenuItem menuItem)
|
||||
display.setTextSize(1, 2);
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
float thermR = thermistors[i].getResistance();
|
||||
float thermR = thermistors[i].getResistance()/1000;
|
||||
display.setCursor(i < 3 ? 0 : (SCREEN_WIDTH / 2 + 20), 20 * (i % 3));
|
||||
display.println(String(i + 1) + " " + String((int)(thermR)));
|
||||
display.println(String(i + 1) + ":" + String(thermR));
|
||||
}
|
||||
centerText(menuItem.title);
|
||||
displayIndicators();
|
||||
@ -130,7 +130,7 @@ void OledDisplay::setup()
|
||||
OledMenu *tempsMenu = new OledMenu(3);
|
||||
tempsMenu->setElements(new OledMenuItem[8]{
|
||||
OledMenuItem("C\0", MENUITEM_THERMISTOR_START + 6),
|
||||
OledMenuItem("R\0", MENUITEM_THERMISTOR_START + 7),
|
||||
OledMenuItem("R(K)\0", MENUITEM_THERMISTOR_START + 7),
|
||||
OledMenuItem("T1\0", MENUITEM_THERMISTOR_START + 0),
|
||||
OledMenuItem("T2\0", MENUITEM_THERMISTOR_START + 1),
|
||||
OledMenuItem("T3\0", MENUITEM_THERMISTOR_START + 2),
|
||||
|
@ -9,19 +9,20 @@ TempCalibration calibration_100K_3950 = {25, 100000, 86, 10324, 169, 1148};
|
||||
// Initalize the 3950 100K thermistors with ACTUAL reference resistor measurnment(Measured between Left pin and GND when the board is powered off) using the default calibration data for 100K thermistor
|
||||
|
||||
// You can also make a custom calibration data for your thermistor and use that instead of the default one pass it as shown below --> keep the naming of the thermistor the same as the one you are replacing
|
||||
//Thermistor thermistor1(THERMISTOR1_PIN, 100000, calibration_100K_3950,ThermistorZ_Placement::TOP,ThermistorXY_Placement::MIDDLE);
|
||||
//TempCalibration calibration_10K_3950 = {25, 10000, 86, 1032, 169, 118};
|
||||
//Thermistor thermistor1(THERMISTOR1_PIN, 100000, calibration_10K_3950,ThermistorZ_Placement::TOP,ThermistorXY_Placement::MIDDLE);
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
//This is where you set your potentiometer values for the 6 thermistors
|
||||
//This is where you set your potentiometer values and positioning for the 6 thermistors
|
||||
|
||||
//You can tweak them from the datasheet to best fit your thermistor but we reccoemnd using the default values and setting the potentiometer to these values
|
||||
// Does not have to be perfect just set it close to this value and record the measured value and put it for the thermistors
|
||||
//To measure the resistence turn off the controller completley and measure between GND and the left pin of the connector with the thermistor unplugged
|
||||
|
||||
//2.5k reference = Best accuracy around 138C
|
||||
Thermistor thermistor1(THERMISTOR1_PIN, 2500,ThermistorZ_Placement::TOP,ThermistorXY_Placement::MIDDLE);
|
||||
Thermistor thermistor1(THERMISTOR1_PIN, 2500,ThermistorZ_Placement::BOTTOM,ThermistorXY_Placement::RIGHT);
|
||||
Thermistor thermistor2(THERMISTOR2_PIN, 2500,ThermistorZ_Placement::TOP,ThermistorXY_Placement::MIDDLE);
|
||||
Thermistor thermistor3(THERMISTOR3_PIN, 2500,ThermistorZ_Placement::TOP,ThermistorXY_Placement::MIDDLE);
|
||||
//1k reference = Best accuracy around 173c
|
||||
@ -75,9 +76,10 @@ ReflowProfile reflowProfiles[] = {
|
||||
|
||||
ReflowProfile chosenReflowProfile = reflowProfiles[0];
|
||||
|
||||
|
||||
|
||||
//Currently unsued -> can be used to calculate current draw of the system along with system voltage and compared to the current sensor and just be a nice sanity check for the system
|
||||
uint16_t plateResistanceOhm = 0;
|
||||
|
||||
|
||||
EEPROMDataManager eepromDataManager = EEPROMDataManager();
|
||||
|
||||
PidControllerData pidControllerData = {0 /*currentTemp*/, 60 /*TargetTemp*/, 255 /*PWM*/};
|
||||
|
@ -1,6 +1,14 @@
|
||||
#include "Thermistor.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief Calculates and returns the temperature based on the resistance of the thermistor.
|
||||
*
|
||||
* This function calculates the temperature using the Steinhart-Hart equation and the coefficients
|
||||
* provided. It takes an average of 5 resistance readings and converts it to temperature using the
|
||||
* scaling factor. The calculated temperature is returned.
|
||||
*
|
||||
* @return The temperature in degrees Celsius.
|
||||
*/
|
||||
float Thermistor::getTemperature()
|
||||
{
|
||||
|
||||
@ -17,9 +25,21 @@ float Thermistor::getTemperature()
|
||||
|
||||
temp = temp / samples;
|
||||
|
||||
// The scaling factor should only be applied when the plate is being heated up -> 60C seems like a good threshold unless you live in the sahara desert with no AC
|
||||
// Its non-linear so it will be more accurate so we will probably need to impliment a refrence table for the scaling factor this is just a rough estimate it will be based on a sensor calibrated on the top middle of the plate
|
||||
if (temp > 60)
|
||||
{
|
||||
temp = temp * scalingFactor;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the coefficients for the thermistor based on the given temperature calibration.
|
||||
*
|
||||
* @param calibration The temperature calibration data.
|
||||
*/
|
||||
void Thermistor::calculateCoefficents(TempCalibration calibration)
|
||||
{
|
||||
|
||||
@ -45,6 +65,47 @@ void Thermistor::calculateCoefficents(TempCalibration calibration)
|
||||
coefficents.c = (c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the scaling factor for the thermistor based on its placement in the 3D space.
|
||||
* The scaling factor is used to adjust the temperature readings of the thermistor.
|
||||
*/
|
||||
void Thermistor::calculateScalingFactor()
|
||||
{
|
||||
|
||||
switch (zPlacement)
|
||||
{
|
||||
case TOP:
|
||||
switch (xyPlacment)
|
||||
{
|
||||
case MIDDLE:
|
||||
scalingFactor = 1;
|
||||
break;
|
||||
case LEFT:
|
||||
scalingFactor = 1.1;
|
||||
break;
|
||||
case RIGHT:
|
||||
scalingFactor = 1.1;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BOTTOM:
|
||||
switch (xyPlacment)
|
||||
{
|
||||
case MIDDLE:
|
||||
scalingFactor = 1.1;
|
||||
break;
|
||||
case LEFT:
|
||||
scalingFactor = 1.2;
|
||||
break;
|
||||
case RIGHT:
|
||||
scalingFactor = 1.2;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float Thermistor::getResistance()
|
||||
{
|
||||
|
||||
@ -56,7 +117,7 @@ float Thermistor::getResistance()
|
||||
float buffer = raw * systemVoltage;
|
||||
float vOut = (buffer) / 1023;
|
||||
|
||||
//Calculate the resistance of the thermistor with the system voltage accounted for
|
||||
// Calculate the resistance of the thermistor with the system voltage accounted for
|
||||
buffer = (systemVoltage / vOut) - 1;
|
||||
|
||||
// return the resistence
|
||||
|
@ -32,7 +32,6 @@ extern TempCalibration calibration_100K_3950;
|
||||
|
||||
extern AnalogRef analogRef;
|
||||
|
||||
// Include any necessary libraries here
|
||||
|
||||
enum ThermistorZ_Placement
|
||||
{
|
||||
@ -56,11 +55,13 @@ public:
|
||||
Thermistor(uint8_t pin, uint16_t resistance, TempCalibration calibration,ThermistorZ_Placement zPlacement,ThermistorXY_Placement xyPlacment) : thermistorPin(pin), setRes(resistance), calibration(calibration),zPlacement(zPlacement),xyPlacment(xyPlacment)
|
||||
{
|
||||
calculateCoefficents(calibration);
|
||||
calculateScalingFactor();
|
||||
}
|
||||
|
||||
Thermistor(uint8_t pin, uint16_t resistance,ThermistorZ_Placement zPlacement,ThermistorXY_Placement xyPlacment) : thermistorPin(pin), setRes(resistance), calibration(calibration_100K_3950),zPlacement(zPlacement),xyPlacment(xyPlacment)
|
||||
{
|
||||
calculateCoefficents(calibration);
|
||||
calculateScalingFactor();
|
||||
}
|
||||
|
||||
// Public Methods
|
||||
@ -71,6 +72,8 @@ public:
|
||||
// Public Variables
|
||||
void calculateCoefficents(TempCalibration calibration);
|
||||
|
||||
float getScalingFactor() { return scalingFactor; };
|
||||
|
||||
private:
|
||||
ThermistorZ_Placement zPlacement;
|
||||
ThermistorXY_Placement xyPlacment;
|
||||
@ -81,6 +84,10 @@ private:
|
||||
Coefficents coefficents;
|
||||
float referenceResistance;
|
||||
TempCalibration calibration;
|
||||
float scalingFactor ;
|
||||
void calculateScalingFactor();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // THERMISTOR_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user