Skip to content

Commit

Permalink
Change PID dummy value to NAN
Browse files Browse the repository at this point in the history
Fixes #17078
  • Loading branch information
thinkyhead committed Mar 6, 2020
1 parent 1da49d0 commit 913de02
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
10 changes: 5 additions & 5 deletions Marlin/src/module/configuration_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,8 @@ void MarlinSettings::postprocess() {
HOTEND_LOOP() {
PIDCF_t pidcf = {
#if DISABLED(PIDTEMP)
DUMMY_PID_VALUE, DUMMY_PID_VALUE, DUMMY_PID_VALUE,
DUMMY_PID_VALUE, DUMMY_PID_VALUE
NAN, NAN, NAN,
NAN, NAN
#else
PID_PARAM(Kp, e),
unscalePID_i(PID_PARAM(Ki, e)),
Expand Down Expand Up @@ -881,7 +881,7 @@ void MarlinSettings::postprocess() {

const PID_t bed_pid = {
#if DISABLED(PIDTEMPBED)
DUMMY_PID_VALUE, DUMMY_PID_VALUE, DUMMY_PID_VALUE
NAN, NAN, NAN
#else
// Store the unscaled PID values
thermalManager.temp_bed.pid.Kp,
Expand Down Expand Up @@ -1725,7 +1725,7 @@ void MarlinSettings::postprocess() {
PIDCF_t pidcf;
EEPROM_READ(pidcf);
#if ENABLED(PIDTEMP)
if (!validating && pidcf.Kp != DUMMY_PID_VALUE) {
if (!validating && !isnan(pidcf.Kp)) {
// Scale PID values since EEPROM values are unscaled
PID_PARAM(Kp, e) = pidcf.Kp;
PID_PARAM(Ki, e) = scalePID_i(pidcf.Ki);
Expand Down Expand Up @@ -1761,7 +1761,7 @@ void MarlinSettings::postprocess() {
PID_t pid;
EEPROM_READ(pid);
#if ENABLED(PIDTEMPBED)
if (!validating && pid.Kp != DUMMY_PID_VALUE) {
if (!validating && !isnan(pid.Kp)) {
// Scale PID values since EEPROM values are unscaled
thermalManager.temp_bed.pid.Kp = pid.Kp;
thermalManager.temp_bed.pid.Ki = scalePID_i(pid.Ki);
Expand Down
8 changes: 3 additions & 5 deletions Marlin/src/module/temperature.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ hotend_pid_t;
typedef IF<(LPQ_MAX_LEN > 255), uint16_t, uint8_t>::type lpq_ptr_t;
#endif

#define DUMMY_PID_VALUE 3000.0f

#if ENABLED(PIDTEMP)
#define _PID_Kp(H) Temperature::temp_hotend[H].pid.Kp
#define _PID_Ki(H) Temperature::temp_hotend[H].pid.Ki
Expand All @@ -92,9 +90,9 @@ hotend_pid_t;
#define _PID_Kf(H) 0
#endif
#else
#define _PID_Kp(H) DUMMY_PID_VALUE
#define _PID_Ki(H) DUMMY_PID_VALUE
#define _PID_Kd(H) DUMMY_PID_VALUE
#define _PID_Kp(H) NAN
#define _PID_Ki(H) NAN
#define _PID_Kd(H) NAN
#define _PID_Kc(H) 1
#endif

Expand Down

0 comments on commit 913de02

Please sign in to comment.