This commit is contained in:
bubnikv 2017-09-22 15:43:56 +02:00
commit a8297369b2
13 changed files with 150 additions and 58 deletions

View file

@ -56,6 +56,7 @@
#define EEPROM_UVLO_TARGET_BED (EEPROM_UVLO_TARGET_HOTEND - 1)
#define EEPROM_UVLO_FEEDRATE (EEPROM_UVLO_TARGET_BED - 2)
#define EEPROM_UVLO_FAN_SPEED (EEPROM_UVLO_FEEDRATE - 1)
#define EEPROM_FAN_CHECK_ENABLED (EEPROM_UVLO_FAN_SPEED - 1)
// Currently running firmware, each digit stored as uint16_t.
@ -68,6 +69,8 @@
// Magic string, indicating that the current or the previous firmware running was the Prusa3D firmware.
#define EEPROM_FIRMWARE_PRUSA_MAGIC 0
#define EEPROM_OFFSET 20 //offset for storing settings using M500
//#define EEPROM_OFFSET
// This configuration file contains the basic settings.
// Advanced settings can be found in Configuration_adv.h

View file

@ -11,12 +11,22 @@
void _EEPROM_writeData(int &pos, uint8_t* value, uint8_t size)
{
do
{
eeprom_write_byte((unsigned char*)pos, *value);
pos++;
value++;
}while(--size);
while (size--) {
uint8_t * const p = (uint8_t * const)pos;
uint8_t v = *value;
// EEPROM has only ~100,000 write cycles,
// so only write bytes that have changed!
if (v != eeprom_read_byte(p)) {
eeprom_write_byte(p, v);
if (eeprom_read_byte(p) != v) {
SERIAL_ECHOLNPGM("EEPROM Error");
return;
}
}
pos++;
value++;
};
}
#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)
@ -30,13 +40,7 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
}
#define EEPROM_READ_VAR(pos, value) _EEPROM_readData(pos, (uint8_t*)&value, sizeof(value))
//======================================================================================
#define EEPROM_OFFSET 20
// 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
@ -46,10 +50,10 @@ void _EEPROM_readData(int &pos, uint8_t* value, uint8_t size)
#define EEPROM_VERSION "V1"
#ifdef EEPROM_SETTINGS
void Config_StoreSettings()
void Config_StoreSettings(uint16_t offset, uint8_t level)
{
char ver[4]= "000";
int i=EEPROM_OFFSET;
int i = offset;
EEPROM_WRITE_VAR(i,ver); // invalidate data first
EEPROM_WRITE_VAR(i,axis_steps_per_unit);
EEPROM_WRITE_VAR(i,max_feedrate);
@ -124,12 +128,17 @@ void Config_StoreSettings()
EEPROM_WRITE_VAR(i, filament_size[2]);
#endif
#endif
if (level >= 10) {
EEPROM_WRITE_VAR(i, extruder_advance_k);
EEPROM_WRITE_VAR(i, advance_ed_ratio);
}
/*MYSERIAL.print("Top address used:\n");
MYSERIAL.print(i);
MYSERIAL.print(i);
MYSERIAL.print("\n");
*/
char ver2[4]=EEPROM_VERSION;
i=EEPROM_OFFSET;
i=offset;
EEPROM_WRITE_VAR(i,ver2); // validate data
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Settings Stored");
@ -138,9 +147,10 @@ void Config_StoreSettings()
#ifndef DISABLE_M503
void Config_PrintSettings()
void Config_PrintSettings(uint8_t level)
{ // Always have this function, even with EEPROM_SETTINGS disabled, the current values will be shown
SERIAL_ECHO_START;
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Steps per unit:");
SERIAL_ECHO_START;
SERIAL_ECHOPAIR(" M92 X",axis_steps_per_unit[X_AXIS]);
@ -259,14 +269,22 @@ void Config_PrintSettings()
SERIAL_ECHOLNPGM("Filament settings: Disabled");
}
#endif
if (level >= 10) {
#ifdef LIN_ADVANCE
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM("Linear advance settings:");
SERIAL_ECHOPAIR(" M900 K", extruder_advance_k);
SERIAL_ECHOPAIR(" E/D = ", advance_ed_ratio);
#endif //LIN_ADVANCE
}
}
#endif
#ifdef EEPROM_SETTINGS
void Config_RetrieveSettings()
void Config_RetrieveSettings(uint16_t offset, uint8_t level)
{
int i=EEPROM_OFFSET;
int i=offset;
char stored_ver[4];
char ver[4]=EEPROM_VERSION;
EEPROM_READ_VAR(i,stored_ver); //read stored version
@ -347,6 +365,10 @@ void Config_RetrieveSettings()
EEPROM_READ_VAR(i, filament_size[2]);
#endif
#endif
if (level >= 10) {
EEPROM_READ_VAR(i, extruder_advance_k);
EEPROM_READ_VAR(i, advance_ed_ratio);
}
calculate_volumetric_multipliers();
// Call updatePID (similar to when we have processed M301)
updatePID();

View file

@ -7,14 +7,14 @@
void Config_ResetDefault();
#ifndef DISABLE_M503
void Config_PrintSettings();
void Config_PrintSettings(uint8_t level = 0);
#else
FORCE_INLINE void Config_PrintSettings() {}
#endif
#ifdef EEPROM_SETTINGS
void Config_StoreSettings();
void Config_RetrieveSettings();
void Config_StoreSettings(uint16_t offset, uint8_t level = 0);
void Config_RetrieveSettings(uint16_t offset, uint8_t level = 0);
#else
FORCE_INLINE void Config_StoreSettings() {}
FORCE_INLINE void Config_RetrieveSettings() { Config_ResetDefault(); Config_PrintSettings(); }

View file

@ -68,7 +68,7 @@
// When first starting the main fan, run it at full speed for the
// given number of milliseconds. This gets the fan spinning reliably
// before setting a PWM value. (Does not work with software PWM for fan on Sanguinololu)
//#define FAN_KICKSTART_TIME 100
#define FAN_KICKSTART_TIME 800

View file

@ -472,7 +472,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define DEFAULT_PID_TEMP 210
#define MIN_PRINT_FAN_SPEED 50
#define MIN_PRINT_FAN_SPEED 75
#ifdef SNMM
#define DEFAULT_RETRACTION 4 //used for PINDA temp calibration and pause print
@ -482,4 +482,6 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define UVLO_Z_AXIS_SHIFT 2
#define HEATBED_V2
#endif //__CONFIGURATION_PRUSA_H

View file

@ -841,7 +841,7 @@ void setup()
SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE);
//lcd_update_enable(false); // why do we need this?? - andre
// loads data from EEPROM if available else uses defaults (and resets step acceleration rate)
Config_RetrieveSettings();
Config_RetrieveSettings(EEPROM_OFFSET);
SdFatUtil::set_stack_guard(); //writes magic number at the end of static variables to protect against overwriting static memory by stack
tp_init(); // Initialize temperature loop
plan_init(); // Initialize planner;
@ -1030,7 +1030,8 @@ void setup()
#endif //DEBUG_DISABLE_STARTMSGS
for (int i = 0; i<4; i++) EEPROM_read_B(EEPROM_BOWDEN_LENGTH + i * 2, &bowden_length[i]);
lcd_update_enable(true);
lcd_implementation_clear();
lcd_update(2);
// Store the currently running firmware into an eeprom,
// so the next time the firmware gets updated, it will know from which version it has been updated.
update_current_firmware_version_to_eeprom();
@ -2798,6 +2799,19 @@ void process_commands()
#endif
case 79: {
for (int i = 255; i > 0; i = i - 5) {
fanSpeed = i;
//delay_keep_alive(2000);
for (int j = 0; j < 100; j++) {
delay_keep_alive(100);
}
fan_speed[1];
MYSERIAL.print(i); SERIAL_ECHOPGM(": "); MYSERIAL.println(fan_speed[1]);
}
}break;
/**
* G80: Mesh-based Z probe, probes a grid and produces a
* mesh to compensate for variable bed height
@ -4886,12 +4900,12 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
case 500: // M500 Store settings in EEPROM
{
Config_StoreSettings();
Config_StoreSettings(EEPROM_OFFSET);
}
break;
case 501: // M501 Read settings from EEPROM
{
Config_RetrieveSettings();
Config_RetrieveSettings(EEPROM_OFFSET);
}
break;
case 502: // M502 Revert to default settings

View file

@ -50,6 +50,42 @@ const float bed_skew_angle_extreme = (0.25f * M_PI / 180.f);
// Positions of the bed reference points in the machine coordinates, referenced to the P.I.N.D.A sensor.
// The points are ordered in a zig-zag fashion to speed up the calibration.
#ifdef HEATBED_V2
// Positions of the bed reference points in the machine coordinates, referenced to the P.I.N.D.A sensor.
// The points are the following: center front, center right, center rear, center left.
const float bed_ref_points_4[] PROGMEM = {
115.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
216.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y,
115.f - BED_ZERO_REF_X, 200.4f - BED_ZERO_REF_Y,
13.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y
};
const float bed_ref_points[] PROGMEM = {
13.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
115.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
216.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
216.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y,
115.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y,
13.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y,
13.f - BED_ZERO_REF_X, 200.4f - BED_ZERO_REF_Y,
115.f - BED_ZERO_REF_X, 200.4f - BED_ZERO_REF_Y,
216.f - BED_ZERO_REF_X, 200.4f - BED_ZERO_REF_Y
};
#else
// Positions of the bed reference points in the machine coordinates, referenced to the P.I.N.D.A sensor.
// The points are the following: center front, center right, center rear, center left.
const float bed_ref_points_4[] PROGMEM = {
115.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
216.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y,
115.f - BED_ZERO_REF_X, 202.4f - BED_ZERO_REF_Y,
13.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y
};
const float bed_ref_points[] PROGMEM = {
13.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
115.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
@ -64,14 +100,7 @@ const float bed_ref_points[] PROGMEM = {
216.f - BED_ZERO_REF_X, 202.4f - BED_ZERO_REF_Y
};
// Positions of the bed reference points in the machine coordinates, referenced to the P.I.N.D.A sensor.
// The points are the following: center front, center right, center rear, center left.
const float bed_ref_points_4[] PROGMEM = {
115.f - BED_ZERO_REF_X, 8.4f - BED_ZERO_REF_Y,
216.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y,
115.f - BED_ZERO_REF_X, 202.4f - BED_ZERO_REF_Y,
13.f - BED_ZERO_REF_X, 104.4f - BED_ZERO_REF_Y
};
#endif //not HEATBED_V2
static inline float sqr(float x) { return x * x; }

View file

@ -1388,15 +1388,6 @@ void microstep_readings()
#endif
}
static void check_fans() {
if (READ(TACH_0) != fan_state[0]) {
fan_edge_counter[0] ++;
fan_state[0] = READ(TACH_0);
}
if (READ(TACH_1) != fan_state[1]) {
fan_edge_counter[1] ++;
fan_state[1] = READ(TACH_1);
}
}

View file

@ -104,9 +104,6 @@ void digipot_current(uint8_t driver, int current);
void microstep_init();
void microstep_readings();
static void check_fans();
#ifdef BABYSTEPPING
void babystep(const uint8_t axis,const bool direction); // perform a short step with a single stepper motor, outside of any convention
#endif

View file

@ -429,26 +429,31 @@ void setExtruderAutoFanState(int pin, bool state)
}
void countFanSpeed()
{
{
//SERIAL_ECHOPGM("edge counter 1:"); MYSERIAL.println(fan_edge_counter[1]);
fan_speed[0] = (fan_edge_counter[0] * (float(250) / (millis() - extruder_autofan_last_check)));
fan_speed[1] = (fan_edge_counter[1] * (float(250) / (millis() - extruder_autofan_last_check)));
/*SERIAL_ECHOPGM("time interval: "); MYSERIAL.println(millis() - extruder_autofan_last_check);
SERIAL_ECHOPGM("extruder fan speed:"); MYSERIAL.print(fan_speed[0]); SERIAL_ECHOPGM("; edge counter:"); MYSERIAL.println(fan_edge_counter[0]);
SERIAL_ECHOPGM("print fan speed:"); MYSERIAL.print(fan_speed[1]); SERIAL_ECHOPGM("; edge counter:"); MYSERIAL.println(fan_edge_counter[1]);
SERIAL_ECHOLNPGM(" ");*/
fan_edge_counter[0] = 0;
fan_edge_counter[1] = 0;
}
void checkFanSpeed()
{
bool fans_check_enabled = (eeprom_read_byte((uint8_t*)EEPROM_FAN_CHECK_ENABLED) > 0);
static unsigned char fan_speed_errors[2] = { 0,0 };
if (fan_speed[0] == 0 && current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE) fan_speed_errors[0]++;
if (fan_speed[0] == 0 && (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)) fan_speed_errors[0]++;
else fan_speed_errors[0] = 0;
if (fan_speed[1] == 0 && fanSpeed > MIN_PRINT_FAN_SPEED) fan_speed_errors[1]++;
if ((fan_speed[1] == 0)&& (fanSpeed > MIN_PRINT_FAN_SPEED)) fan_speed_errors[1]++;
else fan_speed_errors[1] = 0;
if (fan_speed_errors[0] > 5) fanSpeedError(0);
if (fan_speed_errors[1] > 15) fanSpeedError(1);
if ((fan_speed_errors[0] > 5) && fans_check_enabled) fanSpeedError(0); //extruder fan
if ((fan_speed_errors[1] > 15) && fans_check_enabled) fanSpeedError(1); //print fan
}
void fanSpeedError(unsigned char _fan) {
@ -485,8 +490,8 @@ void checkExtruderAutoFans()
// which fan pins need to be turned on?
#if defined(EXTRUDER_0_AUTO_FAN_PIN) && EXTRUDER_0_AUTO_FAN_PIN > -1
if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)
fanState |= 1;
if (current_temperature[0] > EXTRUDER_AUTO_FAN_TEMPERATURE)
fanState |= 1;
#endif
#if defined(EXTRUDER_1_AUTO_FAN_PIN) && EXTRUDER_1_AUTO_FAN_PIN > -1
if (current_temperature[1] > EXTRUDER_AUTO_FAN_TEMPERATURE)
@ -2148,6 +2153,19 @@ ISR(TIMER0_COMPB_vect)
}
}
#endif //BABYSTEPPING
check_fans();
}
void check_fans() {
if (READ(TACH_0) != fan_state[0]) {
fan_edge_counter[0] ++;
fan_state[0] = !fan_state[0];
}
if (READ(TACH_1) != fan_state[1]) {
fan_edge_counter[1] ++;
fan_state[1] = !fan_state[1];
}
}
#ifdef PIDTEMP

View file

@ -222,5 +222,7 @@ void countFanSpeed();
void checkFanSpeed();
void fanSpeedError(unsigned char _fan);
void check_fans();
#endif

View file

@ -29,6 +29,7 @@
int8_t encoderDiff; /* encoderDiff is updated from interrupt context and added to encoderPosition every LCD update */
extern int lcd_change_fil_state;
extern bool fans_check_enabled = true;
//Function pointer to menu functions.
typedef void (*menuFunc_t)();
@ -1058,10 +1059,22 @@ static void lcd_support_menu()
}
MENU_ITEM(submenu, MSG_INFO_EXTRUDER, lcd_menu_extruder_info);
MENU_ITEM(submenu, PSTR("Temperatures"), lcd_menu_temperatures);
if (fans_check_enabled == true) {
MENU_ITEM(function, PSTR("Check fans [EN]"), lcd_set_fan_check);
}
else {
MENU_ITEM(function, PSTR("Check fans [DIS]"), lcd_set_fan_check);
}
#endif //MK1BP
END_MENU();
}
void lcd_set_fan_check() {
fans_check_enabled = !fans_check_enabled;
eeprom_update_byte((unsigned char *)EEPROM_FAN_CHECK_ENABLED, fans_check_enabled);
lcd_goto_menu(lcd_support_menu, 15);
}
void lcd_unLoadFilament()
{

View file

@ -223,6 +223,7 @@ static void extr_unload_1();
static void extr_unload_2();
static void extr_unload_3();
static void lcd_disable_farm_mode();
static void lcd_set_fan_check();
void extr_unload_all();
void extr_unload_used();
void extr_unload();