Merge pull request #82 from XPila/MK3

SG_THR_X = 2, holding currents == running currents
This commit is contained in:
XPila 2017-11-13 18:49:48 +01:00 committed by GitHub
commit cfb811ae4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 27139 additions and 14505 deletions

View File

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

View File

@ -81,6 +81,7 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define AUTOMATIC_RECOVERY_AFTER_CRASH
//DEBUG
//#define _NO_ASM
#define DEBUG_DCODES //D codes
#if 1
//#define DEBUG_FSENSOR_LOG //Reports fsensor status to serial
@ -155,15 +156,15 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
#define TMC2130_SG_HOMING 1 // stallguard homing
//#define TMC2130_SG_HOMING_SW_XY 1 // stallguard "software" homing for XY axes
#define TMC2130_SG_HOMING_SW_Z 1 // stallguard "software" homing for Z axis
#define TMC2130_SG_THRS_X 1 // stallguard sensitivity for X axis
#define TMC2130_SG_THRS_X 2 // stallguard sensitivity for X axis
#define TMC2130_SG_THRS_Y 3 // stallguard sensitivity for Y axis
#define TMC2130_SG_THRS_Z 3 // stallguard sensitivity for Z axis
#define TMC2130_SG_THRS_E 3 // stallguard sensitivity for E axis
#define TMC2130_SG_DELTA 128 // stallguard delta [usteps] (minimum usteps before stallguard readed - SW homing)
//new settings is possible for vsense = 1, running current value > 31 set vsense to zero and shift both currents by 1 bit right (Z axis only)
#define TMC2130_CURRENTS_H {3, 3, 20, 28} // default holding currents for all axes
#define TMC2130_CURRENTS_R {13, 20, 20, 28} // default running currents for all axes
#define TMC2130_CURRENTS_H {13, 20, 20, 40} // default holding currents for all axes
#define TMC2130_CURRENTS_R {13, 20, 20, 40} // default running currents for all axes
//#define TMC2130_DEBUG
//#define TMC2130_DEBUG_WR
@ -374,6 +375,10 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
PREHEAT SETTINGS
*------------------------------------*/
#define FARM_PREHEAT_HOTEND_TEMP 250
#define FARM_PREHEAT_HPB_TEMP 40
#define FARM_PREHEAT_FAN_SPEED 0
#define PLA_PREHEAT_HOTEND_TEMP 215
#define PLA_PREHEAT_HPB_TEMP 55
#define PLA_PREHEAT_FAN_SPEED 0

View File

@ -2,6 +2,20 @@
#include "Marlin.h"
#include "cmdqueue.h"
#include "pat9125.h"
#include <avr/wdt.h>
#define RAMSIZE 0x2000
#define boot_src_addr (*((uint32_t*)(RAMSIZE - 16)))
#define boot_dst_addr (*((uint32_t*)(RAMSIZE - 12)))
#define boot_copy_size (*((uint16_t*)(RAMSIZE - 8)))
#define boot_reserved (*((uint8_t*)(RAMSIZE - 6)))
#define boot_app_flags (*((uint8_t*)(RAMSIZE - 5)))
#define boot_app_magic (*((uint32_t*)(RAMSIZE - 4)))
#define BOOT_APP_FLG_ERASE 0x01
#define BOOT_APP_FLG_COPY 0x02
#define BOOT_APP_FLG_FLASH 0x04
inline void serial_print_hex_nibble(uint8_t val)
{
@ -48,16 +62,17 @@ void dcode_0()
if (*(strchr_pointer + 1) == 0) return;
MYSERIAL.println("D0 - Reset");
if (code_seen('B')) //bootloader
asm volatile("jmp 0x1e000");
{
cli();
wdt_enable(WDTO_15MS);
while(1);
}
else //reset
{
#ifndef _NO_ASM
asm volatile("jmp 0x00000");
/*
cli(); //disable interrupts
wdt_reset(); //reset watchdog
WDTCSR = (1<<WDCE) | (1<<WDE); //enable watchdog
WDTCSR = (1<<WDE) | (1<<WDP0); //30ms prescaler
while(1); //wait for reset
*/
#endif //_NO_ASM
}
}
void dcode_1()
@ -90,7 +105,7 @@ void dcode_2()
for (int i = 0; i < count; i++)
*((uint8_t*)(address + i)) = data[i];
MYSERIAL.print(count, DEC);
MYSERIAL.println(" bytes written to RAM at addres ");
MYSERIAL.println(" bytes written to RAM at address ");
serial_print_hex_word(address);
MYSERIAL.write('\n');
}
@ -134,7 +149,7 @@ void dcode_3()
for (int i = 0; i < count; i++)
eeprom_write_byte((uint8_t*)(address + i), data[i]);
MYSERIAL.print(count, DEC);
MYSERIAL.println(" bytes written to EEPROM at addres ");
MYSERIAL.println(" bytes written to EEPROM at address ");
serial_print_hex_word(address);
MYSERIAL.write('\n');
}
@ -190,6 +205,99 @@ void dcode_4()
}
}
void dcode_5()
{
MYSERIAL.println("D5 - Read/Write FLASH");
uint32_t address = 0x0000; //default 0x0000
uint16_t count = 0x0400; //default 0x0400 (1kb block)
if (code_seen('A')) // Address (0x00000-0x3ffff)
address = (strchr_pointer[1] == 'x')?strtol(strchr_pointer + 2, 0, 16):(int)code_value();
if (code_seen('C')) // Count (0x0001-0x2000)
count = (int)code_value();
address &= 0x3ffff;
if (count > 0x2000) count = 0x2000;
if ((address + count) > 0x40000) count = 0x40000 - address;
bool bErase = false;
bool bCopy = false;
if (code_seen('E')) //Erase
bErase = true;
uint8_t data[16];
if (code_seen('X')) // Data
{
count = parse_hex(strchr_pointer + 1, data, 16);
if (count > 0) bCopy = true;
}
if (bErase || bCopy)
{
if (bErase)
{
MYSERIAL.print(count, DEC);
MYSERIAL.println(" bytes of FLASH at address ");
serial_print_hex_word(address);
MYSERIAL.write(" will be erased\n");
}
if (bCopy)
{
MYSERIAL.print(count, DEC);
MYSERIAL.println(" bytes will be written to FLASH at address ");
serial_print_hex_word(address);
MYSERIAL.write('\n');
}
cli();
boot_app_magic = 0x55aa55aa;
boot_app_flags = (bErase?(BOOT_APP_FLG_ERASE):0) | (bCopy?(BOOT_APP_FLG_COPY):0);
boot_copy_size = (uint16_t)count;
boot_dst_addr = (uint32_t)address;
boot_src_addr = (uint32_t)(&data);
wdt_enable(WDTO_15MS);
while(1);
}
while (count)
{
serial_print_hex_nibble(address >> 16);
serial_print_hex_word(address);
MYSERIAL.write(' ');
uint8_t countperline = 16;
while (count && countperline)
{
uint8_t data = pgm_read_byte_far((uint8_t*)address++);
MYSERIAL.write(' ');
serial_print_hex_byte(data);
countperline--;
count--;
}
MYSERIAL.write('\n');
}
}
void dcode_6()
{
cli();
boot_app_magic = 0x55aa55aa;
boot_app_flags = BOOT_APP_FLG_ERASE | BOOT_APP_FLG_COPY | BOOT_APP_FLG_FLASH;
boot_copy_size = (uint16_t)0xc00;
boot_src_addr = (uint32_t)0x0003e400;
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_2130()
{
// printf("test");
}
void dcode_9125()
{
MYSERIAL.println("D9125 - PAT9125");
@ -244,6 +352,3 @@ void dcode_9125()
}
}
void dcode_2130()
{
}

View File

@ -1,14 +1,17 @@
#ifndef DCODES_H
#define DCODES_H
extern void dcode_0();
extern void dcode_1();
extern void dcode_2();
extern void dcode_3();
extern void dcode_4();
extern void dcode_0(); //D0 - Reset
extern void dcode_1(); //D1 - Clear EEPROM
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_9125();
extern void dcode_2130();
extern void dcode_6(); //D6
extern void dcode_7(); //D7
extern void dcode_2130(); //D2130 - TMC2130
extern void dcode_9125(); //D9125 - PAT9125
#endif //DCODES_H

File diff suppressed because it is too large Load Diff

View File

@ -5769,15 +5769,18 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
dcode_3(); break;
case 4: // D4 - Read/Write PIN
dcode_4(); break;
case 5: // D5 - Read/Write FLASH
dcode_5(); break;
case 6: // D6 - Test
dcode_6(); break;
case 7: // D7 - Test
dcode_7(); break;
case 2130: // D9125 - TMC2130
dcode_2130(); break;
case 9125: // D9125 - PAT9125
dcode_9125(); break;
case 5:
MYSERIAL.println("D5 - Test");
if (code_seen('P'))
selectedSerialPort = (int)code_value();
MYSERIAL.print("selectedSerialPort = ");
MYSERIAL.println(selectedSerialPort, DEC);
break;
case 10: // D10 - Tell the printer that XYZ calibration went OK
calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
break;
@ -5880,11 +5883,11 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
homeaxis(0);
}
break;*/
case 6:
/* case 6:
{
/* MYSERIAL.print("tmc2130_rd_MSCNT(1)=");
MYSERIAL.print("tmc2130_rd_MSCNT(1)=");
int val = tmc2130_rd_MSCNT(tmc2130_cs[1]);
MYSERIAL.println(val);*/
MYSERIAL.println(val);
homeaxis(1);
}
break;
@ -5899,7 +5902,7 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
MYSERIAL.print("swi2c_check=");
MYSERIAL.println(swi2c_check(0x75));
}
break;
break;*/
}
}
#endif //DEBUG_DCODES

File diff suppressed because it is too large Load Diff

View File

@ -128,6 +128,8 @@ uint8_t LastStepMask = 0;
#define CHECK_ENDSTOPS if(check_endstops)
#ifndef _NO_ASM
// intRes = intIn1 * intIn2 >> 16
// uses:
// r26 to store 0
@ -198,6 +200,18 @@ asm volatile ( \
"r26" , "r27" \
)
#else //_NO_ASM
void MultiU16X8toH16(unsigned short& intRes, unsigned char& charIn1, unsigned short& intIn2)
{
}
void MultiU24X24toH16(uint16_t& intRes, int32_t& longIn1, long& longIn2)
{
}
#endif //_NO_ASM
// Some useful constants
#define ENABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 |= (1<<OCIE1A)
@ -742,7 +756,7 @@ void isr() {
// Calculare new timer value
unsigned short timer;
unsigned short step_rate;
uint16_t step_rate;
if (step_events_completed <= (unsigned long int)current_block->accelerate_until) {
// v = t * a -> acc_step_rate = acceleration_time * current_block->acceleration_rate
MultiU24X24toH16(acc_step_rate, acceleration_time, current_block->acceleration_rate);

View File

@ -1346,6 +1346,14 @@ static void lcd_move_menu_axis();
/* Menu implementation */
void lcd_preheat_farm()
{
setTargetHotend0(FARM_PREHEAT_HOTEND_TEMP);
setTargetBed(FARM_PREHEAT_HPB_TEMP);
fanSpeed = 0;
lcd_return_to_status();
setWatch(); // heater sanity check timer
}
void lcd_preheat_pla()
{
@ -1547,6 +1555,9 @@ static void lcd_preheat_menu()
MENU_ITEM(back, MSG_MAIN, lcd_main_menu);
if (farm_mode)
MENU_ITEM(function, PSTR("farm - " STRINGIFY(FARM_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(FARM_PREHEAT_HPB_TEMP)), lcd_preheat_farm);
MENU_ITEM(function, PSTR("ABS - " STRINGIFY(ABS_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(ABS_PREHEAT_HPB_TEMP)), lcd_preheat_abs);
MENU_ITEM(function, PSTR("PLA - " STRINGIFY(PLA_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PLA_PREHEAT_HPB_TEMP)), lcd_preheat_pla);
MENU_ITEM(function, PSTR("PET - " STRINGIFY(PET_PREHEAT_HOTEND_TEMP) "/" STRINGIFY(PET_PREHEAT_HPB_TEMP)), lcd_preheat_pet);
@ -3612,11 +3623,11 @@ static void lcd_settings_menu()
MENU_ITEM(gcode, MSG_DISABLE_STEPPERS, PSTR("M84"));
}
/*if (FSensorStateMenu == 0) {
if (FSensorStateMenu == 0) {
MENU_ITEM(function, MSG_FSENSOR_OFF, lcd_fsensor_state_set);
} else {
MENU_ITEM(function, MSG_FSENSOR_ON, lcd_fsensor_state_set);
}*/
}
if (SilentModeMenu == 0) {
MENU_ITEM(function, MSG_SILENT_MODE_OFF, lcd_silent_mode_set);