Skip to content

Commit

Permalink
now there is pid enabled by defualt
Browse files Browse the repository at this point in the history
Merge branch 'Slowdown' of https://github.com/bkubicek/Marlin

Conflicts:
	Marlin/EEPROM.h
	Marlin/Marlin.pde
  • Loading branch information
bkubicek committed Oct 21, 2011
2 parents cf397ca + d029252 commit 10c2489
Show file tree
Hide file tree
Showing 5 changed files with 280 additions and 185 deletions.
20 changes: 13 additions & 7 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


#ifndef CONFIGURATION_H
#define CONFIGURATION_H

Expand Down Expand Up @@ -44,7 +46,7 @@ const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the

//#define ULTIPANEL
#ifdef ULTIPANEL
#define NEWPANEL //enable this if you have a click-encoder panel
//#define NEWPANEL //enable this if you have a click-encoder panel
#define SDSUPPORT
#define ULTRA_LCD
#define LCD_WIDTH 20
Expand Down Expand Up @@ -140,16 +142,20 @@ bool axis_relative_modes[] = {false, false, false, false};

/// PID settings:
// Uncomment the following line to enable PID support.
//#define PIDTEMP
#define SMOOTHING
#define SMOOTHFACTOR 5.0
float current_raw_average=0;

#define PIDTEMP
#ifdef PIDTEMP
//#define PID_DEBUG 1 // Sends debug data to the serial port.
//#define PID_OPENLOOP 1 // Puts PID in open loop. M104 sets the output power in %
#define PID_MAX 156 // limits current to nozzle
#define PID_INTEGRAL_DRIVE_MAX 156.0
#define PID_MAX 255 // limits current to nozzle
#define PID_INTEGRAL_DRIVE_MAX 255
#define PID_dT 0.16
double Kp = 20.0;
double Ki = 1.5*PID_dT;
double Kd = 80/PID_dT;
double Kp = 1000; //20.0;
double Ki = 0; //1.5*PID_dT;
double Kd = 0; //80/PID_dT;
#endif // PIDTEMP


Expand Down
62 changes: 25 additions & 37 deletions Marlin/EEPROM.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

//======================================================================================
template <class T> int EEPROM_writeAnything(int &ee, const T& value)
{
Expand All @@ -18,10 +19,9 @@ template <class T> int EEPROM_readAnything(int &ee, T& value)
}
//======================================================================================


#define EEPROM_OFFSET 100

#define EEPROM_VERSION "V03" // IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
#define EEPROM_VERSION "V04" // IMPORTANT: Whenever there are changes made to the variables stored in EEPROM
// in the functions below, also increment the version number. This makes sure that
// the default values are used whenever there is a change to the data, to prevent
// wrong data being written to the variables.
Expand All @@ -40,10 +40,13 @@ void StoreSettings() {
EEPROM_writeAnything(i,minsegmenttime);
EEPROM_writeAnything(i,max_xy_jerk);
EEPROM_writeAnything(i,max_z_jerk);
EEPROM_writeAnything(i,Kp);
EEPROM_writeAnything(i,Ki);
EEPROM_writeAnything(i,Kd);
char ver2[4]=EEPROM_VERSION;
i=EEPROM_OFFSET;
EEPROM_writeAnything(i,ver2); // validate data
// Serial.println("Settings Stored");
ECHOLN("Settings Stored");

}

Expand All @@ -52,7 +55,7 @@ void RetrieveSettings(bool def=false){ // if def=true, the default values will
char stored_ver[4];
char ver[4]=EEPROM_VERSION;
EEPROM_readAnything(i,stored_ver); //read stored version
// Serial.print("Version: [");Serial.print(ver);Serial.print("] Stored version: [");Serial.print(stored_ver);Serial.println("]");
// ECHOLN("Version: [" << ver << "] Stored version: [" << stored_ver << "]");
if ((!def)&&(strncmp(ver,stored_ver,3)==0)) { // version number match
EEPROM_readAnything(i,axis_steps_per_unit);
EEPROM_readAnything(i,max_feedrate);
Expand All @@ -64,7 +67,10 @@ 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);
// Serial.println("Stored settings retreived:");
EEPROM_readAnything(i,Kp);
EEPROM_readAnything(i,Ki);
EEPROM_readAnything(i,Kd);
ECHOLN("Stored settings retreived:");
}
else {
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
Expand All @@ -82,39 +88,21 @@ void RetrieveSettings(bool def=false){ // if def=true, the default values will
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
max_xy_jerk=DEFAULT_XYJERK;
max_z_jerk=DEFAULT_ZJERK;
// Serial.println("Using Default settings:");
ECHOLN("Using Default settings:");
}
/*
//Serial.print(" M92");
//Serial.print(" X");Serial.print(axis_steps_per_unit[0]);
//Serial.print(" Y");Serial.print(axis_steps_per_unit[1]);
//Serial.print(" Z");Serial.print(axis_steps_per_unit[2]);
//Serial.print(" E");Serial.println(axis_steps_per_unit[3]);
//Serial.println("Maximum feedrates (mm/s):");
//Serial.print (" M203");
// Serial.print(" X");Serial.print(max_feedrate[0]/60);
// Serial.print(" Y");Serial.print(max_feedrate[1]/60);
// Serial.print(" Z");Serial.print(max_feedrate[2]/60);
// Serial.print(" E");Serial.println(max_feedrate[3]/60);
// Serial.println("Maximum Acceleration (mm/s2):");
// Serial.print(" M201");
// Serial.print(" X");Serial.print(max_acceleration_units_per_sq_second[0]);
// Serial.print(" Y");Serial.print(max_acceleration_units_per_sq_second[1]);
// Serial.print(" Z");Serial.print(max_acceleration_units_per_sq_second[2]);
// Serial.print(" E");Serial.println(max_acceleration_units_per_sq_second[3]);
// Serial.println("Acceleration: S=acceleration, T=retract acceleration");
// Serial.print(" M204");
// Serial.print(" S");Serial.print(acceleration);
// Serial.print(" T");Serial.println(retract_acceleration);
// Serial.println("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)");
// Serial.print(" M205");
// Serial.print(" S");Serial.print(minimumfeedrate/60);
// Serial.print(" T");Serial.print(mintravelfeedrate/60);
// Serial.print(" B");Serial.print(minsegmenttime);
// Serial.print(" X");Serial.print(max_xy_jerk/60);
// Serial.print(" Z");Serial.println(max_z_jerk/60);
//
*/
ECHOLN("Steps per unit:");
ECHOLN(" M92 X" <<_FLOAT(axis_steps_per_unit[0],3) << " Y" << _FLOAT(axis_steps_per_unit[1],3) << " Z" << _FLOAT(axis_steps_per_unit[2],3) << " E" << _FLOAT(axis_steps_per_unit[3],3));
ECHOLN("Maximum feedrates (mm/s):");
ECHOLN(" M203 X" <<_FLOAT(max_feedrate[0]/60,2)<<" Y" << _FLOAT(max_feedrate[1]/60,2) << " Z" << _FLOAT(max_feedrate[2]/60,2) << " E" << _FLOAT(max_feedrate[3]/60,2));
ECHOLN("Maximum Acceleration (mm/s2):");
ECHOLN(" M201 X" <<_FLOAT(max_acceleration_units_per_sq_second[0],0) << " Y" << _FLOAT(max_acceleration_units_per_sq_second[1],0) << " Z" << _FLOAT(max_acceleration_units_per_sq_second[2],0) << " E" << _FLOAT(max_acceleration_units_per_sq_second[3],0));
ECHOLN("Acceleration: S=acceleration, T=retract acceleration");
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));
ECHOLN("PID settings:");
ECHOLN(" M301 P" << _FLOAT(Kp,3) << " I" << _FLOAT(Ki,3) << " D" << _FLOAT(Kd,3));

}


Loading

0 comments on commit 10c2489

Please sign in to comment.