Skip to content

Commit

Permalink
make pid possible to be disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
bkubicek committed Oct 21, 2011
1 parent 73d5bd5 commit ad4ae7c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
12 changes: 12 additions & 0 deletions Marlin/EEPROM.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ void StoreSettings() {
EEPROM_writeAnything(i,minsegmenttime);
EEPROM_writeAnything(i,max_xy_jerk);
EEPROM_writeAnything(i,max_z_jerk);
#ifdef PIDTEMP
EEPROM_writeAnything(i,Kp);
EEPROM_writeAnything(i,Ki);
EEPROM_writeAnything(i,Kd);
#else
EEPROM_writeAnything(i,3000);
EEPROM_writeAnything(i,0);
EEPROM_writeAnything(i,0);
#endif
char ver2[4]=EEPROM_VERSION;
i=EEPROM_OFFSET;
EEPROM_writeAnything(i,ver2); // validate data
Expand All @@ -67,9 +73,13 @@ void RetrieveSettings(bool def=false){ // if def=true, the default values will
EEPROM_readAnything(i,minsegmenttime);
EEPROM_readAnything(i,max_xy_jerk);
EEPROM_readAnything(i,max_z_jerk);
#ifndef PIDTEMP
float Kp,Ki,Kd;
#endif
EEPROM_readAnything(i,Kp);
EEPROM_readAnything(i,Ki);
EEPROM_readAnything(i,Kd);

ECHOLN("Stored settings retreived:");
}
else {
Expand Down Expand Up @@ -100,8 +110,10 @@ void RetrieveSettings(bool def=false){ // if def=true, the default values will
ECHOLN(" M204 S" <<_FLOAT(acceleration,2) << " T" << _FLOAT(retract_acceleration,2));
ECHOLN("Advanced variables: S=Min feedrate (mm/s), T=Min travel feedrate (mm/s), B=minimum segment time (ms), X=maximum xY jerk (mm/s), Z=maximum Z jerk (mm/s)");
ECHOLN(" M205 S" <<_FLOAT(minimumfeedrate/60,2) << " T" << _FLOAT(mintravelfeedrate/60,2) << " B" << _FLOAT(minsegmenttime,2) << " X" << _FLOAT(max_xy_jerk/60,2) << " Z" << _FLOAT(max_z_jerk/60,2));
#ifdef PIDTEMP
ECHOLN("PID settings:");
ECHOLN(" M301 P" << _FLOAT(Kp,3) << " I" << _FLOAT(Ki,3) << " D" << _FLOAT(Kd,3));
#endif

}

Expand Down
4 changes: 3 additions & 1 deletion Marlin/Marlin.pde
Original file line number Diff line number Diff line change
Expand Up @@ -964,9 +964,11 @@ inline void process_commands()
Serial.print(tt);
Serial.print(", raw:");
Serial.print(current_raw);
#if TEMP_1_PIN > -1
#if TEMP_1_PIN > -1
#ifdef PIDTEMP
Serial.print(" B:");
Serial.println(HeaterPower);
#endif
#else
Serial.println();
#endif
Expand Down

1 comment on commit ad4ae7c

@lampmaker
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't do it like this. the EEPROM_writeanything needs to know the type/size of the variable to be written.
Why not just keep Kp,Ki,Kd in the code, even if PID is disabled? The at least the EEPROM reads&writes fine and is compatible.

Alternatively, it's perhaps best to switch between PID and simple on/off using an M code

e.g
M302: use PID
M303: use on/off

Please sign in to comment.