Merge branch 'marlin-1.1.5-einsyrambo' into devel

Added support for use of EinsyRambo on Mini 2.
master
Marcio Teixeira 7 years ago
commit a0b1cda4b8

@ -0,0 +1,392 @@
#ifndef TMC2310Stepper_h
#define TMC2310Stepper_h
//#define TMC2130DEBUG
#if defined(ARDUINO) && ARDUINO >= 100
#include <Arduino.h>
#endif
const uint32_t TMC2130Stepper_version = 0x10100; // v1.1.0
class TMC2130Stepper {
public:
TMC2130Stepper(uint8_t pinEN, uint8_t pinDIR, uint8_t pinStep, uint8_t pinCS);
void begin();
void checkStatus();
void rms_current(uint16_t mA, float multiplier=0.5, float RS=0.11);
uint16_t rms_current();
void SilentStepStick2130(uint16_t mA);
void setCurrent(uint16_t mA, float Rsense, float multiplier);
uint16_t getCurrent();
bool checkOT();
bool getOTPW();
void clear_otpw();
bool isEnabled();
// void takeSteps(int steps);
// void step(int steps, int speed);
// GCONF
uint32_t GCONF();
void GCONF( uint32_t value);
void I_scale_analog( bool B);
void internal_Rsense( bool B);
void en_pwm_mode( bool B);
void enc_commutation( bool B);
void shaft( bool B);
void diag0_error( bool B);
void diag0_otpw( bool B);
void diag0_stall( bool B);
void diag1_stall( bool B);
void diag1_index( bool B);
void diag1_onstate( bool B);
void diag1_steps_skipped( bool B);
void diag0_int_pushpull( bool B);
void diag1_pushpull( bool B);
void small_hysterisis( bool B);
void stop_enable( bool B);
void direct_mode( bool B);
bool I_scale_analog();
bool internal_Rsense();
bool en_pwm_mode();
bool enc_commutation();
bool shaft();
bool diag0_error();
bool diag0_otpw();
bool diag0_stall();
bool diag1_stall();
bool diag1_index();
bool diag1_onstate();
bool diag1_steps_skipped();
bool diag0_int_pushpull();
bool diag1_pushpull();
bool small_hysterisis();
bool stop_enable();
bool direct_mode();
// IHOLD_IRUN
void IHOLD_IRUN( uint32_t input);
uint32_t IHOLD_IRUN();
void ihold( uint8_t B);
void irun( uint8_t B);
void iholddelay( uint8_t B);
uint8_t ihold();
uint8_t irun();
uint8_t iholddelay();
// GSTAT
void GSTAT( uint8_t input);
uint8_t GSTAT();
bool reset();
bool drv_err();
bool uv_cp();
// IOIN
uint32_t IOIN();
bool step();
bool dir();
bool dcen_cfg4();
bool dcin_cfg5();
bool drv_enn_cfg6();
bool dco();
uint8_t version();
// TPOWERDOWN
uint32_t TPOWERDOWN();
void TPOWERDOWN( uint32_t input);
// TSTEP
uint32_t TSTEP();
// TPWMTHRS
uint32_t TPWMTHRS();
void TPWMTHRS( uint32_t input);
// TCOOLTHRS
uint32_t TCOOLTHRS();
void TCOOLTHRS( uint32_t input);
// THIGH
uint32_t THIGH();
void THIGH( uint32_t input);
// XDRIRECT
uint32_t XDIRECT();
void XDIRECT( uint32_t input);
void coil_A( int16_t B);
void coil_B( int16_t B);
int16_t coil_A();
int16_t coil_B();
// VDCMIN
uint32_t VDCMIN();
void VDCMIN( uint32_t input);
// CHOPCONF
uint32_t CHOPCONF();
void CHOPCONF( uint32_t value);
void toff( uint8_t B);
void hstrt( uint8_t B);
void hend( int8_t B);
void fd( uint8_t B);
void disfdcc( bool B);
void rndtf( bool B);
void chm( bool B);
void tbl( uint8_t B);
void vsense( bool B);
void vhighfs( bool B);
void vhighchm( bool B);
void sync( uint8_t B);
void mres( uint8_t B);
void intpol( bool B);
void dedge( bool B);
void diss2g( bool B);
uint8_t toff();
uint8_t hstrt();
int8_t hend();
uint8_t fd();
bool disfdcc();
bool rndtf();
bool chm();
uint8_t tbl();
bool vsense();
bool vhighfs();
bool vhighchm();
uint8_t sync();
uint8_t mres();
bool intpol();
bool dedge();
bool diss2g();
// COOLCONF
void COOLCONF(uint32_t value);
uint32_t COOLCONF();
void semin( uint8_t B);
void seup( uint8_t B);
void semax( uint8_t B);
void sedn( uint8_t B);
void seimin( bool B);
void sgt( uint8_t B);
void sfilt( bool B);
uint8_t semin();
uint8_t seup();
uint8_t semax();
uint8_t sedn();
bool seimin();
uint8_t sgt();
bool sfilt();
// PWMCONF
void PWMCONF( uint32_t value);
uint32_t PWMCONF();
void pwm_ampl( uint8_t B);
void pwm_grad( uint8_t B);
void pwm_freq( uint8_t B);
void pwm_autoscale( bool B);
void pwm_symmetric( bool B);
void freewheel( uint8_t B);
uint8_t pwm_ampl();
uint8_t pwm_grad();
uint8_t pwm_freq();
bool pwm_autoscale();
bool pwm_symmetric();
uint8_t freewheel();
// DRVSTATUS
uint32_t DRV_STATUS();
uint16_t sg_result();
bool fsactive();
uint8_t cs_actual();
bool stallguard();
bool ot();
bool otpw();
bool s2ga();
bool s2gb();
bool ola();
bool olb();
bool stst();
// PWM_SCALE
uint8_t PWM_SCALE();
// ENCM_CTRL
uint8_t ENCM_CTRL();
void ENCM_CTRL( uint8_t input);
void inv( bool B);
void maxspeed( bool B);
bool inv();
bool maxspeed();
// LOST_STEPS
uint32_t LOST_STEPS();
// Helper functions
void microsteps(uint16_t ms);
uint16_t microsteps();
void blank_time(uint8_t value);
uint8_t blank_time();
void hysterisis_end(int8_t value);
int8_t hysterisis_end();
void hysterisis_start(uint8_t value);
uint8_t hysterisis_start();
void sg_current_decrease(uint8_t value);
uint8_t sg_current_decrease();
// Aliases
// RW: GCONF
inline bool external_ref() __attribute__((always_inline)) { return I_scale_analog(); }
inline bool internal_sense_R() __attribute__((always_inline)) { return internal_Rsense(); }
inline bool stealthChop() __attribute__((always_inline)) { return en_pwm_mode(); }
inline bool commutation() __attribute__((always_inline)) { return enc_commutation(); }
inline bool shaft_dir() __attribute__((always_inline)) { return shaft(); }
inline bool diag0_errors() __attribute__((always_inline)) { return diag0_error(); }
inline bool diag0_temp_prewarn() __attribute__((always_inline)) { return diag0_otpw(); }
inline bool diag1_chopper_on() __attribute__((always_inline)) { return diag1_onstate(); }
inline bool diag0_active_high() __attribute__((always_inline)) { return diag0_int_pushpull(); }
inline bool diag1_active_high() __attribute__((always_inline)) { return diag1_pushpull(); }
inline void external_ref( bool value) __attribute__((always_inline)) { I_scale_analog(value); }
inline void internal_sense_R( bool value) __attribute__((always_inline)) { internal_Rsense(value); }
inline void stealthChop( bool value) __attribute__((always_inline)) { en_pwm_mode(value); }
inline void commutation( bool value) __attribute__((always_inline)) { enc_commutation(value); }
inline void shaft_dir( bool value) __attribute__((always_inline)) { shaft(value); }
inline void diag0_errors( bool value) __attribute__((always_inline)) { diag0_error(value); }
inline void diag0_temp_prewarn( bool value) __attribute__((always_inline)) { diag0_otpw(value); }
inline void diag1_chopper_on( bool value) __attribute__((always_inline)) { diag1_onstate(value); }
inline void diag0_active_high( bool value) __attribute__((always_inline)) { diag0_int_pushpull(value); }
inline void diag1_active_high( bool value) __attribute__((always_inline)) { diag1_pushpull(value); }
// RC
inline uint8_t status_flags() __attribute__((always_inline)) { return GSTAT(); }
// R
inline uint32_t input() __attribute__((always_inline)) { return IOIN(); }
// W: IHOLD_IRUN
inline uint8_t hold_current() __attribute__((always_inline)) { return ihold(); }
inline uint8_t run_current() __attribute__((always_inline)) { return irun(); }
inline uint8_t hold_delay() __attribute__((always_inline)) { return iholddelay(); }
inline void hold_current( uint8_t value) __attribute__((always_inline)) { ihold(value); }
inline void run_current( uint8_t value) __attribute__((always_inline)) { irun(value); }
inline void hold_delay( uint8_t value) __attribute__((always_inline)) { iholddelay(value); }
// W
inline uint8_t power_down_delay() __attribute__((always_inline)) { return TPOWERDOWN(); }
inline void power_down_delay( uint8_t value) __attribute__((always_inline)) { TPOWERDOWN(value); }
// R
inline uint32_t microstep_time() __attribute__((always_inline)) { return TSTEP(); }
// W
inline uint32_t stealth_max_speed() __attribute__((always_inline)) { return TPWMTHRS(); }
inline void stealth_max_speed(uint32_t value) __attribute__((always_inline)) { TPWMTHRS(value); }
// W
inline uint32_t coolstep_min_speed() __attribute__((always_inline)) { return TCOOLTHRS(); }
inline void coolstep_min_speed(uint32_t value) __attribute__((always_inline)) { TCOOLTHRS(value); }
// W
inline uint32_t mode_sw_speed() __attribute__((always_inline)) { return THIGH(); }
inline void mode_sw_speed( uint32_t value) __attribute__((always_inline)) { THIGH(value); }
// RW: XDIRECT
inline int16_t coil_A_current() __attribute__((always_inline)) { return coil_A(); }
inline void coil_A_current( int16_t value) __attribute__((always_inline)) { coil_B(value); }
inline int16_t coil_B_current() __attribute__((always_inline)) { return coil_A(); }
inline void coil_B_current( int16_t value) __attribute__((always_inline)) { coil_B(value); }
// W
inline uint32_t DCstep_min_speed() __attribute__((always_inline)) { return VDCMIN(); }
inline void DCstep_min_speed( uint32_t value) __attribute__((always_inline)) { VDCMIN(value); }
// RW: CHOPCONF
inline uint8_t off_time() __attribute__((always_inline)) { return toff(); }
// inline uint8_t hysterisis_start() __attribute__((always_inline)) { return hstrt(); }
// inline int8_t hysterisis_low() __attribute__((always_inline)) { return hend(); }
inline int8_t hysterisis_low() __attribute__((always_inline)) { return hysterisis_end(); }
inline uint8_t fast_decay_time() __attribute__((always_inline)) { return fd(); }
inline bool disable_I_comparator() __attribute__((always_inline)) { return disfdcc(); }
inline bool random_off_time() __attribute__((always_inline)) { return rndtf(); }
inline bool chopper_mode() __attribute__((always_inline)) { return chm(); }
// inline uint8_t blank_time() __attribute__((always_inline)) { return tbl(); }
inline bool high_sense_R() __attribute__((always_inline)) { return vsense(); }
inline bool fullstep_threshold() __attribute__((always_inline)) { return vhighfs(); }
inline bool high_speed_mode() __attribute__((always_inline)) { return vhighchm(); }
inline uint8_t sync_phases() __attribute__((always_inline)) { return sync(); }
// inline uint16_t microsteps() __attribute__((always_inline)) { return mres(); }
inline bool interpolate() __attribute__((always_inline)) { return intpol(); }
inline bool double_edge_step() __attribute__((always_inline)) { return dedge(); }
inline bool disable_short_protection() __attribute__((always_inline)) { return diss2g(); }
inline void off_time( uint8_t value) __attribute__((always_inline)) { toff(value); }
// inline void hysterisis_start( uint8_t value) __attribute__((always_inline)) { hstrt(value); }
// inline void hysterisis_low( int8_t value) __attribute__((always_inline)) { hend(value); }
inline void hysterisis_low( int8_t value) __attribute__((always_inline)) { hysterisis_end(value); }
inline void fast_decay_time( uint8_t value) __attribute__((always_inline)) { fd(value); }
inline void disable_I_comparator( bool value) __attribute__((always_inline)) { disfdcc(value); }
inline void random_off_time( bool value) __attribute__((always_inline)) { rndtf(value); }
inline void chopper_mode( bool value) __attribute__((always_inline)) { chm(value); }
// inline void blank_time( uint8_t value) __attribute__((always_inline)) { tbl(value); }
inline void high_sense_R( bool value) __attribute__((always_inline)) { vsense(value); }
inline void fullstep_threshold( bool value) __attribute__((always_inline)) { vhighfs(value); }
inline void high_speed_mode( bool value) __attribute__((always_inline)) { vhighchm(value); }
inline void sync_phases( uint8_t value) __attribute__((always_inline)) { sync(value); }
// inline void microsteps( uint16_t value) __attribute__((always_inline)) { mres(value); }
inline void interpolate( bool value) __attribute__((always_inline)) { intpol(value); }
inline void double_edge_step( bool value) __attribute__((always_inline)) { dedge(value); }
inline void disable_short_protection(bool value)__attribute__((always_inline)) { diss2g(value); }
// W: COOLCONF
inline uint8_t sg_min() __attribute__((always_inline)) { return semin(); }
inline uint8_t sg_step_width() __attribute__((always_inline)) { return seup(); }
inline uint8_t sg_max() __attribute__((always_inline)) { return semax(); }
// inline uint8_t sg_current_decrease() __attribute__((always_inline)) { return sedn(); }
inline uint8_t smart_min_current() __attribute__((always_inline)) { return seimin(); }
inline int8_t sg_stall_value() __attribute__((always_inline)) { return sgt(); }
inline bool sg_filter() __attribute__((always_inline)) { return sfilt(); }
inline void sg_min( uint8_t value) __attribute__((always_inline)) { semin(value); }
inline void sg_step_width( uint8_t value) __attribute__((always_inline)) { seup(value); }
inline void sg_max( uint8_t value) __attribute__((always_inline)) { semax(value); }
// inline void sg_current_decrease(uint8_t value)__attribute__((always_inline)) { sedn(value); }
inline void smart_min_current( uint8_t value) __attribute__((always_inline)) { seimin(value); }
inline void sg_stall_value( int8_t value) __attribute__((always_inline)) { sgt(value); }
inline void sg_filter( bool value) __attribute__((always_inline)) { sfilt(value); }
// W: PWMCONF
inline uint8_t stealth_amplitude() __attribute__((always_inline)) { return pwm_ampl(); }
inline uint8_t stealth_gradient() __attribute__((always_inline)) { return pwm_grad(); }
inline uint8_t stealth_freq() __attribute__((always_inline)) { return pwm_freq(); }
inline bool stealth_autoscale() __attribute__((always_inline)) { return pwm_autoscale(); }
inline bool stealth_symmetric() __attribute__((always_inline)) { return pwm_symmetric(); }
inline uint8_t standstill_mode() __attribute__((always_inline)) { return freewheel(); }
inline void stealth_amplitude( uint8_t value) __attribute__((always_inline)) { pwm_ampl(value); }
inline void stealth_gradient( uint8_t value) __attribute__((always_inline)) { pwm_grad(value); }
inline void stealth_freq( uint8_t value) __attribute__((always_inline)) { pwm_freq(value); }
inline void stealth_autoscale( bool value) __attribute__((always_inline)) { pwm_autoscale(value); }
inline void stealth_symmetric( bool value) __attribute__((always_inline)) { pwm_symmetric(value); }
inline void standstill_mode( uint8_t value) __attribute__((always_inline)) { freewheel(value); }
// W: ENCM_CTRL
inline bool invert_encoder() __attribute__((always_inline)) { return inv(); }
inline void invert_encoder( bool value) __attribute__((always_inline)) { inv(value); }
// R: DRV_STATUS
inline uint32_t DRVSTATUS() __attribute__((always_inline)) { return DRV_STATUS(); }
float Rsense = 0.11;
bool _started;
uint8_t status_response;
bool flag_otpw = false;
private:
//const uint8_t WRITE = 0b10000000;
//const uint8_t READ = 0b00000000;
uint8_t _pinEN = 16;
uint8_t _pinSTEP = 18;
uint8_t _pinCS = 17;
//const int MOSI_PIN = 12;
//const int MISO_PIN = 11;
//const int SCK_PIN = 13;
uint8_t _pinDIR = 19;
// Shadow registers
uint32_t GCONF_sr = 0x00000000UL,
IHOLD_IRUN_sr = 0x00000000UL,
TSTEP_sr = 0x00000000UL,
TPWMTHRS_sr = 0x00000000UL,
TCOOLTHRS_sr = 0x00000000UL,
THIGH_sr = 0x00000000UL,
XDIRECT_sr = 0x00000000UL,
VDCMIN_sr = 0x00000000UL,
MSLUT0_sr = 0x00000000UL,
MSLUT1_sr = 0x00000000UL,
MSLUT2_sr = 0x00000000UL,
MSLUT3_sr = 0x00000000UL,
MSLUT4_sr = 0x00000000UL,
MSLUT5_sr = 0x00000000UL,
MSLUT6_sr = 0x00000000UL,
MSLUT7_sr = 0x00000000UL,
MSLUTSEL_sr = 0x00000000UL,
CHOPCONF_sr = 0x00000000UL,
COOLCONF_sr = 0x00000000UL,
DCCTRL_sr = 0x00000000UL,
PWMCONF_sr = 0x00050480UL,
tmp_sr = 0x00000000UL,
TPOWERDOWN_sr = 0x00000000UL,
ENCM_CTRL_sr = 0x00000000UL,
GSTAT_sr = 0x00000000UL,
MSLUTSTART_sr = 0x00000000UL;
void send2130(uint8_t addressByte, uint32_t *config);
uint16_t val_mA = 0;
};
#endif

@ -0,0 +1,288 @@
#ifndef TMC2130Stepper_REGDEFS_h
#define TMC2130Stepper_REGDEFS_h
constexpr uint8_t TMC2130_READ = 0x00;
constexpr uint8_t TMC2130_WRITE = 0x80;
// Register memory positions
constexpr uint8_t REG_GCONF = 0x00;
constexpr uint8_t REG_GSTAT = 0x01;
constexpr uint8_t REG_IOIN = 0x04;
constexpr uint8_t REG_IHOLD_IRUN = 0x10;
constexpr uint8_t REG_TPOWERDOWN = 0x11;
constexpr uint8_t REG_TSTEP = 0x12;
constexpr uint8_t REG_TPWMTHRS = 0x13;
constexpr uint8_t REG_TCOOLTHRS = 0x14;
constexpr uint8_t REG_THIGH = 0x15;
constexpr uint8_t REG_XDIRECT = 0x2D;
constexpr uint8_t REG_VDCMIN = 0x33;
constexpr uint8_t REG_MSLUT0 = 0x60;
constexpr uint8_t REG_MSLUT1 = 0x61;
constexpr uint8_t REG_MSLUT2 = 0x62;
constexpr uint8_t REG_MSLUT3 = 0x63;
constexpr uint8_t REG_MSLUT4 = 0x64;
constexpr uint8_t REG_MSLUT5 = 0x65;
constexpr uint8_t REG_MSLUT6 = 0x66;
constexpr uint8_t REG_MSLUT7 = 0x67;
constexpr uint8_t REG_MSLUTSEL = 0x68;
constexpr uint8_t REG_MSLUTSTART = 0x69;
constexpr uint8_t REG_MSCNT = 0x6A;
constexpr uint8_t REG_MSCURACT = 0x6B;
constexpr uint8_t REG_CHOPCONF = 0x6C;
constexpr uint8_t REG_COOLCONF = 0x6D;
constexpr uint8_t REG_DCCTRL = 0x6E;
constexpr uint8_t REG_DRV_STATUS = 0x6F;
constexpr uint8_t REG_PWMCONF = 0x70;
constexpr uint8_t REG_PWM_SCALE = 0x71;
constexpr uint8_t REG_ENCM_CTRL = 0x72;
constexpr uint8_t REG_LOST_STEPS = 0x73;
// SPI_STATUS
constexpr uint8_t RESET_FLAG_bp = 0;
constexpr uint8_t DRIVER_ERROR_bp = 1;
constexpr uint8_t SG2_bp = 2;
constexpr uint8_t STANDSTILL_bp = 3;
constexpr uint32_t RESET_FLAG_bm = 0x1UL;
constexpr uint32_t DRIVER_ERROR_bm = 0x2UL;
constexpr uint32_t SG2_bm = 0x4UL;
constexpr uint32_t STANDSTILL_bm = 0x8UL;
// GCONF
constexpr uint8_t I_SCALE_ANALOG_bp = 0;
constexpr uint8_t INTERNAL_RSENSE_bp = 1;
constexpr uint8_t EN_PWM_MODE_bp = 2;
constexpr uint8_t ENC_COMMUTATION_bp = 3;
constexpr uint8_t SHAFT_bp = 4;
constexpr uint8_t DIAG0_ERROR_bp = 5;
constexpr uint8_t DIAG0_OTPW_bp = 6;
constexpr uint8_t DIAG0_STALL_bp = 7;
constexpr uint8_t DIAG1_STALL_bp = 8;
constexpr uint8_t DIAG1_INDEX_bp = 9;
constexpr uint8_t DIAG1_ONSTATE_bp = 10;
constexpr uint8_t DIAG1_STEPS_SKIPPED_bp = 11;
constexpr uint8_t DIAG0_INT_PUSHPULL_bp = 12;
constexpr uint8_t DIAG1_PUSHPULL_bp = 13;
constexpr uint8_t SMALL_HYSTERISIS_bp = 14;
constexpr uint8_t STOP_ENABLE_bp = 15;
constexpr uint8_t DIRECT_MODE_bp = 16;
constexpr uint32_t GCONF_bm = 0x3FFFFUL;
constexpr uint32_t I_SCALE_ANALOG_bm = 0x1UL;
constexpr uint32_t INTERNAL_RSENSE_bm = 0x2UL;
constexpr uint32_t EN_PWM_MODE_bm = 0x4UL;
constexpr uint32_t ENC_COMMUTATION_bm = 0x8UL;
constexpr uint32_t SHAFT_bm = 0x10UL;
constexpr uint32_t DIAG0_ERROR_bm = 0x20UL;
constexpr uint32_t DIAG0_OTPW_bm = 0x40UL;
constexpr uint32_t DIAG0_STALL_bm = 0x80UL;
constexpr uint32_t DIAG1_STALL_bm = 0x100UL;
constexpr uint32_t DIAG1_INDEX_bm = 0x200UL;
constexpr uint32_t DIAG1_ONSTATE_bm = 0x400UL;
constexpr uint32_t DIAG1_STEPS_SKIPPED_bm = 0x800UL;
constexpr uint32_t DIAG0_INT_PUSHPULL_bm = 0x1000UL;
constexpr uint32_t DIAG1_PUSHPULL_bm = 0x2000UL;
constexpr uint32_t SMALL_HYSTERISIS_bm = 0x4000UL;
constexpr uint32_t STOP_ENABLE_bm = 0x8000UL;
constexpr uint32_t DIRECT_MODE_bm = 0x10000UL;
// GSTAT
constexpr uint8_t RESET_bp = 0;
constexpr uint8_t DRV_ERR_bp = 1;
constexpr uint8_t UV_CP_bp = 2;
constexpr uint32_t GSTAT_bm = 0x7UL;
constexpr uint32_t RESET_bm = 0b1UL;
constexpr uint32_t DRV_ERR_bm = 0b10UL;
constexpr uint32_t UV_CP_bm = 0b100UL;
// IOIN
constexpr uint8_t STEP_bp = 0;
constexpr uint8_t DIR_bp = 1;
constexpr uint8_t DCEN_CFG4_bp = 2;
constexpr uint8_t DCIN_CFG5_bp = 3;
constexpr uint8_t DRV_ENN_CFG6_bp = 4;
constexpr uint8_t DCO_bp = 5;
constexpr uint8_t VERSION_bp = 24;
constexpr uint32_t IOIN_bm = 0xFF00003FUL;
constexpr uint32_t STEP_bm = 0x1UL;
constexpr uint32_t DIR_bm = 0x2UL;
constexpr uint32_t DCEN_CFG4_bm = 0x4UL;
constexpr uint32_t DCIN_CFG5_bm = 0x8UL;
constexpr uint32_t DRV_ENN_CFG6_bm = 0x10UL;
constexpr uint32_t DCO_bm = 0x20UL;
constexpr uint32_t VERSION_bm = 0xFF000000UL;
// IHOLD_IRUN
constexpr uint8_t IHOLD_bp = 0;
constexpr uint8_t IRUN_bp = 8;
constexpr uint8_t IHOLDDELAY_bp = 16;
constexpr uint32_t IHOLD_IRUN_bm = 0xF1F1FUL;
constexpr uint32_t IHOLD_bm = 0x1FUL;
constexpr uint32_t IRUN_bm = 0x1F00UL;
constexpr uint32_t IHOLDDELAY_bm = 0xF0000UL;
// TPOWERDOWN
constexpr uint8_t TPOWERDOWN_bp = 0;
constexpr uint32_t TPOWERDOWN_bm = 0xFFUL;
// TSTEP
constexpr uint8_t TSTEP_bp = 0;
constexpr uint32_t TSTEP_bm = 0xFFFFFUL;
// TPWMTHRS
constexpr uint8_t TPWMTHRS_bp = 0;
constexpr uint32_t TPWMTHRS_bm = 0xFFFFFUL;
// TCOOLTHRS
constexpr uint8_t TCOOLTHRS_bp = 0;
constexpr uint32_t TCOOLTHRS_bm = 0xFFFFFUL;
// THIGH
constexpr uint8_t THIGH_bp = 0;
constexpr uint32_t THIGH_bm = 0xFFFFFUL;
// XDIRECT
constexpr uint8_t XDIRECT_bp = 0;
constexpr uint32_t XDIRECT_bm = 0xFFFFFFFFUL;
constexpr uint8_t COIL_A_bp = 0;
constexpr uint8_t COIL_B_bp = 16;
constexpr uint32_t COIL_A_bm = 0x1FFUL;
constexpr uint32_t COIL_B_bm = 0x1FF0000UL;
// VDCMIN
constexpr uint8_t VDCMIN_bp = 0;
constexpr uint32_t VDCMIN_bm = 0x7FFFFFUL;
// MSLUT0
constexpr uint8_t MSLUT0_bp = 0;
constexpr uint32_t MSLUT0_bm = 0xFFFFFFFFUL;
// MSLUT1
constexpr uint8_t MSLUT1_bp = 0;
constexpr uint32_t MSLUT1_bm = 0xFFFFFFFFUL;
// MSLUT2
constexpr uint8_t MSLUT2_bp = 0;
constexpr uint32_t MSLUT2_bm = 0xFFFFFFFFUL;
// MSLUT3
constexpr uint8_t MSLUT3_bp = 0;
constexpr uint32_t MSLUT3_bm = 0xFFFFFFFFUL;
// MSLUT4
constexpr uint8_t MSLUT4_bp = 0;
constexpr uint32_t MSLUT4_bm = 0xFFFFFFFFUL;
// MSLUT5
constexpr uint8_t MSLUT5_bp = 0;
constexpr uint32_t MSLUT5_bm = 0xFFFFFFFFUL;
// MSLUT6
constexpr uint8_t MSLUT6_bp = 0;
constexpr uint32_t MSLUT6_bm = 0xFFFFFFFFUL;
// MSLUT7
constexpr uint8_t MSLUT7_bp = 0;
constexpr uint32_t MSLUT7_bm = 0xFFFFFFFFUL;
// MSLUTSEL
constexpr uint8_t MSLUTSEL_bp = 0;
constexpr uint32_t MSLUTSEL_bm = 0xFFFFFFFFUL;
// MSLUTSTART
constexpr uint8_t START_SIN_bp = 0;
constexpr uint8_t START_SIN90_bp = 16;
constexpr uint32_t START_SIN_bm = 0xFFUL;
constexpr uint32_t START_SIN90_bm = 0xFF0000UL;
// MSCNT
constexpr uint8_t MSCNT_bp = 0;
constexpr uint32_t MSCNT_bm = 0x3FFUL;
// MSCURACT
constexpr uint8_t CUR_A_bp = 0;
constexpr uint8_t CUR_B_bp = 16;
constexpr uint32_t CUR_A_bm = 0x1FFUL;
constexpr uint32_t CUR_B_bm = 0x1FF0000UL;
// CHOPCONF
constexpr uint8_t TOFF_bp = 0;
constexpr uint8_t HSTRT_bp = 4;
constexpr uint8_t FD_bp = 4;
constexpr uint8_t HEND_bp = 7;
constexpr uint8_t DISFDCC_bp = 12;
constexpr uint8_t RNDTF_bp = 13;
constexpr uint8_t CHM_bp = 14;
constexpr uint8_t TBL_bp = 15;
constexpr uint8_t VSENSE_bp = 17;
constexpr uint8_t VHIGHFS_bp = 18;
constexpr uint8_t VHIGHCHM_bp = 19;
constexpr uint8_t SYNC_bp = 20;
constexpr uint8_t MRES_bp = 24;
constexpr uint8_t INTPOL_bp = 28;
constexpr uint8_t DEDGE_bp = 29;
constexpr uint8_t DISS2G_bp = 30;
constexpr uint32_t CHOPCONF_bm = 0xFFFFFFFFUL;
constexpr uint32_t TOFF_bm = 0xFUL;
constexpr uint32_t HSTRT_bm = 0x70UL;
constexpr uint32_t FD_bm = 0x830UL;
constexpr uint32_t HEND_bm = 0x780UL;
constexpr uint32_t DISFDCC_bm = 0x1000UL;
constexpr uint32_t RNDTF_bm = 0x2000UL;
constexpr uint32_t CHM_bm = 0x4000UL;
constexpr uint32_t TBL_bm = 0x18000UL;
constexpr uint32_t VSENSE_bm = 0x20000UL;
constexpr uint32_t VHIGHFS_bm = 0x40000UL;
constexpr uint32_t VHIGHCHM_bm = 0x80000UL;
constexpr uint32_t SYNC_bm = 0xF00000UL;
constexpr uint32_t MRES_bm = 0xF000000UL;
constexpr uint32_t INTPOL_bm = 0x10000000UL;
constexpr uint32_t DEDGE_bm = 0x20000000UL;
constexpr uint32_t DISS2G_bm = 0x40000000UL;
// COOLCONF
constexpr uint8_t SEMIN_bp = 0;
constexpr uint8_t SEUP_bp = 5;
constexpr uint8_t SEMAX_bp = 8;
constexpr uint8_t SEDN_bp = 13;
constexpr uint8_t SEIMIN_bp = 15;
constexpr uint8_t SGT_bp = 16;
constexpr uint8_t SFILT_bp = 24;
constexpr uint32_t COOLCONF_bm = 0x3FFFFFFUL;
constexpr uint32_t SEMIN_bm = 0xFUL;
constexpr uint32_t SEUP_bm = 0x60UL;
constexpr uint32_t SEMAX_bm = 0xF00UL;
constexpr uint32_t SEDN_bm = 0x6000UL;
constexpr uint32_t SEIMIN_bm = 0x8000UL;
constexpr uint32_t SGT_bm = 0x7F0000UL;
constexpr uint32_t SFILT_bm = 0x1000000UL;
// DCCTRL
constexpr uint8_t DC_TIME_bp = 0;
constexpr uint8_t DC_SG_bp = 16;
constexpr uint32_t DC_TIME_bm = 0x3FFUL;
constexpr uint32_t DC_SG_bm = 0xFF0000UL;
// DRV_STATUS
constexpr uint8_t SG_RESULT_bp = 0;
constexpr uint8_t FSACTIVE_bp = 15;
constexpr uint8_t CS_ACTUAL_bp = 16;
constexpr uint8_t STALLGUARD_bp = 24;
constexpr uint8_t OT_bp = 25;
constexpr uint8_t OTPW_bp = 26;
constexpr uint8_t S2GA_bp = 27;
constexpr uint8_t S2GB_bp = 28;
constexpr uint8_t OLA_bp = 29;
constexpr uint8_t OLB_bp = 30;
constexpr uint8_t STST_bp = 31;
constexpr uint32_t DRV_STATUS_bm = 0xFFFFFFFFUL;
constexpr uint32_t SG_RESULT_bm = 0x3FFUL;
constexpr uint32_t FSACTIVE_bm = 0x8000UL;
constexpr uint32_t CS_ACTUAL_bm = 0x1F0000UL;
constexpr uint32_t STALLGUARD_bm = 0x1000000UL;
constexpr uint32_t OT_bm = 0x2000000UL;
constexpr uint32_t OTPW_bm = 0x4000000UL;
constexpr uint32_t S2GA_bm = 0x8000000UL;
constexpr uint32_t S2GB_bm = 0x10000000UL;
constexpr uint32_t OLA_bm = 0x20000000UL;
constexpr uint32_t OLB_bm = 0x40000000UL;
constexpr uint32_t STST_bm = 0x80000000UL;
// PWMCONF
constexpr uint8_t PWM_AMPL_bp = 0;
constexpr uint8_t PWM_GRAD_bp = 8;
constexpr uint8_t PWM_FREQ_bp = 16;
constexpr uint8_t PWM_AUTOSCALE_bp = 18;
constexpr uint8_t PWM_SYMMETRIC_bp = 19;
constexpr uint8_t FREEWHEEL_bp = 20;
constexpr uint32_t PWMCONF_bm = 0x7FFFFFUL;
constexpr uint32_t PWM_AMPL_bm = 0xFFUL;
constexpr uint32_t PWM_GRAD_bm = 0xFF00UL;
constexpr uint32_t PWM_FREQ_bm = 0x30000UL;
constexpr uint32_t PWM_AUTOSCALE_bm = 0x40000UL;
constexpr uint32_t PWM_SYMMETRIC_bm = 0x80000UL;
constexpr uint32_t FREEWHEEL_bm = 0x300000UL;
// PWM_SCALE
constexpr uint8_t PWM_SCALE_bp = 0;
constexpr uint32_t PWM_SCALE_bm = 0xFFUL;
// ENCM_CTRL
constexpr uint8_t INV_bp = 0;
constexpr uint8_t MAXSPEED_bp = 1;
constexpr uint32_t INV_bm = 0x1UL;
constexpr uint32_t MAXSPEED_bm = 0x2UL;
// LOST_STEPS
constexpr uint8_t LOST_STEPS_bp = 0;
constexpr uint32_t LOST_STEPS_bm = 0xFFFFFUL;
#endif

@ -0,0 +1,33 @@
#ifndef TMC2130Stepper_UTILITY_h
#define TMC2130Stepper_UTILITY_h
void print_HEX(uint32_t data) {
for(uint8_t B=24; B>=4; B-=8){
Serial.print((data>>(B+4))&0xF, HEX);
Serial.print((data>>B)&0xF, HEX);
Serial.print(":");
}
Serial.print((data>>4)&0xF, HEX);
Serial.print(data&0xF, HEX);
}
void print_BIN(uint32_t data) {
int b = 31;
for(; b>=24; b--){
Serial.print((data>>b)&0b1);
}
Serial.print(".");
for(; b>=16; b--){
Serial.print((data>>b)&0b1);
}
Serial.print(".");
for(; b>=8; b--){
Serial.print((data>>b)&0b1);
}
Serial.print(".");
for(; b>=0; b--){
Serial.print((data>>b)&0b1);
}
}
#endif

@ -0,0 +1,309 @@
#include <SPI.h>
#include "TMC2130Stepper.h"
#include "TMC2130Stepper_MACROS.h"
TMC2130Stepper::TMC2130Stepper(uint8_t pinEN, uint8_t pinDIR, uint8_t pinStep, uint8_t pinCS) {
_started = false;
this->_pinEN = pinEN;
this->_pinDIR = pinDIR;
this->_pinSTEP = pinStep;
this->_pinCS = pinCS;
begin();
}
void TMC2130Stepper::begin() {
#ifdef TMC2130DEBUG
Serial.println("TMC2130 Stepper driver library");
Serial.print("Enable pin: ");
Serial.println(_pinEN);
Serial.print("Direction pin: ");
Serial.println(_pinDIR);
Serial.print("Step pin: ");
Serial.println(_pinSTEP);
Serial.print("Chip select pin: ");
Serial.println(_pinCS);
#endif
//set pins
pinMode(_pinEN, OUTPUT);
pinMode(_pinDIR, OUTPUT);
pinMode(_pinSTEP, OUTPUT);
pinMode(_pinCS, OUTPUT);
digitalWrite(_pinEN, HIGH); //deactivate driver (LOW active)
digitalWrite(_pinDIR, LOW); //LOW or HIGH
digitalWrite(_pinSTEP, LOW);
digitalWrite(_pinCS, HIGH);
/*
pinMode(MOSI, OUTPUT);
pinMode(MISO, INPUT);
pinMode(SCK, OUTPUT);
digitalWrite(MOSI, LOW);
digitalWrite(MISO, HIGH);
digitalWrite(SCK, LOW);
SPI.begin();
*/
GCONF(GCONF_sr);
CHOPCONF(CHOPCONF_sr);
COOLCONF(COOLCONF_sr);
PWMCONF(PWMCONF_sr);
IHOLD_IRUN(IHOLD_IRUN_sr);
toff(8); //off_time(8);
tbl(1); //blank_time(24);
_started = true;
}
//uint32_t TMC2130Stepper::send2130(uint8_t addressByte, uint32_t *config, uint32_t value, uint32_t mask) {
void TMC2130Stepper::send2130(uint8_t addressByte, uint32_t *config) {
//uint8_t s;
SPI.begin();
SPI.beginTransaction(SPISettings(16000000/8, MSBFIRST, SPI_MODE3));
digitalWrite(_pinCS, LOW);
status_response = SPI.transfer(addressByte & 0xFF); // s =
#ifdef TMC2130DEBUG
Serial.println("## Received parameters:");
Serial.print("## Address byte: ");
Serial.println(addressByte, HEX);
Serial.print("## Config: ");
Serial.println(*config, BIN);
Serial.print("## status_response: ");
Serial.println(status_response, BIN);
#endif
if (addressByte >> 7) { // Check if WRITE command
//*config &= ~mask; // Clear bits being set
//*config |= (value & mask); // Set new values
SPI.transfer((*config >> 24) & 0xFF);
SPI.transfer((*config >> 16) & 0xFF);
SPI.transfer((*config >> 8) & 0xFF);
SPI.transfer(*config & 0xFF);
#ifdef TMC2130DEBUG
Serial.println("## WRITE cmd");
Serial.println("##########################");
#endif
} else { // READ command
SPI.transfer16(0x0000); // Clear SPI
SPI.transfer16(0x0000);
digitalWrite(_pinCS, HIGH);
digitalWrite(_pinCS, LOW);
SPI.transfer(addressByte & 0xFF); // Send the address byte again
*config = SPI.transfer(0x00);
*config <<= 8;
*config |= SPI.transfer(0x00);
*config <<= 8;
*config |= SPI.transfer(0x00);
*config <<= 8;
*config |= SPI.transfer(0x00);
#ifdef TMC2130DEBUG
Serial.println("## READ cmd");
Serial.print("## Received config: ");
Serial.println(*config, BIN);
Serial.println("##########################");
#endif
}
digitalWrite(_pinCS, HIGH);
SPI.endTransaction();
//return s;
}
bool TMC2130Stepper::checkOT() {
uint32_t response = DRV_STATUS();
if (response & OTPW_bm) {
flag_otpw = 1;
return true; // bit 26 for overtemperature warning flag
}
return false;
}
bool TMC2130Stepper::getOTPW() { return flag_otpw; }
void TMC2130Stepper::clear_otpw() { flag_otpw = 0; }
bool TMC2130Stepper::isEnabled() { return !digitalRead(_pinEN) && toff(); }
///////////////////////////////////////////////////////////////////////////////////////
// R+C: GSTAT
void TMC2130Stepper::GSTAT(uint8_t input){
GSTAT_sr = input;
WRITE_REG(GSTAT);
}
uint8_t TMC2130Stepper::GSTAT() { READ_REG_R(GSTAT); }
bool TMC2130Stepper::reset() { GET_BYTE(GSTAT, RESET); }
bool TMC2130Stepper::drv_err() { GET_BYTE(GSTAT, DRV_ERR); }
bool TMC2130Stepper::uv_cp() { GET_BYTE(GSTAT, UV_CP); }
///////////////////////////////////////////////////////////////////////////////////////
// R: IOIN
uint32_t TMC2130Stepper::IOIN() { READ_REG_R(IOIN); }
bool TMC2130Stepper::step() { GET_BYTE_R(IOIN, STEP); }
bool TMC2130Stepper::dir() { GET_BYTE_R(IOIN, DIR); }
bool TMC2130Stepper::dcen_cfg4() { GET_BYTE_R(IOIN, DCEN_CFG4); }
bool TMC2130Stepper::dcin_cfg5() { GET_BYTE_R(IOIN, DCIN_CFG5); }
bool TMC2130Stepper::drv_enn_cfg6() { GET_BYTE_R(IOIN, DRV_ENN_CFG6); }
bool TMC2130Stepper::dco() { GET_BYTE_R(IOIN, DCO); }
uint8_t TMC2130Stepper::version() { GET_BYTE_R(IOIN, VERSION); }
///////////////////////////////////////////////////////////////////////////////////////
// W: TPOWERDOWN
uint32_t TMC2130Stepper::TPOWERDOWN() { return TPOWERDOWN_sr; }
void TMC2130Stepper::TPOWERDOWN(uint32_t input) {
TPOWERDOWN_sr = input;
WRITE_REG(TPOWERDOWN);
}
///////////////////////////////////////////////////////////////////////////////////////
// R: TSTEP
uint32_t TMC2130Stepper::TSTEP() { READ_REG_R(TSTEP); }
///////////////////////////////////////////////////////////////////////////////////////
// W: TPWMTHRS
uint32_t TMC2130Stepper::TPWMTHRS() { return TPWMTHRS_sr; }
void TMC2130Stepper::TPWMTHRS(uint32_t input) {
TPWMTHRS_sr = input;
WRITE_REG(TPWMTHRS);
}
///////////////////////////////////////////////////////////////////////////////////////
// W: TCOOLTHRS
uint32_t TMC2130Stepper::TCOOLTHRS() { return TCOOLTHRS_sr; }
void TMC2130Stepper::TCOOLTHRS(uint32_t input) {
TCOOLTHRS_sr = input;
WRITE_REG(TCOOLTHRS);
}
///////////////////////////////////////////////////////////////////////////////////////
// W: THIGH
uint32_t TMC2130Stepper::THIGH() { return THIGH_sr; }
void TMC2130Stepper::THIGH(uint32_t input) {
THIGH_sr = input;
WRITE_REG(THIGH);
}
///////////////////////////////////////////////////////////////////////////////////////
// RW: XDIRECT
uint32_t TMC2130Stepper::XDIRECT() { READ_REG(XDIRECT); }
void TMC2130Stepper::XDIRECT(uint32_t input) {
XDIRECT_sr = input;
WRITE_REG(XDIRECT);
}
void TMC2130Stepper::coil_A(int16_t B) { MOD_REG(XDIRECT, COIL_A); }
void TMC2130Stepper::coil_B(int16_t B) { MOD_REG(XDIRECT, COIL_B); }
int16_t TMC2130Stepper::coil_A() { GET_BYTE_R(XDIRECT, COIL_A); }
int16_t TMC2130Stepper::coil_B() { GET_BYTE_R(XDIRECT, COIL_A); }
///////////////////////////////////////////////////////////////////////////////////////
// W: VDCMIN
uint32_t TMC2130Stepper::VDCMIN() { return VDCMIN_sr; }
void TMC2130Stepper::VDCMIN(uint32_t input) {
VDCMIN_sr = input;
WRITE_REG(VDCMIN);
}
///////////////////////////////////////////////////////////////////////////////////////
// R: PWM_SCALE
uint8_t TMC2130Stepper::PWM_SCALE() { READ_REG_R(PWM_SCALE); }
///////////////////////////////////////////////////////////////////////////////////////
// W: ENCM_CTRL
uint8_t TMC2130Stepper::ENCM_CTRL() { return ENCM_CTRL_sr; }
void TMC2130Stepper::ENCM_CTRL(uint8_t input) {
ENCM_CTRL_sr = input;
WRITE_REG(ENCM_CTRL);
}
void TMC2130Stepper::inv(bool B) { MOD_REG(ENCM_CTRL, INV); }
void TMC2130Stepper::maxspeed(bool B) { MOD_REG(ENCM_CTRL, MAXSPEED); }
bool TMC2130Stepper::inv() { GET_BYTE(ENCM_CTRL, INV); }
bool TMC2130Stepper::maxspeed() { GET_BYTE(ENCM_CTRL, MAXSPEED);}
///////////////////////////////////////////////////////////////////////////////////////
// R: LOST_STEPS
uint32_t TMC2130Stepper::LOST_STEPS() { READ_REG_R(LOST_STEPS); }
/**
* Helper functions
*/
/*
Requested current = mA = I_rms/1000
Equation for current:
I_rms = (CS+1)/32 * V_fs/(R_sense+0.02ohm) * 1/sqrt(2)
Solve for CS ->
CS = 32*sqrt(2)*I_rms*(R_sense+0.02)/V_fs - 1
Example:
vsense = 0b0 -> V_fs = 0.325V
mA = 1640mA = I_rms/1000 = 1.64A
R_sense = 0.10 Ohm
->
CS = 32*sqrt(2)*1.64*(0.10+0.02)/0.325 - 1 = 26.4
CS = 26
*/
void TMC2130Stepper::rms_current(uint16_t mA, float multiplier, float RS) {
Rsense = RS;
uint8_t CS = 32.0*1.41421*mA/1000.0*(Rsense+0.02)/0.325 - 1;
// If Current Scale is too low, turn on high sensitivity R_sense and calculate again
if (CS < 16) {
vsense(true);
CS = 32.0*1.41421*mA/1000.0*(Rsense+0.02)/0.180 - 1;
} else if(vsense()) { // If CS >= 16, turn off high_sense_r if it's currently ON
vsense(false);
}
irun(CS);
ihold(CS*multiplier);
val_mA = mA;
}
uint16_t TMC2130Stepper::rms_current() {
return (float)(irun()+1)/32.0 * (vsense()?0.180:0.325)/(Rsense+0.02) / 1.41421 * 1000;
}
void TMC2130Stepper::setCurrent(uint16_t mA, float R, float multiplier) { rms_current(mA, multiplier, R); }
uint16_t TMC2130Stepper::getCurrent() { return val_mA; }
void TMC2130Stepper::SilentStepStick2130(uint16_t current) { rms_current(current); }
void TMC2130Stepper::microsteps(uint16_t ms) {
switch(ms) {
case 256: mres(0); break;
case 128: mres(1); break;
case 64: mres(2); break;
case 32: mres(3); break;
case 16: mres(4); break;
case 8: mres(5); break;
case 4: mres(6); break;
case 2: mres(7); break;
case 0: mres(8); break;
default: break;
}
}
uint16_t TMC2130Stepper::microsteps() {
switch(mres()) {
case 0: return 256;
case 1: return 128;
case 2: return 64;
case 3: return 32;
case 4: return 16;
case 5: return 8;
case 6: return 4;
case 7: return 2;
case 8: return 0;
}
return 0;
}
void TMC2130Stepper::sg_current_decrease(uint8_t value) {
switch(value) {
case 32: sedn(0b00); break;
case 8: sedn(0b01); break;
case 2: sedn(0b10); break;
case 1: sedn(0b11); break;
}
}
uint8_t TMC2130Stepper::sg_current_decrease() {
switch(sedn()) {
case 0b00: return 32;
case 0b01: return 8;
case 0b10: return 2;
case 0b11: return 1;
}
return 0;
}

@ -0,0 +1,68 @@
#include "TMC2130Stepper.h"
#include "TMC2130Stepper_MACROS.h"
// CHOPCONF
uint32_t TMC2130Stepper::CHOPCONF() { READ_REG(CHOPCONF); }
void TMC2130Stepper::CHOPCONF(uint32_t input) {
CHOPCONF_sr = input;
WRITE_REG(CHOPCONF);
}
void TMC2130Stepper::toff( uint8_t B ) { MOD_REG(CHOPCONF, TOFF); }
void TMC2130Stepper::hstrt( uint8_t B ) { MOD_REG(CHOPCONF, HSTRT); }
void TMC2130Stepper::hend( int8_t B ) { MOD_REG(CHOPCONF, HEND); }
void TMC2130Stepper::fd( uint8_t B ) { MOD_REG(CHOPCONF, FD); }
void TMC2130Stepper::disfdcc( bool B ) { MOD_REG(CHOPCONF, DISFDCC); }
void TMC2130Stepper::rndtf( bool B ) { MOD_REG(CHOPCONF, RNDTF); }
void TMC2130Stepper::chm( bool B ) { MOD_REG(CHOPCONF, CHM); }
void TMC2130Stepper::tbl( uint8_t B ) { MOD_REG(CHOPCONF, TBL); }
void TMC2130Stepper::vsense( bool B ) { MOD_REG(CHOPCONF, VSENSE); }
void TMC2130Stepper::vhighfs( bool B ) { MOD_REG(CHOPCONF, VHIGHFS); }
void TMC2130Stepper::vhighchm( bool B ) { MOD_REG(CHOPCONF, VHIGHCHM); }
void TMC2130Stepper::sync( uint8_t B ) { MOD_REG(CHOPCONF, SYNC); }
void TMC2130Stepper::mres( uint8_t B ) { MOD_REG(CHOPCONF, MRES); }
void TMC2130Stepper::intpol( bool B ) { MOD_REG(CHOPCONF, INTPOL); }
void TMC2130Stepper::dedge( bool B ) { MOD_REG(CHOPCONF, DEDGE); }
void TMC2130Stepper::diss2g( bool B ) { MOD_REG(CHOPCONF, DISS2G); }
uint8_t TMC2130Stepper::toff() { GET_BYTE(CHOPCONF, TOFF); }
uint8_t TMC2130Stepper::hstrt() { GET_BYTE(CHOPCONF, HSTRT); }
int8_t TMC2130Stepper::hend() { GET_BYTE(CHOPCONF, HEND); }
uint8_t TMC2130Stepper::fd() { GET_BYTE(CHOPCONF, FD); }
bool TMC2130Stepper::disfdcc() { GET_BYTE(CHOPCONF, DISFDCC); }
bool TMC2130Stepper::rndtf() { GET_BYTE(CHOPCONF, RNDTF); }
bool TMC2130Stepper::chm() { GET_BYTE(CHOPCONF, CHM); }
uint8_t TMC2130Stepper::tbl() { GET_BYTE(CHOPCONF, TBL); }
bool TMC2130Stepper::vsense() { GET_BIT( CHOPCONF, VSENSE); }
bool TMC2130Stepper::vhighfs() { GET_BYTE(CHOPCONF, VHIGHFS); }
bool TMC2130Stepper::vhighchm() { GET_BYTE(CHOPCONF, VHIGHCHM); }
uint8_t TMC2130Stepper::sync() { GET_BYTE(CHOPCONF, SYNC); }
uint8_t TMC2130Stepper::mres() { GET_BYTE(CHOPCONF, MRES); }
bool TMC2130Stepper::intpol() { GET_BYTE(CHOPCONF, INTPOL); }
bool TMC2130Stepper::dedge() { GET_BYTE(CHOPCONF, DEDGE); }
bool TMC2130Stepper::diss2g() { GET_BYTE(CHOPCONF, DISS2G); }
void TMC2130Stepper::hysterisis_end(int8_t value) { hend(value+3); }
int8_t TMC2130Stepper::hysterisis_end() { return hend()-3; };
void TMC2130Stepper::hysterisis_start(uint8_t value) { hstrt(value-1); }
uint8_t TMC2130Stepper::hysterisis_start() { return hstrt()+1; }
void TMC2130Stepper::blank_time(uint8_t value) {
switch (value) {
case 16: tbl(0b00); break;
case 24: tbl(0b01); break;
case 36: tbl(0b10); break;
case 54: tbl(0b11); break;
}
}
uint8_t TMC2130Stepper::blank_time() {
switch (tbl()) {
case 0b00: return 16;
case 0b01: return 24;
case 0b10: return 36;
case 0b11: return 54;
}
return 0;
}

@ -0,0 +1,25 @@
#include "TMC2130Stepper.h"
#include "TMC2130Stepper_MACROS.h"
// COOLCONF
uint32_t TMC2130Stepper::COOLCONF() { return COOLCONF_sr; }
void TMC2130Stepper::COOLCONF(uint32_t input) {
COOLCONF_sr = input;
WRITE_REG(COOLCONF);
}
void TMC2130Stepper::semin( uint8_t B ) { MOD_REG(COOLCONF, SEMIN); }
void TMC2130Stepper::seup( uint8_t B ) { MOD_REG(COOLCONF, SEUP); }
void TMC2130Stepper::semax( uint8_t B ) { MOD_REG(COOLCONF, SEMAX); }
void TMC2130Stepper::sedn( uint8_t B ) { MOD_REG(COOLCONF, SEDN); }
void TMC2130Stepper::seimin( bool B ) { MOD_REG(COOLCONF, SEIMIN); }
void TMC2130Stepper::sgt( uint8_t B ) { MOD_REG(COOLCONF, SGT); }
void TMC2130Stepper::sfilt( bool B ) { MOD_REG(COOLCONF, SFILT); }
uint8_t TMC2130Stepper::semin() { GET_BYTE(COOLCONF, SEMIN); }
uint8_t TMC2130Stepper::seup() { GET_BYTE(COOLCONF, SEUP); }
uint8_t TMC2130Stepper::semax() { GET_BYTE(COOLCONF, SEMAX); }
uint8_t TMC2130Stepper::sedn() { GET_BYTE(COOLCONF, SEDN); }
bool TMC2130Stepper::seimin() { GET_BYTE(COOLCONF, SEIMIN); }
uint8_t TMC2130Stepper::sgt() { GET_BYTE(COOLCONF, SGT); }
bool TMC2130Stepper::sfilt() { GET_BYTE(COOLCONF, SFILT); }

@ -0,0 +1,29 @@
#include "TMC2130Stepper.h"
#include "TMC2130Stepper_MACROS.h"
uint32_t TMC2130Stepper::DRV_STATUS() { READ_REG_R(DRV_STATUS); }
uint16_t TMC2130Stepper::sg_result(){ GET_BYTE_R(DRV_STATUS, SG_RESULT); }
bool TMC2130Stepper::fsactive() { GET_BYTE_R(DRV_STATUS, FSACTIVE); }
uint8_t TMC2130Stepper::cs_actual() { GET_BYTE_R(DRV_STATUS, CS_ACTUAL); }
bool TMC2130Stepper::stallguard() { GET_BYTE_R(DRV_STATUS, STALLGUARD); }
bool TMC2130Stepper::ot() { GET_BYTE_R(DRV_STATUS, OT); }
bool TMC2130Stepper::otpw() { GET_BYTE_R(DRV_STATUS, OTPW); }
bool TMC2130Stepper::s2ga() { GET_BYTE_R(DRV_STATUS, S2GA); }
bool TMC2130Stepper::s2gb() { GET_BYTE_R(DRV_STATUS, S2GB); }
bool TMC2130Stepper::ola() { GET_BYTE_R(DRV_STATUS, OLA); }
bool TMC2130Stepper::olb() { GET_BYTE_R(DRV_STATUS, OLB); }
bool TMC2130Stepper::stst() { GET_BYTE_R(DRV_STATUS, STST); }
/*
uint16_t TMC2130Stepper::sg_result() {
uint32_t drv_status = 0x00000000UL;
Serial.print("drv_status=");
Serial.print(drv_status);
drv_status = DRV_STATUS();
Serial.print("\tdrv_status=");
Serial.print(drv_status);
Serial.print("\t");
return drv_status&SG_RESULT_bm;
}
*/

@ -0,0 +1,54 @@
#include "TMC2130Stepper.h"
#include "TMC2130Stepper_MACROS.h"
// GCONF
uint32_t TMC2130Stepper::GCONF() { READ_REG(GCONF); }
void TMC2130Stepper::GCONF(uint32_t input) {
GCONF_sr = input;
WRITE_REG(GCONF);
}
void TMC2130Stepper::I_scale_analog(bool B) { MOD_REG(GCONF, I_SCALE_ANALOG); }
void TMC2130Stepper::internal_Rsense(bool B) { MOD_REG(GCONF, INTERNAL_RSENSE); }
void TMC2130Stepper::en_pwm_mode(bool B) { MOD_REG(GCONF, EN_PWM_MODE); }
void TMC2130Stepper::enc_commutation(bool B) { MOD_REG(GCONF, ENC_COMMUTATION); }
void TMC2130Stepper::shaft(bool B) { MOD_REG(GCONF, SHAFT); }
void TMC2130Stepper::diag0_error(bool B) { MOD_REG(GCONF, DIAG0_ERROR); }
void TMC2130Stepper::diag0_otpw(bool B) { MOD_REG(GCONF, DIAG0_OTPW); }
void TMC2130Stepper::diag0_stall(bool B) { MOD_REG(GCONF, DIAG0_STALL); }
void TMC2130Stepper::diag1_stall(bool B) { MOD_REG(GCONF, DIAG1_STALL); }
void TMC2130Stepper::diag1_index(bool B) { MOD_REG(GCONF, DIAG1_INDEX); }
void TMC2130Stepper::diag1_onstate(bool B) { MOD_REG(GCONF, DIAG1_ONSTATE); }
void TMC2130Stepper::diag1_steps_skipped(bool B) { MOD_REG(GCONF, DIAG1_STEPS_SKIPPED); }
void TMC2130Stepper::diag0_int_pushpull(bool B) { MOD_REG(GCONF, DIAG0_INT_PUSHPULL); }
void TMC2130Stepper::diag1_pushpull(bool B) { MOD_REG(GCONF, DIAG1_PUSHPULL); }
void TMC2130Stepper::small_hysterisis(bool B) { MOD_REG(GCONF, SMALL_HYSTERISIS); }
void TMC2130Stepper::stop_enable(bool B) { MOD_REG(GCONF, STOP_ENABLE); }
void TMC2130Stepper::direct_mode(bool B) { MOD_REG(GCONF, DIRECT_MODE); }
bool TMC2130Stepper::I_scale_analog() { GET_BYTE(GCONF, I_SCALE_ANALOG); }
bool TMC2130Stepper::internal_Rsense() { GET_BYTE(GCONF, INTERNAL_RSENSE); }
bool TMC2130Stepper::en_pwm_mode() { GET_BYTE(GCONF, EN_PWM_MODE); }
bool TMC2130Stepper::enc_commutation() { GET_BYTE(GCONF, ENC_COMMUTATION); }
bool TMC2130Stepper::shaft() { GET_BYTE(GCONF, SHAFT); }
bool TMC2130Stepper::diag0_error() { GET_BYTE(GCONF, DIAG0_ERROR); }
bool TMC2130Stepper::diag0_otpw() { GET_BYTE(GCONF, DIAG0_OTPW); }
bool TMC2130Stepper::diag0_stall() { GET_BYTE(GCONF, DIAG0_STALL); }
bool TMC2130Stepper::diag1_stall() { GET_BYTE(GCONF, DIAG1_STALL); }
bool TMC2130Stepper::diag1_index() { GET_BYTE(GCONF, DIAG1_INDEX); }
bool TMC2130Stepper::diag1_onstate() { GET_BYTE(GCONF, DIAG1_ONSTATE); }
bool TMC2130Stepper::diag1_steps_skipped() { GET_BYTE(GCONF, DIAG1_STEPS_SKIPPED); }
bool TMC2130Stepper::diag0_int_pushpull() { GET_BYTE(GCONF, DIAG0_INT_PUSHPULL); }
bool TMC2130Stepper::diag1_pushpull() { GET_BYTE(GCONF, DIAG1_PUSHPULL); }
bool TMC2130Stepper::small_hysterisis() { GET_BYTE(GCONF, SMALL_HYSTERISIS); }
bool TMC2130Stepper::stop_enable() { GET_BYTE(GCONF, STOP_ENABLE); }
bool TMC2130Stepper::direct_mode() { GET_BYTE(GCONF, DIRECT_MODE); }
/*
bit 18 not implemented:
test_mode 0:
Normal operation 1:
Enable analog test output on pin DCO. IHOLD[1..0] selects the function of DCO:
02: T120, DAC, VDDH Attention:
Not for user, set to 0 for normal operation!
*/

@ -0,0 +1,16 @@
#include "TMC2130Stepper.h"
#include "TMC2130Stepper_MACROS.h"
// IHOLD_IRUN
void TMC2130Stepper::IHOLD_IRUN(uint32_t input) {
IHOLD_IRUN_sr = input;
WRITE_REG(IHOLD_IRUN);
}
uint32_t TMC2130Stepper::IHOLD_IRUN() { return IHOLD_IRUN_sr; }
void TMC2130Stepper::ihold(uint8_t B) { MOD_REG(IHOLD_IRUN, IHOLD); }
void TMC2130Stepper::irun(uint8_t B) { MOD_REG(IHOLD_IRUN, IRUN); }
void TMC2130Stepper::iholddelay(uint8_t B) { MOD_REG(IHOLD_IRUN, IHOLDDELAY); }
uint8_t TMC2130Stepper::ihold() { GET_BYTE(IHOLD_IRUN, IHOLD); }
uint8_t TMC2130Stepper::irun() { GET_BYTE(IHOLD_IRUN, IRUN); }
uint8_t TMC2130Stepper::iholddelay() { GET_BYTE(IHOLD_IRUN, IHOLDDELAY); }

@ -0,0 +1,22 @@
#ifndef TMC2130Stepper_MACROS_H
#define TMC2130Stepper_MACROS_H
#include "TMC2130Stepper.h"
#include "../TMC2130Stepper_REGDEFS.h"
#define WRITE_REG(R) send2130(TMC2130_WRITE|REG_##R, &R##_sr);
#define READ_REG(R) send2130(TMC2130_READ|REG_##R, &R##_sr); return R##_sr
#define READ_REG_R(R) tmp_sr=0; send2130(TMC2130_READ|REG_##R, &tmp_sr); return tmp_sr;
#define MOD_REG(REG, SETTING) REG##_sr &= ~SETTING##_bm; \
REG##_sr |= ((uint32_t)B<<SETTING##_bp)&SETTING##_bm; \
WRITE_REG(REG);
#define GET_BYTE(REG, SETTING) return (REG()&SETTING##_bm) >> SETTING##_bp;
#define GET_BYTE_R(REG, SETTING) return (REG()&SETTING##_bm) >> SETTING##_bp;
#define GET_BIT(REG, SETTING) return (bool)((REG()&SETTING##_bm) >> SETTING##_bp);
#endif

@ -0,0 +1,24 @@
#include "TMC2130Stepper.h"
#include "TMC2130Stepper_MACROS.h"
// PWMCONF
uint32_t TMC2130Stepper::PWMCONF() { return PWMCONF_sr; }
void TMC2130Stepper::PWMCONF(uint32_t input) {
PWMCONF_sr = input;
WRITE_REG(PWMCONF);
}
void TMC2130Stepper::pwm_ampl( uint8_t B ) { MOD_REG(PWMCONF, PWM_AMPL); }
void TMC2130Stepper::pwm_grad( uint8_t B ) { MOD_REG(PWMCONF, PWM_GRAD); }
void TMC2130Stepper::pwm_freq( uint8_t B ) { MOD_REG(PWMCONF, PWM_FREQ); }
void TMC2130Stepper::pwm_autoscale( bool B ) { MOD_REG(PWMCONF, PWM_AUTOSCALE); }
void TMC2130Stepper::pwm_symmetric( bool B ) { MOD_REG(PWMCONF, PWM_SYMMETRIC); }
void TMC2130Stepper::freewheel( uint8_t B ) { MOD_REG(PWMCONF, FREEWHEEL); }
uint8_t TMC2130Stepper::pwm_ampl() { GET_BYTE(PWMCONF, PWM_AMPL); }
uint8_t TMC2130Stepper::pwm_grad() { GET_BYTE(PWMCONF, PWM_GRAD); }
uint8_t TMC2130Stepper::pwm_freq() { GET_BYTE(PWMCONF, PWM_FREQ); }
bool TMC2130Stepper::pwm_autoscale() { GET_BYTE(PWMCONF, PWM_AUTOSCALE); }
bool TMC2130Stepper::pwm_symmetric() { GET_BYTE(PWMCONF, PWM_SYMMETRIC); }
uint8_t TMC2130Stepper::freewheel() { GET_BYTE(PWMCONF, FREEWHEEL); }

@ -13,13 +13,17 @@
* got disabled.
*/
#define LULZBOT_FW_VERSION ".24" // Change this with each update
#define LULZBOT_FW_VERSION ".25" // Change this with each update
#if ( \
!defined(LULZBOT_Gladiola_Mini) && \
!defined(LULZBOT_Hibiscus_Mini2) && \
!defined(LULZBOT_Gladiola_MiniLCD) && \
!defined(LULZBOT_Hibiscus_Mini2LCD) && \
!defined(LULZBOT_Gladiola_EinsyMini) && \
!defined(LULZBOT_Hibiscus_EinsyMini2) && \
!defined(LULZBOT_Gladiola_EinsyMiniLCD) && \
!defined(LULZBOT_Hibiscus_EinsyMini2LCD) && \
!defined(LULZBOT_Juniper_TAZ5) && \
!defined(LULZBOT_Oliveoil_TAZ6) && \
!defined(LULZBOT_Quiver_TAZ7) \
@ -56,6 +60,38 @@
#define LULZBOT_UUID "351487b6-ca9a-4c1a-8765-d668b1da6585"
#endif
#if defined(LULZBOT_Gladiola_EinsyMini)
/* Modified Gladiola Mini with Einsy board and half-height
* X & Y motors (full-height Z motors must be re-wired in
* series). X & Y endstops replaced w/ bumpers. */
#define LULZBOT_CUSTOM_MACHINE_NAME "LulzBot Mini"
#define LULZBOT_LCD_MACHINE_NAME "Mini Einsy"
#define LULZBOT_IS_MINI
#define LULZBOT_MINI_BED
#define LULZBOT_USE_EINSYRAMBO
#define LULZBOT_USE_EARLY_EINSY
#define LULZBOT_USE_AUTOLEVELING
#define LULZBOT_SENSORLESS_HOMING
#define LULZBOT_USE_Z_SCREW
#define LULZBOT_BAUDRATE 115200
#define LULZBOT_UUID "4479bf92-7e47-4c2c-be95-64dd01bd413b"
#endif
#if defined(LULZBOT_Gladiola_EinsyMiniLCD)
#define LULZBOT_CUSTOM_MACHINE_NAME "LulzBot Mini"
#define LULZBOT_LCD_MACHINE_NAME "Mini Einsy"
#define LULZBOT_IS_MINI
#define LULZBOT_MINI_BED
#define LULZBOT_USE_EINSYRAMBO
#define LULZBOT_USE_EARLY_EINSY
#define LULZBOT_USE_LCD_DISPLAY
#define LULZBOT_USE_AUTOLEVELING
#define LULZBOT_SENSORLESS_HOMING
#define LULZBOT_USE_Z_SCREW
#define LULZBOT_BAUDRATE 115200
#define LULZBOT_UUID "4479bf92-7e47-4c2c-be95-64dd01bd413b"
#endif
#if defined(LULZBOT_Hibiscus_Mini2)
#define LULZBOT_CUSTOM_MACHINE_NAME "LulzBot Mini 2"
#define LULZBOT_LCD_MACHINE_NAME "Mini 2"
@ -72,6 +108,39 @@
#define LULZBOT_UUID "1b8d32d3-0596-4335-8cd4-f3741a095087"
#endif
#if defined(LULZBOT_Hibiscus_EinsyMini2)
#define LULZBOT_CUSTOM_MACHINE_NAME "LulzBot Mini 2"
#define LULZBOT_LCD_MACHINE_NAME "Mini Einsy 2"
#define LULZBOT_IS_MINI
#define LULZBOT_MINI_BED
#define LULZBOT_USE_EINSYRAMBO
#define LULZBOT_USE_EARLY_EINSY
#define LULZBOT_TWO_PIECE_BED
#define LULZBOT_USE_AUTOLEVELING
#define LULZBOT_SENSORLESS_HOMING
#define LULZBOT_USE_Z_BELT
#define LULZBOT_BAUDRATE 250000
#define LULZBOT_PRINTCOUNTER
#define LULZBOT_UUID "e5502411-d46d-421d-ba3a-a20126d7930f"
#endif
#if defined(LULZBOT_Hibiscus_EinsyMini2LCD)
#define LULZBOT_CUSTOM_MACHINE_NAME "LulzBot Mini 2"
#define LULZBOT_LCD_MACHINE_NAME "Mini Einsy 2"
#define LULZBOT_IS_MINI
#define LULZBOT_MINI_BED
#define LULZBOT_USE_EINSYRAMBO
#define LULZBOT_USE_EARLY_EINSY
#define LULZBOT_USE_LCD_DISPLAY
#define LULZBOT_TWO_PIECE_BED
#define LULZBOT_USE_AUTOLEVELING
#define LULZBOT_SENSORLESS_HOMING
#define LULZBOT_USE_Z_BELT
#define LULZBOT_BAUDRATE 250000
#define LULZBOT_PRINTCOUNTER
#define LULZBOT_UUID "e5502411-d46d-421d-ba3a-a20126d7930f"
#endif
#if defined(LULZBOT_Gladiola_MiniLCD)
#define LULZBOT_CUSTOM_MACHINE_NAME "LulzBot Mini"
#define LULZBOT_LCD_MACHINE_NAME "Mini LCD"
@ -202,7 +271,12 @@
#define LULZBOT_NORMALLY_OPEN_ENDSTOP true
#define LULZBOT_NO_ENDSTOP true
#if defined(LULZBOT_IS_MINI)
#if defined(LULZBOT_IS_MINI) && defined(LULZBOT_USE_EINSYRAMBO)
// Experimental Mini retrofitted with EinsyRambo from UltiMachine
#define LULZBOT_MOTHERBOARD BOARD_EINSYRAMBO
#define LULZBOT_CONTROLLER_FAN_PIN FAN1_PIN // Digital pin 6
#elif defined(LULZBOT_IS_MINI)
#define LULZBOT_MOTHERBOARD BOARD_MINIRAMBO
#define LULZBOT_CONTROLLER_FAN_PIN FAN1_PIN // Digital pin 6
@ -961,6 +1035,195 @@
#define LULZBOT_Z_MIN_ENDSTOP_INVERTING LULZBOT_NORMALLY_OPEN_ENDSTOP
#define LULZBOT_Z_MIN_PROBE_ENDSTOP_INVERTING LULZBOT_NORMALLY_OPEN_ENDSTOP
/******************************* SENSORLESS HOMING ******************************/
#if defined(LULZBOT_USE_EINSYRAMBO)
#define LULZBOT_HAVE_TMC2130
// EinsyRambo uses a 220 mOhm sense resistor
#define LULZBOT_R_SENSE 0.22
#define LULZBOT_HOLD_MULTIPLIER 0.5
#define LULZBOT_TMC_INIT(st) \
/* The EinsyRambo connects both diag pins to the same */ \
/* microcontroller pin and provides a pull up resistor, */ \
/* so configure the pin as active low. */ \
st.diag0_active_high(0); \
st.diag1_active_high(0); \
st.diag1_stall(1); \
/* Reverse the motor direction so it matches the Rambo */ \
st.shaft_dir(1); \
st.external_ref(0); /* I_scale_analog = 0 */ \
st.internal_sense_R(0); /* internal_Rsense = 0 */
#define LULZBOT_TMC_REPORT(AXIS) \
{ \
uint32_t DRVSTATUS = stepper##AXIS.DRV_STATUS(); \
uint32_t IOIN = stepper##AXIS.IOIN(); \
uint32_t IHOLD_IRUN = stepper##AXIS.IHOLD_IRUN(); \
uint32_t CHOPCONF = stepper##AXIS.CHOPCONF(); \
uint32_t COOLCONF = stepper##AXIS.COOLCONF(); \
int8_t SGT = (COOLCONF >> 16) & 0b1111111; \
uint16_t SG_RESULT = (DRVSTATUS) & 0b111111111; \
bool drv_enn = (IOIN >> 4) & 0b1; \
bool stst = (DRVSTATUS >> 31) & 0b1; \
bool olb = (DRVSTATUS >> 30) & 0b1; \
bool ola = (DRVSTATUS >> 29) & 0b1; \
bool s2gb = (DRVSTATUS >> 28) & 0b1; \
bool s2ga = (DRVSTATUS >> 27) & 0b1; \
bool otpw = (DRVSTATUS >> 26) & 0b1; \
bool ot = (DRVSTATUS >> 25) & 0b1; \
bool fsactive = (DRVSTATUS >> 15) & 0b1; \
uint16_t ihold = (IHOLD_IRUN) & 0b11111; \
uint16_t irun = (IHOLD_IRUN >> 8) & 0b11111; \
bool vsense = (CHOPCONF >> 17) & 0b1; \
SERIAL_ECHOPGM(" " #AXIS ":"); \
SERIAL_ECHOPGM(" ihr:"); \
SERIAL_ECHO(ihold); \
SERIAL_ECHOPGM("/"); \
SERIAL_ECHO(irun); \
SERIAL_ECHOPGM(" vsen:"); \
SERIAL_ECHO(vsense); \
if(stepper##AXIS.coolstep_min_speed() == 1024UL * 1024UL - 1UL) { \
SERIAL_ECHOPGM(" sgt:"); \
SERIAL_ECHO(LULZBOT_SIGN_EXTEND_SGT(SGT)); \
if(num_sg > 0) { \
SERIAL_ECHOPGM(" avg_sg:"); \
SERIAL_ECHO(sum_sg_##AXIS/num_sg); \
} \
} else { \
SERIAL_ECHOPGM(" stealth"); \
} \
if(!drv_enn) SERIAL_ECHOPGM(" en"); \
if(stst) SERIAL_ECHOPGM(" st"); \
if(olb) SERIAL_ECHOPGM(" olb"); \
if(ola) SERIAL_ECHOPGM(" ola"); \
if(s2gb) SERIAL_ECHOPGM(" s2gb"); \
if(s2ga) SERIAL_ECHOPGM(" s2ga"); \
if(otpw) SERIAL_ECHOPGM(" otpw"); \
if(ot) SERIAL_ECHOPGM(" ot"); \
if(fsactive) SERIAL_ECHOPGM(" fsactive"); \
SERIAL_EOL(); \
}
#define LULZBOT_SIGN_EXTEND_SGT(sgt) int8_t(sgt | ((sgt << 1) & 0x80))
/* The following function accumulates the average of a
stallguard values during a planner move */
#define LULZBOT_TMC_STALLGUARD_AVG_VARS \
static uint8_t current_tail, tally_freq = 10; \
static uint32_t sum_sg_X = 0, sum_sg_Y = 0, sum_sg_Z = 0, sum_sg_E0 = 0, num_sg = 0;
#define LULZBOT_TMC_STALLGUARD_AVG_FUNC \
if(--tally_freq == 0) { \
tally_freq = 10; \
if(planner.blocks_queued()) { \
/* Reset accumulators at the start of each movement */ \
if(current_tail != planner.block_buffer_tail) { \
current_tail = planner.block_buffer_tail; \
sum_sg_X = sum_sg_Y = sum_sg_Z = sum_sg_E0 = num_sg = 0; \
} \
/* While in motion, accumulate sg values */ \
sum_sg_X += stepperX.DRV_STATUS() & 0b111111111; \
sum_sg_Y += stepperY.DRV_STATUS() & 0b111111111; \
sum_sg_Z += stepperZ.DRV_STATUS() & 0b111111111; \
sum_sg_E0 += stepperE0.DRV_STATUS() & 0b111111111; \
num_sg++; \
} \
}
#define LULZBOT_TMC_M119_STALLGUARD_REPORT \
SERIAL_ECHOLNPGM("TMC2130 Status:"); \
LULZBOT_TMC_REPORT(X) \
LULZBOT_TMC_REPORT(Y) \
LULZBOT_TMC_REPORT(Z) \
LULZBOT_TMC_REPORT(E0)
#define LULZBOT_ENABLE_STALLGUARD(st) \
/* Enable stallguard by disabling steathchop */ \
st.coolstep_min_speed(1024UL * 1024UL - 1UL); \
st.stealthChop(0);
#define LULZBOT_ENABLE_STEALTHCHOP(st) \
st.coolstep_min_speed(0); \
st.stealthChop(1);
#define LULZBOT_TMC2130_ADV { \
/* LULZBOT_ENABLE_STALLGUARD(stepperZ) */ \
/* Set stallguard value for Z sensing */ \
/* stepperZ.sg_stall_value(5); */ \
}
/* When STEALTHCHOP is disabled, sometimes the X axis refuses to
* move at the start of G28, because the stallguard is triggered.
* Toggling in and out of STEALHCHOP mode seems to resolve this. */
#define LULZBOT_CLEAR_STALLGUARD_FLAG(st) \
LULZBOT_ENABLE_STEALTHCHOP(st) \
LULZBOT_ENABLE_STALLGUARD(st)
/* Leaving the toolhead resting on the endstops will likely cause
* chatter if the machine is immediately re-homed, so don't leave
* the head sitting on the endstop after homing. */
#define LULZBOT_BACKOFF_DIST 3
#define LULZBOT_BACKOFF_FEEDRATE 5
#define LULZBOT_AFTER_Z_HOME_ACTION \
do_blocking_move_to_xy( \
LULZBOT_INVERT_X_HOME_DIR < 0 ? LULZBOT_BACKOFF_DIST : LULZBOT_STANDARD_X_MAX_POS - LULZBOT_BACKOFF_DIST, \
LULZBOT_INVERT_Y_HOME_DIR < 0 ? LULZBOT_BACKOFF_DIST : LULZBOT_STANDARD_Y_MAX_POS - LULZBOT_BACKOFF_DIST, \
LULZBOT_BACKOFF_FEEDRATE \
);
#else
#define LULZBOT_TMC_M119_STALLGUARD_REPORT
#define LULZBOT_TMC_STALLGUARD_AVG_VARS
#define LULZBOT_TMC_STALLGUARD_AVG_FUNC
#endif
#if defined(LULZBOT_SENSORLESS_HOMING)
#define LULZBOT_USE_XMIN_PLUG // Uses Stallguard
//#define LULZBOT_USE_XMAX_PLUG // Uses Stallguard
//#define LULZBOT_USE_YMIN_PLUG // Uses Stallguard
#define LULZBOT_USE_YMAX_PLUG // Uses Stallguard
#define LULZBOT_USE_ZMIN_PLUG
#define LULZBOT_USE_ZMAX_PLUG
#define LULZBOT_X_MIN_ENDSTOP_INVERTING LULZBOT_NORMALLY_OPEN_ENDSTOP
//#define LULZBOT_X_MAX_ENDSTOP_INVERTING LULZBOT_NORMALLY_OPEN_ENDSTOP
#define LULZBOT_Y_MAX_ENDSTOP_INVERTING LULZBOT_NORMALLY_OPEN_ENDSTOP
//#define LULZBOT_Y_MIN_ENDSTOP_INVERTING LULZBOT_NORMALLY_OPEN_ENDSTOP
#define LULZBOT_Z_MAX_ENDSTOP_INVERTING LULZBOT_NORMALLY_OPEN_ENDSTOP
// The following does not seem to work when both
// MAX and MIN are using Stallguard.
// It also appears that when this is enabled
// stallguard is never cleared.
//#define LULZBOT_ENDSTOP_INTERRUPTS_FEATURE
//#define LULZBOT_STEALTHCHOP
#undef LULZBOT_ENDSTOPS_ALWAYS_ON_DEFAULT
// According to Jason at UltiMachine, setting the lower the
// stealth freq the cooler the motor drivers will operate.
#define LULZBOT_STEALTH_FREQ 0
// Quickhome does not work with sensorless homing
#undef LULZBOT_QUICKHOME
#define LULZBOT_X_HOMING_SENSITIVITY 3
#define LULZBOT_Y_HOMING_SENSITIVITY 3
#endif
#if defined(LULZBOT_SENSORLESS_HOMING)
#define LULZBOT_X_HOME_BUMP_MM 0
#define LULZBOT_Y_HOME_BUMP_MM 0
#else
#define LULZBOT_X_HOME_BUMP_MM 5
#define LULZBOT_Y_HOME_BUMP_MM 5
#endif
/**************************** ADVANCED PAUSE FEATURE ****************************/
#if defined(LULZBOT_USE_LCD_DISPLAY)
@ -1035,7 +1298,17 @@
// Values for XYZ vary by printer model, values for E vary by toolhead.
#if defined(LULZBOT_IS_MINI) && defined(LULZBOT_USE_Z_SCREW)
#if defined(LULZBOT_USE_EINSYRAMBO)
#define LULZBOT_MOTOR_CURRENT_XY 800 // mA
#define LULZBOT_MOTOR_CURRENT_Z 960 // mA
#if LULZBOT_MOTOR_CURRENT_E > 960
#warning This toolhead may not work properly with the EinsyRambo
#undef LULZBOT_MOTOR_CURRENT_E
#define LULZBOT_MOTOR_CURRENT_E 960 // mA
#endif
#elif defined(LULZBOT_IS_MINI) && defined(LULZBOT_USE_Z_SCREW)
#define LULZBOT_MOTOR_CURRENT_XY 1300 // mA
#define LULZBOT_MOTOR_CURRENT_Z 1630 // mA
@ -1115,7 +1388,24 @@
#define LULZBOT_Z_STEPS 1790.08264463
#endif
#if defined(LULZBOT_IS_MINI)
#if defined(LULZBOT_USE_EINSYRAMBO)
// Neither define LULZBOT_PWM_MOTOR_CURRENT nor LULZBOT_DIGIPOT_MOTOR_CURRENT,
// as the current is set in Configuration_adv.h under the HAVE_TMC2130 block
// Make sure the current is in range, as setting it above this causes the
// value in irun to wrap around to zero, which fails silently!
#if LULZBOT_MOTOR_CURRENT_XY > 960 || \
LULZBOT_MOTOR_CURRENT_Z > 960 || \
LULZBOT_MOTOR_CURRENT_E > 960
#error Motor currents exceed the maximum values that can be set on the EinsyRambo
#endif
#define LULZBOT_X_CURRENT LULZBOT_MOTOR_CURRENT_XY
#define LULZBOT_Y_CURRENT LULZBOT_MOTOR_CURRENT_XY
#define LULZBOT_Z_CURRENT LULZBOT_MOTOR_CURRENT_Z
#define LULZBOT_E0_CURRENT LULZBOT_MOTOR_CURRENT_E
#elif defined(LULZBOT_IS_MINI)
#define LULZBOT_PWM_MOTOR_CURRENT { \
LULZBOT_MOTOR_CURRENT_XY, \
LULZBOT_MOTOR_CURRENT_Z, \

@ -253,7 +253,9 @@
// If you want endstops to stay on (by default) even when not homing
// enable this option. Override at any time with M120, M121.
#define ENDSTOPS_ALWAYS_ON_DEFAULT LULZBOT_ENDSTOPS_ALWAYS_ON_DEFAULT
#if defined(LULZBOT_ENDSTOPS_ALWAYS_ON_DEFAULT)
#define ENDSTOPS_ALWAYS_ON_DEFAULT
#endif
// @section extras
@ -348,14 +350,18 @@
// @section homing
//homing hits the endstop, then retracts by this distance, before it tries to slowly bump again:
#define X_HOME_BUMP_MM 5
#define Y_HOME_BUMP_MM 5
#define X_HOME_BUMP_MM LULZBOT_X_HOME_BUMP_MM
#define Y_HOME_BUMP_MM LULZBOT_Y_HOME_BUMP_MM
#define Z_HOME_BUMP_MM 2
#define HOMING_BUMP_DIVISOR {2, 2, 4} // Re-Bump Speed Divisor (Divides the Homing Feedrate)
#if defined(LULZBOT_QUICKHOME)
#define QUICK_HOME LULZBOT_QUICKHOME //if this is defined, if both x and y are to be homed, a diagonal move will be performed initially.
#endif
// When G28 is called, this option will make Y home before X
//#define HOME_Y_BEFORE_X
#if defined(LULZBOT_HOME_Y_BEFORE_X)
#define HOME_Y_BEFORE_X
#endif
// @section machine
@ -432,8 +438,12 @@
* M908 - BQ_ZUM_MEGA_3D, RAMBO, PRINTRBOARD_REVF, RIGIDBOARD_V2 & SCOOVO_X9H
* M909, M910 & LCD - only PRINTRBOARD_REVF & RIGIDBOARD_V2
*/
#if defined(LULZBOT_PWM_MOTOR_CURRENT)
#define PWM_MOTOR_CURRENT LULZBOT_PWM_MOTOR_CURRENT // Values in milliamps
#endif
#if defined(LULZBOT_DIGIPOT_MOTOR_CURRENT)
#define DIGIPOT_MOTOR_CURRENT LULZBOT_DIGIPOT_MOTOR_CURRENT // Values 0-255 (RAMBO 135 = ~0.75A, 185 = ~1A)
#endif
//#define DAC_MOTOR_CURRENT_DEFAULT { 70, 80, 90, 80 } // Default drive percent - X, Y, Z, E axis
// Uncomment to enable an I2C based DIGIPOT like on the Azteeg X3 Pro
@ -946,17 +956,17 @@
* Stepper driver settings
*/
#define R_SENSE 0.11 // R_sense resistor for SilentStepStick2130
#define HOLD_MULTIPLIER 0.5 // Scales down the holding current from run current
#define R_SENSE LULZBOT_R_SENSE // R_sense resistor for SilentStepStick2130
#define HOLD_MULTIPLIER LULZBOT_HOLD_MULTIPLIER // Scales down the holding current from run current
#define INTERPOLATE 1 // Interpolate X/Y/Z_MICROSTEPS to 256
#define X_CURRENT 1000 // rms current in mA. Multiply by 1.41 for peak current.
#define X_CURRENT LULZBOT_X_CURRENT // rms current in mA. Multiply by 1.41 for peak current.
#define X_MICROSTEPS 16 // 0..256
#define Y_CURRENT 1000
#define Y_CURRENT LULZBOT_Y_CURRENT
#define Y_MICROSTEPS 16
#define Z_CURRENT 1000
#define Z_CURRENT LULZBOT_Z_CURRENT
#define Z_MICROSTEPS 16
//#define X2_CURRENT 1000
@ -968,8 +978,8 @@
//#define Z2_CURRENT 1000
//#define Z2_MICROSTEPS 16
//#define E0_CURRENT 1000
//#define E0_MICROSTEPS 16
#define E0_CURRENT LULZBOT_E0_CURRENT
#define E0_MICROSTEPS 16
//#define E1_CURRENT 1000
//#define E1_MICROSTEPS 16
@ -987,7 +997,9 @@
* Use Trinamic's ultra quiet stepping mode.
* When disabled, Marlin will use spreadCycle stepping mode.
*/
#if defined(LULZBOT_STEALTHCHOP)
#define STEALTHCHOP
#endif
/**
* Let Marlin automatically control stepper current.
@ -1042,11 +1054,13 @@
* It is advised to set X/Y_HOME_BUMP_MM to 0.
* M914 X/Y to live tune the setting
*/
//#define SENSORLESS_HOMING
#if defined(LULZBOT_SENSORLESS_HOMING)
#define SENSORLESS_HOMING
#endif
#if ENABLED(SENSORLESS_HOMING)
#define X_HOMING_SENSITIVITY 19
#define Y_HOMING_SENSITIVITY 19
#define X_HOMING_SENSITIVITY LULZBOT_X_HOMING_SENSITIVITY
#define Y_HOMING_SENSITIVITY LULZBOT_Y_HOMING_SENSITIVITY
#endif
/**
@ -1060,7 +1074,7 @@
* stepperX.interpolate(0); \
* }
*/
#define TMC2130_ADV() { }
#define TMC2130_ADV() LULZBOT_TMC2130_ADV
#endif // HAVE_TMC2130

@ -89,6 +89,9 @@ U8GLIB ?= 1
# https://www.stix.id.au/wiki/AVR_relocation_truncations_workaround
RELOC_WORKAROUND ?= 1
# this defines whether to include the Trinamic TMC2630Stepper
TMC2630 ?= 1
############
# The following added by AlephObjects for adjusting the name of the output
# hex file
@ -293,6 +296,10 @@ ifeq ($(U8GLIB), 1)
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/U8glib/utility
endif
ifeq ($(TMC2630), 1)
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMC2130Stepper
VPATH += $(ARDUINO_INSTALL_DIR)/libraries/TMC2130Stepper/source
endif
ifeq ($(HARDWARE_VARIANT), arduino)
HARDWARE_SUB_VARIANT ?= mega
@ -319,7 +326,7 @@ CXXSRC = WMath.cpp WString.cpp Print.cpp Marlin_main.cpp \
temperature.cpp cardreader.cpp configuration_store.cpp \
watchdog.cpp SPI.cpp servo.cpp Tone.cpp ultralcd.cpp digipot_mcp4451.cpp \
dac_mcp4728.cpp vector_3.cpp least_squares_fit.cpp endstops.cpp stopwatch.cpp utility.cpp \
printcounter.cpp nozzle.cpp serial.cpp gcode.cpp Max7219_Debug_LEDs.cpp
printcounter.cpp nozzle.cpp serial.cpp gcode.cpp Max7219_Debug_LEDs.cpp stepper_indirection.cpp
ifeq ($(NEOPIXEL), 1)
CXXSRC += Adafruit_NeoPixel.cpp
endif
@ -344,6 +351,10 @@ LD_PREFIX=-nodefaultlibs
LD_SUFFIX=-lm -lgcc -lc -lgcc
endif
ifeq ($(TMC2630), 1)
CXXSRC += TMC2130Stepper.cpp TMC2130Stepper_CHOPCONF.cpp TMC2130Stepper_COOLCONF.cpp TMC2130Stepper_DRV_STATUS.cpp TMC2130Stepper_GCONF.cpp TMC2130Stepper_IHOLD_IRUN.cpp TMC2130Stepper_PWMCONF.cpp
endif
#Check for Arduino 1.0.0 or higher and use the correct source files for that version
ifeq ($(shell [ $(ARDUINO_VERSION) -ge 100 ] && echo true), true)
CXXSRC += main.cpp

@ -29,8 +29,8 @@
#include "Version.h"
#include "Configuration.h"
#include "Conditionals_LCD.h"
#include "Configuration_adv.h"
#include "pins.h"
#include "Configuration_adv.h"
#ifndef USBCON
#define HardwareSerial_h // trick to disable the standard HWserial
#endif

@ -2301,7 +2301,6 @@ static void clean_up_after_endstop_or_probe_move() {
refresh_cmd_timeout();
#if ENABLED(PROBE_DOUBLE_TOUCH)
// Do a first probe at the fast speed
#if defined(LULZBOT_PROBE_Z_WITH_REWIPE)
LULZBOT_PROBE_Z_WITH_REWIPE(Z_PROBE_SPEED_FAST);
@ -2971,8 +2970,9 @@ static void do_homing_move(const AxisEnum axis, const float distance, const floa
st.coolstep_min_speed(0);
st.stealthChop(1);
}
#else
LULZBOT_CLEAR_STALLGUARD_FLAG(st)
#endif
st.diag1_stall(enable ? 1 : 0);
}
#endif
@ -4014,7 +4014,6 @@ inline void gcode_G28(const bool always_home_all) {
#endif
#if ENABLED(HOME_Y_BEFORE_X)
// Home Y
if (home_all || homeY) {
HOMEAXIS(Y);
@ -9916,8 +9915,12 @@ inline void gcode_M502() {
static void tmc2130_get_sgt(TMC2130Stepper &st, const char name) {
SERIAL_CHAR(name);
#if defined(LULZBOT_SIGN_EXTEND_SGT)
SERIAL_ECHOLNPAIR(" driver homing sensitivity set to ", LULZBOT_SIGN_EXTEND_SGT(st.sgt()));
#else
SERIAL_ECHOPGM(" driver homing sensitivity set to ");
SERIAL_ECHOLN(st.sgt());
#endif
}
static void tmc2130_set_sgt(TMC2130Stepper &st, const char name, const int8_t sgt_val) {
st.sgt(sgt_val);
@ -9948,10 +9951,6 @@ inline void gcode_M502() {
if (values[Z_AXIS]) tmc2130_set_current(stepperZ, 'Z', values[Z_AXIS]);
else tmc2130_get_current(stepperZ, 'Z');
#endif
#if ENABLED(E0_IS_TMC2130)
if (values[E_AXIS]) tmc2130_set_current(stepperE0, 'E', values[E_AXIS]);
else tmc2130_get_current(stepperE0, 'E');
#endif
#if ENABLED(AUTOMATIC_CURRENT_CONTROL)
if (parser.seen('S')) auto_current_control = parser.value_bool();
@ -10040,6 +10039,10 @@ inline void gcode_M502() {
if (parser.seen(axis_codes[Y_AXIS])) tmc2130_set_sgt(stepperY, 'Y', parser.value_int());
else tmc2130_get_sgt(stepperY, 'Y');
#endif
#if ENABLED(E0_IS_TMC2130)
if (parser.seen(axis_codes[E_AXIS])) tmc2130_set_sgt(stepperE0, 'E', parser.value_int());
else tmc2130_get_sgt(stepperE0, 'E');
#endif
}
#endif // SENSORLESS_HOMING

@ -89,6 +89,7 @@
#define BOARD_RAMBO 301 // Rambo
#define BOARD_MINIRAMBO 302 // Mini-Rambo
#define BOARD_SCOOVO_X9H 303 // abee Scoovo X9H
#define BOARD_EINSYRAMBO 304 // Einsy-Rambo
#define BOARD_MEGACONTROLLER 310 // Mega controller
#define BOARD_ELEFU_3 21 // Elefu Ra Board (v3)
#define BOARD_5DPRINT 88 // 5DPrint D8 Driver Board

@ -133,6 +133,8 @@ void Endstops::init() {
} // Endstops::init
LULZBOT_TMC_STALLGUARD_AVG_VARS
void Endstops::report_state() {
if (endstop_hit_bits) {
#if ENABLED(ULTRA_LCD)
@ -181,6 +183,7 @@ void Endstops::report_state() {
}
#endif
}
LULZBOT_TMC_STALLGUARD_AVG_FUNC
} // Endstops::report_state
void Endstops::M119() {
@ -225,6 +228,7 @@ void Endstops::M119() {
SERIAL_PROTOCOLPGM(MSG_FILAMENT_RUNOUT_SENSOR);
SERIAL_PROTOCOLLN(((READ(FIL_RUNOUT_PIN)^FIL_RUNOUT_INVERTING) ? MSG_ENDSTOP_HIT : MSG_ENDSTOP_OPEN));
#endif
LULZBOT_TMC_M119_STALLGUARD_REPORT
} // Endstops::M119
#if ENABLED(Z_DUAL_ENDSTOPS)

@ -142,6 +142,8 @@
#include "pins_RAMBO.h" // ATmega2560
#elif MB(MINIRAMBO)
#include "pins_MINIRAMBO.h" // ATmega2560
#elif MB(EINSYRAMBO)
#include "pins_EINSYRAMBO.h" // ATmega2560
#elif MB(ELEFU_3)
#include "pins_ELEFU_3.h" // ATmega2560
#elif MB(LEAPFROG)

@ -0,0 +1,209 @@
/**
* Marlin 3D Printer Firmware
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* Einsy-Rambo pin assignments
*/
#ifndef __AVR_ATmega2560__
#error "Oops! Make sure you have 'Arduino Mega 2560 or Rambo' selected from the 'Tools -> Boards' menu."
#endif
#define BOARD_NAME "Einsy Rambo"
#define LARGE_FLASH true
// Enable use of TMC2130
#define HAVE_TMC2130
#define X_IS_TMC2130
#define Y_IS_TMC2130
#define Z_IS_TMC2130
#define E0_IS_TMC2130
#if defined(LULZBOT_USE_EARLY_EINSY)
#define BOARD_X_DIAG_PIN 40 // PG1 as defined in "fastio_1280.h"
#define BOARD_Y_DIAG_PIN 69 // PK7 as defined in "fastio_1280.h"
#define BOARD_Z_DIAG_PIN 68 // PK6 as defined in "fastio_1280.h"
#define BOARD_E0_DIAG_PIN 65 // PK3 as defined in "fastio_1280.h"
#else
#define BOARD_Z_THRES_PIN 57 // PF3 as defined in "fastio_1280.h"
#define BOARD_X_DIAG_PIN 64 // PK2 as defined in "fastio_1280.h"
#define BOARD_Y_DIAG_PIN 69 // PK7 as defined in "fastio_1280.h"
#define BOARD_Z_DIAG_PIN 68 // PK6 as defined in "fastio_1280.h"
#define BOARD_E0_DIAG_PIN 65 // PK3 as defined in "fastio_1280.h"
#endif
#define BOARD_X_MIN_PIN 12
#define BOARD_Y_MIN_PIN 11
#define BOARD_Z_MIN_PIN 10
#if defined(LULZBOT_USE_EARLY_EINSY)
// EINY 0-.1 - EINSY 0.3
#define BOARD_X_MAX_PIN 30
#define BOARD_Y_MAX_PIN 24
#define BOARD_Z_MAX_PIN 23
#endif
//
// Limit Switches
//
// EINY 0-.1 - EINSY 0.3 have MAX switches
#if defined(LULZBOT_USE_EARLY_EINSY) && defined(LULZBOT_SENSORLESS_HOMING)
#define X_MIN_PIN BOARD_X_DIAG_PIN
#define Y_MIN_PIN BOARD_Y_MIN_PIN
#define Z_MIN_PIN BOARD_Z_MIN_PIN
#define X_MAX_PIN BOARD_X_MAX_PIN
#define Y_MAX_PIN BOARD_Y_DIAG_PIN
#define Z_MAX_PIN BOARD_Z_MAX_PIN
#elif defined(LULZBOT_USE_EARLY_EINSY)
#define X_MIN_PIN BOARD_X_MIN_PIN
#define Y_MIN_PIN BOARD_Y_MIN_PIN
#define Z_MIN_PIN BOARD_Z_MIN_PIN
#define X_MAX_PIN BOARD_X_MAX_PIN
#define Y_MAX_PIN BOARD_Y_MAX_PIN
#define Z_MAX_PIN BOARD_Z_MAX_PIN
// Einsy 0.4+ lacks MAX switches
#elif defined(LULZBOT_SENSORLESS_HOMING)
#define X_MIN_PIN BOARD_X_DIAG_PIN
#define Y_MIN_PIN -1
#define Z_MIN_PIN BOARD_Y_MIN_PIN
#define X_MAX_PIN -1
#define Y_MAX_PIN BOARD_Y_DIAG_PIN
#define Z_MAX_PIN BOARD_X_MIN_PIN
#else
#define X_MIN_PIN BOARD_X_MIN_PIN
#define Y_MIN_PIN BOARD_Y_MIN_PIN
#define Z_MIN_PIN BOARD_Z_MIN_PIN
#define X_MAX_PIN -1 // 30
#define Y_MAX_PIN -1 // 24
#define Z_MAX_PIN BOARD_Z_THRES_PIN
#endif
//
// Steppers
//
#define X_STEP_PIN 37
#define X_DIR_PIN 49
#define X_ENABLE_PIN 29
#define Y_STEP_PIN 36
#define Y_DIR_PIN 48
#define Y_ENABLE_PIN 28
#define Z_STEP_PIN 35
#define Z_DIR_PIN 47
#define Z_ENABLE_PIN 27
#define E0_STEP_PIN 34
#define E0_DIR_PIN 43
#define E0_ENABLE_PIN 26
#define E1_STEP_PIN -1
#define E1_DIR_PIN -1
#define E1_ENABLE_PIN -1
// Microstepping pins - Mapping not from fastio.h (?)
#define X_MS1_PIN -1
#define X_MS2_PIN -1
#define X_CS_PIN 41
#define Y_MS1_PIN -1
#define Y_MS2_PIN -1
#define Y_CS_PIN 39
#define Z_MS1_PIN -1
#define Z_MS2_PIN -1
#define Z_CS_PIN 67
#define E0_MS1_PIN -1
#define E0_MS2_PIN -1
#define E0_CS_PIN 66
#define MOTOR_CURRENT_PWM_XY_PIN 46
#define MOTOR_CURRENT_PWM_Z_PIN 45
#define MOTOR_CURRENT_PWM_E_PIN 44
// Motor current PWM conversion, PWM value = MotorCurrentSetting * 255 / range
#ifndef MOTOR_CURRENT_PWM_RANGE
#define MOTOR_CURRENT_PWM_RANGE 2000
#endif
#define DEFAULT_PWM_MOTOR_CURRENT {1300, 1300, 1300}
//
// Temperature Sensors
//
#define TEMP_0_PIN 0 // Analog Input
#define TEMP_1_PIN 1 // Analog Input
#define TEMP_BED_PIN 2 // Analog Input
//
// Heaters / Fans
//
#define HEATER_0_PIN 3
#define HEATER_1_PIN 7
#define HEATER_2_PIN 6
#define HEATER_BED_PIN 4
#define FAN_PIN 8
#define FAN1_PIN 6
//
// Misc. Functions
//
#if defined(LULZBOT_USE_EARLY_EINSY)
#define SDSS 53 // EINY 0-.1 - EINSY 0.3
#else
#define SDSS 77 // EINSY 0.4
#endif
#define LED_PIN 13
//
// LCD / Controller
//
#if ENABLED(ULTRA_LCD)
#define KILL_PIN 32
#if ENABLED(NEWPANEL)
// Beeper on AUX-4
#define BEEPER_PIN 84
#define LCD_PINS_RS 82
#if defined(LULZBOT_USE_EARLY_EINSY)
// EINY 0.1- EINSY-0.3
#define LCD_PINS_ENABLE 18
#define LCD_PINS_D4 19
#else
// EINSY 0.4+
#define LCD_PINS_ENABLE 61
#define LCD_PINS_D4 59
#endif
#define LCD_PINS_D5 70
#define LCD_PINS_D6 85
#define LCD_PINS_D7 71
// buttons are directly attached using AUX-2
#define BTN_EN1 14
#define BTN_EN2 72
#define BTN_ENC 9 // the click
#define SD_DETECT_PIN 15
#endif // NEWPANEL
#endif // ULTRA_LCD

@ -126,7 +126,6 @@
// TMC2130 Driver objects and inits
//
#if ENABLED(HAVE_TMC2130)
#include <SPI.h>
#include <TMC2130Stepper.h>
#include "enum.h"
@ -181,9 +180,13 @@
st.power_down_delay(128); // ~2s until driver lowers to hold current
st.hysterisis_start(0); // HSTRT = 1
st.hysterisis_low(1); // HEND = -2
#if defined(LULZBOT_TMC_INIT)
LULZBOT_TMC_INIT(st);
#else
st.diag1_active_high(1); // For sensorless homing
#endif
#if ENABLED(STEALTHCHOP)
st.stealth_freq(1); // f_pwm = 2/683 f_clk
st.stealth_freq(LULZBOT_STEALTH_FREQ); // f_pwm = 2/683 f_clk
st.stealth_autoscale(1);
st.stealth_gradient(5);
st.stealth_amplitude(255);

@ -901,6 +901,7 @@ void kill_screen(const char* lcd_msg) {
static void lcd_store_settings();
static void lcd_load_settings();
void lcd_main_menu() {
START_MENU();
MENU_BACK(MSG_WATCH);

@ -56,7 +56,7 @@
#define CPU_ST7920_DELAY_1 DELAY_0_NOP
#define CPU_ST7920_DELAY_2 DELAY_3_NOP
#define CPU_ST7920_DELAY_3 DELAY_0_NOP
#elif (MOTHERBOARD == BOARD_MINIRAMBO)
#elif (MOTHERBOARD == BOARD_MINIRAMBO) || (MOTHERBOARD == BOARD_EINSYRAMBO)
#define CPU_ST7920_DELAY_1 DELAY_0_NOP
#define CPU_ST7920_DELAY_2 DELAY_4_NOP
#define CPU_ST7920_DELAY_3 DELAY_0_NOP

@ -16,7 +16,7 @@
####
# The following variables list the models and toolheads to build for:
MINI_MODELS="Gladiola_Mini Hibiscus_Mini2 Gladiola_MiniLCD Hibiscus_Mini2LCD"
MINI_MODELS="Gladiola_Mini Hibiscus_Mini2 Gladiola_MiniLCD Hibiscus_Mini2LCD Gladiola_EinsyMini Hibiscus_EinsyMini2 Gladiola_EinsyMiniLCD Hibiscus_EinsyMini2LCD"
MINI_TOOLHEADS="Gladiola_SingleExtruder Albatross_Flexystruder Finch_Aerostruder Finch_AerostruderV2"
TAZ_MODELS="Juniper_TAZ5 Oliveoil_TAZ6 Quiver_TAZ7"

Loading…
Cancel
Save