Merge pull request #1664 from MRprusa3d/PFW-811
"disable_z()" for Delta PSU
This commit is contained in:
commit
8b806f692e
@ -172,6 +172,17 @@ void manage_inactivity(bool ignore_stepper_queue=false);
|
||||
#define disable_z() {}
|
||||
#endif
|
||||
|
||||
#ifdef PSU_Delta
|
||||
void init_force_z();
|
||||
void check_force_z();
|
||||
#undef disable_z()
|
||||
#define disable_z() disable_force_z()
|
||||
void disable_force_z();
|
||||
#undef enable_disable_z()
|
||||
#define enable_z() enable_force_z()
|
||||
void enable_force_z();
|
||||
#endif // PSU_Delta
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1298,6 +1298,9 @@ void setup()
|
||||
update_mode_profile();
|
||||
tmc2130_init();
|
||||
#endif //TMC2130
|
||||
#ifdef PSU_Delta
|
||||
init_force_z(); // ! important for correct Z-axis initialization
|
||||
#endif // PSU_Delta
|
||||
|
||||
setup_photpin();
|
||||
|
||||
@ -1335,7 +1338,7 @@ void setup()
|
||||
}
|
||||
#endif //TMC2130
|
||||
|
||||
#if defined(Z_AXIS_ALWAYS_ON)
|
||||
#if defined(Z_AXIS_ALWAYS_ON) && !defined(PSU_Delta)
|
||||
enable_z();
|
||||
#endif
|
||||
farm_mode = eeprom_read_byte((uint8_t*)EEPROM_FARM_MODE);
|
||||
@ -9813,3 +9816,69 @@ void marlin_wait_for_click()
|
||||
}
|
||||
|
||||
#define FIL_LOAD_LENGTH 60
|
||||
|
||||
#ifdef PSU_Delta
|
||||
bool bEnableForce_z;
|
||||
|
||||
void init_force_z()
|
||||
{
|
||||
WRITE(Z_ENABLE_PIN,Z_ENABLE_ON);
|
||||
bEnableForce_z=true; // "true"-value enforce "disable_force_z()" executing
|
||||
disable_force_z();
|
||||
}
|
||||
|
||||
void check_force_z()
|
||||
{
|
||||
if(!(bEnableForce_z||eeprom_read_byte((uint8_t*)EEPROM_SILENT)))
|
||||
init_force_z(); // causes enforced switching into disable-state
|
||||
}
|
||||
|
||||
void disable_force_z()
|
||||
{
|
||||
uint16_t z_microsteps=0;
|
||||
|
||||
if(!bEnableForce_z)
|
||||
return; // motor already disabled (may be ;-p )
|
||||
bEnableForce_z=false;
|
||||
|
||||
// alignment to full-step
|
||||
#ifdef TMC2130
|
||||
z_microsteps=tmc2130_rd_MSCNT(Z_TMC2130_CS);
|
||||
#endif // TMC2130
|
||||
planner_abort_hard();
|
||||
sei();
|
||||
plan_buffer_line(
|
||||
current_position[X_AXIS],
|
||||
current_position[Y_AXIS],
|
||||
current_position[Z_AXIS]+float((1024-z_microsteps+7)>>4)/cs.axis_steps_per_unit[Z_AXIS],
|
||||
current_position[E_AXIS],
|
||||
40, active_extruder);
|
||||
st_synchronize();
|
||||
|
||||
// switching to silent mode
|
||||
#ifdef TMC2130
|
||||
tmc2130_mode=TMC2130_MODE_SILENT;
|
||||
update_mode_profile();
|
||||
tmc2130_init(true);
|
||||
#endif // TMC2130
|
||||
|
||||
axis_known_position[Z_AXIS]=false;
|
||||
}
|
||||
|
||||
|
||||
void enable_force_z()
|
||||
{
|
||||
if(bEnableForce_z)
|
||||
return; // motor already enabled (may be ;-p )
|
||||
bEnableForce_z=true;
|
||||
|
||||
// mode recovering
|
||||
#ifdef TMC2130
|
||||
tmc2130_mode=eeprom_read_byte((uint8_t*)EEPROM_SILENT)?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL;
|
||||
update_mode_profile();
|
||||
tmc2130_init(true);
|
||||
#endif // TMC2130
|
||||
|
||||
WRITE(Z_ENABLE_PIN,Z_ENABLE_ON); // slightly redundant ;-p
|
||||
}
|
||||
#endif // PSU_Delta
|
||||
|
@ -368,6 +368,7 @@
|
||||
#define PIN_SET(pin) PORT(pin) |= __MSK(pin)
|
||||
#define PIN_VAL(pin, val) if (val) PIN_SET(pin); else PIN_CLR(pin);
|
||||
#define PIN_GET(pin) (PIN(pin) & __MSK(pin))
|
||||
#define PIN_INQ(pin) (PORT(pin) & __MSK(pin))
|
||||
|
||||
|
||||
#endif //_IO_ATMEGA2560
|
||||
|
@ -1122,7 +1122,7 @@ void clear_current_adv_vars() {
|
||||
}
|
||||
|
||||
#endif // LIN_ADVANCE
|
||||
|
||||
|
||||
void st_init()
|
||||
{
|
||||
#ifdef TMC2130
|
||||
@ -1306,6 +1306,9 @@ void st_init()
|
||||
SET_OUTPUT(Z2_STEP_PIN);
|
||||
WRITE(Z2_STEP_PIN,INVERT_Z_STEP_PIN);
|
||||
#endif
|
||||
#ifdef PSU_Delta
|
||||
init_force_z();
|
||||
#endif // PSU_Delta
|
||||
disable_z();
|
||||
#endif
|
||||
#if defined(E0_STEP_PIN) && (E0_STEP_PIN > -1)
|
||||
|
@ -143,7 +143,7 @@ uint16_t __tcoolthrs(uint8_t axis)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tmc2130_init()
|
||||
void tmc2130_init(bool bSupressFlag=false)
|
||||
{
|
||||
// DBG(_n("tmc2130_init(), mode=%S\n"), tmc2130_mode?_n("STEALTH"):_n("NORMAL"));
|
||||
WRITE(X_TMC2130_CS, HIGH);
|
||||
@ -216,6 +216,11 @@ void tmc2130_init()
|
||||
tmc2130_set_wave(E_AXIS, 247, tmc2130_wave_fac[E_AXIS]);
|
||||
#endif //TMC2130_LINEARITY_CORRECTION
|
||||
|
||||
#ifdef PSU_Delta
|
||||
if(!bSupressFlag)
|
||||
check_force_z();
|
||||
#endif // PSU_Delta
|
||||
|
||||
}
|
||||
|
||||
uint8_t tmc2130_sample_diag()
|
||||
|
@ -51,7 +51,7 @@ typedef struct
|
||||
extern tmc2130_chopper_config_t tmc2130_chopper_config[4];
|
||||
|
||||
//initialize tmc2130
|
||||
extern void tmc2130_init();
|
||||
extern void tmc2130_init(bool bSupressFlag=false);
|
||||
//check diag pins (called from stepper isr)
|
||||
extern void tmc2130_st_isr();
|
||||
//update stall guard (called from st_synchronize inside the loop)
|
||||
|
@ -26,6 +26,9 @@
|
||||
#define STEEL_SHEET
|
||||
#define HAS_SECOND_SERIAL_PORT
|
||||
|
||||
// PSU
|
||||
#define PSU_Delta // uncomment if DeltaElectronics PSU installed
|
||||
|
||||
|
||||
// Uncomment the below for the E3D PT100 temperature sensor (with or without PT100 Amplifier)
|
||||
//#define E3D_PT100_EXTRUDER_WITH_AMP
|
||||
|
Loading…
Reference in New Issue
Block a user