Commit ee98a976 authored by MagoKimbra's avatar MagoKimbra

New Pid endstop and fix M303 error

parent 7f4d4221
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
// startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this
// build by the user have been successfully uploaded into firmware. // build by the user have been successfully uploaded into firmware.
#define STRING_VERSION "4.1.3" #define STRING_VERSION "4.1.3"
#define STRING_URL "reprap.org"
#define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time
#define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes. #define STRING_CONFIG_H_AUTHOR "(none, default config)" // Who made the changes.
#define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1 #define STRING_SPLASH_LINE1 "v" STRING_VERSION // will be shown during bootup in line 1
...@@ -222,6 +221,7 @@ ...@@ -222,6 +221,7 @@
#define PID_FUNCTIONAL_RANGE 10 // degC #define PID_FUNCTIONAL_RANGE 10 // degC
#define PID_INTEGRAL_DRIVE_MAX PID_MAX // Limit for the integral term #define PID_INTEGRAL_DRIVE_MAX PID_MAX // Limit for the integral term
#define K1 0.95 // Smoothing factor within the PID #define K1 0.95 // Smoothing factor within the PID
#define MAX_OVERSHOOT_PID_AUTOTUNE 20 // Max valor for overshoot autotune
// HotEnd{HE0,HE1,HE2,HE3} // HotEnd{HE0,HE1,HE2,HE3}
#define DEFAULT_Kp {40, 40, 40, 40} // Kp for E0, E1, E2, E3 #define DEFAULT_Kp {40, 40, 40, 40} // Kp for E0, E1, E2, E3
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
/** /**
* Whenever an M104 or M109 increases the target temperature the firmware will wait for the * Whenever an M104 or M109 increases the target temperature the firmware will wait for the
* WATCH_TEMP_PERIOD to transpire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE * WATCH_TEMP_PERIOD to expire, and if the temperature hasn't increased by WATCH_TEMP_INCREASE
* degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109, * degrees, the machine is halted, requiring a hard reset. This test restarts with any M104/M109,
* but only if the current temperature is far enough below the target for a reliable test. * but only if the current temperature is far enough below the target for a reliable test.
*/ */
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#define BIT(b) (1<<(b)) #define BIT(b) (1<<(b))
#define TEST(n,b) (((n)&BIT(b))!=0) #define TEST(n,b) (((n)&BIT(b))!=0)
#define SET_BIT(n,b,value) (n) ^= ((-value)^(n)) & (BIT(b))
#define RADIANS(d) ((d)*M_PI/180.0) #define RADIANS(d) ((d)*M_PI/180.0)
#define DEGREES(r) ((d)*180.0/M_PI) #define DEGREES(r) ((d)*180.0/M_PI)
#define NOLESS(v,n) do{ if (v < n) v = n; }while(0) #define NOLESS(v,n) do{ if (v < n) v = n; }while(0)
......
...@@ -3667,11 +3667,13 @@ inline void gcode_G92() { ...@@ -3667,11 +3667,13 @@ inline void gcode_G92() {
didXYZ = true; didXYZ = true;
} }
} }
#if defined(DELTA) || defined(SCARA) if (didXYZ) {
if (didXYZ) sync_plan_position_delta(); #if defined(DELTA) || defined(SCARA)
#else sync_plan_position_delta();
if (didXYZ) sync_plan_position(); #else
#endif sync_plan_position();
#endif
}
} }
#ifdef ULTIPANEL #ifdef ULTIPANEL
...@@ -5961,7 +5963,7 @@ inline void gcode_T() { ...@@ -5961,7 +5963,7 @@ inline void gcode_T() {
#else // !DUAL_X_CARRIAGE #else // !DUAL_X_CARRIAGE
// Offset hotend (only by XY) // Offset hotend (only by XY)
#if HOTENDS > 1 #if HOTENDS > 1
for (int i=X_AXIS; i<=Y_AXIS; i++) for (int i = X_AXIS; i <= Y_AXIS; i++)
current_position[i] += hotend_offset[i][target_extruder] - hotend_offset[i][active_extruder]; current_position[i] += hotend_offset[i][target_extruder] - hotend_offset[i][active_extruder];
#endif // HOTENDS > 1 #endif // HOTENDS > 1
...@@ -6409,7 +6411,10 @@ void process_next_command() { ...@@ -6409,7 +6411,10 @@ void process_next_command() {
#endif // PREVENT_DANGEROUS_EXTRUDE #endif // PREVENT_DANGEROUS_EXTRUDE
case 303: // M303 PID autotune case 303: // M303 PID autotune
gcode_M303(); break; gcode_M303();
gcode_LastN += 1;
FlushSerialRequestResend();
break;
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
case 304: // M304 case 304: // M304
......
...@@ -39,15 +39,15 @@ ...@@ -39,15 +39,15 @@
#endif #endif
#endif #endif
#define START "start" //start for host #define START "start" //start for host
#define OK "ok" //ok answer for host #define OK "ok" //ok answer for host
#define ER "Error:" //error for host #define ER "Error: " //error for host
#define WT "wait" //wait for host #define WT "wait" //wait for host
#define DB "<MK4>: " //message for user #define DB "MK4: " //message for user
#define RS "Resend:" //resend for host #define RS "Resend: " //resend for host
#define PAUSE "//action:pause" //command for host that support action #define PAUSE "//action:pause" //command for host that support action
#define RESUME "//action:resume" //command for host that support action #define RESUME "//action:resume" //command for host that support action
#define DISCONNECT "//action:disconnect" //command for host that support action #define DISCONNECT "//action:disconnect" //command for host that support action
#define SERIAL_INIT(baud) MYSERIAL.begin(baud), delay(1) #define SERIAL_INIT(baud) MYSERIAL.begin(baud), delay(1)
#define SERIAL_WRITE(x) MYSERIAL.write(x) #define SERIAL_WRITE(x) MYSERIAL.write(x)
......
This diff is collapsed.
...@@ -55,9 +55,9 @@ float current_temperature_bed = 0.0; ...@@ -55,9 +55,9 @@ float current_temperature_bed = 0.0;
#endif #endif
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
float bedKp=DEFAULT_bedKp; float bedKp = DEFAULT_bedKp;
float bedKi=(DEFAULT_bedKi*PID_dT); float bedKi = (DEFAULT_bedKi*PID_dT);
float bedKd=(DEFAULT_bedKd/PID_dT); float bedKd = (DEFAULT_bedKd/PID_dT);
#endif //PIDTEMPBED #endif //PIDTEMPBED
#ifdef FAN_SOFT_PWM #ifdef FAN_SOFT_PWM
...@@ -181,8 +181,7 @@ static void updateTemperaturesFromRawValues(); ...@@ -181,8 +181,7 @@ static void updateTemperaturesFromRawValues();
//================================ Functions ================================ //================================ Functions ================================
//=========================================================================== //===========================================================================
void PID_autotune(float temp, int hotend, int ncycles) void PID_autotune(float temp, int hotend, int ncycles) {
{
float input = 0.0; float input = 0.0;
int cycles = 0; int cycles = 0;
bool heating = true; bool heating = true;
...@@ -300,7 +299,7 @@ void PID_autotune(float temp, int hotend, int ncycles) ...@@ -300,7 +299,7 @@ void PID_autotune(float temp, int hotend, int ncycles)
} }
} }
} }
if (input > temp + 20) { if (input > temp + MAX_OVERSHOOT_PID_AUTOTUNE) {
ECHO_LM(ER, MSG_PID_TEMP_TOO_HIGH); ECHO_LM(ER, MSG_PID_TEMP_TOO_HIGH);
return; return;
} }
...@@ -315,7 +314,7 @@ void PID_autotune(float temp, int hotend, int ncycles) ...@@ -315,7 +314,7 @@ void PID_autotune(float temp, int hotend, int ncycles)
} }
else { else {
p = soft_pwm[hotend]; p = soft_pwm[hotend];
ECHO_SMV(OK, MSG_T, input); ECHO_SMV(OK, MSG_T, input, 1);
ECHO_EMV(MSG_AT, p); ECHO_EMV(MSG_AT, p);
} }
......
...@@ -66,7 +66,7 @@ extern float current_temperature_bed; ...@@ -66,7 +66,7 @@ extern float current_temperature_bed;
#ifdef PIDTEMP #ifdef PIDTEMP
extern float Kp[HOTENDS], Ki[HOTENDS], Kd[HOTENDS]; extern float Kp[HOTENDS], Ki[HOTENDS], Kd[HOTENDS];
#define PID_PARAM(param,e) param[e] // use macro to point to array value #define PID_PARAM(param, e) param[e] // use macro to point to array value
float scalePID_i(float i); float scalePID_i(float i);
float scalePID_d(float d); float scalePID_d(float d);
float unscalePID_i(float i); float unscalePID_i(float i);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment