Skip to content

Commit

Permalink
Adjust temperature.cpp to allow a different timeout for the heat bed,…
Browse files Browse the repository at this point in the history
… and adjust the thermistor settings for the third heater (the bed).
  • Loading branch information
giseburt committed Apr 5, 2017
1 parent 39c3986 commit 8645603
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions g2core/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@
#ifndef TEMP_MIN_RISE_DEGREES_OVER_TIME
#define TEMP_MIN_RISE_DEGREES_OVER_TIME (float)10.0
#endif
#ifndef TEMP_MIN_BED_RISE_DEGREES_OVER_TIME
#define TEMP_MIN_BED_RISE_DEGREES_OVER_TIME (float)3.0
#endif
#ifndef TEMP_MIN_RISE_TIME
#define TEMP_MIN_RISE_TIME (float)(60.0 * 1000.0) // 20 seconds
#define TEMP_MIN_RISE_TIME (float)(60.0 * 1000.0) // one minute
#endif
#ifndef TEMP_MIN_RISE_DEGREES_FROM_TARGET
#define TEMP_MIN_RISE_DEGREES_FROM_TARGET (float)10.0
Expand Down Expand Up @@ -230,8 +233,8 @@ void ADCPin<kADC2_PinNumber>::interrupt() {

// Heated bed
Thermistor<kADC0_PinNumber> thermistor3 {
/*T1:*/ 20.0, /*T2:*/ 190.0, /*T3:*/ 255.0,
/*R1:*/ 140000.0, /*R2:*/ 490.0, /*R3:*/ 109.0, /*pullup_resistance:*/ 4700, /*inline_resistance:*/ 4700
/*T1:*/ 20.0, /*T2:*/ 42.0, /*T3:*/ 76.0,
/*R1:*/ 140000.0, /*R2:*/ 36755.0, /*R3:*/ 10000.0, /*pullup_resistance:*/ 4700, /*inline_resistance:*/ 4700
};
#if ADC0_AVAILABLE == 1
namespace Motate {
Expand Down Expand Up @@ -331,11 +334,12 @@ struct PID {
bool _at_set_point;

Timeout _rise_time_timeout; // used to keep track of if we are increasing temperature fast enough
float _min_rise_over_time; // the amount of degrees that it must rise in the given time
float _rise_time_checkpoint; // when we start the timer, we set _rise_time_checkpoint to the minimum goal

bool _enable; // set true to enable this heater

PID(float P, float I, float D, float startSetPoint = 0.0) : _p_factor{P/100.0f}, _i_factor{I/100.0f}, _d_factor{D/100.0f}, _set_point{startSetPoint}, _at_set_point{false} {};
PID(float P, float I, float D, float min_rise_over_time, float startSetPoint = 0.0) : _p_factor{P/100.0f}, _i_factor{I/100.0f}, _d_factor{D/100.0f}, _set_point{startSetPoint}, _at_set_point{false}, _min_rise_over_time(min_rise_over_time) {};

float getNewOutput(float input) {
// If the input is < 0, the sensor failed
Expand Down Expand Up @@ -380,7 +384,7 @@ struct PID {

if (!_rise_time_timeout.isSet() && (_set_point > (input + TEMP_MIN_RISE_DEGREES_FROM_TARGET))) {
_rise_time_timeout.set(TEMP_MIN_RISE_TIME);
_rise_time_checkpoint = min(input + TEMP_MIN_RISE_DEGREES_OVER_TIME, _set_point + TEMP_SETPOINT_HYSTERESIS);
_rise_time_checkpoint = min(input + _min_rise_over_time, _set_point + TEMP_SETPOINT_HYSTERESIS);
}
}

Expand Down Expand Up @@ -437,9 +441,9 @@ struct PID {
// NOTICE, the JSON alters incoming values for these!
// {he1p:9} == 9.0/100.0 here

PID pid1 { 9.0, 0.11, 400.0 }; // default values
PID pid2 { 7.5, 0.12, 400.0 }; // default values
PID pid3 { 7.5, 0.12, 400.0 }; // default values
PID pid1 { 9.0, 0.11, 400.0, TEMP_MIN_RISE_DEGREES_OVER_TIME }; // default values
PID pid2 { 7.5, 0.12, 400.0, TEMP_MIN_RISE_DEGREES_OVER_TIME }; // default values
PID pid3 { 7.5, 0.12, 400.0, TEMP_MIN_BED_RISE_DEGREES_OVER_TIME }; // default values
Timeout pid_timeout;


Expand Down

0 comments on commit 8645603

Please sign in to comment.