Browse Source

Build Number = 108
FSensor log can be enabled with D9125L1
Selftest menu
PINDA D codes

Robert Pelnar 7 years ago
parent
commit
ee2f927148
6 changed files with 109 additions and 35 deletions
  1. 2 2
      Firmware/Configuration.h
  2. 1 1
      Firmware/Configuration_prusa.h
  3. 82 13
      Firmware/Dcodes.cpp
  4. 5 2
      Firmware/Dcodes.h
  5. 1 1
      Firmware/Marlin.h
  6. 18 16
      Firmware/Marlin_main.cpp

+ 2 - 2
Firmware/Configuration.h

@@ -9,8 +9,8 @@
 
 // Firmware version
 #define FW_version "3.0.12-RC2"
-//#define FW_build   107
-#define FW_build   --BUILD-NUMBER--
+#define FW_build   108
+//#define FW_build   --BUILD-NUMBER--
 #define FW_version_build FW_version " b" STR(FW_build)
 
 

+ 1 - 1
Firmware/Configuration_prusa.h

@@ -84,7 +84,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
 //#define _NO_ASM
 #define DEBUG_DCODES //D codes
 #if 1
-//#define DEBUG_FSENSOR_LOG          //Reports fsensor status to serial
+#define DEBUG_FSENSOR_LOG          //Reports fsensor status to serial
 //#define DEBUG_CRASHDET_COUNTERS  //Display crash-detection counters on LCD
 //#define DEBUG_RESUME_PRINT       //Resume/save print debug enable 
 //#define DEBUG_UVLO_AUTOMATIC_RECOVER // Power panic automatic recovery debug output 

+ 82 - 13
Firmware/Dcodes.cpp

@@ -1,5 +1,7 @@
 #include "Dcodes.h"
 #include "Marlin.h"
+#
+#include "ConfigurationStore.h"
 #include "cmdqueue.h"
 #include "pat9125.h"
 #include <avr/wdt.h>
@@ -16,6 +18,10 @@
 #define BOOT_APP_FLG_COPY  0x02
 #define BOOT_APP_FLG_FLASH 0x04
 
+extern uint8_t fsensor_log;
+extern float current_temperature_pinda;
+extern float axis_steps_per_unit[NUM_AXIS];
+
 
 inline void serial_print_hex_nibble(uint8_t val)
 {
@@ -77,11 +83,12 @@ void dcode_0()
 
 void dcode_1()
 {
-	MYSERIAL.println("D1 - Clear EEPROM");
+	MYSERIAL.println("D1 - Clear EEPROM and RESET");
 	cli();
-	for (int i = 0; i < 4096; i++)
-		eeprom_write_byte((unsigned char*)i, (unsigned char)0);
-	sei();
+	for (int i = 0; i < 8192; i++)
+		eeprom_write_byte((unsigned char*)i, (unsigned char)0xff);
+	wdt_enable(WDTO_15MS);
+	while(1);
 }
 
 void dcode_2()
@@ -128,6 +135,7 @@ void dcode_2()
 		MYSERIAL.write('\n');
 	}
 }
+
 void dcode_3()
 {
 	MYSERIAL.println("D3 - Read/Write EEPROM");
@@ -272,6 +280,13 @@ void dcode_5()
 
 void dcode_6()
 {
+	MYSERIAL.println("D6 - Read/Write external FLASH");
+}
+
+void dcode_7()
+{
+	MYSERIAL.println("D7 - Read/Write Bootloader");
+/*
 	cli();
 	boot_app_magic = 0x55aa55aa;
 	boot_app_flags = BOOT_APP_FLG_ERASE | BOOT_APP_FLG_COPY | BOOT_APP_FLG_FLASH;
@@ -280,17 +295,68 @@ void dcode_6()
 	boot_dst_addr = (uint32_t)0x0003f400;
 	wdt_enable(WDTO_15MS);
 	while(1);
-
-/*	MYSERIAL.println("D6 - Test");
-	MYSERIAL.print("REGx90=0x");
-	MYSERIAL.println(REGx90, HEX);
-	REGx90 = 100;
-	MYSERIAL.print("REGx90=0x");
-	MYSERIAL.println(REGx90, HEX);*/
+*/
 }
 
-void dcode_7()
+void dcode_8()
 {
+	MYSERIAL.println("D8 - Read/Write PINDA");
+	uint8_t cal_status = calibration_status_pinda();
+	float temp_pinda = current_temperature_pinda;
+	float offset_z = temp_compensation_pinda_thermistor_offset(temp_pinda);
+	if ((strchr_pointer[1+1] == '?') || (strchr_pointer[1+1] == 0))
+	{
+		MYSERIAL.print("cal_status=");
+		MYSERIAL.println(cal_status?"1":"0");
+		for (uint8_t i = 0; i < 6; i++)
+		{
+			MYSERIAL.print("temp_pinda=");
+			MYSERIAL.print(35 + i * 5, DEC);
+			MYSERIAL.print("C, temp_shift=");
+			uint16_t offs = 0;
+			if (i > 0) offs = eeprom_read_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + (i - 1));
+			MYSERIAL.print(((float)offs) / axis_steps_per_unit[Z_AXIS], 3);
+			MYSERIAL.println("mm");
+		}
+	}
+	else if (strchr_pointer[1+1] == '!')
+	{
+		cal_status = 1;
+		eeprom_write_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, cal_status);
+		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 0, 50); //40C - 
+		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 1, 100); //45C - 
+		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 2, 150); //50C - 
+		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 3, 200); //55C - 
+		eeprom_write_word(((uint16_t*)EEPROM_PROBE_TEMP_SHIFT) + 4, 250); //60C - 
+	}
+	else
+	{
+		if (code_seen('P')) // Pinda temperature [C]
+			temp_pinda = code_value();
+		offset_z = temp_compensation_pinda_thermistor_offset(temp_pinda);
+		if (code_seen('Z')) // Z Offset [mm]
+		{
+			offset_z = code_value();
+		}
+	}
+	MYSERIAL.print("temp_pinda=");
+	MYSERIAL.println(temp_pinda);
+	MYSERIAL.print("offset_z=");
+	MYSERIAL.println(offset_z, 3);
+}
+
+void dcode_10()
+{//Tell the printer that XYZ calibration went OK
+	MYSERIAL.println("D10 - XYZ calibration = OK");
+	calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST); 
+}
+
+void dcode_12()
+{//Reset Filament error, Power loss and crash counter ( Do it before every print and you can get stats for the print )
+	MYSERIAL.println("D12 - Reset failstat counters");
+    eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, 0x00);
+    eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, 0x00);
+    eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, 0x00);
 }
 
 void dcode_2130()
@@ -350,5 +416,8 @@ void dcode_9125()
 		MYSERIAL.print("pat9125_y=");
 		MYSERIAL.print(pat9125_y, DEC);
 	}
+	if (code_seen('L'))
+	{
+		fsensor_log = (int)code_value();
+	}
 }
-

+ 5 - 2
Firmware/Dcodes.h

@@ -7,9 +7,12 @@ extern void dcode_2(); //D2 - Read/Write RAM
 extern void dcode_3(); //D3 - Read/Write EEPROM
 extern void dcode_4(); //D4 - Read/Write PIN
 extern void dcode_5(); //D5 - Read/Write FLASH
+extern void dcode_6(); //D6 - Read/Write external FLASH
+extern void dcode_7(); //D7 - Read/Write Bootloader
+extern void dcode_8(); //D8 - Read/Write PINDA
 
-extern void dcode_6(); //D6
-extern void dcode_7(); //D7
+extern void dcode_10(); //D10 - XYZ calibration = OK
+extern void dcode_12(); //D12 - Reset failstat counters
 
 extern void dcode_2130(); //D2130 - TMC2130
 extern void dcode_9125(); //D9125 - PAT9125

+ 1 - 1
Firmware/Marlin.h

@@ -362,7 +362,7 @@ void temp_compensation_apply();
 void temp_compensation_start();
 
 #ifdef PINDA_THERMISTOR
-float temp_compensation_pinda_thermistor_offset();
+float temp_compensation_pinda_thermistor_offset(float temperature_pinda);
 #endif //PINDA_THERMISTOR
 
 void wait_for_heater(long codenum);

+ 18 - 16
Firmware/Marlin_main.cpp

@@ -3252,17 +3252,18 @@ void process_commands()
 			float offset_z = 0;
 
 #ifdef PINDA_THERMISTOR
-			offset_z = temp_compensation_pinda_thermistor_offset();
+			offset_z = temp_compensation_pinda_thermistor_offset(current_temperature_pinda);
 #endif //PINDA_THERMISTOR
-			#ifdef SUPPORT_VERBOSITY
-			if (verbosity_level >= 1) {
+//			#ifdef SUPPORT_VERBOSITY
+//			if (verbosity_level >= 1)
+			{
 				SERIAL_ECHOPGM("mesh bed leveling: ");
 				MYSERIAL.print(current_position[Z_AXIS], 5);
 				SERIAL_ECHOPGM(" offset: ");
 				MYSERIAL.print(offset_z, 5);
 				SERIAL_ECHOLNPGM("");
 			}
-			#endif // SUPPORT_VERBOSITY
+//			#endif // SUPPORT_VERBOSITY
 			mbl.set_z(ix, iy, current_position[Z_AXIS] - offset_z); //store measured z values z_values[iy][ix] = z - offset_z;
 
 			custom_message_state--;
@@ -5771,24 +5772,25 @@ case 404:  //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
 		dcode_4(); break;
 	case 5: // D5 - Read/Write FLASH
 		dcode_5(); break;
-	case 6: // D6 - Test
+	case 6: // D6 - Read/Write external FLASH
 		dcode_6(); break;
-	case 7: // D7 - Test
+	case 7: // D7 - Read/Write Bootloader
 		dcode_7(); break;
+	case 8: // D8 - Read/Write PINDA
+		dcode_8(); break;
+
+	case 10: // D10 - XYZ calibration = OK
+		dcode_10(); break;
+    
+    case 12: //D12 - Reset failstat counters
+		dcode_12(); break;
+
 	case 2130: // D9125 - TMC2130
 		dcode_2130(); break;
 	case 9125: // D9125 - PAT9125
 		dcode_9125(); break;
 
 
-	case 10: // D10 - Tell the printer that XYZ calibration went OK
-        calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST); 
-        break;
-    
-    case 12: //D12 - Reset Filament error, Power loss and crash counter ( Do it before every print and you can get stats for the print )
-        eeprom_update_byte((uint8_t*)EEPROM_CRASH_COUNT, 0x00);
-        eeprom_update_byte((uint8_t*)EEPROM_FERROR_COUNT, 0x00);
-        eeprom_update_byte((uint8_t*)EEPROM_POWER_COUNT, 0x00);
 	case 999:
 	{
 		MYSERIAL.println("D999 - crash");
@@ -6883,11 +6885,11 @@ float temp_comp_interpolation(float inp_temperature) {
 }
 
 #ifdef PINDA_THERMISTOR
-float temp_compensation_pinda_thermistor_offset()
+float temp_compensation_pinda_thermistor_offset(float temperature_pinda)
 {
 	if (!temp_cal_active) return 0;
 	if (!calibration_status_pinda()) return 0;
-	return temp_comp_interpolation(current_temperature_pinda) / axis_steps_per_unit[Z_AXIS];
+	return temp_comp_interpolation(temperature_pinda) / axis_steps_per_unit[Z_AXIS];
 }
 #endif //PINDA_THERMISTOR