123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607 |
- #ifndef TMC26XStepper_h
- #define TMC26XStepper_h
- #define TMC26X_OVERTEMPERATURE_PREWARING 1
- #define TMC26X_OVERTEMPERATURE_SHUTDOWN 2
- #define TMC26X_READOUT_POSITION 0
- #define TMC26X_READOUT_STALLGUARD 1
- #define TMC26X_READOUT_CURRENT 3
- #define COOL_STEP_HALF_CS_LIMIT 0
- #define COOL_STEP_QUARTDER_CS_LIMIT 1
- class TMC26XStepper {
- public:
-
- TMC26XStepper(int number_of_steps, int cs_pin, int dir_pin, int step_pin, unsigned int current, unsigned int resistor=150);
-
-
- void start();
-
-
- void un_start();
-
- void setSpeed(unsigned int whatSpeed);
-
-
- unsigned int getSpeed(void);
-
-
- void setMicrosteps(int number_of_steps);
-
-
- int getMicrosteps(void);
-
- char step(int number_of_steps);
-
-
- char move(void);
-
- char isMoving(void);
-
-
- unsigned int getStepsLeft(void);
-
-
- char stop(void);
-
-
- void setConstantOffTimeChopper(char constant_off_time, char blank_time, char fast_decay_time_setting, char sine_wave_offset, unsigned char use_current_comparator);
-
-
- void setSpreadCycleChopper(char constant_off_time, char blank_time, char hysteresis_start, char hysteresis_end, char hysteresis_decrement);
-
- void setRandomOffTime(char value);
-
-
- void setCurrent(unsigned int current);
-
-
- unsigned int getCurrent(void);
-
-
-
- void setStallGuardThreshold(char stall_guard_threshold, char stall_guard_filter_enabled);
-
-
- char getStallGuardThreshold(void);
-
-
- char getStallGuardFilter(void);
-
-
- void setCoolStepConfiguration(unsigned int lower_SG_threshold, unsigned int SG_hysteresis, unsigned char current_decrement_step_size,
- unsigned char current_increment_step_size, unsigned char lower_current_limit);
-
-
- void setCoolStepEnabled(boolean enabled);
-
-
-
- boolean isCoolStepEnabled();
-
- unsigned int getCoolStepLowerSgThreshold();
-
-
- unsigned int getCoolStepUpperSgThreshold();
-
-
- unsigned char getCoolStepNumberOfSGReadings();
-
-
- unsigned char getCoolStepCurrentIncrementSize();
-
-
- unsigned char getCoolStepLowerCurrentLimit();
-
-
- int getMotorPosition(void);
-
-
- int getCurrentStallGuardReading(void);
-
-
- unsigned char getCurrentCSReading(void);
-
-
-
- boolean isCurrentScalingHalfed();
-
- unsigned int getCurrentCurrent(void);
-
-
- boolean isStallGuardOverThreshold(void);
-
-
- char getOverTemperature(void);
-
-
-
- boolean isShortToGroundA(void);
-
- boolean isShortToGroundB(void);
-
- boolean isOpenLoadA(void);
-
- boolean isOpenLoadB(void);
-
-
- boolean isStandStill(void);
-
- boolean isStallGuardReached(void);
-
-
- void setEnabled(boolean enabled);
-
-
- boolean isEnabled();
-
- void readStatus(char read_value);
-
-
- int getResistor();
-
- void debugLastStatus(void);
-
- int version(void);
- private:
- unsigned int steps_left;
- int direction;
- unsigned long step_delay;
- int number_of_steps;
- unsigned int speed;
- unsigned int resistor;
-
- unsigned long last_step_time;
- unsigned long next_step_time;
-
-
- unsigned long driver_control_register_value;
- unsigned long chopper_config_register;
- unsigned long cool_step_register_value;
- unsigned long stall_guard2_current_register_value;
- unsigned long driver_configuration_register_value;
-
- unsigned long driver_status_result;
-
-
- inline int getReadoutValue();
-
-
- unsigned char cs_pin;
- unsigned char step_pin;
- unsigned char dir_pin;
-
-
- boolean started;
- int microsteps;
- char constant_off_time;
- unsigned char cool_step_lower_threshold;
- boolean cool_step_enabled;
-
-
- inline void send262(unsigned long datagram);
- };
- #endif
|