application: add bed temperatures (WIP)
This commit is contained in:
parent
b071eb6737
commit
8b62d16436
|
@ -337,12 +337,41 @@ static float bed_tophalf_temperature(void)
|
||||||
|
|
||||||
// convert to °C
|
// convert to °C
|
||||||
// calibrated using a DS18B20 (accuracy = +- 0.5°C), with 12-bit precision
|
// calibrated using a DS18B20 (accuracy = +- 0.5°C), with 12-bit precision
|
||||||
// 558 = 19.500 °C, 1624 = 50.625, 2850 = 82.250
|
// 558 = 19.500 °C, 616 = 21.8 °C, 1624 = 50.625 °C, 2850 = 82.250 °C, 2926 = 83.625 °C
|
||||||
// 616 = 21.8 C, 2926 = 83.625
|
|
||||||
|
|
||||||
return measurement * 0.0273778 + 4.22317;
|
return measurement * 0.0270798 + 4.38946;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** read bed bottom half temperature
|
||||||
|
* @return temperature in °C
|
||||||
|
*/
|
||||||
|
static float bed_bothalf_temperature(void)
|
||||||
|
{
|
||||||
|
const uint16_t measurement = sensor_max1247_read(1); // read measured value from corresponding thermistor
|
||||||
|
|
||||||
|
// convert to °C
|
||||||
|
// calibrated using a DS18B20 (accuracy = +- 0.5°C), with 12-bit precision
|
||||||
|
// 549 = 19.312 °C, 12 = 63.3 °C
|
||||||
|
|
||||||
|
return measurement * 0.0270798 + 4.38946;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** read bed tube temperature
|
||||||
|
* @return temperature in °C
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
static float bed_tube_temperature(void)
|
||||||
|
{
|
||||||
|
const uint16_t measurement = sensor_max1247_read(3); // read measured value from corresponding thermistor
|
||||||
|
|
||||||
|
// convert to °C
|
||||||
|
// calibrated using a DS18B20 (accuracy = +- 0.5°C), with 12-bit precision
|
||||||
|
// 19.312 °C = 564
|
||||||
|
|
||||||
|
return measurement * 0.0270798 + 4.38946;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/** read heat sink temperature
|
/** read heat sink temperature
|
||||||
* @return temperature in °C
|
* @return temperature in °C
|
||||||
*/
|
*/
|
||||||
|
@ -352,14 +381,11 @@ static float bed_heatsink_temperature(void)
|
||||||
|
|
||||||
// convert to °C
|
// convert to °C
|
||||||
// calibrated using a DS18B20 (accuracy = +- 0.5°C), with 12-bit precision
|
// calibrated using a DS18B20 (accuracy = +- 0.5°C), with 12-bit precision
|
||||||
//
|
// 557 = 19.312 °C, 1624 = 50.625 °C
|
||||||
|
|
||||||
return measurement * 0.0273778 + 4.22317; // TODO this values are from the bed top half
|
return measurement * 0.0273778 + 4.22317;
|
||||||
}
|
}
|
||||||
|
|
||||||
// bottom 12 = 63.3 °C
|
|
||||||
// heat sink
|
|
||||||
|
|
||||||
/** run PID control for bed temperature (using the top half) */
|
/** run PID control for bed temperature (using the top half) */
|
||||||
static void bed_pid(void)
|
static void bed_pid(void)
|
||||||
{
|
{
|
||||||
|
@ -403,10 +429,6 @@ static void bed_pid(void)
|
||||||
tec_power((uint16_t)power); // set power
|
tec_power((uint16_t)power); // set power
|
||||||
}
|
}
|
||||||
|
|
||||||
// bottom 19.312 = 549
|
|
||||||
// sink 19.312 = 557
|
|
||||||
// tube 19.312 = 564
|
|
||||||
|
|
||||||
/** display available commands
|
/** display available commands
|
||||||
* @param[in] argument no argument required
|
* @param[in] argument no argument required
|
||||||
*/
|
*/
|
||||||
|
@ -1020,10 +1042,11 @@ void main(void)
|
||||||
// read temperatures
|
// read temperatures
|
||||||
const float lid_temp = lid_temperature();
|
const float lid_temp = lid_temperature();
|
||||||
const float heatsink_temp = bed_heatsink_temperature();
|
const float heatsink_temp = bed_heatsink_temperature();
|
||||||
const float bed_temp = bed_tophalf_temperature();
|
const float top_temp = bed_tophalf_temperature();
|
||||||
|
const float bot_temp = bed_bothalf_temperature();
|
||||||
// read bed temperatures
|
// read bed temperatures
|
||||||
printf("bed: top=%.2f, bottom=%u, sink=%u %.02f, tube=%u; 393-A=%u; 339-3=%u\n", bed_temp, sensor_max1247_read(1), sensor_max1247_read(2), heatsink_temp, sensor_max1247_read(3), gpio_get(GPIO_PORT(BED_PIN_393A), GPIO_PIN(BED_PIN_393A)) ? 1 : 0, gpio_get(GPIO_PORT(BED_PIN_3393), GPIO_PIN(BED_PIN_3393)) ? 1 : 0);
|
printf("bed: top=%u %.2f, bottom=%u %.02f, sink=%u %.02f, tube=%u; 393-A=%u; 339-3=%u\n",sensor_max1247_read(0), top_temp, sensor_max1247_read(1), bot_temp, sensor_max1247_read(2), heatsink_temp, sensor_max1247_read(3), gpio_get(GPIO_PORT(BED_PIN_393A), GPIO_PIN(BED_PIN_393A)) ? 1 : 0, gpio_get(GPIO_PORT(BED_PIN_3393), GPIO_PIN(BED_PIN_3393)) ? 1 : 0);
|
||||||
printf("lid: %.02f V\n", lid_temp);
|
printf("lid: %.04f °C\n", lid_temp);
|
||||||
if (ds18b20_present) {
|
if (ds18b20_present) {
|
||||||
const float temp = sensor_ds18b20_temperature(0); // get temperature
|
const float temp = sensor_ds18b20_temperature(0); // get temperature
|
||||||
sensor_ds18b20_convert(0); // start next conversion (since it takes almost 1 s)
|
sensor_ds18b20_convert(0); // start next conversion (since it takes almost 1 s)
|
||||||
|
@ -1032,9 +1055,9 @@ void main(void)
|
||||||
// time to check if everything is OK
|
// time to check if everything is OK
|
||||||
if (!error && STATE_SAFE != state) { // only check if we are not in the safe state
|
if (!error && STATE_SAFE != state) { // only check if we are not in the safe state
|
||||||
// check lid temperature
|
// check lid temperature
|
||||||
if (lid_temp < 5.0) { // voltage is at the upper limit (3.3V), meaning it is directly connected to the 5V pull-up resistor, and the lid thermistor does not pull it to ground
|
if (lid_temp < 5.0) { // voltage is at the upper limit (3.3V), meaning it is directly connected to the 3.3V pull-up resistor, and the lid thermistor does not pull it to ground
|
||||||
error = "lid thermistor is probably not connected";
|
error = "lid thermistor is probably not connected";
|
||||||
} else if (lid_temp > 100) {
|
} else if (lid_temp > 100.0) {
|
||||||
error = "lid is getting too warm";
|
error = "lid is getting too warm";
|
||||||
}
|
}
|
||||||
// check fan
|
// check fan
|
||||||
|
|
Loading…
Reference in New Issue