Commit 546a5da8 authored by MagoKimbra's avatar MagoKimbra

Add Pid for any Extruder

parent 3de15132
...@@ -253,30 +253,11 @@ ...@@ -253,30 +253,11 @@
#define PID_dT ((OVERSAMPLENR * 10.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine #define PID_dT ((OVERSAMPLENR * 10.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine
// If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it // If you are using a pre-configured hotend then you can use one of the value sets by uncommenting it
// IeC HotEnd // HotEnd{HE0,HE1,HE2,HE3}
#define DEFAULT_Kp 41.51 #define DEFAULT_Kp {41.51,50,0,0}
#define DEFAULT_Ki 7.28 #define DEFAULT_Ki {7.28,15,0,0}
#define DEFAULT_Kd 59.17 #define DEFAULT_Kd {59.17,90,0,0}
// Buda-Style HotEnd 2.0
// #define DEFAULT_Kp 33.24
// #define DEFAULT_Ki 2.12
// #define DEFAULT_Kd 130.15
// Ultimaker
// #define DEFAULT_Kp 22.2
// #define DEFAULT_Ki 1.08
// #define DEFAULT_Kd 114
// MakerGear
// #define DEFAULT_Kp 7.0
// #define DEFAULT_Ki 0.1
// #define DEFAULT_Kd 12
// Mendel Parts V9 on 12V
// #define DEFAULT_Kp 63.0
// #define DEFAULT_Ki 2.25
// #define DEFAULT_Kd 440
#endif // PIDTEMP #endif // PIDTEMP
// Bed Temperature Control // Bed Temperature Control
......
...@@ -246,9 +246,9 @@ void Config_PrintSettings() ...@@ -246,9 +246,9 @@ void Config_PrintSettings()
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("PID settings:"); SERIAL_ECHOLNPGM("PID settings:");
SERIAL_ECHO_START; SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M301 P",Kp); SERIAL_ECHOPAIR(" M301 P",Kp[active_extruder]);
SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki)); SERIAL_ECHOPAIR(" I" ,unscalePID_i(Ki[active_extruder]));
SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd)); SERIAL_ECHOPAIR(" D" ,unscalePID_d(Kd[active_extruder]));
SERIAL_ECHOLN(""); SERIAL_ECHOLN("");
#endif #endif
} }
...@@ -350,7 +350,10 @@ void Config_ResetDefault() ...@@ -350,7 +350,10 @@ void Config_ResetDefault()
float tmp2[]=DEFAULT_MAX_FEEDRATE; float tmp2[]=DEFAULT_MAX_FEEDRATE;
float tmp3[]=DEFAULT_RETRACTION_MAX_FEEDRATE; float tmp3[]=DEFAULT_RETRACTION_MAX_FEEDRATE;
long tmp4[]=DEFAULT_MAX_ACCELERATION; long tmp4[]=DEFAULT_MAX_ACCELERATION;
float tmp5[]=DEFAULT_Kp;
float tmp6[]=DEFAULT_Ki;
float tmp7[]=DEFAULT_Kd;
for (short i=0;i<7;i++) for (short i=0;i<7;i++)
{ {
axis_steps_per_unit[i]=tmp1[i]; axis_steps_per_unit[i]=tmp1[i];
...@@ -405,9 +408,18 @@ void Config_ResetDefault() ...@@ -405,9 +408,18 @@ void Config_ResetDefault()
lcd_contrast = DEFAULT_LCD_CONTRAST; lcd_contrast = DEFAULT_LCD_CONTRAST;
#endif #endif
#ifdef PIDTEMP #ifdef PIDTEMP
Kp = DEFAULT_Kp; for (short i=0;i<4;i++)
Ki = scalePID_i(DEFAULT_Ki); {
Kd = scalePID_d(DEFAULT_Kd); #ifdef SINGLENOZZLE
Kp[i] = tmp5[0];
Ki[i] = scalePID_i(tmp6[0]);
Kd[i] = scalePID_d(tmp7[0]);
#else
Kp[i] = tmp5[i];
Ki[i] = scalePID_i(tmp6[i]);
Kd[i] = scalePID_d(tmp7[i]);
#endif
}
// call updatePID (similar to when we have processed M301) // call updatePID (similar to when we have processed M301)
updatePID(); updatePID();
......
...@@ -238,7 +238,8 @@ extern int feedmultiply; ...@@ -238,7 +238,8 @@ extern int feedmultiply;
extern int extrudemultiply; // Sets extrude multiply factor (in percent) for all extruders extern int extrudemultiply; // Sets extrude multiply factor (in percent) for all extruders
extern int extruder_multiply[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually extern int extruder_multiply[EXTRUDERS]; // sets extrude multiply factor (in percent) for each extruder individually
extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner extern float volumetric_multiplier[EXTRUDERS]; // reciprocal of cross-sectional area of filament (in square millimeters), stored this way to reduce computational burden in planner
extern float current_position[NUM_AXIS] ; extern float current_position[NUM_AXIS];
extern float destination[NUM_AXIS];
extern float add_homing[3]; extern float add_homing[3];
#ifdef NPR2 #ifdef NPR2
extern int old_color; // old color for system NPR2 extern int old_color; // old color for system NPR2
......
...@@ -61,6 +61,10 @@ ...@@ -61,6 +61,10 @@
#include <SPI.h> #include <SPI.h>
#endif #endif
#ifdef FIRMWARE_TEST
#include "firmware_test.h"
#endif
#define VERSION_STRING "4.0.0" #define VERSION_STRING "4.0.0"
// look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html // look here for descriptions of G-codes: http://linuxcnc.org/handbook/gcode/g-code.html
...@@ -254,6 +258,7 @@ float volumetric_multiplier[EXTRUDERS] = {1.0 ...@@ -254,6 +258,7 @@ float volumetric_multiplier[EXTRUDERS] = {1.0
#endif #endif
}; };
float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 }; float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0 };
float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
float add_homing[3]={0,0,0}; float add_homing[3]={0,0,0};
#ifdef NPR2 #ifdef NPR2
...@@ -391,7 +396,6 @@ bool cancel_heatup = false ; ...@@ -391,7 +396,6 @@ bool cancel_heatup = false ;
//=============================Private Variables============================= //=============================Private Variables=============================
//=========================================================================== //===========================================================================
const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'}; const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
static float offset[3] = {0.0, 0.0, 0.0}; static float offset[3] = {0.0, 0.0, 0.0};
static bool home_all_axis = true; static bool home_all_axis = true;
...@@ -4410,9 +4414,9 @@ Sigma_Exit: ...@@ -4410,9 +4414,9 @@ Sigma_Exit:
#ifdef PIDTEMP #ifdef PIDTEMP
case 301: // M301 case 301: // M301
{ {
if(code_seen('P')) Kp = code_value(); if(code_seen('P')) Kp[active_extruder] = code_value();
if(code_seen('I')) Ki = scalePID_i(code_value()); if(code_seen('I')) Ki[active_extruder] = scalePID_i(code_value());
if(code_seen('D')) Kd = scalePID_d(code_value()); if(code_seen('D')) Kd[active_extruder] = scalePID_d(code_value());
#ifdef PID_ADD_EXTRUSION_RATE #ifdef PID_ADD_EXTRUSION_RATE
if(code_seen('C')) Kc = code_value(); if(code_seen('C')) Kc = code_value();
...@@ -4421,11 +4425,11 @@ Sigma_Exit: ...@@ -4421,11 +4425,11 @@ Sigma_Exit:
updatePID(); updatePID();
SERIAL_PROTOCOL(MSG_OK); SERIAL_PROTOCOL(MSG_OK);
SERIAL_PROTOCOL(" p:"); SERIAL_PROTOCOL(" p:");
SERIAL_PROTOCOL(Kp); SERIAL_PROTOCOL(Kp[active_extruder]);
SERIAL_PROTOCOL(" i:"); SERIAL_PROTOCOL(" i:");
SERIAL_PROTOCOL(unscalePID_i(Ki)); SERIAL_PROTOCOL(unscalePID_i(Ki[active_extruder]));
SERIAL_PROTOCOL(" d:"); SERIAL_PROTOCOL(" d:");
SERIAL_PROTOCOL(unscalePID_d(Kd)); SERIAL_PROTOCOL(unscalePID_d(Kd[active_extruder]));
#ifdef PID_ADD_EXTRUSION_RATE #ifdef PID_ADD_EXTRUSION_RATE
SERIAL_PROTOCOL(" c:"); SERIAL_PROTOCOL(" c:");
//Kc does not have scaling applied above, or in resetting defaults //Kc does not have scaling applied above, or in resetting defaults
...@@ -5930,232 +5934,6 @@ void setPwmFrequency(uint8_t pin, int val) ...@@ -5930,232 +5934,6 @@ void setPwmFrequency(uint8_t pin, int val)
} }
#endif //FAST_PWM_FAN #endif //FAST_PWM_FAN
#ifdef FIRMWARE_TEST
void FirmwareTest(){
SERIAL_ECHOLN("---------- FIRMWARE TEST --------------");
SERIAL_ECHOLN("--------- by MarlinKimbra -------------");
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN(MSG_FWTEST_01);
SERIAL_ECHOLN(MSG_FWTEST_02);
SERIAL_ECHOLN(MSG_FWTEST_YES_NO);
serial_char = MYSERIAL.read();
while(serial_char!='y' && serial_char!='Y' && serial_char!='n' && serial_char!='N'){
serial_char = MYSERIAL.read();
}
if (serial_char=='y' || serial_char=='Y'){
SERIAL_ECHOLN(MSG_FWTEST_03);
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** ENDSTOP X *****");
#if defined(X_MIN_PIN) && X_MIN_PIN > -1 && X_HOME_DIR == -1
if (!READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP X: ");
#elif defined(X_MAX_PIN) && X_MAX_PIN > -1 && X_HOME_DIR == 1
if (!READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP X: ");
#endif
SERIAL_ECHOLN(MSG_ENDSTOP_OPEN);
}
else
{
SERIAL_ECHOLN("X ENDSTOP ERROR");
SERIAL_ECHO(MSG_FWTEST_INVERT);
#if X_HOME_DIR == -1
SERIAL_ECHOLN("#define X_MIN_ENDSTOP_INVERTING");
#else
SERIAL_ECHOLN("#define X_MAX_ENDSTOP_INVERTING");
#endif
return;
}
SERIAL_ECHOLN("Premere e tenere premuto l'endstop X.");
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_char = MYSERIAL.read();
while(serial_char!='y' && serial_char!='Y'){
serial_char = MYSERIAL.read();
}
#if defined(X_MIN_PIN) && X_MIN_PIN > -1 && X_HOME_DIR == -1
if (READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP X: ");
#elif defined(X_MAX_PIN) && X_MAX_PIN > -1 && X_HOME_DIR == 1
if (READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP X: ");
#endif
SERIAL_ECHOLN(MSG_ENDSTOP_HIT);
}
else
{
SERIAL_ECHO("X ");
SERIAL_ECHOLN(MSG_FWTEST_ENDSTOP_ERR);
return;
}
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** ENDSTOP Y *****");
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1 && Y_HOME_DIR == -1
if (!READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP Y: ");
#elif defined(Y_MAX_PIN) && Y_MAX_PIN > -1 && Y_HOME_DIR == 1
if (!READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP Y: ");
#endif
SERIAL_ECHOLN(MSG_ENDSTOP_OPEN);
}
else
{
SERIAL_ECHOLN("Y ENDSTOP ERROR");
SERIAL_ECHO(MSG_FWTEST_INVERT);
#if Y_HOME_DIR == -1
SERIAL_ECHOLN("#define Y_MIN_ENDSTOP_INVERTING");
#else
SERIAL_ECHOLN("#define Y_MAX_ENDSTOP_INVERTING");
#endif
return;
}
SERIAL_ECHOLN("Premere e tenere premuto l'endstop Y.");
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_char = MYSERIAL.read();
while(serial_char!='y' && serial_char!='Y'){
serial_char = MYSERIAL.read();
}
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1 && Y_HOME_DIR == -1
if (READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP Y: ");
#elif defined(Y_MAX_PIN) && Y_MAX_PIN > -1 && Y_HOME_DIR == 1
if (READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP Y: ");
#endif
SERIAL_ECHOLN(MSG_ENDSTOP_HIT);
}
else
{
SERIAL_ECHO("Y ");
SERIAL_ECHOLN(MSG_FWTEST_ENDSTOP_ERR);
return;
}
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** ENDSTOP Z *****");
#if defined(Z_MIN_PIN) && Z_MIN_PIN > -1 && Z_HOME_DIR == -1
if (!READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP Z: ");
#elif defined(Z_MAX_PIN) && Z_MAX_PIN > -1 && Z_HOME_DIR == 1
if (!READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP Z: ");
#endif
SERIAL_ECHOLN(MSG_ENDSTOP_OPEN);
}
else
{
SERIAL_ECHOLN("Z ENDSTOP ERROR");
SERIAL_ECHO(MSG_FWTEST_INVERT);
#if Z_HOME_DIR == -1
SERIAL_ECHOLN("#define Z_MIN_ENDSTOP_INVERTING");
#else
SERIAL_ECHOLN("#define Z_MAX_ENDSTOP_INVERTING");
#endif
return;
}
SERIAL_ECHOLN("Premere e tenere premuto l'endstop Z.");
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_char = MYSERIAL.read();
while(serial_char!='y' && serial_char!='Y'){
serial_char = MYSERIAL.read();
}
#if defined(Z_MIN_PIN) && Z_MIN_PIN > -1 && Z_HOME_DIR == -1
if (READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP Z: ");
#elif defined(Z_MAX_PIN) && Z_MAX_PIN > -1 && Z_HOME_DIR == 1
if (READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP Z: ");
#endif
SERIAL_ECHOLN(MSG_ENDSTOP_HIT);
}
else
{
SERIAL_ECHO("Z ");
SERIAL_ECHOLN(MSG_FWTEST_ENDSTOP_ERR);
return;
}
SERIAL_ECHOLN("ENDSTOP OK");
SERIAL_ECHOLN(" ");
}
SERIAL_ECHOLN("***** TEST MOTOR *****");
SERIAL_ECHOLN(MSG_FWTEST_ATTENTION);
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_char = MYSERIAL.read();
while(serial_char!='y' && serial_char!='Y'){
serial_char = MYSERIAL.read();
}
SERIAL_ECHOLN(MSG_FWTEST_04);
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** MOTOR X *****");
#if defined(PS_ON_PIN) && PS_ON_PIN > -1
SET_OUTPUT(PS_ON_PIN);
WRITE(PS_ON_PIN, PS_ON_AWAKE);
#endif
st_synchronize();
for(int8_t i=0; i < NUM_AXIS; i++) current_position[i] = 0;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
destination[X_AXIS] = current_position[X_AXIS] + 5;
prepare_move();
st_synchronize();
SERIAL_ECHOLN(MSG_FWTEST_XAXIS);
SERIAL_ECHOLN(MSG_FWTEST_YES_NO);
serial_char = MYSERIAL.read();
while(serial_char!='y' && serial_char!='Y' && serial_char!='n' && serial_char!='N'){
serial_char = MYSERIAL.read();
}
if(serial_char=='y' || serial_char=='Y'){
SERIAL_ECHOLN("MOTOR X OK");
}
else
{
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define INVERT_X_DIR");
return;
}
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** MOTOR Y *****");
destination[Y_AXIS] = current_position[Y_AXIS] + 5;
prepare_move();
st_synchronize();
SERIAL_ECHOLN(MSG_FWTEST_YAXIS);
SERIAL_ECHOLN(MSG_FWTEST_YES_NO);
serial_char = MYSERIAL.read();
while(serial_char!='y' && serial_char!='Y' && serial_char!='n' && serial_char!='N'){
serial_char = MYSERIAL.read();
}
if(serial_char=='y' || serial_char=='Y'){
SERIAL_ECHOLN("MOTOR Y OK");
}
else
{
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define INVERT_Y_DIR");
return;
}
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** MOTOR Z *****");
destination[Z_AXIS] = current_position[Z_AXIS] + 5;
prepare_move();
st_synchronize();
SERIAL_ECHOLN(MSG_FWTEST_ZAXIS);
SERIAL_ECHOLN(MSG_FWTEST_YES_NO);
serial_char = MYSERIAL.read();
while(serial_char!='y' && serial_char!='Y' && serial_char!='n' && serial_char!='N'){
serial_char = MYSERIAL.read();
}
if(serial_char=='y' || serial_char=='Y'){
SERIAL_ECHOLN("MOTOR Z OK");
}
else
{
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define INVERT_Z_DIR");
return;
}
SERIAL_ECHOLN("MOTOR OK");
SERIAL_ECHOLN(" ");
}
#endif //FIRMWARE_TEST
bool setTargetedHotend(int code){ bool setTargetedHotend(int code){
tmp_extruder = active_extruder; tmp_extruder = active_extruder;
if(code_seen('T')) { if(code_seen('T')) {
......
/*
Test.h
Tools for firmware test
By MagoKimbra
*/
#include "Marlin.h"
#include "stepper.h"
#include "planner.h"
#include "temperature.h"
#include "language.h"
static char serial_answer;
void FirmwareTest(){
SERIAL_ECHOLN("---------- FIRMWARE TEST --------------");
SERIAL_ECHOLN("--------- by MarlinKimbra -------------");
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN(MSG_FWTEST_01);
SERIAL_ECHOLN(MSG_FWTEST_02);
SERIAL_ECHOLN(MSG_FWTEST_YES_NO);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y' && serial_answer!='n' && serial_answer!='N'){
serial_answer = MYSERIAL.read();
}
if (serial_answer=='y' || serial_answer=='Y'){
SERIAL_ECHOLN(MSG_FWTEST_03);
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** ENDSTOP X *****");
#if defined(X_MIN_PIN) && X_MIN_PIN > -1 && X_HOME_DIR == -1
if (!READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP X: ");
SERIAL_ECHOLN(MSG_ENDSTOP_OPEN);
}
else
{
SERIAL_ECHOLN("X ENDSTOP ERROR");
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define X_MIN_ENDSTOP_INVERTING");
return;
}
SERIAL_ECHO(MSG_FWTEST_PRESS);
SERIAL_ECHOLN("X");
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y' && !(READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING)){
serial_answer = MYSERIAL.read();
}
if (READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP X: ");
SERIAL_ECHOLN(MSG_ENDSTOP_HIT);
}
else
{
SERIAL_ECHO("X ");
SERIAL_ECHOLN(MSG_FWTEST_ENDSTOP_ERR);
return;
}
#elif defined(X_MAX_PIN) && X_MAX_PIN > -1 && X_HOME_DIR == 1
if (!READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP X: ");
SERIAL_ECHOLN(MSG_ENDSTOP_OPEN);
}
else
{
SERIAL_ECHOLN("X ENDSTOP ERROR");
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define X_MAX_ENDSTOP_INVERTING");
return;
}
SERIAL_ECHO(MSG_FWTEST_PRESS);
SERIAL_ECHOLN("X");
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y' && !(READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING)){
serial_answer = MYSERIAL.read();
}
if (READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP X: ");
SERIAL_ECHOLN(MSG_ENDSTOP_HIT);
}
else
{
SERIAL_ECHO("X ");
SERIAL_ECHOLN(MSG_FWTEST_ENDSTOP_ERR);
return;
}
#elif X_HOME_DIR == -1
SERIAL_ECHOLN("ATTENZIONE! X_HOME_DIR = -1, ma e' definito DISABLE_MIN_ENDSTOPS");
return;
#elif X_HOME_DIR == 1
SERIAL_ECHOLN("ATTENZIONE! X_HOME_DIR = 1, ma e' definito DISABLE_MAX_ENDSTOPS");
return;
#endif
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** ENDSTOP Y *****");
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1 && Y_HOME_DIR == -1
if (!READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP Y: ");
SERIAL_ECHOLN(MSG_ENDSTOP_OPEN);
}
else
{
SERIAL_ECHOLN("Y ENDSTOP ERROR");
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define Y_MIN_ENDSTOP_INVERTING");
return;
}
SERIAL_ECHO(MSG_FWTEST_PRESS);
SERIAL_ECHOLN("Y");
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y' && !(READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING)){
serial_answer = MYSERIAL.read();
}
if (READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP Y: ");
SERIAL_ECHOLN(MSG_ENDSTOP_HIT);
}
else
{
SERIAL_ECHO("Y ");
SERIAL_ECHOLN(MSG_FWTEST_ENDSTOP_ERR);
return;
}
#elif defined(Y_MAX_PIN) && Y_MAX_PIN > -1 && Y_HOME_DIR == 1
if (!READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP Y: ");
SERIAL_ECHOLN(MSG_ENDSTOP_OPEN);
}
else
{
SERIAL_ECHOLN("Y ENDSTOP ERROR");
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define Y_MAX_ENDSTOP_INVERTING");
return;
}
SERIAL_ECHO(MSG_FWTEST_PRESS);
SERIAL_ECHOLN("Y");
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y' && !(READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING)){
serial_answer = MYSERIAL.read();
}
if (READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP Y: ");
SERIAL_ECHOLN(MSG_ENDSTOP_HIT);
}
else
{
SERIAL_ECHO("Y ");
SERIAL_ECHOLN(MSG_FWTEST_ENDSTOP_ERR);
return;
}
#elif Y_HOME_DIR == -1
SERIAL_ECHOLN("ATTENZIONE! Y_HOME_DIR = -1, ma e' definito DISABLE_MIN_ENDSTOPS");
return;
#elif Y_HOME_DIR == 1
SERIAL_ECHOLN("ATTENZIONE! Y_HOME_DIR = 1, ma e' definito DISABLE_MAX_ENDSTOPS");
return;
#endif
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** ENDSTOP Z *****");
#if defined(Z_MIN_PIN) && Z_MIN_PIN > -1 && Z_HOME_DIR == -1
if (!READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP Z: ");
SERIAL_ECHOLN(MSG_ENDSTOP_OPEN);
}
else
{
SERIAL_ECHOLN("Z ENDSTOP ERROR");
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define Z_MIN_ENDSTOP_INVERTING");
return;
}
SERIAL_ECHO(MSG_FWTEST_PRESS);
SERIAL_ECHOLN("Z");
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y' && !(READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING)){
serial_answer = MYSERIAL.read();
}
if (READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING){
SERIAL_ECHO("MIN ENDSTOP Z: ");
SERIAL_ECHOLN(MSG_ENDSTOP_HIT);
}
else
{
SERIAL_ECHO("Z ");
SERIAL_ECHOLN(MSG_FWTEST_ENDSTOP_ERR);
return;
}
#elif defined(Z_MAX_PIN) && Z_MAX_PIN > -1 && Z_HOME_DIR == 1
if (!READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP Z: ");
SERIAL_ECHOLN(MSG_ENDSTOP_OPEN);
}
else
{
SERIAL_ECHOLN("Z ENDSTOP ERROR");
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define Z_MAX_ENDSTOP_INVERTING");
return;
}
SERIAL_ECHO(MSG_FWTEST_PRESS);
SERIAL_ECHOLN("Z");
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y' && !(READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING)){
serial_answer = MYSERIAL.read();
}
if (READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING){
SERIAL_ECHO("MAX ENDSTOP Z: ");
SERIAL_ECHOLN(MSG_ENDSTOP_HIT);
}
else
{
SERIAL_ECHO("Z ");
SERIAL_ECHOLN(MSG_FWTEST_ENDSTOP_ERR);
return;
}
#elif Z_HOME_DIR == -1
SERIAL_ECHOLN("ATTENZIONE! Z_HOME_DIR = -1, ma e' definito DISABLE_MIN_ENDSTOPS");
return;
#elif Z_HOME_DIR == 1
SERIAL_ECHOLN("ATTENZIONE! Z_HOME_DIR = 1, ma e' definito DISABLE_MAX_ENDSTOPS");
return;
#endif
SERIAL_ECHOLN("ENDSTOP OK");
SERIAL_ECHOLN(" ");
}
#if defined(PS_ON_PIN) && PS_ON_PIN > -1
SET_OUTPUT(PS_ON_PIN);
WRITE(PS_ON_PIN, PS_ON_AWAKE);
#endif
// Reset position to 0
st_synchronize();
for(int8_t i=0; i < NUM_AXIS; i++) current_position[i] = 0;
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
SERIAL_ECHOLN("***** TEST MOTOR *****");
SERIAL_ECHOLN(MSG_FWTEST_ATTENTION);
SERIAL_ECHOLN(MSG_FWTEST_YES);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y'){
serial_answer = MYSERIAL.read();
}
SERIAL_ECHOLN(MSG_FWTEST_04);
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** MOTOR X *****");
destination[X_AXIS] = current_position[X_AXIS] + 5;
prepare_move();
st_synchronize();
SERIAL_ECHOLN(MSG_FWTEST_XAXIS);
SERIAL_ECHOLN(MSG_FWTEST_YES_NO);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y' && serial_answer!='n' && serial_answer!='N'){
serial_answer = MYSERIAL.read();
}
if(serial_answer=='y' || serial_answer=='Y'){
SERIAL_ECHOLN("MOTOR X OK");
}
else
{
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define INVERT_X_DIR");
return;
}
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** MOTOR Y *****");
destination[Y_AXIS] = current_position[Y_AXIS] + 5;
prepare_move();
st_synchronize();
SERIAL_ECHOLN(MSG_FWTEST_YAXIS);
SERIAL_ECHOLN(MSG_FWTEST_YES_NO);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y' && serial_answer!='n' && serial_answer!='N'){
serial_answer = MYSERIAL.read();
}
if(serial_answer=='y' || serial_answer=='Y'){
SERIAL_ECHOLN("MOTOR Y OK");
}
else
{
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define INVERT_Y_DIR");
return;
}
SERIAL_ECHOLN(" ");
SERIAL_ECHOLN("***** MOTOR Z *****");
destination[Z_AXIS] = current_position[Z_AXIS] + 5;
prepare_move();
st_synchronize();
SERIAL_ECHOLN(MSG_FWTEST_ZAXIS);
SERIAL_ECHOLN(MSG_FWTEST_YES_NO);
serial_answer = MYSERIAL.read();
while(serial_answer!='y' && serial_answer!='Y' && serial_answer!='n' && serial_answer!='N'){
serial_answer = MYSERIAL.read();
}
if(serial_answer=='y' || serial_answer=='Y'){
SERIAL_ECHOLN("MOTOR Z OK");
}
else
{
SERIAL_ECHO(MSG_FWTEST_INVERT);
SERIAL_ECHOLN("#define INVERT_Z_DIR");
return;
}
SERIAL_ECHOLN("MOTOR OK");
SERIAL_ECHOLN(" ");
}
...@@ -289,6 +289,7 @@ ...@@ -289,6 +289,7 @@
#define MSG_FWTEST_NO "Put the N command to go next" #define MSG_FWTEST_NO "Put the N command to go next"
#define MSG_FWTEST_YES_NO "Put the Y or N command to go next" #define MSG_FWTEST_YES_NO "Put the Y or N command to go next"
#define MSG_FWTEST_ENDSTOP_ERR "ENDSTOP ERROR! Check wire and connection" #define MSG_FWTEST_ENDSTOP_ERR "ENDSTOP ERROR! Check wire and connection"
#define MSG_FWTEST_PRESS "Press and hold the endstop "
#define MSG_FWTEST_INVERT "Reverse value in " #define MSG_FWTEST_INVERT "Reverse value in "
#define MSG_FWTEST_XAXIS "Has the nozzle moved to the right?" #define MSG_FWTEST_XAXIS "Has the nozzle moved to the right?"
#define MSG_FWTEST_YAXIS "Has the nozzle moved forward?" #define MSG_FWTEST_YAXIS "Has the nozzle moved forward?"
...@@ -1112,6 +1113,7 @@ ...@@ -1112,6 +1113,7 @@
#define MSG_FWTEST_NO "Dai il comando N per andare avanti" #define MSG_FWTEST_NO "Dai il comando N per andare avanti"
#define MSG_FWTEST_YES_NO "Dai il comando Y o N per andare avanti" #define MSG_FWTEST_YES_NO "Dai il comando Y o N per andare avanti"
#define MSG_FWTEST_ENDSTOP_ERR "ENDSTOP ERROR! Controllare cavi e connessioni" #define MSG_FWTEST_ENDSTOP_ERR "ENDSTOP ERROR! Controllare cavi e connessioni"
#define MSG_FWTEST_PRESS "Premere e tenere premuto l'endstop "
#define MSG_FWTEST_INVERT "Invertire valore in " #define MSG_FWTEST_INVERT "Invertire valore in "
#define MSG_FWTEST_XAXIS "Il nozzle si e' spostato a destra?" #define MSG_FWTEST_XAXIS "Il nozzle si e' spostato a destra?"
#define MSG_FWTEST_YAXIS "Il nozzle si e' spostato in avanti" #define MSG_FWTEST_YAXIS "Il nozzle si e' spostato in avanti"
......
...@@ -57,11 +57,11 @@ float current_temperature_bed = 0.0; ...@@ -57,11 +57,11 @@ float current_temperature_bed = 0.0;
float redundant_temperature = 0.0; float redundant_temperature = 0.0;
#endif #endif
#ifdef PIDTEMP #ifdef PIDTEMP
float Kp=DEFAULT_Kp; float Kp[4];
float Ki=(DEFAULT_Ki*PID_dT); float Ki[4];
float Kd=(DEFAULT_Kd/PID_dT); float Kd[4];
#ifdef PID_ADD_EXTRUSION_RATE #ifdef PID_ADD_EXTRUSION_RATE
float Kc=DEFAULT_Kc; float Kc;
#endif #endif
#endif //PIDTEMP #endif //PIDTEMP
...@@ -371,11 +371,11 @@ void updatePID() ...@@ -371,11 +371,11 @@ void updatePID()
#ifdef PIDTEMP #ifdef PIDTEMP
#ifndef SINGLENOZZLE #ifndef SINGLENOZZLE
for(int e = 0; e < EXTRUDERS; e++) { for(int e = 0; e < EXTRUDERS; e++) {
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki[e];
} }
#else #else
for(int e = 0; e < 1; e++) { for(int e = 0; e < 1; e++) {
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki[0];
} }
#endif #endif
#endif #endif
...@@ -501,14 +501,14 @@ void manage_heater() ...@@ -501,14 +501,14 @@ void manage_heater()
temp_iState[e] = 0.0; temp_iState[e] = 0.0;
pid_reset[e] = false; pid_reset[e] = false;
} }
pTerm[e] = Kp * pid_error[e]; pTerm[e] = Kp[e] * pid_error[e];
temp_iState[e] += pid_error[e]; temp_iState[e] += pid_error[e];
temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]); temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]);
iTerm[e] = Ki * temp_iState[e]; iTerm[e] = Ki[e] * temp_iState[e];
//K1 defined in Configuration.h in the PID settings //K1 defined in Configuration.h in the PID settings
#define K2 (1.0-K1) #define K2 (1.0-K1)
dTerm[e] = (Kd * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]); dTerm[e] = (Kd[e] * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]);
pid_output = constrain(pTerm[e] + iTerm[e] - dTerm[e], 0, PID_MAX); pid_output = constrain(pTerm[e] + iTerm[e] - dTerm[e], 0, PID_MAX);
} }
temp_dState[e] = pid_input; temp_dState[e] = pid_input;
...@@ -845,7 +845,7 @@ void tp_init() ...@@ -845,7 +845,7 @@ void tp_init()
maxttemp[e] = maxttemp[0]; maxttemp[e] = maxttemp[0];
#ifdef PIDTEMP #ifdef PIDTEMP
temp_iState_min[e] = 0.0; temp_iState_min[e] = 0.0;
temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki; temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / Ki[e];
#endif //PIDTEMP #endif //PIDTEMP
#ifdef PIDTEMPBED #ifdef PIDTEMPBED
temp_iState_min_bed = 0.0; temp_iState_min_bed = 0.0;
......
...@@ -60,7 +60,7 @@ extern unsigned char soft_pwm_bed; ...@@ -60,7 +60,7 @@ extern unsigned char soft_pwm_bed;
#endif #endif
#ifdef PIDTEMP #ifdef PIDTEMP
extern float Kp,Ki,Kd,Kc; extern float Kp[4],Ki[4],Kd[4],Kc;
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);
......
...@@ -976,8 +976,8 @@ static void lcd_control_temperature_menu() ...@@ -976,8 +976,8 @@ static void lcd_control_temperature_menu()
{ {
#ifdef PIDTEMP #ifdef PIDTEMP
// set up temp variables - undo the default scaling // set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki); raw_Ki = unscalePID_i(Ki[active_extruder]);
raw_Kd = unscalePID_d(Kd); raw_Kd = unscalePID_d(Kd[active_extruder]);
#endif #endif
START_MENU(); START_MENU();
...@@ -1009,7 +1009,7 @@ static void lcd_control_temperature_menu() ...@@ -1009,7 +1009,7 @@ static void lcd_control_temperature_menu()
MENU_ITEM_EDIT(float32, MSG_FACTOR, &autotemp_factor, 0.0, 1.0); MENU_ITEM_EDIT(float32, MSG_FACTOR, &autotemp_factor, 0.0, 1.0);
#endif #endif
#ifdef PIDTEMP #ifdef PIDTEMP
MENU_ITEM_EDIT(float52, MSG_PID_P, &Kp, 1, 9990); MENU_ITEM_EDIT(float52, MSG_PID_P, &Kp[active_extruder], 1, 9990);
// i is typically a small value so allows values below 1 // i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i); MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I, &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d); MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D, &raw_Kd, 1, 9990, copy_and_scalePID_d);
...@@ -1899,7 +1899,7 @@ char *ftostr52(const float &x) ...@@ -1899,7 +1899,7 @@ char *ftostr52(const float &x)
void copy_and_scalePID_i() void copy_and_scalePID_i()
{ {
#ifdef PIDTEMP #ifdef PIDTEMP
Ki = scalePID_i(raw_Ki); Ki[active_extruder] = scalePID_i(raw_Ki);
updatePID(); updatePID();
#endif #endif
} }
...@@ -1909,7 +1909,7 @@ void copy_and_scalePID_i() ...@@ -1909,7 +1909,7 @@ void copy_and_scalePID_i()
void copy_and_scalePID_d() void copy_and_scalePID_d()
{ {
#ifdef PIDTEMP #ifdef PIDTEMP
Kd = scalePID_d(raw_Kd); Kd[active_extruder] = scalePID_d(raw_Kd);
updatePID(); updatePID();
#endif #endif
} }
......
...@@ -56,6 +56,7 @@ Features: ...@@ -56,6 +56,7 @@ Features:
* Bed Auto Leveling for cartesian and delta printer * Bed Auto Leveling for cartesian and delta printer
* Z probe repetability test * Z probe repetability test
* Setting step for unit and feedrate for extruders * Setting step for unit and feedrate for extruders
* Setting PID for any extruder
* Real-time filament diameter measurement and control * Real-time filament diameter measurement and control
* MKR4 suppport for 4 extruder but only two driver * MKR4 suppport for 4 extruder but only two driver
* Singlenozzle support * Singlenozzle support
...@@ -86,6 +87,12 @@ Different feedrate for all extruder ...@@ -86,6 +87,12 @@ Different feedrate for all extruder
----------------- -----------------
* \#define DEFAULT_MAX_FEEDRATE {300,300,2,100,100,100,100} // X, Y, Z, E0, E1, E2, E3 (mm/sec) * \#define DEFAULT_MAX_FEEDRATE {300,300,2,100,100,100,100} // X, Y, Z, E0, E1, E2, E3 (mm/sec)
Different PID for all extruder
-----------------
* \#define DEFAULT_Kp {41.51,50,0,0}
* \#define DEFAULT_Ki {7.28,15,0,0}
* \#define DEFAULT_Kd {59.17,90,0,0}
Add Feedrate for retraction Add Feedrate for retraction
----------------- -----------------
* \#define DEFAULT_RETRACTION_MAX_FEEDRATE {150,150,150,150} // E0, E1, E2, E3 (mm/sec) * \#define DEFAULT_RETRACTION_MAX_FEEDRATE {150,150,150,150} // E0, E1, E2, E3 (mm/sec)
......
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