TMC2130 + software SG homing + LF lineendings + tmc2130 debug M-Codes
M910 - tmc2130_init M911 - set holding currents M912 - set running currents M913 - print currents
This commit is contained in:
parent
c839209780
commit
f6a8e1df9d
14 changed files with 765 additions and 594 deletions
|
@ -267,10 +267,10 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
|
||||||
#define DISABLE_E false // For all extruders
|
#define DISABLE_E false // For all extruders
|
||||||
#define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled
|
#define DISABLE_INACTIVE_EXTRUDER true //disable only inactive extruders and keep active extruder enabled
|
||||||
|
|
||||||
#define INVERT_X_DIR false // for Mendel set to false, for Orca set to true
|
#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_Y_DIR false // for Mendel set to true, for Orca set to false
|
||||||
#define INVERT_Z_DIR false // for Mendel set to false, for Orca set to true
|
#define INVERT_Z_DIR true // for Mendel set to false, for Orca set to true
|
||||||
#define INVERT_E0_DIR true // for direct drive extruder v9 set to true, for geared extruder set to false
|
#define INVERT_E0_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
|
||||||
#define INVERT_E1_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
|
#define INVERT_E1_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
|
||||||
#define INVERT_E2_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
|
#define INVERT_E2_DIR false // for direct drive extruder v9 set to true, for geared extruder set to false
|
||||||
|
|
||||||
|
@ -424,8 +424,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
|
||||||
// #define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis
|
// #define EXTRUDER_OFFSET_Y {0.0, 5.00} // (in mm) for each extruder, offset of the hotend on the Y axis
|
||||||
|
|
||||||
// The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously)
|
// The speed change that does not require acceleration (i.e. the software might assume it can be done instantaneously)
|
||||||
#define DEFAULT_XJERK 10.0 // (mm/sec)
|
#define DEFAULT_XJERK 5.0 // (mm/sec)
|
||||||
#define DEFAULT_YJERK 10.0 // (mm/sec)
|
#define DEFAULT_YJERK 5.0 // (mm/sec)
|
||||||
#define DEFAULT_ZJERK 0.2 // (mm/sec)
|
#define DEFAULT_ZJERK 0.2 // (mm/sec)
|
||||||
#define DEFAULT_EJERK 2.5 // (mm/sec)
|
#define DEFAULT_EJERK 2.5 // (mm/sec)
|
||||||
|
|
||||||
|
@ -461,8 +461,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
|
||||||
#define SDSUPPORT // Enable SD Card Support in Hardware Console
|
#define SDSUPPORT // Enable SD Card Support in Hardware Console
|
||||||
//#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)
|
//#define SDSLOW // Use slower SD transfer mode (not normally needed - uncomment if you're getting volume init error)
|
||||||
#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication
|
#define SD_CHECK_AND_RETRY // Use CRC checks and retries on the SD communication
|
||||||
#define ENCODER_PULSES_PER_STEP 4 // Increase if you have a high resolution encoder
|
#define ENCODER_PULSES_PER_STEP 2 // Increase if you have a high resolution encoder
|
||||||
#define ENCODER_STEPS_PER_MENU_ITEM 1 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
#define ENCODER_STEPS_PER_MENU_ITEM 2 // Set according to ENCODER_PULSES_PER_STEP or your liking
|
||||||
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
//#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
|
||||||
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
//#define ULTIPANEL //the UltiPanel as on Thingiverse
|
||||||
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
//#define LCD_FEEDBACK_FREQUENCY_HZ 1000 // this is the tone frequency the buzzer plays when on UI feedback. ie Screen Click
|
||||||
|
|
|
@ -302,9 +302,9 @@ extern unsigned int custom_message_state;
|
||||||
extern char snmm_filaments_used;
|
extern char snmm_filaments_used;
|
||||||
extern unsigned long PingTime;
|
extern unsigned long PingTime;
|
||||||
|
|
||||||
extern bool fan_state[2];
|
extern bool fan_state[2];
|
||||||
extern int fan_edge_counter[2];
|
extern int fan_edge_counter[2];
|
||||||
extern int fan_speed[2];
|
extern int fan_speed[2];
|
||||||
|
|
||||||
// Handling multiple extruders pins
|
// Handling multiple extruders pins
|
||||||
extern uint8_t active_extruder;
|
extern uint8_t active_extruder;
|
||||||
|
|
|
@ -1803,7 +1803,7 @@ static float probe_pt(float x, float y, float z_before) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #ifdef ENABLE_AUTO_BED_LEVELING
|
#endif // #ifdef ENABLE_AUTO_BED_LEVELING
|
||||||
|
/*
|
||||||
void homeaxis(int axis) {
|
void homeaxis(int axis) {
|
||||||
#define HOMEAXIS_DO(LETTER) \
|
#define HOMEAXIS_DO(LETTER) \
|
||||||
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
||||||
|
@ -1814,7 +1814,8 @@ void homeaxis(int axis) {
|
||||||
0) {
|
0) {
|
||||||
int axis_home_dir = home_dir(axis);
|
int axis_home_dir = home_dir(axis);
|
||||||
#ifdef HAVE_TMC2130_DRIVERS
|
#ifdef HAVE_TMC2130_DRIVERS
|
||||||
tmc2130_st_home_enter(axis);
|
if ((axis == X_AXIS) || (axis == Y_AXIS))
|
||||||
|
tmc2130_home_enter(axis);
|
||||||
#endif //HAVE_TMC2130_DRIVERS
|
#endif //HAVE_TMC2130_DRIVERS
|
||||||
|
|
||||||
current_position[axis] = 0;
|
current_position[axis] = 0;
|
||||||
|
@ -1832,7 +1833,7 @@ void homeaxis(int axis) {
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
|
|
||||||
destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
|
destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
|
||||||
feedrate = homing_feedrate[axis]/2 ;
|
// feedrate = homing_feedrate[axis]/2 ;
|
||||||
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||||
st_synchronize();
|
st_synchronize();
|
||||||
axis_is_at_home(axis);
|
axis_is_at_home(axis);
|
||||||
|
@ -1842,11 +1843,93 @@ void homeaxis(int axis) {
|
||||||
axis_known_position[axis] = true;
|
axis_known_position[axis] = true;
|
||||||
|
|
||||||
#ifdef HAVE_TMC2130_DRIVERS
|
#ifdef HAVE_TMC2130_DRIVERS
|
||||||
tmc2130_st_home_enter(axis);
|
if ((axis == X_AXIS) || (axis == Y_AXIS))
|
||||||
|
tmc2130_home_exit();
|
||||||
#endif //HAVE_TMC2130_DRIVERS
|
#endif //HAVE_TMC2130_DRIVERS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**/
|
||||||
|
|
||||||
|
void homeaxis(int axis) {
|
||||||
|
#define HOMEAXIS_DO(LETTER) \
|
||||||
|
((LETTER##_MIN_PIN > -1 && LETTER##_HOME_DIR==-1) || (LETTER##_MAX_PIN > -1 && LETTER##_HOME_DIR==1))
|
||||||
|
|
||||||
|
if (axis==X_AXIS ? HOMEAXIS_DO(X) :
|
||||||
|
axis==Y_AXIS ? HOMEAXIS_DO(Y) :
|
||||||
|
0) {
|
||||||
|
int axis_home_dir = home_dir(axis);
|
||||||
|
|
||||||
|
#ifdef HAVE_TMC2130_DRIVERS
|
||||||
|
tmc2130_home_enter(axis);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
current_position[axis] = 0;
|
||||||
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||||
|
|
||||||
|
destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
|
||||||
|
feedrate = homing_feedrate[axis];
|
||||||
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||||
|
|
||||||
|
// sg_homing_delay = 0;
|
||||||
|
st_synchronize();
|
||||||
|
|
||||||
|
current_position[axis] = 0;
|
||||||
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||||
|
destination[axis] = -home_retract_mm(axis) * axis_home_dir;
|
||||||
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||||
|
// sg_homing_delay = 0;
|
||||||
|
st_synchronize();
|
||||||
|
|
||||||
|
destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
|
||||||
|
#ifdef HAVE_TMC2130_DRIVERS
|
||||||
|
if (tmc2130_didLastHomingStall())
|
||||||
|
feedrate = homing_feedrate[axis];
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
feedrate = homing_feedrate[axis] / 2;
|
||||||
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||||
|
// sg_homing_delay = 0;
|
||||||
|
st_synchronize();
|
||||||
|
axis_is_at_home(axis);
|
||||||
|
destination[axis] = current_position[axis];
|
||||||
|
feedrate = 0.0;
|
||||||
|
endstops_hit_on_purpose();
|
||||||
|
axis_known_position[axis] = true;
|
||||||
|
|
||||||
|
#ifdef HAVE_TMC2130_DRIVERS
|
||||||
|
tmc2130_home_exit();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
else if (axis==Z_AXIS ? HOMEAXIS_DO(Z) :
|
||||||
|
0) {
|
||||||
|
int axis_home_dir = home_dir(axis);
|
||||||
|
|
||||||
|
current_position[axis] = 0;
|
||||||
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||||
|
|
||||||
|
destination[axis] = 1.5 * max_length(axis) * axis_home_dir;
|
||||||
|
feedrate = homing_feedrate[axis];
|
||||||
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||||
|
st_synchronize();
|
||||||
|
|
||||||
|
current_position[axis] = 0;
|
||||||
|
plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
|
||||||
|
destination[axis] = -home_retract_mm(axis) * axis_home_dir;
|
||||||
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||||
|
st_synchronize();
|
||||||
|
|
||||||
|
destination[axis] = 2*home_retract_mm(axis) * axis_home_dir;
|
||||||
|
feedrate = homing_feedrate[axis]/2 ;
|
||||||
|
plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder);
|
||||||
|
st_synchronize();
|
||||||
|
axis_is_at_home(axis);
|
||||||
|
destination[axis] = current_position[axis];
|
||||||
|
feedrate = 0.0;
|
||||||
|
endstops_hit_on_purpose();
|
||||||
|
axis_known_position[axis] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**/
|
||||||
void home_xy()
|
void home_xy()
|
||||||
{
|
{
|
||||||
set_destination_to_current();
|
set_destination_to_current();
|
||||||
|
@ -5399,6 +5482,37 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 910: // M910 TMC2130 init
|
||||||
|
{
|
||||||
|
tmc2130_init();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 911: // M911 Set TMC2130 holding currents
|
||||||
|
{
|
||||||
|
if (code_seen('X')) tmc2130_set_current_h(0, code_value());
|
||||||
|
if (code_seen('Y')) tmc2130_set_current_h(1, code_value());
|
||||||
|
if (code_seen('Z')) tmc2130_set_current_h(2, code_value());
|
||||||
|
if (code_seen('E')) tmc2130_set_current_h(3, code_value());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 912: // M912 Set TMC2130 running currents
|
||||||
|
{
|
||||||
|
if (code_seen('X')) tmc2130_set_current_r(0, code_value());
|
||||||
|
if (code_seen('Y')) tmc2130_set_current_r(1, code_value());
|
||||||
|
if (code_seen('Z')) tmc2130_set_current_r(2, code_value());
|
||||||
|
if (code_seen('E')) tmc2130_set_current_r(3, code_value());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 913: // M912 Print TMC2130 currents
|
||||||
|
{
|
||||||
|
tmc2130_print_currents();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
||||||
{
|
{
|
||||||
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
|
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
|
||||||
|
|
|
@ -1,74 +1,74 @@
|
||||||
#include "pat9125.h"
|
#include "pat9125.h"
|
||||||
#include "swspi.h"
|
#include "swspi.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef SWSPI_RPI
|
#ifdef SWSPI_RPI
|
||||||
// #include <bcm2835.h>
|
// #include <bcm2835.h>
|
||||||
#define DELAY(delay) usleep(delay)
|
#define DELAY(delay) usleep(delay)
|
||||||
#endif //SWSPI_RPI
|
#endif //SWSPI_RPI
|
||||||
|
|
||||||
#ifdef SWSPI_AVR
|
#ifdef SWSPI_AVR
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#define DELAY(delay) delayMicroseconds(delay)
|
#define DELAY(delay) delayMicroseconds(delay)
|
||||||
#endif //SWSPI_AVR
|
#endif //SWSPI_AVR
|
||||||
|
|
||||||
unsigned char ucPID1 = 0;
|
unsigned char ucPID1 = 0;
|
||||||
unsigned char ucPID2 = 0;
|
unsigned char ucPID2 = 0;
|
||||||
int pat9125_x = 0;
|
int pat9125_x = 0;
|
||||||
int pat9125_y = 0;
|
int pat9125_y = 0;
|
||||||
|
|
||||||
int pat9125_init(unsigned char xres, unsigned char yres)
|
int pat9125_init(unsigned char xres, unsigned char yres)
|
||||||
{
|
{
|
||||||
swspi_init();
|
swspi_init();
|
||||||
ucPID1 = pat9125_rd_reg(PAT9125_PID1);
|
ucPID1 = pat9125_rd_reg(PAT9125_PID1);
|
||||||
ucPID2 = pat9125_rd_reg(PAT9125_PID2);
|
ucPID2 = pat9125_rd_reg(PAT9125_PID2);
|
||||||
if ((ucPID1 != 0x31) || (ucPID2 != 0x91))
|
if ((ucPID1 != 0x31) || (ucPID2 != 0x91))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pat9125_wr_reg(PAT9125_RES_X, xres);
|
pat9125_wr_reg(PAT9125_RES_X, xres);
|
||||||
pat9125_wr_reg(PAT9125_RES_Y, yres);
|
pat9125_wr_reg(PAT9125_RES_Y, yres);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pat9125_update()
|
int pat9125_update()
|
||||||
{
|
{
|
||||||
if ((ucPID1 == 0x31) && (ucPID2 == 0x91))
|
if ((ucPID1 == 0x31) && (ucPID2 == 0x91))
|
||||||
{
|
{
|
||||||
unsigned char ucMotion = pat9125_rd_reg(PAT9125_MOTION);
|
unsigned char ucMotion = pat9125_rd_reg(PAT9125_MOTION);
|
||||||
if (ucMotion & 0x80)
|
if (ucMotion & 0x80)
|
||||||
{
|
{
|
||||||
int iDX = pat9125_rd_reg(PAT9125_DELTA_XL);
|
int iDX = pat9125_rd_reg(PAT9125_DELTA_XL);
|
||||||
int iDY = pat9125_rd_reg(PAT9125_DELTA_YL);
|
int iDY = pat9125_rd_reg(PAT9125_DELTA_YL);
|
||||||
if (iDX >= 0x80) iDX = iDX - 256;
|
if (iDX >= 0x80) iDX = iDX - 256;
|
||||||
if (iDY >= 0x80) iDY = iDY - 256;
|
if (iDY >= 0x80) iDY = iDY - 256;
|
||||||
pat9125_x += iDX;
|
pat9125_x += iDX;
|
||||||
pat9125_y += iDY;
|
pat9125_y += iDY;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char pat9125_rd_reg(unsigned char addr)
|
unsigned char pat9125_rd_reg(unsigned char addr)
|
||||||
{
|
{
|
||||||
swspi_start();
|
swspi_start();
|
||||||
DELAY(100);
|
DELAY(100);
|
||||||
swspi_tx(addr & 0x7f);
|
swspi_tx(addr & 0x7f);
|
||||||
DELAY(100);
|
DELAY(100);
|
||||||
unsigned char data = swspi_rx();
|
unsigned char data = swspi_rx();
|
||||||
swspi_stop();
|
swspi_stop();
|
||||||
DELAY(100);
|
DELAY(100);
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pat9125_wr_reg(unsigned char addr, unsigned char data)
|
void pat9125_wr_reg(unsigned char addr, unsigned char data)
|
||||||
{
|
{
|
||||||
swspi_start();
|
swspi_start();
|
||||||
DELAY(100);
|
DELAY(100);
|
||||||
swspi_tx(addr | 0x80);
|
swspi_tx(addr | 0x80);
|
||||||
DELAY(100);
|
DELAY(100);
|
||||||
swspi_tx(data);
|
swspi_tx(data);
|
||||||
swspi_stop();
|
swspi_stop();
|
||||||
DELAY(100);
|
DELAY(100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,38 +1,38 @@
|
||||||
#ifndef PAT9125_H
|
#ifndef PAT9125_H
|
||||||
#define PAT9125_H
|
#define PAT9125_H
|
||||||
|
|
||||||
//#define PAT9125_RPI
|
//#define PAT9125_RPI
|
||||||
#define PAT9125_AVR
|
#define PAT9125_AVR
|
||||||
|
|
||||||
//PAT9125 registers
|
//PAT9125 registers
|
||||||
#define PAT9125_PID1 0x00
|
#define PAT9125_PID1 0x00
|
||||||
#define PAT9125_PID2 0x01
|
#define PAT9125_PID2 0x01
|
||||||
#define PAT9125_MOTION 0x02
|
#define PAT9125_MOTION 0x02
|
||||||
#define PAT9125_DELTA_XL 0x03
|
#define PAT9125_DELTA_XL 0x03
|
||||||
#define PAT9125_DELTA_YL 0x04
|
#define PAT9125_DELTA_YL 0x04
|
||||||
#define PAT9125_MODE 0x05
|
#define PAT9125_MODE 0x05
|
||||||
#define PAT9125_CONFIG 0x06
|
#define PAT9125_CONFIG 0x06
|
||||||
#define PAT9125_WP 0x09
|
#define PAT9125_WP 0x09
|
||||||
#define PAT9125_SLEEP1 0x0a
|
#define PAT9125_SLEEP1 0x0a
|
||||||
#define PAT9125_SLEEP2 0x0b
|
#define PAT9125_SLEEP2 0x0b
|
||||||
#define PAT9125_RES_X 0x0d
|
#define PAT9125_RES_X 0x0d
|
||||||
#define PAT9125_RES_Y 0x0e
|
#define PAT9125_RES_Y 0x0e
|
||||||
#define PAT9125_DELTA_XYH 0x12
|
#define PAT9125_DELTA_XYH 0x12
|
||||||
#define PAT9125_SHUTTER 0x14
|
#define PAT9125_SHUTTER 0x14
|
||||||
#define PAT9125_FRAME 0x17
|
#define PAT9125_FRAME 0x17
|
||||||
#define PAT9125_ORIENTATION 0x19
|
#define PAT9125_ORIENTATION 0x19
|
||||||
|
|
||||||
extern unsigned char ucPID1;
|
extern unsigned char ucPID1;
|
||||||
extern unsigned char ucPID2;
|
extern unsigned char ucPID2;
|
||||||
|
|
||||||
extern int pat9125_x;
|
extern int pat9125_x;
|
||||||
extern int pat9125_y;
|
extern int pat9125_y;
|
||||||
|
|
||||||
int pat9125_init(unsigned char xres, unsigned char yres);
|
int pat9125_init(unsigned char xres, unsigned char yres);
|
||||||
int pat9125_update();
|
int pat9125_update();
|
||||||
|
|
||||||
unsigned char pat9125_rd_reg(unsigned char addr);
|
unsigned char pat9125_rd_reg(unsigned char addr);
|
||||||
void pat9125_wr_reg(unsigned char addr, unsigned char data);
|
void pat9125_wr_reg(unsigned char addr, unsigned char data);
|
||||||
|
|
||||||
|
|
||||||
#endif //PAT9125_H
|
#endif //PAT9125_H
|
||||||
|
|
|
@ -83,11 +83,12 @@ static bool old_y_max_endstop=false;
|
||||||
static bool old_z_min_endstop=false;
|
static bool old_z_min_endstop=false;
|
||||||
static bool old_z_max_endstop=false;
|
static bool old_z_max_endstop=false;
|
||||||
|
|
||||||
#ifdef SG_HOMING
|
#ifdef SG_HOMING_SW
|
||||||
static bool check_endstops = false;
|
static bool check_endstops = false;
|
||||||
#else
|
#else
|
||||||
static bool check_endstops = true;
|
static bool check_endstops = true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool check_z_endstop = false;
|
static bool check_z_endstop = false;
|
||||||
|
|
||||||
int8_t SilentMode;
|
int8_t SilentMode;
|
||||||
|
@ -403,7 +404,11 @@ ISR(TIMER1_COMPA_vect)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
|
#if defined(X_MIN_PIN) && X_MIN_PIN > -1
|
||||||
bool x_min_endstop=(READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING);
|
#ifndef SG_HOMING_SW
|
||||||
|
bool x_min_endstop = (READ(X_MIN_PIN) != X_MIN_ENDSTOP_INVERTING);
|
||||||
|
#else //SG_HOMING_SW
|
||||||
|
bool x_min_endstop = tmc2130_axis_stalled[X_AXIS];
|
||||||
|
#endif //SG_HOMING_SW
|
||||||
if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
|
if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
|
||||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||||
endstop_x_hit=true;
|
endstop_x_hit=true;
|
||||||
|
@ -419,7 +424,11 @@ ISR(TIMER1_COMPA_vect)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
#if defined(X_MAX_PIN) && X_MAX_PIN > -1
|
#if defined(X_MAX_PIN) && X_MAX_PIN > -1
|
||||||
bool x_max_endstop=(READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING);
|
#ifndef SG_HOMING_SW
|
||||||
|
bool x_max_endstop = (READ(X_MAX_PIN) != X_MAX_ENDSTOP_INVERTING);
|
||||||
|
#else //SG_HOMING_SW
|
||||||
|
bool x_max_endstop = tmc2130_axis_stalled[X_AXIS];
|
||||||
|
#endif //SG_HOMING_SW
|
||||||
if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
|
if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
|
||||||
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
||||||
endstop_x_hit=true;
|
endstop_x_hit=true;
|
||||||
|
@ -439,7 +448,11 @@ ISR(TIMER1_COMPA_vect)
|
||||||
CHECK_ENDSTOPS
|
CHECK_ENDSTOPS
|
||||||
{
|
{
|
||||||
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
|
#if defined(Y_MIN_PIN) && Y_MIN_PIN > -1
|
||||||
bool y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
|
#ifndef SG_HOMING_SW
|
||||||
|
bool y_min_endstop=(READ(Y_MIN_PIN) != Y_MIN_ENDSTOP_INVERTING);
|
||||||
|
#else //SG_HOMING_SW
|
||||||
|
bool y_min_endstop = tmc2130_axis_stalled[Y_AXIS];
|
||||||
|
#endif //SG_HOMING_SW
|
||||||
if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
|
if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
|
||||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||||
endstop_y_hit=true;
|
endstop_y_hit=true;
|
||||||
|
@ -453,7 +466,11 @@ ISR(TIMER1_COMPA_vect)
|
||||||
CHECK_ENDSTOPS
|
CHECK_ENDSTOPS
|
||||||
{
|
{
|
||||||
#if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
|
#if defined(Y_MAX_PIN) && Y_MAX_PIN > -1
|
||||||
bool y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING);
|
#ifndef SG_HOMING_SW
|
||||||
|
bool y_max_endstop=(READ(Y_MAX_PIN) != Y_MAX_ENDSTOP_INVERTING);
|
||||||
|
#else //SG_HOMING_SW
|
||||||
|
bool y_max_endstop = tmc2130_axis_stalled[Y_AXIS];
|
||||||
|
#endif //SG_HOMING_SW
|
||||||
if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
|
if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
|
||||||
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
||||||
endstop_y_hit=true;
|
endstop_y_hit=true;
|
||||||
|
@ -864,15 +881,23 @@ void st_init()
|
||||||
// Block until all buffered steps are executed
|
// Block until all buffered steps are executed
|
||||||
void st_synchronize()
|
void st_synchronize()
|
||||||
{
|
{
|
||||||
while( blocks_queued()) {
|
while(blocks_queued())
|
||||||
manage_heater();
|
{
|
||||||
// Vojtech: Don't disable motors inside the planner!
|
|
||||||
manage_inactivity(true);
|
|
||||||
lcd_update();
|
|
||||||
#ifdef HAVE_TMC2130_DRIVERS
|
#ifdef HAVE_TMC2130_DRIVERS
|
||||||
tmc2130_st_synchronize();
|
manage_heater();
|
||||||
|
// Vojtech: Don't disable motors inside the planner!
|
||||||
|
if (!tmc2130_update_sg())
|
||||||
|
{
|
||||||
|
manage_inactivity(true);
|
||||||
|
lcd_update();
|
||||||
|
}
|
||||||
|
#else //HAVE_TMC2130_DRIVERS
|
||||||
|
manage_heater();
|
||||||
|
// Vojtech: Don't disable motors inside the planner!
|
||||||
|
manage_inactivity(true);
|
||||||
|
lcd_update();
|
||||||
#endif //HAVE_TMC2130_DRIVERS
|
#endif //HAVE_TMC2130_DRIVERS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void st_set_position(const long &x, const long &y, const long &z, const long &e)
|
void st_set_position(const long &x, const long &y, const long &z, const long &e)
|
||||||
|
@ -901,6 +926,13 @@ long st_get_position(uint8_t axis)
|
||||||
return count_pos;
|
return count_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void st_get_position_xy(long &x, long &y)
|
||||||
|
{
|
||||||
|
CRITICAL_SECTION_START;
|
||||||
|
x = count_position[X_AXIS];
|
||||||
|
y = count_position[Y_AXIS];
|
||||||
|
CRITICAL_SECTION_END;
|
||||||
|
}
|
||||||
|
|
||||||
float st_get_position_mm(uint8_t axis)
|
float st_get_position_mm(uint8_t axis)
|
||||||
{
|
{
|
||||||
|
|
|
@ -54,6 +54,8 @@ void st_set_e_position(const long &e);
|
||||||
// Get current position in steps
|
// Get current position in steps
|
||||||
long st_get_position(uint8_t axis);
|
long st_get_position(uint8_t axis);
|
||||||
|
|
||||||
|
// Get current x and y position in steps
|
||||||
|
void st_get_position_xy(long &x, long &y);
|
||||||
|
|
||||||
// Get current position in mm
|
// Get current position in mm
|
||||||
float st_get_position_mm(uint8_t axis);
|
float st_get_position_mm(uint8_t axis);
|
||||||
|
|
|
@ -1,107 +1,107 @@
|
||||||
#include "swspi.h"
|
#include "swspi.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef SWSPI_RPI
|
#ifdef SWSPI_RPI
|
||||||
#include <bcm2835.h>
|
#include <bcm2835.h>
|
||||||
#define GPIO_INP(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_INPT)
|
#define GPIO_INP(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_INPT)
|
||||||
#define GPIO_OUT(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_OUTP)
|
#define GPIO_OUT(gpio) bcm2835_gpio_fsel(gpio, BCM2835_GPIO_FSEL_OUTP)
|
||||||
#define GPIO_SET(gpio) bcm2835_gpio_write(gpio, HIGH)
|
#define GPIO_SET(gpio) bcm2835_gpio_write(gpio, HIGH)
|
||||||
#define GPIO_CLR(gpio) bcm2835_gpio_write(gpio, LOW)
|
#define GPIO_CLR(gpio) bcm2835_gpio_write(gpio, LOW)
|
||||||
#define GPIO_GET(gpio) (bcm2835_gpio_lev(gpio) != LOW)
|
#define GPIO_GET(gpio) (bcm2835_gpio_lev(gpio) != LOW)
|
||||||
#define DELAY(delay) usleep(delay)
|
#define DELAY(delay) usleep(delay)
|
||||||
#endif //SWSPI_RPI
|
#endif //SWSPI_RPI
|
||||||
|
|
||||||
#ifdef SWSPI_AVR
|
#ifdef SWSPI_AVR
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#define GPIO_INP(gpio) pinMode(gpio, INPUT)
|
#define GPIO_INP(gpio) pinMode(gpio, INPUT)
|
||||||
#define GPIO_OUT(gpio) pinMode(gpio, OUTPUT)
|
#define GPIO_OUT(gpio) pinMode(gpio, OUTPUT)
|
||||||
#define GPIO_SET(gpio) digitalWrite(gpio, HIGH)
|
#define GPIO_SET(gpio) digitalWrite(gpio, HIGH)
|
||||||
#define GPIO_CLR(gpio) digitalWrite(gpio, LOW)
|
#define GPIO_CLR(gpio) digitalWrite(gpio, LOW)
|
||||||
#define GPIO_GET(gpio) (digitalRead(gpio) != LOW)
|
#define GPIO_GET(gpio) (digitalRead(gpio) != LOW)
|
||||||
#define DELAY(delay) delayMicroseconds(delay)
|
#define DELAY(delay) delayMicroseconds(delay)
|
||||||
#endif //SWSPI_AVR
|
#endif //SWSPI_AVR
|
||||||
|
|
||||||
#if (SWSPI_POL != 0)
|
#if (SWSPI_POL != 0)
|
||||||
#define SWSPI_SCK_UP GPIO_CLR(SWSPI_SCK)
|
#define SWSPI_SCK_UP GPIO_CLR(SWSPI_SCK)
|
||||||
#define SWSPI_SCK_DN GPIO_SET(SWSPI_SCK)
|
#define SWSPI_SCK_DN GPIO_SET(SWSPI_SCK)
|
||||||
#else
|
#else
|
||||||
#define SWSPI_SCK_UP GPIO_SET(SWSPI_SCK)
|
#define SWSPI_SCK_UP GPIO_SET(SWSPI_SCK)
|
||||||
#define SWSPI_SCK_DN GPIO_CLR(SWSPI_SCK)
|
#define SWSPI_SCK_DN GPIO_CLR(SWSPI_SCK)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
void swspi_init()
|
void swspi_init()
|
||||||
{
|
{
|
||||||
GPIO_INP(SWSPI_MISO);
|
GPIO_INP(SWSPI_MISO);
|
||||||
GPIO_OUT(SWSPI_MOSI);
|
GPIO_OUT(SWSPI_MOSI);
|
||||||
GPIO_OUT(SWSPI_SCK);
|
GPIO_OUT(SWSPI_SCK);
|
||||||
GPIO_OUT(SWSPI_CS);
|
GPIO_OUT(SWSPI_CS);
|
||||||
GPIO_CLR(SWSPI_MOSI);
|
GPIO_CLR(SWSPI_MOSI);
|
||||||
SWSPI_SCK_DN;
|
SWSPI_SCK_DN;
|
||||||
GPIO_SET(SWSPI_CS);
|
GPIO_SET(SWSPI_CS);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if (SWSPI_MOSI == SWSPI_MISO)
|
#if (SWSPI_MOSI == SWSPI_MISO)
|
||||||
|
|
||||||
void swspi_tx(unsigned char tx)
|
void swspi_tx(unsigned char tx)
|
||||||
{
|
{
|
||||||
GPIO_OUT(SWSPI_MOSI);
|
GPIO_OUT(SWSPI_MOSI);
|
||||||
unsigned char i = 0; for (; i < 8; i++)
|
unsigned char i = 0; for (; i < 8; i++)
|
||||||
{
|
{
|
||||||
if (tx & 0x80) GPIO_SET(SWSPI_MOSI);
|
if (tx & 0x80) GPIO_SET(SWSPI_MOSI);
|
||||||
else GPIO_CLR(SWSPI_MOSI);
|
else GPIO_CLR(SWSPI_MOSI);
|
||||||
DELAY(SWSPI_DEL);
|
DELAY(SWSPI_DEL);
|
||||||
SWSPI_SCK_UP;
|
SWSPI_SCK_UP;
|
||||||
DELAY(SWSPI_DEL);
|
DELAY(SWSPI_DEL);
|
||||||
SWSPI_SCK_DN;
|
SWSPI_SCK_DN;
|
||||||
tx <<= 1;
|
tx <<= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char swspi_rx()
|
unsigned char swspi_rx()
|
||||||
{
|
{
|
||||||
GPIO_INP(SWSPI_MISO);
|
GPIO_INP(SWSPI_MISO);
|
||||||
unsigned char rx = 0;
|
unsigned char rx = 0;
|
||||||
unsigned char i = 0; for (; i < 8; i++)
|
unsigned char i = 0; for (; i < 8; i++)
|
||||||
{
|
{
|
||||||
rx <<= 1;
|
rx <<= 1;
|
||||||
DELAY(SWSPI_DEL);
|
DELAY(SWSPI_DEL);
|
||||||
SWSPI_SCK_UP;
|
SWSPI_SCK_UP;
|
||||||
DELAY(SWSPI_DEL);
|
DELAY(SWSPI_DEL);
|
||||||
rx |= GPIO_GET(SWSPI_MISO)?1:0;
|
rx |= GPIO_GET(SWSPI_MISO)?1:0;
|
||||||
SWSPI_SCK_DN;
|
SWSPI_SCK_DN;
|
||||||
}
|
}
|
||||||
return rx;
|
return rx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else //(SWSPI_MOSI == SWSPI_MISO)
|
#else //(SWSPI_MOSI == SWSPI_MISO)
|
||||||
|
|
||||||
unsigned char swspi_txrx(unsigned char tx)
|
unsigned char swspi_txrx(unsigned char tx)
|
||||||
{
|
{
|
||||||
unsigned char rx = 0;
|
unsigned char rx = 0;
|
||||||
unsigned char i = 0; for (; i < 8; i++)
|
unsigned char i = 0; for (; i < 8; i++)
|
||||||
{
|
{
|
||||||
rx <<= 1;
|
rx <<= 1;
|
||||||
if (tx & 0x80) GPIO_SET(SWSPI_MOSI);
|
if (tx & 0x80) GPIO_SET(SWSPI_MOSI);
|
||||||
else GPIO_CLR(SWSPI_MOSI);
|
else GPIO_CLR(SWSPI_MOSI);
|
||||||
DELAY(SWSPI_DEL);
|
DELAY(SWSPI_DEL);
|
||||||
SWSPI_SCK_UP;
|
SWSPI_SCK_UP;
|
||||||
DELAY(SWSPI_DEL);
|
DELAY(SWSPI_DEL);
|
||||||
rx |= GPIO_GET(SWSPI_MISO)?1:0;
|
rx |= GPIO_GET(SWSPI_MISO)?1:0;
|
||||||
SWSPI_SCK_DN;
|
SWSPI_SCK_DN;
|
||||||
tx <<= 1;
|
tx <<= 1;
|
||||||
}
|
}
|
||||||
return rx;
|
return rx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //(SWSPI_MOSI == SWSPI_MISO)
|
#endif //(SWSPI_MOSI == SWSPI_MISO)
|
||||||
|
|
||||||
void swspi_start()
|
void swspi_start()
|
||||||
{
|
{
|
||||||
GPIO_CLR(SWSPI_CS);
|
GPIO_CLR(SWSPI_CS);
|
||||||
}
|
}
|
||||||
|
|
||||||
void swspi_stop()
|
void swspi_stop()
|
||||||
{
|
{
|
||||||
GPIO_SET(SWSPI_CS);
|
GPIO_SET(SWSPI_CS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,48 +1,48 @@
|
||||||
#ifndef SWSPI_H
|
#ifndef SWSPI_H
|
||||||
#define SWSPI_H
|
#define SWSPI_H
|
||||||
|
|
||||||
|
|
||||||
//#define SWSPI_RPI
|
//#define SWSPI_RPI
|
||||||
#define SWSPI_AVR
|
#define SWSPI_AVR
|
||||||
|
|
||||||
#ifdef SWSPI_RPI
|
#ifdef SWSPI_RPI
|
||||||
//#define SWSPI_MISO 9
|
//#define SWSPI_MISO 9
|
||||||
#define SWSPI_MISO 10
|
#define SWSPI_MISO 10
|
||||||
#define SWSPI_MOSI 10
|
#define SWSPI_MOSI 10
|
||||||
#define SWSPI_SCK 11
|
#define SWSPI_SCK 11
|
||||||
#define SWSPI_CS 7
|
#define SWSPI_CS 7
|
||||||
#endif //SWSPI_RPI
|
#endif //SWSPI_RPI
|
||||||
|
|
||||||
#ifdef SWSPI_AVR
|
#ifdef SWSPI_AVR
|
||||||
#define SWSPI_MISO 16
|
#define SWSPI_MISO 16
|
||||||
#define SWSPI_MOSI 16
|
#define SWSPI_MOSI 16
|
||||||
#define SWSPI_SCK 17
|
#define SWSPI_SCK 17
|
||||||
#define SWSPI_CS 20
|
#define SWSPI_CS 20
|
||||||
#endif //SWSPI_AVR
|
#endif //SWSPI_AVR
|
||||||
|
|
||||||
#define SWSPI_POL 1 //polarity
|
#define SWSPI_POL 1 //polarity
|
||||||
#define SWSPI_PHA 0 //phase
|
#define SWSPI_PHA 0 //phase
|
||||||
#define SWSPI_DOR 0 //data order
|
#define SWSPI_DOR 0 //data order
|
||||||
#define SWSPI_DEL 100 //delay
|
#define SWSPI_DEL 100 //delay
|
||||||
|
|
||||||
|
|
||||||
void swspi_init();
|
void swspi_init();
|
||||||
|
|
||||||
#if (SWSPI_MOSI == SWSPI_MISO)
|
#if (SWSPI_MOSI == SWSPI_MISO)
|
||||||
|
|
||||||
void swspi_tx(unsigned char tx);
|
void swspi_tx(unsigned char tx);
|
||||||
unsigned char swspi_rx();
|
unsigned char swspi_rx();
|
||||||
|
|
||||||
#else //(SWSPI_MOSI == SWSPI_MISO)
|
#else //(SWSPI_MOSI == SWSPI_MISO)
|
||||||
|
|
||||||
#define swspi_tx swspi_txrx
|
#define swspi_tx swspi_txrx
|
||||||
#define swspi_rx swspi_txrx
|
#define swspi_rx swspi_txrx
|
||||||
unsigned char swspi_txrx(unsigned char tx);
|
unsigned char swspi_txrx(unsigned char tx);
|
||||||
|
|
||||||
#endif //(SWSPI_MOSI == SWSPI_MISO)
|
#endif //(SWSPI_MOSI == SWSPI_MISO)
|
||||||
|
|
||||||
void swspi_start();
|
void swspi_start();
|
||||||
void swspi_stop();
|
void swspi_stop();
|
||||||
|
|
||||||
|
|
||||||
#endif //SWSPI_H
|
#endif //SWSPI_H
|
||||||
|
|
|
@ -405,55 +405,55 @@ void setExtruderAutoFanState(int pin, bool state)
|
||||||
analogWrite(pin, newFanSpeed);
|
analogWrite(pin, newFanSpeed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void countFanSpeed()
|
void countFanSpeed()
|
||||||
{
|
{
|
||||||
fan_speed[0] = (fan_edge_counter[0] * (float(250) / (millis() - extruder_autofan_last_check)));
|
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)));
|
fan_speed[1] = (fan_edge_counter[1] * (float(250) / (millis() - extruder_autofan_last_check)));
|
||||||
|
|
||||||
fan_edge_counter[0] = 0;
|
fan_edge_counter[0] = 0;
|
||||||
fan_edge_counter[1] = 0;
|
fan_edge_counter[1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkFanSpeed()
|
void checkFanSpeed()
|
||||||
{
|
{
|
||||||
static unsigned char fan_speed_errors[2] = { 0,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;
|
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;
|
else fan_speed_errors[1] = 0;
|
||||||
|
|
||||||
if (fan_speed_errors[0] > 5) fanSpeedError(0);
|
if (fan_speed_errors[0] > 5) fanSpeedError(0);
|
||||||
if (fan_speed_errors[1] > 5) fanSpeedError(1);
|
if (fan_speed_errors[1] > 5) fanSpeedError(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void fanSpeedError(unsigned char _fan) {
|
void fanSpeedError(unsigned char _fan) {
|
||||||
|
|
||||||
if (card.sdprinting) {
|
if (card.sdprinting) {
|
||||||
card.pauseSDPrint();
|
card.pauseSDPrint();
|
||||||
}
|
}
|
||||||
|
|
||||||
setTargetHotend0(0);
|
setTargetHotend0(0);
|
||||||
/*lcd_update();
|
/*lcd_update();
|
||||||
WRITE(BEEPER, HIGH);
|
WRITE(BEEPER, HIGH);
|
||||||
delayMicroseconds(500);
|
delayMicroseconds(500);
|
||||||
WRITE(BEEPER, LOW);
|
WRITE(BEEPER, LOW);
|
||||||
delayMicroseconds(100);*/
|
delayMicroseconds(100);*/
|
||||||
|
|
||||||
|
|
||||||
SERIAL_ERROR_START;
|
SERIAL_ERROR_START;
|
||||||
switch (_fan) {
|
switch (_fan) {
|
||||||
case 0:
|
case 0:
|
||||||
SERIAL_ERRORLNPGM("ERROR: Extruder fan speed is lower then expected");
|
SERIAL_ERRORLNPGM("ERROR: Extruder fan speed is lower then expected");
|
||||||
LCD_ALERTMESSAGEPGM("Err: EXTR. FAN ERROR");
|
LCD_ALERTMESSAGEPGM("Err: EXTR. FAN ERROR");
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
SERIAL_ERRORLNPGM("ERROR: Print fan speed is lower then expected");
|
SERIAL_ERRORLNPGM("ERROR: Print fan speed is lower then expected");
|
||||||
LCD_ALERTMESSAGEPGM("Err: PRINT FAN ERROR");
|
LCD_ALERTMESSAGEPGM("Err: PRINT FAN ERROR");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void checkExtruderAutoFans()
|
void checkExtruderAutoFans()
|
||||||
|
@ -628,8 +628,8 @@ void manage_heater()
|
||||||
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
|
(defined(EXTRUDER_2_AUTO_FAN_PIN) && EXTRUDER_2_AUTO_FAN_PIN > -1)
|
||||||
if(millis() - extruder_autofan_last_check > 1000) // only need to check fan state very infrequently
|
if(millis() - extruder_autofan_last_check > 1000) // only need to check fan state very infrequently
|
||||||
{
|
{
|
||||||
countFanSpeed();
|
countFanSpeed();
|
||||||
checkFanSpeed();
|
checkFanSpeed();
|
||||||
checkExtruderAutoFans();
|
checkExtruderAutoFans();
|
||||||
extruder_autofan_last_check = millis();
|
extruder_autofan_last_check = millis();
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,9 +207,9 @@ void PID_autotune(float temp, int extruder, int ncycles);
|
||||||
void setExtruderAutoFanState(int pin, bool state);
|
void setExtruderAutoFanState(int pin, bool state);
|
||||||
void checkExtruderAutoFans();
|
void checkExtruderAutoFans();
|
||||||
|
|
||||||
void countFanSpeed();
|
void countFanSpeed();
|
||||||
void checkFanSpeed();
|
void checkFanSpeed();
|
||||||
void fanSpeedError(unsigned char _fan);
|
void fanSpeedError(unsigned char _fan);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,206 @@
|
||||||
#include "tmc2130.h"
|
#include "tmc2130.h"
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
uint32_t tmc2130_read(uint8_t chipselect, uint8_t address)
|
//externals for debuging
|
||||||
|
extern float current_position[4];
|
||||||
|
extern void st_get_position_xy(long &x, long &y);
|
||||||
|
|
||||||
|
//chipselect pins
|
||||||
|
uint8_t tmc2130_cs[4] = { X_TMC2130_CS, Y_TMC2130_CS, Z_TMC2130_CS, E0_TMC2130_CS };
|
||||||
|
//holding currents
|
||||||
|
uint8_t tmc2130_current_h[4] = TMC2130_CURRENTS_H;
|
||||||
|
//running currents
|
||||||
|
uint8_t tmc2130_current_r[4] = TMC2130_CURRENTS_R;
|
||||||
|
//axis stalled flags
|
||||||
|
uint8_t tmc2130_axis_stalled[4] = {0, 0, 0, 0};
|
||||||
|
//last homing stalled
|
||||||
|
uint8_t tmc2130_LastHomingStalled = 0;
|
||||||
|
|
||||||
|
uint8_t sg_homing_axis = 0xff;
|
||||||
|
uint8_t sg_homing_delay = 0;
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t tmc2130_read(uint8_t cs, uint8_t address);
|
||||||
|
void tmc2130_write(uint8_t cs, uint8_t address, uint8_t wval1, uint8_t wval2, uint8_t wval3, uint8_t wval4);
|
||||||
|
uint8_t tmc2130_read8(uint8_t cs, uint8_t address);
|
||||||
|
uint32_t tmc2130_readRegister(uint8_t cs, uint8_t address);
|
||||||
|
uint16_t tmc2130_readSG(uint8_t cs);
|
||||||
|
uint16_t tmc2130_readTStep(uint8_t cs);
|
||||||
|
void tmc2130_chopconf(uint8_t cs, bool extrapolate256 = 0, uint16_t microstep_resolution = 16);
|
||||||
|
void tmc2130_PWMconf(uint8_t cs, uint8_t PWMautoScale = PWM_AUTOSCALE, uint8_t PWMfreq = PWM_FREQ, uint8_t PWMgrad = PWM_GRAD, uint8_t PWMampl = PWM_AMPL);
|
||||||
|
void tmc2130_PWMthreshold(uint8_t cs);
|
||||||
|
void tmc2130_disable_motor(uint8_t driver);
|
||||||
|
|
||||||
|
|
||||||
|
void tmc2130_init()
|
||||||
|
{
|
||||||
|
MYSERIAL.println("tmc2130_init");
|
||||||
|
WRITE(X_TMC2130_CS, HIGH);
|
||||||
|
WRITE(Y_TMC2130_CS, HIGH);
|
||||||
|
WRITE(Z_TMC2130_CS, HIGH);
|
||||||
|
WRITE(E0_TMC2130_CS, HIGH);
|
||||||
|
SET_OUTPUT(X_TMC2130_CS);
|
||||||
|
SET_OUTPUT(Y_TMC2130_CS);
|
||||||
|
SET_OUTPUT(Z_TMC2130_CS);
|
||||||
|
SET_OUTPUT(E0_TMC2130_CS);
|
||||||
|
SPI.begin();
|
||||||
|
for (int i = 0; i < 3; i++) //X Y Z axes
|
||||||
|
{
|
||||||
|
tmc2130_write(tmc2130_cs[i], 0x00, 0, 0, 0, 0x04); //address=0x0 GCONF - bit 2 activate stealthChop
|
||||||
|
tmc2130_write(tmc2130_cs[i], 0x10, 0, 15, tmc2130_current_r[i], tmc2130_current_h[i]); //0x10 IHOLD_IRUN
|
||||||
|
tmc2130_write(tmc2130_cs[i], 0x11, 0, 0, 0, 0);
|
||||||
|
tmc2130_PWMconf(tmc2130_cs[i]); //address=0x70 PWM_CONF //reset default=0x00050480
|
||||||
|
//tmc2130_PWMthreshold(tmc2130_cs[i]);
|
||||||
|
tmc2130_chopconf(tmc2130_cs[i], 1, 16);
|
||||||
|
}
|
||||||
|
for (int i = 3; i < 4; i++) //E axis
|
||||||
|
{
|
||||||
|
tmc2130_write(tmc2130_cs[i], 0x00, 0, 0, 0, 0x00); //address=0x0 GCONF - bit 2 activate stealthChop
|
||||||
|
tmc2130_write(tmc2130_cs[i], 0x10, 0, 15, tmc2130_current_r[i], tmc2130_current_h[i]); //0x10 IHOLD_IRUN
|
||||||
|
tmc2130_write(tmc2130_cs[i], 0x11, 0, 0, 0, 0);
|
||||||
|
tmc2130_chopconf(tmc2130_cs[i], 1, 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool tmc2130_update_sg()
|
||||||
|
{
|
||||||
|
if ((sg_homing_axis == X_AXIS) || (sg_homing_axis == Y_AXIS))
|
||||||
|
{
|
||||||
|
uint8_t cs = tmc2130_cs[sg_homing_axis];
|
||||||
|
uint16_t tstep = tmc2130_readTStep(cs);
|
||||||
|
if (tstep < TCOOLTHRS)
|
||||||
|
{
|
||||||
|
if(sg_homing_delay < 10) // wait for a few tens microsteps until stallGuard is used //todo: read out microsteps directly, instead of delay counter
|
||||||
|
sg_homing_delay++;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint16_t sg = tmc2130_readSG(cs);
|
||||||
|
if (sg==0)
|
||||||
|
{
|
||||||
|
tmc2130_axis_stalled[sg_homing_axis] = true;
|
||||||
|
tmc2130_LastHomingStalled = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tmc2130_axis_stalled[sg_homing_axis] = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tmc2130_axis_stalled[sg_homing_axis] = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
tmc2130_axis_stalled[X_AXIS] = false;
|
||||||
|
tmc2130_axis_stalled[Y_AXIS] = false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tmc2130_check_overtemp()
|
||||||
|
{
|
||||||
|
const static char TMC_OVERTEMP_MSG[] PROGMEM = "TMC DRIVER OVERTEMP ";
|
||||||
|
static uint32_t checktime = 0;
|
||||||
|
//drivers_disabled[0] = 1; //TEST
|
||||||
|
if( millis() - checktime > 1000 )
|
||||||
|
{
|
||||||
|
for(int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
uint32_t drv_status = tmc2130_read(tmc2130_cs[i], 0x6F); //0x6F DRV_STATUS
|
||||||
|
if (drv_status & ((uint32_t)1<<26))
|
||||||
|
{ // BIT 26 - over temp prewarning ~120C (+-20C)
|
||||||
|
SERIAL_ERRORRPGM(TMC_OVERTEMP_MSG);
|
||||||
|
SERIAL_ECHOLN(i);
|
||||||
|
for(int x = 0; x < 4; x++) tmc2130_disable_motor(x);
|
||||||
|
kill(TMC_OVERTEMP_MSG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checktime = millis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void tmc2130_home_enter(uint8_t axis)
|
||||||
|
{
|
||||||
|
MYSERIAL.print("tmc2130_home_enter ");
|
||||||
|
MYSERIAL.println((int)axis);
|
||||||
|
uint8_t cs = tmc2130_cs[axis];
|
||||||
|
sg_homing_axis = axis;
|
||||||
|
sg_homing_delay = 0;
|
||||||
|
tmc2130_axis_stalled[X_AXIS] = false;
|
||||||
|
tmc2130_axis_stalled[Y_AXIS] = false;
|
||||||
|
//Configuration to spreadCycle
|
||||||
|
//tmc2130_write(cs, 0x0, 0, 0, 0, 0x01);
|
||||||
|
tmc2130_write(cs, 0x0, 0, 0, 0, 0x00);
|
||||||
|
tmc2130_write(cs, 0x6D, 0, (axis == X_AXIS)?SG_THRESHOLD_X:SG_THRESHOLD_Y,0,0);
|
||||||
|
tmc2130_write(cs, 0x14, 0, 0, 0, TCOOLTHRS);
|
||||||
|
}
|
||||||
|
|
||||||
|
void tmc2130_home_exit()
|
||||||
|
{
|
||||||
|
MYSERIAL.println("tmc2130_home_exit");
|
||||||
|
if ((sg_homing_axis == X_AXIS) || (sg_homing_axis == Y_AXIS))
|
||||||
|
{
|
||||||
|
// Configuration back to stealthChop
|
||||||
|
tmc2130_write(tmc2130_cs[sg_homing_axis], 0x0, 0, 0, 0, 0x04);
|
||||||
|
sg_homing_axis = 0xff;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
extern uint8_t tmc2130_didLastHomingStall()
|
||||||
|
{
|
||||||
|
uint8_t ret = tmc2130_LastHomingStalled;
|
||||||
|
tmc2130_LastHomingStalled = false;
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tmc2130_set_current_h(uint8_t axis, uint8_t current)
|
||||||
|
{
|
||||||
|
MYSERIAL.print("tmc2130_set_current_h ");
|
||||||
|
MYSERIAL.print((int)axis);
|
||||||
|
MYSERIAL.print(" ");
|
||||||
|
MYSERIAL.println((int)current);
|
||||||
|
if (current > 15) current = 15; //current>15 is unsafe
|
||||||
|
tmc2130_current_h[axis] = current;
|
||||||
|
tmc2130_write(tmc2130_cs[axis], 0x10, 0, 15, tmc2130_current_r[axis], tmc2130_current_h[axis]); //0x10 IHOLD_IRUN
|
||||||
|
}
|
||||||
|
|
||||||
|
void tmc2130_set_current_r(uint8_t axis, uint8_t current)
|
||||||
|
{
|
||||||
|
MYSERIAL.print("tmc2130_set_current_r ");
|
||||||
|
MYSERIAL.print((int)axis);
|
||||||
|
MYSERIAL.print(" ");
|
||||||
|
MYSERIAL.println((int)current);
|
||||||
|
if (current > 15) current = 15; //current>15 is unsafe
|
||||||
|
tmc2130_current_r[axis] = current;
|
||||||
|
tmc2130_write(tmc2130_cs[axis], 0x10, 0, 15, tmc2130_current_r[axis], tmc2130_current_h[axis]); //0x10 IHOLD_IRUN
|
||||||
|
}
|
||||||
|
|
||||||
|
void tmc2130_print_currents()
|
||||||
|
{
|
||||||
|
MYSERIAL.println("tmc2130_print_currents");
|
||||||
|
MYSERIAL.println("\tH\rR");
|
||||||
|
|
||||||
|
MYSERIAL.print("X\t");
|
||||||
|
MYSERIAL.print((int)tmc2130_current_h[0]);
|
||||||
|
MYSERIAL.print("\t");
|
||||||
|
MYSERIAL.println((int)tmc2130_current_r[0]);
|
||||||
|
|
||||||
|
MYSERIAL.print("Y\t");
|
||||||
|
MYSERIAL.print((int)tmc2130_current_h[1]);
|
||||||
|
MYSERIAL.print("\t");
|
||||||
|
MYSERIAL.println((int)tmc2130_current_r[1]);
|
||||||
|
|
||||||
|
MYSERIAL.print("Z\t");
|
||||||
|
MYSERIAL.print((int)tmc2130_current_h[2]);
|
||||||
|
MYSERIAL.print("\t");
|
||||||
|
MYSERIAL.println((int)tmc2130_current_r[2]);
|
||||||
|
|
||||||
|
MYSERIAL.print("E\t");
|
||||||
|
MYSERIAL.print((int)tmc2130_current_h[3]);
|
||||||
|
MYSERIAL.print("\t");
|
||||||
|
MYSERIAL.println((int)tmc2130_current_r[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t tmc2130_read(uint8_t cs, uint8_t address)
|
||||||
{
|
{
|
||||||
uint32_t val32;
|
uint32_t val32;
|
||||||
uint8_t val0;
|
uint8_t val0;
|
||||||
|
@ -15,23 +214,23 @@ uint32_t tmc2130_read(uint8_t chipselect, uint8_t address)
|
||||||
uint8_t val4;
|
uint8_t val4;
|
||||||
//datagram1 - read request (address + dummy write)
|
//datagram1 - read request (address + dummy write)
|
||||||
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));
|
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));
|
||||||
digitalWrite(chipselect,LOW);
|
digitalWrite(cs,LOW);
|
||||||
SPI.transfer(address);
|
SPI.transfer(address);
|
||||||
SPI.transfer(0);
|
SPI.transfer(0);
|
||||||
SPI.transfer(0);
|
SPI.transfer(0);
|
||||||
SPI.transfer(0);
|
SPI.transfer(0);
|
||||||
SPI.transfer(0);
|
SPI.transfer(0);
|
||||||
digitalWrite(chipselect, HIGH);
|
digitalWrite(cs, HIGH);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
//datagram2 - response
|
//datagram2 - response
|
||||||
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));
|
SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));
|
||||||
digitalWrite(chipselect,LOW);
|
digitalWrite(cs,LOW);
|
||||||
val0 = SPI.transfer(0);
|
val0 = SPI.transfer(0);
|
||||||
val1 = SPI.transfer(0);
|
val1 = SPI.transfer(0);
|
||||||
val2 = SPI.transfer(0);
|
val2 = SPI.transfer(0);
|
||||||
val3 = SPI.transfer(0);
|
val3 = SPI.transfer(0);
|
||||||
val4 = SPI.transfer(0);
|
val4 = SPI.transfer(0);
|
||||||
digitalWrite(chipselect, HIGH);
|
digitalWrite(cs, HIGH);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
#ifdef TMC_DBG_READS
|
#ifdef TMC_DBG_READS
|
||||||
MYSERIAL.print("SPIRead 0x");
|
MYSERIAL.print("SPIRead 0x");
|
||||||
|
@ -55,7 +254,7 @@ uint32_t tmc2130_read(uint8_t chipselect, uint8_t address)
|
||||||
return val32;
|
return val32;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmc2130_write(uint8_t chipselect, uint8_t address,uint8_t wval1,uint8_t wval2,uint8_t wval3,uint8_t wval4)
|
void tmc2130_write(uint8_t cs, uint8_t address,uint8_t wval1,uint8_t wval2,uint8_t wval3,uint8_t wval4)
|
||||||
{
|
{
|
||||||
uint32_t val32;
|
uint32_t val32;
|
||||||
uint8_t val0;
|
uint8_t val0;
|
||||||
|
@ -65,23 +264,23 @@ void tmc2130_write(uint8_t chipselect, uint8_t address,uint8_t wval1,uint8_t wva
|
||||||
uint8_t val4;
|
uint8_t val4;
|
||||||
//datagram1 - write
|
//datagram1 - write
|
||||||
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
||||||
digitalWrite(chipselect,LOW);
|
digitalWrite(cs,LOW);
|
||||||
SPI.transfer(address+0x80);
|
SPI.transfer(address+0x80);
|
||||||
SPI.transfer(wval1);
|
SPI.transfer(wval1);
|
||||||
SPI.transfer(wval2);
|
SPI.transfer(wval2);
|
||||||
SPI.transfer(wval3);
|
SPI.transfer(wval3);
|
||||||
SPI.transfer(wval4);
|
SPI.transfer(wval4);
|
||||||
digitalWrite(chipselect, HIGH);
|
digitalWrite(cs, HIGH);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
//datagram2 - response
|
//datagram2 - response
|
||||||
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
||||||
digitalWrite(chipselect,LOW);
|
digitalWrite(cs,LOW);
|
||||||
val0 = SPI.transfer(0);
|
val0 = SPI.transfer(0);
|
||||||
val1 = SPI.transfer(0);
|
val1 = SPI.transfer(0);
|
||||||
val2 = SPI.transfer(0);
|
val2 = SPI.transfer(0);
|
||||||
val3 = SPI.transfer(0);
|
val3 = SPI.transfer(0);
|
||||||
val4 = SPI.transfer(0);
|
val4 = SPI.transfer(0);
|
||||||
digitalWrite(chipselect, HIGH);
|
digitalWrite(cs, HIGH);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
#ifdef TMC_DBG_WRITE
|
#ifdef TMC_DBG_WRITE
|
||||||
MYSERIAL.print("WriteRead 0x");
|
MYSERIAL.print("WriteRead 0x");
|
||||||
|
@ -102,66 +301,66 @@ void tmc2130_write(uint8_t chipselect, uint8_t address,uint8_t wval1,uint8_t wva
|
||||||
#endif //TMC_DBG_READS
|
#endif //TMC_DBG_READS
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t tmc2130_read8(uint8_t chipselect, uint8_t address)
|
uint8_t tmc2130_read8(uint8_t cs, uint8_t address)
|
||||||
{
|
{
|
||||||
//datagram1 - write
|
//datagram1 - write
|
||||||
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
||||||
digitalWrite(chipselect,LOW);
|
digitalWrite(cs,LOW);
|
||||||
SPI.transfer(address);
|
SPI.transfer(address);
|
||||||
SPI.transfer(0x00);
|
SPI.transfer(0x00);
|
||||||
SPI.transfer(0x00);
|
SPI.transfer(0x00);
|
||||||
SPI.transfer(0x00);
|
SPI.transfer(0x00);
|
||||||
SPI.transfer(0x00);
|
SPI.transfer(0x00);
|
||||||
digitalWrite(chipselect, HIGH);
|
digitalWrite(cs, HIGH);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
uint8_t val0;
|
uint8_t val0;
|
||||||
//datagram2 - response
|
//datagram2 - response
|
||||||
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
||||||
digitalWrite(chipselect,LOW);
|
digitalWrite(cs,LOW);
|
||||||
val0 = SPI.transfer(0);
|
val0 = SPI.transfer(0);
|
||||||
digitalWrite(chipselect, HIGH);
|
digitalWrite(cs, HIGH);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
return val0;
|
return val0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t tmc2130_readRegister(uint8_t chipselect, uint8_t address)
|
uint32_t tmc2130_readRegister(uint8_t cs, uint8_t address)
|
||||||
{
|
{
|
||||||
//datagram1 - write
|
//datagram1 - write
|
||||||
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
||||||
digitalWrite(chipselect,LOW);
|
digitalWrite(cs,LOW);
|
||||||
SPI.transfer(address);
|
SPI.transfer(address);
|
||||||
SPI.transfer(0x00);
|
SPI.transfer(0x00);
|
||||||
SPI.transfer(0x00);
|
SPI.transfer(0x00);
|
||||||
SPI.transfer(0x00);
|
SPI.transfer(0x00);
|
||||||
SPI.transfer(0x00);
|
SPI.transfer(0x00);
|
||||||
digitalWrite(chipselect, HIGH);
|
digitalWrite(cs, HIGH);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
uint32_t val0;
|
uint32_t val0;
|
||||||
//datagram2 - response
|
//datagram2 - response
|
||||||
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
SPI.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE3));
|
||||||
digitalWrite(chipselect,LOW);
|
digitalWrite(cs,LOW);
|
||||||
SPI.transfer(0); // ignore status bits
|
SPI.transfer(0); // ignore status bits
|
||||||
val0 = SPI.transfer(0); // MSB
|
val0 = SPI.transfer(0); // MSB
|
||||||
val0 = (val0 << 8) | SPI.transfer(0);
|
val0 = (val0 << 8) | SPI.transfer(0);
|
||||||
val0 = (val0 << 8) | SPI.transfer(0);
|
val0 = (val0 << 8) | SPI.transfer(0);
|
||||||
val0 = (val0 << 8) | SPI.transfer(0); //LSB
|
val0 = (val0 << 8) | SPI.transfer(0); //LSB
|
||||||
digitalWrite(chipselect, HIGH);
|
digitalWrite(cs, HIGH);
|
||||||
SPI.endTransaction();
|
SPI.endTransaction();
|
||||||
return val0;
|
return val0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t tmc2130_readSG(uint8_t chipselect)
|
uint16_t tmc2130_readSG(uint8_t cs)
|
||||||
{
|
{
|
||||||
uint8_t address = 0x6F;
|
uint8_t address = 0x6F;
|
||||||
uint32_t registerValue = tmc2130_readRegister(chipselect, address);
|
uint32_t registerValue = tmc2130_readRegister(cs, address);
|
||||||
uint16_t val0 = registerValue & 0x3ff;
|
uint16_t val0 = registerValue & 0x3ff;
|
||||||
return val0;
|
return val0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t tmc2130_readTStep(uint8_t chipselect)
|
uint16_t tmc2130_readTStep(uint8_t cs)
|
||||||
{
|
{
|
||||||
uint8_t address = 0x12;
|
uint8_t address = 0x12;
|
||||||
uint32_t registerValue = tmc2130_readRegister(chipselect, address);
|
uint32_t registerValue = tmc2130_readRegister(cs, address);
|
||||||
uint16_t val0 = 0;
|
uint16_t val0 = 0;
|
||||||
if(registerValue & 0x000f0000)
|
if(registerValue & 0x000f0000)
|
||||||
val0 = 0xffff;
|
val0 = 0xffff;
|
||||||
|
@ -170,9 +369,9 @@ uint16_t tmc2130_readTStep(uint8_t chipselect)
|
||||||
return val0;
|
return val0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmc2130_chopconf(uint8_t cs, bool extrapolate256 = 0, uint16_t microstep_resolution = 16)
|
void tmc2130_chopconf(uint8_t cs, bool extrapolate256, uint16_t microstep_resolution)
|
||||||
{
|
{
|
||||||
uint8_t mres=0b0100;
|
uint8_t mres = 0b0100;
|
||||||
if(microstep_resolution == 256) mres = 0b0000;
|
if(microstep_resolution == 256) mres = 0b0000;
|
||||||
if(microstep_resolution == 128) mres = 0b0001;
|
if(microstep_resolution == 128) mres = 0b0001;
|
||||||
if(microstep_resolution == 64) mres = 0b0010;
|
if(microstep_resolution == 64) mres = 0b0010;
|
||||||
|
@ -183,182 +382,23 @@ void tmc2130_chopconf(uint8_t cs, bool extrapolate256 = 0, uint16_t microstep_re
|
||||||
if(microstep_resolution == 2) mres = 0b0111;
|
if(microstep_resolution == 2) mres = 0b0111;
|
||||||
if(microstep_resolution == 1) mres = 0b1000;
|
if(microstep_resolution == 1) mres = 0b1000;
|
||||||
mres |= extrapolate256 << 4; //bit28 intpol
|
mres |= extrapolate256 << 4; //bit28 intpol
|
||||||
//tmc2130_write(cs,0x6C,mres,0x01,0x00,0xD3);
|
//tmc2130_write(cs, 0x6C, mres, 0x01, 0x00, 0xD3);
|
||||||
tmc2130_write(cs,0x6C,mres,0x01,0x00,0xC3);
|
tmc2130_write(cs, 0x6C, mres, 0x01, 0x00, 0xC3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmc2130_PWMconf(uint8_t cs, uint8_t PWMautoScale = PWM_AUTOSCALE, uint8_t PWMfreq = PWM_FREQ, uint8_t PWMgrad = PWM_GRAD, uint8_t PWMampl = PWM_AMPL)
|
void tmc2130_PWMconf(uint8_t cs, uint8_t PWMautoScale, uint8_t PWMfreq, uint8_t PWMgrad, uint8_t PWMampl)
|
||||||
{
|
{
|
||||||
tmc2130_write(cs,0x70,0x00,(PWMautoScale+PWMfreq),PWMgrad,PWMampl); // TMC LJ -> For better readability changed to 0x00 and added PWMautoScale and PWMfreq
|
tmc2130_write(cs, 0x70, 0x00, (PWMautoScale+PWMfreq), PWMgrad, PWMampl); // TMC LJ -> For better readability changed to 0x00 and added PWMautoScale and PWMfreq
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmc2130_PWMthreshold(uint8_t cs)
|
void tmc2130_PWMthreshold(uint8_t cs)
|
||||||
{
|
{
|
||||||
tmc2130_write(cs,0x13,0x00,0x00,0x00,0x00); // TMC LJ -> Adds possibility to swtich from stealthChop to spreadCycle automatically
|
tmc2130_write(cs, 0x13, 0x00, 0x00, 0x00, 0x00); // TMC LJ -> Adds possibility to swtich from stealthChop to spreadCycle automatically
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
uint8_t st_didLastHomingStall()
|
|
||||||
{
|
|
||||||
uint8_t returnValue = sg_lastHomingStalled;
|
|
||||||
sg_lastHomingStalled = false;
|
|
||||||
return returnValue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tmc2130_disable_motor(uint8_t driver)
|
void tmc2130_disable_motor(uint8_t driver)
|
||||||
{
|
{
|
||||||
uint8_t cs[4] = { X_TMC2130_CS, Y_TMC2130_CS, Z_TMC2130_CS, E0_TMC2130_CS };
|
tmc2130_write(tmc2130_cs[driver], 0x6C, 0, 01, 0, 0);
|
||||||
tmc2130_write(cs[driver],0x6C,0,01,0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tmc2130_check_overtemp()
|
|
||||||
{
|
|
||||||
const static char TMC_OVERTEMP_MSG[] PROGMEM = "TMC DRIVER OVERTEMP ";
|
|
||||||
uint8_t cs[4] = { X_TMC2130_CS, Y_TMC2130_CS, Z_TMC2130_CS, E0_TMC2130_CS };
|
|
||||||
static uint32_t checktime = 0;
|
|
||||||
//drivers_disabled[0] = 1; //TEST
|
|
||||||
if( millis() - checktime > 1000 )
|
|
||||||
{
|
|
||||||
for(int i=0;i<4;i++)
|
|
||||||
{
|
|
||||||
uint32_t drv_status = tmc2130_read(cs[i], 0x6F); //0x6F DRV_STATUS
|
|
||||||
if (drv_status & ((uint32_t)1<<26))
|
|
||||||
{ // BIT 26 - over temp prewarning ~120C (+-20C)
|
|
||||||
SERIAL_ERRORRPGM(TMC_OVERTEMP_MSG);
|
|
||||||
SERIAL_ECHOLN(i);
|
|
||||||
for(int x=0; x<4;x++) tmc2130_disable_motor(x);
|
|
||||||
kill(TMC_OVERTEMP_MSG);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
checktime = millis();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tmc2130_init()
|
|
||||||
{
|
|
||||||
uint8_t cs[4] = { X_TMC2130_CS, Y_TMC2130_CS, Z_TMC2130_CS, E0_TMC2130_CS };
|
|
||||||
// uint8_t current[4] = { 31, 31, 31, 31 };
|
|
||||||
// uint8_t current_h[4] = { 12, 12, 12, 12 };
|
|
||||||
// uint8_t current_r[4] = { 24, 24, 24, 24 };
|
|
||||||
// uint8_t current_r[4] = { 32, 32, 32, 32 };
|
|
||||||
// uint8_t current_h[4] = { 14, 14, 14, 14 };
|
|
||||||
uint8_t current_h[4] = { 2, 2, 2, 4 };
|
|
||||||
uint8_t current_r[4] = { 6, 6, 8, 8 };
|
|
||||||
WRITE(X_TMC2130_CS, HIGH);
|
|
||||||
WRITE(Y_TMC2130_CS, HIGH);
|
|
||||||
WRITE(Z_TMC2130_CS, HIGH);
|
|
||||||
WRITE(E0_TMC2130_CS, HIGH);
|
|
||||||
SET_OUTPUT(X_TMC2130_CS);
|
|
||||||
SET_OUTPUT(Y_TMC2130_CS);
|
|
||||||
SET_OUTPUT(Z_TMC2130_CS);
|
|
||||||
SET_OUTPUT(E0_TMC2130_CS);
|
|
||||||
SPI.begin();
|
|
||||||
/* for(int i=0;i<4;i++)
|
|
||||||
{
|
|
||||||
//tmc2130_write(cs[i],0x6C,0b10100,01,00,0xC5);
|
|
||||||
tmc2130_chopconf(cs[i],1,16);
|
|
||||||
tmc2130_write(cs[i],0x10,0,15,current_h[i],current_r[i]); //0x10 IHOLD_IRUN
|
|
||||||
//tmc2130_write(cs[i],0x0,0,0,0,0x05); //address=0x0 GCONF EXT VREF
|
|
||||||
tmc2130_write(cs[i],0x0,0,0,0,0x05); //address=0x0 GCONF EXT VREF - activate stealthChop
|
|
||||||
//tmc2130_write(cs[i],0x11,0,0,0,0xA);
|
|
||||||
|
|
||||||
// Uncomment lines below to use a different configuration (pwm_autoscale = 0) for XY axes
|
|
||||||
if(i==0 || i==1)
|
|
||||||
tmc2130_PWMconf(cs[i],PWM_AUTOSCALE_XY,PWM_FREQ_XY,PWM_GRAD_XY,PWM_AMPL_XY); //address=0x70 PWM_CONF //reset default=0x00050480
|
|
||||||
else
|
|
||||||
tmc2130_PWMconf(cs[i]); //address=0x70 PWM_CONF //reset default=0x00050480
|
|
||||||
tmc2130_PWMthreshold(cs[i]);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
#ifdef MK3_TEST1
|
|
||||||
for (int i=0;i<4;i++)
|
|
||||||
{
|
|
||||||
tmc2130_write(cs[i],0x0,0,0,0,0x00); //address=0x0 GCONF - bit 2 activate stealthChop
|
|
||||||
tmc2130_write(cs[i],0x10,0,15,current_r[i],current_h[i]); //0x10 IHOLD_IRUN
|
|
||||||
tmc2130_chopconf(cs[i],0,16);
|
|
||||||
}
|
|
||||||
#else //MK3_TEST1
|
|
||||||
for (int i=0;i<3;i++)
|
|
||||||
{
|
|
||||||
tmc2130_write(cs[i],0x0,0,0,0,0x04); //address=0x0 GCONF - bit 2 activate stealthChop
|
|
||||||
tmc2130_write(cs[i],0x10,0,15,current_r[i],current_h[i]); //0x10 IHOLD_IRUN
|
|
||||||
tmc2130_write(cs[i],0x11,0,0,0,0);
|
|
||||||
tmc2130_PWMconf(cs[i]); //address=0x70 PWM_CONF //reset default=0x00050480
|
|
||||||
// tmc2130_PWMthreshold(cs[i]);
|
|
||||||
tmc2130_chopconf(cs[i],1,16);
|
|
||||||
}
|
|
||||||
for (int i=3;i<4;i++)
|
|
||||||
{
|
|
||||||
tmc2130_write(cs[i],0x0,0,0,0,0x00); //address=0x0 GCONF - bit 2 activate stealthChop
|
|
||||||
tmc2130_write(cs[i],0x10,0,15,current_r[i],current_h[i]); //0x10 IHOLD_IRUN
|
|
||||||
tmc2130_write(cs[i],0x11,0,0,0,0);
|
|
||||||
tmc2130_chopconf(cs[i],1,16);
|
|
||||||
}
|
|
||||||
#endif //MK3_TEST1
|
|
||||||
}
|
|
||||||
|
|
||||||
void tmc2130_st_synchronize()
|
|
||||||
{
|
|
||||||
uint8_t delay = 0;
|
|
||||||
if(sg_homing_axis == X_AXIS || sg_homing_axis == Y_AXIS)
|
|
||||||
{
|
|
||||||
uint8_t axis;
|
|
||||||
if(sg_homing_axis == X_AXIS)
|
|
||||||
axis = X_TMC2130_CS;
|
|
||||||
else
|
|
||||||
axis = Y_TMC2130_CS;
|
|
||||||
uint16_t tstep = tmc2130_readTStep(axis);
|
|
||||||
// SERIAL_PROTOCOLLN(tstep);
|
|
||||||
if(tstep < TCOOLTHRS)
|
|
||||||
{
|
|
||||||
if(delay < 255) // wait for a few tens microsteps until stallGuard is used //todo: read out microsteps directly, instead of delay counter
|
|
||||||
delay++;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uint16_t sg = tmc2130_readSG(axis);
|
|
||||||
if(sg==0)
|
|
||||||
{
|
|
||||||
sg_axis_stalled[sg_homing_axis] = true;
|
|
||||||
sg_lastHomingStalled = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
sg_axis_stalled[sg_homing_axis] = false;
|
|
||||||
// SERIAL_PROTOCOLLN(sg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sg_axis_stalled[sg_homing_axis] = false;
|
|
||||||
delay = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sg_axis_stalled[X_AXIS] = false;
|
|
||||||
sg_axis_stalled[Y_AXIS] = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void tmc2130_st_home_enter(uint8_t axis)
|
|
||||||
{
|
|
||||||
sg_homing_axis = axis;
|
|
||||||
// Configuration to spreadCycle
|
|
||||||
// tmc2130_write((axis == X_AXIS)? X_TMC2130_CS : Y_TMC2130_CS,0x0,0,0,0,0x01);
|
|
||||||
tmc2130_write((axis == X_AXIS)? X_TMC2130_CS : Y_TMC2130_CS,0x0,0,0,0,0x00);
|
|
||||||
tmc2130_write((axis == X_AXIS)? X_TMC2130_CS : Y_TMC2130_CS,0x6D,0,(axis == X_AXIS)?SG_THRESHOLD_X:SG_THRESHOLD_Y,0,0);
|
|
||||||
tmc2130_write((axis == X_AXIS)? X_TMC2130_CS : Y_TMC2130_CS,0x14,0,0,0,TCOOLTHRS);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tmc2130_st_home_exit()
|
|
||||||
{
|
|
||||||
if ((sg_homing_axis == X_AXIS) || (sg_homing_axis == X_AXIS))
|
|
||||||
{
|
|
||||||
// Configuration back to stealthChop
|
|
||||||
tmc2130_write((sg_homing_axis == X_AXIS)? X_TMC2130_CS : Y_TMC2130_CS, 0x0, 0, 0, 0, 0x04);
|
|
||||||
sg_homing_axis = 0xff;
|
|
||||||
sg_axis_stalled[X_AXIS] = false;
|
|
||||||
sg_axis_stalled[Y_AXIS] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //HAVE_TMC2130_DRIVERS
|
#endif //HAVE_TMC2130_DRIVERS
|
||||||
|
|
|
@ -1,26 +1,33 @@
|
||||||
#ifndef TMC2130_H
|
#ifndef TMC2130_H
|
||||||
#define TMC2130_H
|
#define TMC2130_H
|
||||||
|
|
||||||
static uint8_t sg_homing_axis = 0xFF;
|
//holding and running currents
|
||||||
static uint8_t sg_axis_stalled[2] = {0, 0};
|
extern uint8_t tmc2130_current_h[4];
|
||||||
static uint8_t sg_lastHomingStalled = false;
|
extern uint8_t tmc2130_current_r[4];
|
||||||
|
//flags for axis stall detection
|
||||||
|
extern uint8_t tmc2130_axis_stalled[4];
|
||||||
|
|
||||||
void tmc2130_check_overtemp();
|
extern uint8_t sg_homing_delay;
|
||||||
|
|
||||||
void tmc2130_write(uint8_t chipselect, uint8_t address,uint8_t wval1,uint8_t wval2,uint8_t wval3,uint8_t wval4);
|
|
||||||
uint8_t tmc2130_read8(uint8_t chipselect, uint8_t address);
|
|
||||||
uint16_t tmc2130_readSG(uint8_t chipselect);
|
|
||||||
uint16_t tmc2130_readTStep(uint8_t chipselect);
|
|
||||||
void tmc2130_PWMconf(uint8_t cs, uint8_t PWMgrad, uint8_t PWMampl);
|
|
||||||
|
|
||||||
uint8_t st_didLastHomingStall();
|
//initialize tmc2130
|
||||||
|
extern void tmc2130_init();
|
||||||
|
//update stall guard (called from st_synchronize inside the loop)
|
||||||
|
extern bool tmc2130_update_sg();
|
||||||
|
//temperature watching (called from )
|
||||||
|
extern void tmc2130_check_overtemp();
|
||||||
|
//enter homing (called from homeaxis before homing starts)
|
||||||
|
extern void tmc2130_home_enter(uint8_t axis);
|
||||||
|
//exit homing (called from homeaxis after homing ends)
|
||||||
|
extern void tmc2130_home_exit();
|
||||||
|
//
|
||||||
|
extern uint8_t tmc2130_didLastHomingStall();
|
||||||
|
|
||||||
void tmc2130_st_synchronize();
|
//set holding current for any axis (G911)
|
||||||
|
extern void tmc2130_set_current_h(uint8_t axis, uint8_t current);
|
||||||
|
//set running current for any axis (G912)
|
||||||
|
extern void tmc2130_set_current_r(uint8_t axis, uint8_t current);
|
||||||
|
//print currents
|
||||||
|
extern void tmc2130_print_currents();
|
||||||
|
|
||||||
void tmc2130_st_home_enter(uint8_t axis);
|
#endif //TMC2130_H
|
||||||
|
|
||||||
void tmc2130_st_home_exit();
|
|
||||||
|
|
||||||
void tmc2130_init();
|
|
||||||
|
|
||||||
#endif TMC2130_H
|
|
|
@ -6,14 +6,14 @@
|
||||||
*------------------------------------*/
|
*------------------------------------*/
|
||||||
|
|
||||||
// Printer revision
|
// Printer revision
|
||||||
#define FILAMENT_SIZE "1_75mm_MK2"
|
#define FILAMENT_SIZE "1_75mm_MK3"
|
||||||
#define NOZZLE_TYPE "E3Dv6full"
|
#define NOZZLE_TYPE "E3Dv6full"
|
||||||
|
|
||||||
// Developer flag
|
// Developer flag
|
||||||
#define DEVELOPER
|
#define DEVELOPER
|
||||||
|
|
||||||
// Printer name
|
// Printer name
|
||||||
#define CUSTOM_MENDEL_NAME "Prusa i3 MK2"
|
#define CUSTOM_MENDEL_NAME "Prusa i3 MK3"
|
||||||
|
|
||||||
// Electronics
|
// Electronics
|
||||||
#define MOTHERBOARD BOARD_EINY_0_1a
|
#define MOTHERBOARD BOARD_EINY_0_1a
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
*------------------------------------*/
|
*------------------------------------*/
|
||||||
|
|
||||||
// Steps per unit {X,Y,Z,E}
|
// Steps per unit {X,Y,Z,E}
|
||||||
#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,161.3}
|
#define DEFAULT_AXIS_STEPS_PER_UNIT {100,100,3200/8,140}
|
||||||
|
|
||||||
// Endstop inverting
|
// Endstop inverting
|
||||||
const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
|
const bool X_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic of the endstop.
|
||||||
|
@ -64,10 +64,10 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||||
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
|
#define NUM_AXIS 4 // The axis order in all axis related arrays is X, Y, Z, E
|
||||||
#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000
|
#define HOMING_FEEDRATE {3000, 3000, 800, 0} // set the homing speeds (mm/min) // 3000 is also valid for stallGuard homing. Valid range: 2200 - 3000
|
||||||
|
|
||||||
#define DEFAULT_MAX_FEEDRATE {500, 500, 12, 120} // (mm/sec)
|
#define DEFAULT_MAX_FEEDRATE {400, 400, 12, 120} // (mm/sec)
|
||||||
#define DEFAULT_MAX_ACCELERATION {300,300,300,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_MAX_ACCELERATION {2000,2000,500,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 1500 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
#define DEFAULT_ACCELERATION 1200 // X, Y, Z and E max acceleration in mm/s^2 for printing moves
|
||||||
#define DEFAULT_RETRACT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for retracts
|
#define DEFAULT_RETRACT_ACCELERATION 1500 // X, Y, Z and E max acceleration in mm/s^2 for retracts
|
||||||
|
|
||||||
|
|
||||||
|
@ -84,41 +84,17 @@ const bool Z_MIN_ENDSTOP_INVERTING = false; // set to true to invert the logic o
|
||||||
#define PWM_AMPL 0xC8 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
#define PWM_AMPL 0xC8 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
||||||
#define PWM_AUTOSCALE 0x04 // 0x04 since writing in PWM_CONF (Activates PWM autoscaling)
|
#define PWM_AUTOSCALE 0x04 // 0x04 since writing in PWM_CONF (Activates PWM autoscaling)
|
||||||
#define PWM_FREQ 0x01 // 0x01 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK)
|
#define PWM_FREQ 0x01 // 0x01 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK)
|
||||||
|
|
||||||
// Special configuration for XY axes for operation (during standstill, use same settings as for other axes) //todo
|
|
||||||
#define PWM_GRAD_XY 156 // 0x0F - Sets gradient - (max 15 with PWM autoscale activated)
|
|
||||||
#define PWM_AMPL_XY 63 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
|
||||||
#define PWM_AUTOSCALE_XY 0x00 // 0x04 since writing in PWM_CONF (Activates PWM autoscaling)
|
|
||||||
#define PWM_FREQ_XY 0x01 // 0x01 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK)
|
|
||||||
|
|
||||||
#define PWM_THRS 0x00 // TPWM_THRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode
|
#define PWM_THRS 0x00 // TPWM_THRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode
|
||||||
|
|
||||||
#define SG_HOMING 1
|
#define SG_HOMING_SW 1 // stallguard "software" homing
|
||||||
#define SG_THRESHOLD 13
|
//#define SG_HOMING_HW 1 // stallguard "hardware" homing
|
||||||
#define TCOOLTHRS 239
|
#define SG_THRESHOLD_X 8 // stallguard sensitivity for X axis
|
||||||
|
#define SG_THRESHOLD_Y 8 // stallguard sensitivity for Y axis
|
||||||
|
#define TCOOLTHRS 239 // coolstep treshold
|
||||||
|
|
||||||
#define TMC_DEBUG
|
#define TMC2130_CURRENTS_H {2, 2, 2, 4} // default holding currents for all axes
|
||||||
|
#define TMC2130_CURRENTS_R {6, 6, 8, 8} // default running currents for all axes
|
||||||
// PWM register configuration
|
#define TMC2130_DEBUG
|
||||||
#define PWM_GRAD 0x08 // 0x0F - Sets gradient - (max 15 with PWM autoscale activated)
|
|
||||||
#define PWM_AMPL 0xC8 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
|
||||||
#define PWM_AUTOSCALE 0x04 // 0x04 since writing in PWM_CONF (Activates PWM autoscaling)
|
|
||||||
#define PWM_FREQ 0x01 // 0x01 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK)
|
|
||||||
|
|
||||||
// Special configuration for XY axes for operation (during standstill, use same settings as for other axes) //todo
|
|
||||||
#define PWM_GRAD_XY 156 // 0x0F - Sets gradient - (max 15 with PWM autoscale activated)
|
|
||||||
#define PWM_AMPL_XY 63 // 0xFF - Sets PWM amplitude to 200 (max is 255)
|
|
||||||
#define PWM_AUTOSCALE_XY 0x00 // 0x04 since writing in PWM_CONF (Activates PWM autoscaling)
|
|
||||||
#define PWM_FREQ_XY 0x01 // 0x01 since writing in PWM_CONF (Sets PWM frequency to 2/683 fCLK)
|
|
||||||
|
|
||||||
#define PWM_THRS 0x00 // TPWM_THRS - Sets the switching speed threshold based on TSTEP from stealthChop to spreadCycle mode
|
|
||||||
|
|
||||||
#define SG_HOMING 1
|
|
||||||
#define SG_THRESHOLD_X 8
|
|
||||||
#define SG_THRESHOLD_Y 8
|
|
||||||
#define TCOOLTHRS 239
|
|
||||||
|
|
||||||
#define TMC_DEBUG
|
|
||||||
//#define TMC_DBG_READS
|
//#define TMC_DBG_READS
|
||||||
//#define TMC_DBG_WRITE
|
//#define TMC_DBG_WRITE
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue