Commit 766db58b authored by MagoKimbra's avatar MagoKimbra

Add menu for pid

parent 8090e01b
......@@ -671,7 +671,9 @@
#include "Configuration_adv.h"
#include "thermistortables.h"
#endif //__CONFIGURATION_H
......@@ -11,8 +11,7 @@ void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size)
eeprom_write_byte((unsigned char*)pos, *value);
pos++;
value++;
}
while(--size);
}while(--size);
}
#define EEPROM_WRITE_VAR(pos, value) _EEPROM_writeData(pos, (uint8_t*)&value, sizeof(value))
void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
......@@ -22,8 +21,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
*value = eeprom_read_byte((unsigned char*)pos);
pos++;
value++;
}
while(--size);
}while(--size);
}
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
//======================================================================================
......@@ -453,26 +451,26 @@ void Config_ResetDefault()
//Setting default baudrate for serial
baudrate=BAUDRATE;
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
float tmp2[]=DEFAULT_MAX_FEEDRATE;
float tmp3[]=DEFAULT_RETRACTION_MAX_FEEDRATE;
long tmp4[]=DEFAULT_MAX_ACCELERATION;
const static float tmp1[] MARLIN_PROGMEM = DEFAULT_AXIS_STEPS_PER_UNIT;
const static float tmp2[] MARLIN_PROGMEM = DEFAULT_MAX_FEEDRATE;
const static float tmp3[] MARLIN_PROGMEM = DEFAULT_RETRACTION_MAX_FEEDRATE;
const static long tmp4[] MARLIN_PROGMEM = DEFAULT_MAX_ACCELERATION;
#ifdef PIDTEMP
float tmp5[]=DEFAULT_Kp;
float tmp6[]=DEFAULT_Ki;
float tmp7[]=DEFAULT_Kd;
const static float tmp5[] MARLIN_PROGMEM = DEFAULT_Kp;
const static float tmp6[] MARLIN_PROGMEM = DEFAULT_Ki;
const static float tmp7[] MARLIN_PROGMEM = DEFAULT_Kd;
#endif // PIDTEMP
for (short i=0;i<7;i++)
{
axis_steps_per_unit[i]=tmp1[i];
max_feedrate[i]=tmp2[i];
max_acceleration_units_per_sq_second[i]=tmp4[i];
axis_steps_per_unit[i] = pgm_read_float(&tmp1[i]);
max_feedrate[i] = pgm_read_float(&tmp2[i]);
max_acceleration_units_per_sq_second[i]=pgm_read_float(&tmp4[i]);
}
for (short i=0;i<4;i++)
{
max_retraction_feedrate[i]=tmp3[i];
max_retraction_feedrate[i]=pgm_read_float(&tmp3[i]);
#ifdef SCARA
axis_scaling[i]=1;
#endif
......@@ -522,13 +520,13 @@ void Config_ResetDefault()
for (short i=0;i<4;i++)
{
#ifdef SINGLENOZZLE
Kp[i] = tmp5[0];
Ki[i] = scalePID_i(tmp6[0]);
Kd[i] = scalePID_d(tmp7[0]);
Kp[i] = pgm_read_float(&tmp5[0]);;
Ki[i] = scalePID_i(pgm_read_float(&tmp6[0]));
Kd[i] = scalePID_d(pgm_read_float(&tmp7[0]));
#else
Kp[i] = tmp5[i];
Ki[i] = scalePID_i(tmp6[i]);
Kd[i] = scalePID_d(tmp7[i]);
Kp[i] = pgm_read_float(&tmp5[i]);;
Ki[i] = scalePID_i(pgm_read_float(&tmp6[i]));
Kd[i] = scalePID_d(pgm_read_float(&tmp7[i]));
#endif
}
......@@ -539,15 +537,15 @@ void Config_ResetDefault()
retract_length = RETRACT_LENGTH;
#if EXTRUDERS > 1
retract_length_swap = RETRACT_LENGTH_SWAP;
#endif
#endif //EXTRUDERS > 1
retract_feedrate = RETRACT_FEEDRATE;
retract_zlift = RETRACT_ZLIFT;
retract_recover_length = RETRACT_RECOVER_LENGTH;
#if EXTRUDERS > 1
retract_recover_length_swap = RETRACT_RECOVER_LENGTH_SWAP;
#endif
#endif //EXTRUDERS > 1
retract_recover_feedrate = RETRACT_RECOVER_FEEDRATE;
#endif
#endif //FWRETRACT
volumetric_enabled = false;
filament_size[0] = DEFAULT_NOMINAL_FILAMENT_DIA;
......@@ -557,9 +555,9 @@ void Config_ResetDefault()
filament_size[2] = DEFAULT_NOMINAL_FILAMENT_DIA;
#if EXTRUDERS > 3
filament_size[3] = DEFAULT_NOMINAL_FILAMENT_DIA;
#endif
#endif
#endif
#endif //EXTRUDERS > 3
#endif //EXTRUDERS > 2
#endif //EXTRUDERS > 1
calculate_volumetric_multipliers();
SERIAL_ECHO_START;
......
......@@ -41,6 +41,25 @@
#include "HardwareSerial.h"
#endif
#ifdef __GNUC__
#ifndef GCC_VERSION2
#define GCC_VERSION2 (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#endif
#if GCC_VERSION2 < 40602 // Test for GCC < 4.6.2
#ifdef PROGMEM
#define MARLIN_PROGMEM __attribute__((section(".progmem.data")))
#ifdef PSTR
#undef PSTR
#define PSTR(s) (__extension__({static const prog_char __c[] MARLIN_PROGMEM = (s); &__c[0];})) // Copied from pgmspace.h in avr-libc source
#endif
#endif
#endif
#endif
#include "MarlinSerial.h"
#ifndef cbi
......
......@@ -403,8 +403,8 @@ bool cancel_heatup = false ;
int laser_ttl_modulation = 0;
#endif
const char errormagic[] PROGMEM = "Error:";
const char echomagic[] PROGMEM = "echo:";
const prog_char errormagic[] MARLIN_PROGMEM = "Error:";
const prog_char echomagic[] MARLIN_PROGMEM = "echo:";
//===========================================================================
//=============================Private Variables=============================
......@@ -971,7 +971,7 @@ DEFINE_PGM_READ_ANY(float, float);
DEFINE_PGM_READ_ANY(signed char, byte);
#define XYZ_CONSTS_FROM_CONFIG(type, array, CONFIG) \
static const PROGMEM type array##_P[3] = \
static const type array##_P[3] MARLIN_PROGMEM = \
{ X_##CONFIG, Y_##CONFIG, Z_##CONFIG }; \
static inline type array(int axis) \
{ return pgm_read_any(&array##_P[axis]); }
......
......@@ -79,6 +79,15 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_P1 "PID-P E2"
#define MSG_PID_I1 "PID-I E2"
#define MSG_PID_D1 "PID-D E2"
#define MSG_PID_P2 "PID-P E3"
#define MSG_PID_I2 "PID-I E3"
#define MSG_PID_D2 "PID-D E3"
#define MSG_PID_P3 "PID-P E4"
#define MSG_PID_I3 "PID-I E4"
#define MSG_PID_D3 "PID-D E4"
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......
......@@ -66,6 +66,15 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_P1 "PID-P E2"
#define MSG_PID_I1 "PID-I E2"
#define MSG_PID_D1 "PID-D E2"
#define MSG_PID_P2 "PID-P E3"
#define MSG_PID_I2 "PID-I E3"
#define MSG_PID_D2 "PID-D E3"
#define MSG_PID_P3 "PID-P E4"
#define MSG_PID_I3 "PID-I E4"
#define MSG_PID_D3 "PID-D E4"
#define MSG_ACC "Acel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......
......@@ -66,6 +66,15 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_P1 "PID-P E2"
#define MSG_PID_I1 "PID-I E2"
#define MSG_PID_D1 "PID-D E2"
#define MSG_PID_P2 "PID-P E3"
#define MSG_PID_I2 "PID-I E3"
#define MSG_PID_D2 "PID-D E3"
#define MSG_PID_P3 "PID-P E4"
#define MSG_PID_I3 "PID-I E4"
#define MSG_PID_D3 "PID-D E4"
#define MSG_ACC "Azelerazioa"
#define MSG_VXY_JERK "Vxy-astindua"
#define MSG_VZ_JERK "Vz-astindua"
......
......@@ -79,6 +79,15 @@
#define MSG_PID_P "PID-P"
#define MSG_PID_I "PID-I"
#define MSG_PID_D "PID-D"
#define MSG_PID_P1 "PID-P E2"
#define MSG_PID_I1 "PID-I E2"
#define MSG_PID_D1 "PID-D E2"
#define MSG_PID_P2 "PID-P E3"
#define MSG_PID_I2 "PID-I E3"
#define MSG_PID_D2 "PID-D E3"
#define MSG_PID_P3 "PID-P E4"
#define MSG_PID_I3 "PID-I E4"
#define MSG_PID_D3 "PID-D E4"
#define MSG_ACC "Accel"
#define MSG_VXY_JERK "Vxy-jerk"
#define MSG_VZ_JERK "Vz-jerk"
......
......@@ -81,7 +81,7 @@ unsigned long axis_steps_per_sqr_second[7];
matrix_3x3 plan_bed_level_matrix = {
1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0,
0.0, 0.0, 1.0
};
#endif // #ifdef ENABLE_AUTO_BED_LEVELING
......
......@@ -5,7 +5,7 @@
#if F_CPU == 16000000
const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\
const prog_uint16_t speed_lookuptable_fast[256][2] MARLIN_PROGMEM = {\
{ 62500, 55556}, { 6944, 3268}, { 3676, 1176}, { 2500, 607}, { 1893, 369}, { 1524, 249}, { 1275, 179}, { 1096, 135},
{ 961, 105}, { 856, 85}, { 771, 69}, { 702, 58}, { 644, 49}, { 595, 42}, { 553, 37}, { 516, 32},
{ 484, 28}, { 456, 25}, { 431, 23}, { 408, 20}, { 388, 19}, { 369, 16}, { 353, 16}, { 337, 14},
......@@ -40,7 +40,7 @@ const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {\
{ 31, 0}, { 31, 0}, { 31, 0}, { 31, 1}, { 30, 0}, { 30, 0}, { 30, 0}, { 30, 0}
};
const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\
const prog_uint16_t speed_lookuptable_slow[256][2] MARLIN_PROGMEM = {\
{ 62500, 12500}, { 50000, 8334}, { 41666, 5952}, { 35714, 4464}, { 31250, 3473}, { 27777, 2777}, { 25000, 2273}, { 22727, 1894},
{ 20833, 1603}, { 19230, 1373}, { 17857, 1191}, { 16666, 1041}, { 15625, 920}, { 14705, 817}, { 13888, 731}, { 13157, 657},
{ 12500, 596}, { 11904, 541}, { 11363, 494}, { 10869, 453}, { 10416, 416}, { 10000, 385}, { 9615, 356}, { 9259, 331},
......@@ -77,7 +77,7 @@ const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {\
#elif F_CPU == 20000000
const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {
const uint16_t speed_lookuptable_fast[256][2] MARLIN_PROGMEM = {
{62500, 54055}, {8445, 3917}, {4528, 1434}, {3094, 745}, {2349, 456}, {1893, 307}, {1586, 222}, {1364, 167},
{1197, 131}, {1066, 105}, {961, 86}, {875, 72}, {803, 61}, {742, 53}, {689, 45}, {644, 40},
{604, 35}, {569, 32}, {537, 28}, {509, 25}, {484, 23}, {461, 21}, {440, 19}, {421, 17},
......@@ -112,7 +112,7 @@ const uint16_t speed_lookuptable_fast[256][2] PROGMEM = {
{39, 0}, {39, 0}, {39, 1}, {38, 0}, {38, 0}, {38, 0}, {38, 0}, {38, 0},
};
const uint16_t speed_lookuptable_slow[256][2] PROGMEM = {
const uint16_t speed_lookuptable_slow[256][2] MARLIN_PROGMEM = {
{62500, 10417}, {52083, 7441}, {44642, 5580}, {39062, 4340}, {34722, 3472}, {31250, 2841}, {28409, 2368}, {26041, 2003},
{24038, 1717}, {22321, 1488}, {20833, 1302}, {19531, 1149}, {18382, 1021}, {17361, 914}, {16447, 822}, {15625, 745},
{14880, 676}, {14204, 618}, {13586, 566}, {13020, 520}, {12500, 481}, {12019, 445}, {11574, 414}, {11160, 385},
......
......@@ -33,6 +33,7 @@
#include "ultralcd.h"
#include "temperature.h"
#include "watchdog.h"
#include "thermistortables.h"
#include "Sd2PinMap.h"
......
......@@ -979,12 +979,6 @@ static void lcd_config_menu()
static void lcd_control_temperature_menu()
{
#ifdef PIDTEMP
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[active_extruder]);
raw_Kd = unscalePID_d(Kd[active_extruder]);
#endif
START_MENU();
MENU_ITEM(back, MSG_CONTROL, lcd_control_menu);
#if TEMP_SENSOR_0 != 0
......@@ -1014,11 +1008,43 @@ static void lcd_control_temperature_menu()
MENU_ITEM_EDIT(float32, MSG_FACTOR, &autotemp_factor, 0.0, 1.0);
#endif
#ifdef PIDTEMP
MENU_ITEM_EDIT(float52, MSG_PID_P, &Kp[active_extruder], 1, 9990);
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[0]);
raw_Kd = unscalePID_d(Kd[0]);
MENU_ITEM_EDIT(float52, MSG_PID_P, &Kp[0], 1, 9990);
// 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_D, &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif//PIDTEMP
#ifndef SINGLENOZZLE
#if EXTRUDERS > 1
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[1]);
raw_Kd = unscalePID_d(Kd[1]);
MENU_ITEM_EDIT(float52, MSG_PID_P1, &Kp[1], 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I1, &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D1, &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //EXTRUDERS > 1
#if EXTRUDERS > 2
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[2]);
raw_Kd = unscalePID_d(Kd[2]);
MENU_ITEM_EDIT(float52, MSG_PID_P2, &Kp[2], 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I2, &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D2, &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //EXTRUDERS > 2
#if EXTRUDERS > 3
// set up temp variables - undo the default scaling
raw_Ki = unscalePID_i(Ki[3]);
raw_Kd = unscalePID_d(Kd[3]);
MENU_ITEM_EDIT(float52, MSG_PID_P2, &Kp[3], 1, 9990);
// i is typically a small value so allows values below 1
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_I3, &raw_Ki, 0.01, 9990, copy_and_scalePID_i);
MENU_ITEM_EDIT_CALLBACK(float52, MSG_PID_D3, &raw_Kd, 1, 9990, copy_and_scalePID_d);
#endif //EXTRUDERS > 2
#endif //SINGLENOZZLE
#endif //PIDTEMP
MENU_ITEM(submenu, MSG_PREHEAT_PLA_SETTINGS, lcd_control_temperature_preheat_pla_settings_menu);
MENU_ITEM(submenu, MSG_PREHEAT_ABS_SETTINGS, lcd_control_temperature_preheat_abs_settings_menu);
MENU_ITEM(submenu, MSG_PREHEAT_GUM_SETTINGS, lcd_control_temperature_preheat_gum_settings_menu);
......
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