mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-23 12:04:19 +00:00
Added temperature offset/gain settings for AD595.
This commit is contained in:
parent
3f20f37c78
commit
73344e69c1
@ -66,6 +66,12 @@
|
|||||||
#define HEATER_2_MAXTEMP 275
|
#define HEATER_2_MAXTEMP 275
|
||||||
#define BED_MAXTEMP 150
|
#define BED_MAXTEMP 150
|
||||||
|
|
||||||
|
//These defines help to calibrate the AD595 sensor in case you get wrong temperature measurements.
|
||||||
|
//The measured temperature is defined as "actualTemp = (measuredTemp * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET"
|
||||||
|
#define TEMP_SENSOR_AD595_OFFSET 0.0
|
||||||
|
#define TEMP_SENSOR_AD595_GAIN 1.0
|
||||||
|
|
||||||
|
|
||||||
// PID settings:
|
// PID settings:
|
||||||
// Comment the following line to disable PID and enable bang-bang.
|
// Comment the following line to disable PID and enable bang-bang.
|
||||||
#define PIDTEMP
|
#define PIDTEMP
|
||||||
|
@ -312,7 +312,7 @@ int temp2analog(int celsius, uint8_t e) {
|
|||||||
|
|
||||||
return (1023 * OVERSAMPLENR) - raw;
|
return (1023 * OVERSAMPLENR) - raw;
|
||||||
}
|
}
|
||||||
return celsius * (1024.0 / (5.0 * 100.0) ) * OVERSAMPLENR;
|
return ((celsius-TEMP_SENSOR_AD595_OFFSET)/TEMP_SENSOR_AD595_GAIN) * (1024.0 / (5.0 * 100.0) ) * OVERSAMPLENR;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Takes bed temperature value as input and returns corresponding raw value.
|
// Takes bed temperature value as input and returns corresponding raw value.
|
||||||
@ -342,7 +342,7 @@ int temp2analogBed(int celsius) {
|
|||||||
|
|
||||||
return (1023 * OVERSAMPLENR) - raw;
|
return (1023 * OVERSAMPLENR) - raw;
|
||||||
#elif defined BED_USES_AD595
|
#elif defined BED_USES_AD595
|
||||||
return lround(celsius * (1024.0 * OVERSAMPLENR/ (5.0 * 100.0) ) );
|
return lround(((celsius-TEMP_SENSOR_AD595_OFFSET)/TEMP_SENSOR_AD595_GAIN) * (1024.0 * OVERSAMPLENR/ (5.0 * 100.0) ) );
|
||||||
#else
|
#else
|
||||||
#warning No heater-type defined for the bed.
|
#warning No heater-type defined for the bed.
|
||||||
return 0;
|
return 0;
|
||||||
@ -390,7 +390,7 @@ float analog2temp(int raw, uint8_t e) {
|
|||||||
|
|
||||||
return celsius;
|
return celsius;
|
||||||
}
|
}
|
||||||
return raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR;
|
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Derived from RepRap FiveD extruder::getTemperature()
|
// Derived from RepRap FiveD extruder::getTemperature()
|
||||||
@ -421,7 +421,7 @@ float analog2tempBed(int raw) {
|
|||||||
return celsius;
|
return celsius;
|
||||||
|
|
||||||
#elif defined BED_USES_AD595
|
#elif defined BED_USES_AD595
|
||||||
return raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR;
|
return ((raw * ((5.0 * 100.0) / 1024.0) / OVERSAMPLENR) * TEMP_SENSOR_AD595_GAIN) + TEMP_SENSOR_AD595_OFFSET;
|
||||||
#else
|
#else
|
||||||
#warning No heater-type defined for the bed.
|
#warning No heater-type defined for the bed.
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user