Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hi #2

Closed
wants to merge 146 commits into from
Closed

Hi #2

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
7907edf
first compile using arduino22
bkubicek Aug 22, 2011
36d1c3f
better settings
bkubicek Aug 22, 2011
57d0011
dis-funcional ad595
bkubicek Aug 23, 2011
5b93020
unworking temp reading still, added lcd support
bkubicek Aug 23, 2011
4fd12ae
ah wirking f** it up
bkubicek Aug 23, 2011
4630b16
ok, now it seems to work with the temperatures
bkubicek Aug 23, 2011
b84f6e1
tuned configuration
bkubicek Aug 23, 2011
d471651
Fixes to allow simple LCD display. Added FANCY_BUTTONS define to al…
Aug 24, 2011
e35f914
Implemented Max Endstops for X,Y,Z axis
Aug 24, 2011
6096262
Updated Readme for this fork
Aug 24, 2011
f1a7c8b
Updated Readme typos
Aug 24, 2011
3d0ce29
Corrected one more readme typo
Aug 24, 2011
6416e20
Fixed max endstops locking other axis' movements
Aug 24, 2011
7d7ad08
Credits..
bkubicek Aug 25, 2011
b203697
Let me introduce myself :-)
lampmaker Aug 26, 2011
535506a
Edited README via GitHub
ErikZalm Aug 26, 2011
461e267
pre-update
bkubicek Aug 28, 2011
fae0bc5
Merge branch 'master' of https://github.com/bkubicek/Marlin
bkubicek Aug 28, 2011
e7e7b35
lcd improvement, real speed override for lcd/sd printing, config.h ba…
bkubicek Aug 28, 2011
b430763
Version number
bkubicek Aug 29, 2011
0156fda
buttons improvement, actual measures
bkubicek Aug 29, 2011
37321fb
trying to add redbutton sd-reset, so that moving to the file page doe…
bkubicek Aug 29, 2011
f231c9e
Reapply code for implementing max endstops for X,Y,Z axis and fixing…
Sep 4, 2011
ed7ee42
protospace: Analog fan
bkubicek Sep 9, 2011
05a816d
solved problem with floating buttons, limit of maximum velocity.
bkubicek Sep 9, 2011
083ff50
timer
bkubicek Sep 9, 2011
7d753d2
autostart debugging
bkubicek Sep 9, 2011
acaefb5
back to default config
bkubicek Sep 9, 2011
a9f2c95
added minute counting for no-sdcard printing
bkubicek Sep 10, 2011
07d1962
Keep floating point math pure -- to attempt to prevent rounding error…
Sep 13, 2011
c8f734d
Disable SDSUPPORT by default so that folks can use RepG to connect
Sep 13, 2011
659f607
step debugging
bkubicek Sep 13, 2011
5c1eda9
Merge branch 'master' of https://github.com/bkubicek/Marlin
bkubicek Sep 13, 2011
e8f05ea
disabled the step debugging for default users
bkubicek Sep 14, 2011
309774a
larger speed limits
bkubicek Sep 14, 2011
87eb941
leftovers
bkubicek Sep 14, 2011
4670145
Merge branch 'master' of https://github.com/bkubicek/Marlin
bkubicek Sep 14, 2011
c4b330c
Extruder Stepper now properly disables as necessary
Sep 14, 2011
a6de9cf
added a lot of corrections
bkubicek Sep 16, 2011
20019c4
Merge branch 'master' of https://github.com/bkubicek/Marlin
bkubicek Sep 16, 2011
6c11c3d
Added a MIN_SEGMENT_TIME option in configuration.h. this sets the min…
lampmaker Sep 17, 2011
c6e6a78
Changed defines for SIMPLE or FANCY LCD (removing FANCY_BUTTONS). It…
Sep 17, 2011
cf4c468
No lcd should be enabled by default, IMHO, in the current all lcd stu…
bkubicek Sep 18, 2011
58b0fb8
Modified step counter to follow plan_set_position's input.
lampmaker Sep 18, 2011
3dae132
Wrapped prev commit in #ifdef DEBUG_STEPS
lampmaker Sep 18, 2011
d6f6bdc
making acceleration and max speeds value changeable by gcode.
bkubicek Sep 20, 2011
063e7c7
unix end of line
bkubicek Sep 20, 2011
712ca8d
made acceration and feedrate limits software-configurable.
bkubicek Sep 20, 2011
4799597
Merge branch 'master' of https://github.com/bkubicek/Marlin
bkubicek Sep 20, 2011
0375751
typos, stupid me
bkubicek Sep 20, 2011
849a021
removed enquecommand lcd dependency, its also used for sd
bkubicek Sep 20, 2011
25e71c4
Decreased command buffer size for SIMPLE_LCD. Added boot-up message.…
Sep 21, 2011
afad7d0
Whoops! Disable SIMPLE_LCD by default
Sep 21, 2011
2ce018c
prefetch
bkubicek Sep 21, 2011
a0677ff
Merge branch 'master' of https://github.com/bkubicek/Marlin
bkubicek Sep 21, 2011
72936b0
tuned config.
bkubicek Sep 21, 2011
152e7f4
sane config for average users. If you survive the homeing, your build…
bkubicek Sep 21, 2011
7c6b0f9
Decreased the max speeds so average users can use this firmware
bkubicek Sep 21, 2011
5da29eb
checkautostart caused a compile error.
bkubicek Sep 21, 2011
405e7ed
Branch to test alternative method of slowing down.
lampmaker Sep 23, 2011
e7e3ffe
Prevent div by 0 in case blockcount==0
lampmaker Sep 25, 2011
dee0da7
Fixed error when extruding only
lampmaker Sep 29, 2011
60a4bf7
Merged with main; fixed acceleration error when extruding only
lampmaker Sep 29, 2011
a3d9721
Edited README via GitHub
bkubicek Oct 1, 2011
91e0025
Edited README via GitHub
bkubicek Oct 1, 2011
994f4d7
minimum feedrate
bkubicek Oct 1, 2011
2194521
Merge branch 'master' of https://github.com/bkubicek/Marlin
bkubicek Oct 1, 2011
cb56af5
add flattr button to github
bkubicek Oct 1, 2011
bea1c7c
sane public config
bkubicek Oct 1, 2011
478f68a
corrected readme
bkubicek Oct 1, 2011
48517b8
Edited README.md via GitHub
bkubicek Oct 1, 2011
c884af2
Edited README.md via GitHub
bkubicek Oct 1, 2011
61b665c
Edited README.md via GitHub
bkubicek Oct 1, 2011
e3b53eb
remove old menu
bkubicek Oct 1, 2011
bb0402d
cleanup
bkubicek Oct 1, 2011
0431f77
no test
bkubicek Oct 1, 2011
7b9d8b2
pretestingextruder
bkubicek Oct 2, 2011
3890e37
Merge commit '61b665c35ff92d32957234160a8feebfab95ba77' into Slowdown
lampmaker Oct 4, 2011
b2bf43b
Added possibility to store data in EEPROM
lampmaker Oct 4, 2011
a43fe1a
Set default minimum feedrates to 0
lampmaker Oct 4, 2011
fde9550
main menu and status seem ok
bkubicek Oct 8, 2011
c651bbd
prepare menu start
bkubicek Oct 8, 2011
8b18a3d
menu filled, missing changeable number system
bkubicek Oct 8, 2011
b117d44
found error
bkubicek Oct 8, 2011
9d196b5
sd menu/printing seems to work
bkubicek Oct 9, 2011
2b2bb3a
file error
bkubicek Oct 10, 2011
1cc85ea
whoa, amazing. the control menu seems to work, and the xyjerk now has…
bkubicek Oct 10, 2011
6891beb
wow, xy_jerk higher makes a big difference in print quality
bkubicek Oct 10, 2011
9ac43c9
joris found a bug
bkubicek Oct 10, 2011
3765075
maybe remove trapping in submenus
bkubicek Oct 10, 2011
0bbe1dc
increased default xy and z-jerk
lampmaker Oct 11, 2011
78c631e
menu to enum.
bkubicek Oct 11, 2011
22eb4f6
Merge remote-tracking branch 'remotes/origin/Slowdown'
bkubicek Oct 12, 2011
c4450ac
Merge branch 'newlcd'
bkubicek Oct 12, 2011
0d1cb1c
sd card refresh working
bkubicek Oct 12, 2011
77791a6
added disable for ultipanel
bkubicek Oct 12, 2011
40ec9ed
encoder updates more often
bkubicek Oct 12, 2011
f0cba28
fixed thermistor tables and sane config for average user
bkubicek Oct 12, 2011
12e6bfb
for joris.
bkubicek Oct 12, 2011
b958fd5
sane config for everybody
bkubicek Oct 12, 2011
4589ab3
Added back Simple LCD functionality that was obliterated by Berhnard'…
Oct 12, 2011
9358b45
Merge remote-tracking branch 'origin/master'
Oct 12, 2011
8cf8408
added support for smaller lcd in a useful, compatible way
bkubicek Oct 12, 2011
1a8ef67
Allow ULTRA_LCD (any lcd) to compile without SDSUPPORT
Oct 13, 2011
e7cc585
Allow non-Ultipanel lcd's to display message text on bottom line
Oct 13, 2011
bac956e
Enabled PID. EXPERIMENTAL!
lampmaker Oct 14, 2011
2942d3a
Changed PID parameters: max integral limit
lampmaker Oct 14, 2011
8766972
Some modifications to PID:
lampmaker Oct 14, 2011
1f3c0e5
EEPROM now stores & retreives PID settings
lampmaker Oct 14, 2011
1fc8fa3
Disabled EEPROM info sent to serial
lampmaker Oct 15, 2011
3e3e8dd
removed more info sent to serial
lampmaker Oct 15, 2011
b3f5d1e
strange lcd problem with newpanel
bkubicek Oct 15, 2011
e807a8f
Merge branch 'master' of https://github.com/bkubicek/Marlin
bkubicek Oct 15, 2011
1a0195b
sane config
bkubicek Oct 15, 2011
c96c076
better default values
bkubicek Oct 15, 2011
0c7a39f
Some minor mistakes found by action68
bkubicek Oct 16, 2011
9f57cdd
; fixed
bkubicek Oct 16, 2011
d72e485
Included Streaming lib; added ECHO
lampmaker Oct 18, 2011
300549d
fixed typo
lampmaker Oct 18, 2011
f335826
Echo PID settings
lampmaker Oct 18, 2011
d029252
Merge remote-tracking branch 'Bkubicek/Slowdown' into Slowdown
lampmaker Oct 18, 2011
e4ff5e5
found the bug in the new panels. Pullup on output pins instead of inp…
bkubicek Oct 21, 2011
67c63c1
SD card autodetect added.
bkubicek Oct 21, 2011
cf397ca
enable beep again
bkubicek Oct 21, 2011
10c2489
now there is pid enabled by defualt
bkubicek Oct 21, 2011
73d5bd5
minimize offset temperature in pid
bkubicek Oct 21, 2011
ad4ae7c
make pid possible to be disabled
bkubicek Oct 21, 2011
743f775
added fan control into menu
bkubicek Oct 21, 2011
1aa236f
updates full for lcd
bkubicek Oct 23, 2011
0ad9779
Fixed bug in M105 processing when PID is disabled.
lampmaker Oct 24, 2011
062da65
fix minimum feedrate
bkubicek Oct 26, 2011
328a5dd
smaller memory footprint of without advance.
bkubicek Oct 26, 2011
6d55967
enable watchdog with manual reset (still untested, but doing at least…
bkubicek Oct 26, 2011
0e5054a
Disabled PID because its not working while in print..
bkubicek Oct 30, 2011
b65970e
better PID values.
bkubicek Nov 1, 2011
873903f
Merge branch 'master' of https://github.com/bkubicek/Marlin
bkubicek Nov 1, 2011
742fb2e
disabled lcd for most users
bkubicek Nov 1, 2011
5877a0f
circumvent the display from overwriting the speed-factor
bkubicek Nov 1, 2011
e1e0abd
next try.
bkubicek Nov 1, 2011
c896db5
display update bug
bkubicek Nov 1, 2011
786b83d
PID now working. Actually, its more than pid, lets call it PIDC. Addi…
bkubicek Nov 2, 2011
1353ab3
a bit higher even.
bkubicek Nov 2, 2011
566ed1f
PID-I was a bit too low.
bkubicek Nov 2, 2011
3a49a0d
float should be sufficient.
bkubicek Nov 3, 2011
259a5ac
trying just PI instead of PID
bkubicek Nov 3, 2011
81202a8
made it possible to have an intermediate M92 command without the extr…
bkubicek Nov 3, 2011
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 105 additions & 37 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
@@ -1,39 +1,64 @@

#ifndef CONFIGURATION_H
#define CONFIGURATION_H

// BASIC SETTINGS: select your board type, thermistor type, axis scaling, and endstop configuration

//// The following define selects which electronics board you have. Please choose the one that matches your setup
// Gen6 = 5,
#define MOTHERBOARD 5
#define MOTHERBOARD 7

//// Thermistor settings:
// 1 is 100k thermistor
// 2 is 200k thermistor
// 3 is mendel-parts thermistor
#define THERMISTORHEATER 3
#define THERMISTORHEATER 2
// Select one of these only to define how the nozzle temp is read.
//#define HEATER_USES_THERMISTOR
#define HEATER_USES_AD595
//#define HEATER_USES_MAX6675

// Select one of these only to define how the bed temp is read.
//#define BED_USES_THERMISTOR
//#define BED_USES_AD595

#define HEATER_CHECK_INTERVAL 50
#define BED_CHECK_INTERVAL 5000
#define BNUMTEMPS NUMTEMPS
#define bedtemptable temptable

//// Calibration variables
// X, Y, Z, E steps per unit - Metric Mendel / Orca with V9 extruder:
float axis_steps_per_unit[] = {40, 40, 3333.92, 67};
// For E steps per unit = 67 for v9 with direct drive (needs finetuning) for other extruders this needs to be changed
// Metric Prusa Mendel with Makergear geared stepper extruder:
//float axis_steps_per_unit[] = {80,80,3200/1.25,1380};

//// Endstop Settings
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors
// The pullups are needed if you directly connect a mechanical endswitch between the signal and ground pins.
const bool ENDSTOPS_INVERTING = false; // set to true to invert the logic of the endstops.
const bool ENDSTOPS_INVERTING = true; // set to true to invert the logic of the endstops.
// For optos H21LOB set to true, for Mendel-Parts newer optos TCST2103 set to false

// This determines the communication speed of the printer
#define BAUDRATE 250000
#define BAUDRATE 115200

// Comment out (using // at the start of the line) to disable SD support:
//#define SDSUPPORT

// #define ULTRA_LCD //any lcd
#define LCD_WIDTH 16
#define LCD_HEIGHT 2

//#define ULTIPANEL
#ifdef ULTIPANEL
#define NEWPANEL //enable this if you have a click-encoder panel
#define SDSUPPORT
#define ULTRA_LCD
#define LCD_WIDTH 20
#define LCD_HEIGHT 4
#endif


#define SDSUPPORT // Enable SD Card Support in Hardware Console



const int dropsegments=5; //everything with this number of steps will be ignored as move

//// ADVANCED SETTINGS - to tweak parameters

#include "thermistortables.h"
Expand All @@ -47,14 +72,14 @@ const bool ENDSTOPS_INVERTING = false; // set to true to invert the logic of the
// Disables axis when it's not being used.
#define DISABLE_X false
#define DISABLE_Y false
#define DISABLE_Z true
#define DISABLE_Z false
#define DISABLE_E false

// Inverting axis direction
#define INVERT_X_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_Y_DIR false // for Mendel set to true, for Orca set to false
#define INVERT_Z_DIR true // for Mendel set to false, for Orca set to true
#define INVERT_E_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
#define INVERT_E_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false

//// ENDSTOP SETTINGS:
// Sets direction of endstops when homing; 1=MAX, -1=MIN
Expand All @@ -64,26 +89,47 @@ const bool ENDSTOPS_INVERTING = false; // set to true to invert the logic of the

#define min_software_endstops false //If true, axis won't move to coordinates less than zero.
#define max_software_endstops true //If true, axis won't move to coordinates greater than the defined lengths below.
#define X_MAX_LENGTH 200
#define Y_MAX_LENGTH 200
#define Z_MAX_LENGTH 100
#define X_MAX_LENGTH 210
#define Y_MAX_LENGTH 210
#define Z_MAX_LENGTH 210

//// MOVEMENT SETTINGS
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
float max_feedrate[] = {60000, 60000, 100, 500000}; // set the max speeds
float homing_feedrate[] = {2400, 2400, 80, 0}; // set the homing speeds
//note: on bernhards ultimaker 200 200 12 are working well.
float homing_feedrate[] = {70*60, 70*60, 12*60, 0}; // set the homing speeds
//the followint checks if an extrusion is existent in the move. if _not_, the speed of the move is set to the maximum speed.
//!!!!!!Use only if you know that your printer works at the maximum declared speeds.
// works around the skeinforge cool-bug. There all moves are slowed to have a minimum layer time. However slow travel moves= ooze
#define TRAVELING_AT_MAXSPEED
bool axis_relative_modes[] = {false, false, false, false};

//// Acceleration settings
// X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.
float acceleration = 2000; // Normal acceleration mm/s^2
float retract_acceleration = 7000; // Normal acceleration mm/s^2
float max_jerk = 20*60;
long max_acceleration_units_per_sq_second[] = {7000,7000,100,10000}; // X, Y, Z and E max acceleration in mm/s^2 for printing moves or retracts
// Not used long max_travel_acceleration_units_per_sq_second[] = {500,500,50,500}; // X, Y, Z max acceleration in mm/s^2 for travel moves

// default settings

#define DEFAULT_AXIS_STEPS_PER_UNIT {79.87220447,79.87220447,200*8/3,14} // default steps per unit for ultimaker
#define DEFAULT_MAX_FEEDRATE {160*60, 160*60, 10*60, 500000}
#define DEFAULT_MAX_ACCELERATION {9000,9000,150,10000} // X, Y, Z, E maximum start speed for accelerated moves. E default values are good for skeinforge 40+, for older versions raise them a lot.

#define DEFAULT_ACCELERATION 4600 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
#define DEFAULT_RETRACT_ACCELERATION 7000 // X, Y, Z and E max acceleration in mm/s^2 for r retracts

#define DEFAULT_MINIMUMFEEDRATE 0*60 // minimum feedrate
#define DEFAULT_MINTRAVELFEEDRATE 140*60

// minimum time in microseconds that a movement needs to take if the buffer is emptied. Increase this number if you see blobs while printing high speed & high detail. It will slowdown on the detailed stuff.
#define DEFAULT_MINSEGMENTTIME 20000
#define DEFAULT_XYJERK 30.0*60
#define DEFAULT_ZJERK 10.0*60

// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature
//this enables the watchdog interrupt.
#define USE_WATCHDOG
//you cannot reboot on a mega2560 due to a bug in he bootloader. Hence, you have to reset manually, and this is done hereby:
#define RESET_MANUAL

#define WATCHDOG_TIMEOUT 4


// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109
//#define WATCHPERIOD 5000 //5 seconds

Expand All @@ -97,21 +143,43 @@ long max_acceleration_units_per_sq_second[] = {7000,7000,100,10000}; // X, Y, Z
#define MAXTEMP 275





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


#define GRACETEMP 0 //temperature which already counts as reached for M109
#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_dT 0.16
double Kp = 20.0;
double Ki = 1.5*PID_dT;
double Kd = 80/PID_dT;
//#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 255 // limits current to nozzle
#define PID_INTEGRAL_DRIVE_MAX 255
#define PID_dT 0.05
//machine with red silicon: 1950:45 second ; with fan fully blowin 3000:47

#define PID_CRITIAL_GAIN 3000
#define PID_SWING_AT_CRITIAL 45 //seconds
#define PIDIADD 5
/*
//PID according to Ziegler-Nichols method
float Kp = 0.6*PID_CRITIAL_GAIN;
float Ki =PIDIADD+2*Kp/PID_SWING_AT_CRITIAL*PID_dT;
float Kd = Kp*PID_SWING_AT_CRITIAL/8./PID_dT;
*/
//PI according to Ziegler-Nichols method
float Kp = PID_CRITIAL_GAIN/2.2;
float Ki =1.2*Kp/PID_SWING_AT_CRITIAL*PID_dT;
float Kd = 0;
float Kc = 9; //heatingpower=Kc*(e_speed)
#endif // PIDTEMP


// extruder advance constant (s2/mm3)
//
// advance (steps) = STEPS_PER_CUBIC_MM_E * EXTUDER_ADVANCE_K * cubic mm per second ^ 2
Expand All @@ -122,9 +190,9 @@ double Kd = 80/PID_dT;
//#define ADVANCE

#ifdef ADVANCE
#define EXTRUDER_ADVANCE_K 0.02
#define EXTRUDER_ADVANCE_K .3

#define D_FILAMENT 1.7
#define D_FILAMENT 2.8
#define STEPS_MM_E 65
#define EXTRUTION_AREA (0.25 * D_FILAMENT * D_FILAMENT * 3.14159)
#define STEPS_PER_CUBIC_MM_E (axis_steps_per_unit[E_AXIS]/ EXTRUTION_AREA)
Expand Down
120 changes: 120 additions & 0 deletions Marlin/EEPROM.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@

//======================================================================================
template <class T> int EEPROM_writeAnything(int &ee, const T& value)
{
const byte* p = (const byte*)(const void*)&value;
int i;
for (i = 0; i < sizeof(value); i++)
EEPROM.write(ee++, *p++);
return i;
}
//======================================================================================
template <class T> int EEPROM_readAnything(int &ee, T& value)
{
byte* p = (byte*)(void*)&value;
int i;
for (i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(ee++);
return i;
}
//======================================================================================

#define EEPROM_OFFSET 100

#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.
// ALSO: always make sure the variables in the Store and retrieve sections are in the same order.
void StoreSettings() {
char ver[4]= "000";
int i=EEPROM_OFFSET;
EEPROM_writeAnything(i,ver); // invalidate data first
EEPROM_writeAnything(i,axis_steps_per_unit);
EEPROM_writeAnything(i,max_feedrate);
EEPROM_writeAnything(i,max_acceleration_units_per_sq_second);
EEPROM_writeAnything(i,acceleration);
EEPROM_writeAnything(i,retract_acceleration);
EEPROM_writeAnything(i,minimumfeedrate);
EEPROM_writeAnything(i,mintravelfeedrate);
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
ECHOLN("Settings Stored");

}

void RetrieveSettings(bool def=false){ // if def=true, the default values will be used
int i=EEPROM_OFFSET;
char stored_ver[4];
char ver[4]=EEPROM_VERSION;
EEPROM_readAnything(i,stored_ver); //read stored version
// 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);
EEPROM_readAnything(i,max_acceleration_units_per_sq_second);
EEPROM_readAnything(i,acceleration);
EEPROM_readAnything(i,retract_acceleration);
EEPROM_readAnything(i,minimumfeedrate);
EEPROM_readAnything(i,mintravelfeedrate);
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 {
float tmp1[]=DEFAULT_AXIS_STEPS_PER_UNIT;
float tmp2[]=DEFAULT_MAX_FEEDRATE;
long tmp3[]=DEFAULT_MAX_ACCELERATION;
for (int i=0;i<4;i++) {
axis_steps_per_unit[i]=tmp1[i];
max_feedrate[i]=tmp2[i];
max_acceleration_units_per_sq_second[i]=tmp3[i];
}
acceleration=DEFAULT_ACCELERATION;
retract_acceleration=DEFAULT_RETRACT_ACCELERATION;
minimumfeedrate=DEFAULT_MINIMUMFEEDRATE;
minsegmenttime=DEFAULT_MINSEGMENTTIME;
mintravelfeedrate=DEFAULT_MINTRAVELFEEDRATE;
max_xy_jerk=DEFAULT_XYJERK;
max_z_jerk=DEFAULT_ZJERK;
ECHOLN("Using Default settings:");
}
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));
#ifdef PIDTEMP
ECHOLN("PID settings:");
ECHOLN(" M301 P" << _FLOAT(Kp,3) << " I" << _FLOAT(Ki,3) << " D" << _FLOAT(Kd,3));
#endif

}


Loading