Skip to content

Commit

Permalink
Devt (bdring#609)
Browse files Browse the repository at this point in the history
* Fixed various small bugs (bdring#605)

* Fixed various small bugs

* Fixed potential cast bug

* Fixed double reporting of errors

Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>

* Stallguard tuning (bdring#607)

* Devt (bdring#571)

* Handles Tranimic drivers errors better

- If an unsupported driver is specified, it will give a message and not crash.

* Cleaned up unused files

Got rid of old unipolar files
Got rid of servo axis feature - it is a motor class now
Got rid of solenoid pen feature - never really used and it should be a motor class if it is.

* Fix ENABLE_AUTHENTICATION (bdring#569)

* Fixed authentication code.

* Removed another const cast

Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>

* Fix step leakage with inverted steps (bdring#570)

* Fix step leakage with inverted steps

* Update build date for merge

Co-authored-by: Bart Dring <bdring@buildlog.net>

Co-authored-by: Stefan de Bruijn <atlaste@users.noreply.github.com>
Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>
Co-authored-by: Mitch Bradley <wmb@firmworks.com>
Co-authored-by: Bart Dring <bdring@buildlog.net>

* Update platformio.ini

Per PR 583

* Created an enum for mode

* Removing some unused machine defs

* Added test machine definition

* Clean up for PR

* Remove test machine def.

Co-authored-by: Stefan de Bruijn <atlaste@users.noreply.github.com>
Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>
Co-authored-by: Mitch Bradley <wmb@firmworks.com>
Co-authored-by: Bart Dring <bdring@buildlog.net>

Co-authored-by: Stefan de Bruijn <atlaste@users.noreply.github.com>
Co-authored-by: Stefan de Bruijn <stefan@nubilosoft.com>
Co-authored-by: Mitch Bradley <wmb@firmworks.com>
Co-authored-by: Bart Dring <bdring@buildlog.net>
  • Loading branch information
5 people authored Sep 21, 2020
1 parent 050aa19 commit 639b6c1
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 173 deletions.
2 changes: 1 addition & 1 deletion Grbl_Esp32/src/Grbl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// Grbl versioning system

const char* const GRBL_VERSION = "1.3a";
const char* const GRBL_VERSION_BUILD = "20200910";
const char* const GRBL_VERSION_BUILD = "20200919";

//#include <sdkconfig.h>
#include <Arduino.h>
Expand Down
140 changes: 0 additions & 140 deletions Grbl_Esp32/src/Machines/6_pack_trinamic_V1.h

This file was deleted.

19 changes: 10 additions & 9 deletions Grbl_Esp32/src/Machines/6_pack_trinamic_stallguard.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@
#define I2S_OUT_WS GPIO_NUM_17
#define I2S_OUT_DATA GPIO_NUM_21


#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_STALLGUARD
#define TRINAMIC_RUN_MODE Motors::TrinamicMode::CoolStep
#define TRINAMIC_HOMING_MODE Motors::TrinamicMode::StallGuard

// Motor Socket #1
#define X_TRINAMIC_DRIVER 2130
Expand Down Expand Up @@ -91,16 +90,16 @@
Click on each module to get example for using the modules in the sockets
Socket #1
#1 GPIO_NUM_33
#2 GPIO_NUM_32
#3 GPIO_NUM_35 (input only)
#4 GPIO_NUM_34 (input only)
#1 GPIO_NUM_33 (Sg1)
#2 GPIO_NUM_32 (Sg2)
#3 GPIO_NUM_35 (Sg3) (input only)
#4 GPIO_NUM_34 (Sg4) (input only)
Socket #2
#1 GPIO_NUM_2
#2 GPIO_NUM_25
#3 GPIO_NUM_39 (input only)
#4 GPIO_NUM_36 (input only)
#3 GPIO_NUM_39 (Sg5) (input only)
#4 GPIO_NUM_36 (Sg6) (input only)
Socket #3
#1 GPIO_NUM_26
Expand All @@ -122,12 +121,14 @@ Socket #5
*/

// Socket #1 (Empty)
// Install StallGuard Jumpers
#define X_LIMIT_PIN GPIO_NUM_33 // Sg1
#define Y_LIMIT_PIN GPIO_NUM_32 // Sg2
#define Z_LIMIT_PIN GPIO_NUM_35 // Sg3
#define A_LIMIT_PIN GPIO_NUM_34 // Sg4

// Socket #2 (Empty)
// Install StallGuard Jumpers
#define B_LIMIT_PIN GPIO_NUM_39 // Sg5
#define C_LIMIT_PIN GPIO_NUM_36 // Sg6

Expand Down
4 changes: 2 additions & 2 deletions Grbl_Esp32/src/Machines/i2s_out_xyzabc_trinamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
#define I2S_OUT_WS GPIO_NUM_17
#define I2S_OUT_DATA GPIO_NUM_21

#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_COOLSTEP
#define TRINAMIC_RUN_MODE TrinamicMode :: CoolStep
#define TRINAMIC_HOMING_MODE TrinamicMode :: CoolStep

#define X_TRINAMIC_DRIVER 2130
#define X_DISABLE_PIN I2SO(0)
Expand Down
4 changes: 2 additions & 2 deletions Grbl_Esp32/src/Machines/spi_daisy_4axis_xyyz.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

#define TRINAMIC_DAISY_CHAIN

#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_COOLSTEP
#define TRINAMIC_RUN_MODE TrinamicMode :: CoolStep
#define TRINAMIC_HOMING_MODE TrinamicMode :: CoolStep

// Use SPI enable instead of the enable pin
// The hardware enable pin is tied to ground
Expand Down
4 changes: 2 additions & 2 deletions Grbl_Esp32/src/Machines/spi_daisy_4axis_xyz.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

#define TRINAMIC_DAISY_CHAIN

#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_COOLSTEP
#define TRINAMIC_RUN_MODE TrinamicMode :: CoolStep
#define TRINAMIC_HOMING_MODE TrinamicMode :: CoolStep

// Use SPI enable instead of the enable pin
// The hardware enable pin is tied to ground
Expand Down
2 changes: 1 addition & 1 deletion Grbl_Esp32/src/Machines/spi_daisy_4axis_xyza.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

#define TRINAMIC_DAISY_CHAIN

#define TRINAMIC_RUN_MODE TRINAMIC_MODE_STEALTHCHOP
#define TRINAMIC_RUN_MODE TrinamicMode::StealthChop

// Use SPI enable instead of the enable pin
// The hardware enable pin is tied to ground
Expand Down
4 changes: 2 additions & 2 deletions Grbl_Esp32/src/Machines/tmc2130_pen.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
#define X_LIMIT_PIN GPIO_NUM_32
#endif

#define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP
#define TRINAMIC_HOMING_MODE TRINAMIC_MODE_COOLSTEP
#define TRINAMIC_RUN_MODE TrinamicMode :: CoolStep
#define TRINAMIC_HOMING_MODE TrinamicMode :: CoolStep

#define X_STEP_PIN GPIO_NUM_12
#define X_DIRECTION_PIN GPIO_NUM_26
Expand Down
14 changes: 7 additions & 7 deletions Grbl_Esp32/src/Motors/TrinamicDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,21 +205,21 @@ namespace Motors {
_lastMode = _mode;

switch (_mode) {
case TRINAMIC_MODE_STEALTHCHOP:
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "TRINAMIC_MODE_STEALTHCHOP");
case TrinamicMode ::StealthChop:
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "StealthChop");
tmcstepper->en_pwm_mode(true);
tmcstepper->pwm_autoscale(true);
tmcstepper->diag1_stall(false);
break;
case TRINAMIC_MODE_COOLSTEP:
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "TRINAMIC_MODE_COOLSTEP");
case TrinamicMode :: CoolStep:
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Coolstep");
tmcstepper->en_pwm_mode(false);
tmcstepper->pwm_autoscale(false);
tmcstepper->TCOOLTHRS(NORMAL_TCOOLTHRS); // when to turn on coolstep
tmcstepper->THIGH(NORMAL_THIGH);
break;
case TRINAMIC_MODE_STALLGUARD:
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "TRINAMIC_MODE_STALLGUARD");
case TrinamicMode ::StallGuard:
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Stallguard");
tmcstepper->en_pwm_mode(false);
tmcstepper->pwm_autoscale(false);
tmcstepper->TCOOLTHRS(calc_tstep(homing_feed_rate->get(), 150.0));
Expand Down Expand Up @@ -286,7 +286,7 @@ namespace Motors {
if (_disabled) {
tmcstepper->toff(TRINAMIC_TOFF_DISABLE);
} else {
if (_mode == TRINAMIC_MODE_STEALTHCHOP) {
if (_mode == TrinamicMode::StealthChop) {
tmcstepper->toff(TRINAMIC_TOFF_STEALTHCHOP);
} else {
tmcstepper->toff(TRINAMIC_TOFF_COOLSTEP);
Expand Down
23 changes: 16 additions & 7 deletions Grbl_Esp32/src/Motors/TrinamicDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@

#include <TMCStepper.h> // https://github.com/teemuatlut/TMCStepper

#define TRINAMIC_MODE_STEALTHCHOP 0 // very quiet
#define TRINAMIC_MODE_COOLSTEP 1 // everything runs cooler so higher current possible
#define TRINAMIC_MODE_STALLGUARD 2 // coolstep plus generates stall indication
//#define TRINAMIC_MODE_STEALTHCHOP 0 // very quiet
//#define TRINAMIC_MODE_COOLSTEP 1 // everything runs cooler so higher current possible
//#define TRINAMIC_MODE_STALLGUARD 2 // coolstep plus generates stall indication

const float TMC2130_RSENSE_DEFAULT = 0.11f;
const float TMC5160_RSENSE_DEFAULT = 0.075f;
Expand All @@ -39,8 +39,9 @@ const int TRINAMIC_SPI_FREQ = 100000;
const double TRINAMIC_FCLK = 12700000.0; // Internal clock Approx (Hz) used to calculate TSTEP from homing rate

// ==== defaults OK to define them in your machine definition ====

#ifndef TRINAMIC_RUN_MODE
# define TRINAMIC_RUN_MODE TRINAMIC_MODE_COOLSTEP
# define TRINAMIC_RUN_MODE TrinamicMode ::StealthChop
#endif

#ifndef TRINAMIC_HOMING_MODE
Expand All @@ -60,6 +61,14 @@ const double TRINAMIC_FCLK = 12700000.0; // Internal clock Approx (Hz) used to
#endif

namespace Motors {

enum class TrinamicMode : uint8_t {
None = 0, // not for machine defs!
StealthChop = 1,
CoolStep = 2,
StallGuard = 3,
};

class TrinamicDriver : public StandardStepper {
public:
TrinamicDriver(uint8_t axis_index,
Expand All @@ -86,14 +95,14 @@ namespace Motors {
uint32_t calc_tstep(float speed, float percent);

TMC2130Stepper* tmcstepper; // all other driver types are subclasses of this one
uint8_t _homing_mode;
TrinamicMode _homing_mode;
uint8_t cs_pin = UNDEFINED_PIN; // The chip select pin (can be the same for daisy chain)
uint16_t _driver_part_number; // example: use 2130 for TMC2130
float _r_sense;
int8_t spi_index;

protected:
uint8_t _mode;
uint8_t _lastMode = 255;
TrinamicMode _mode;
TrinamicMode _lastMode = TrinamicMode::None;
};
}

0 comments on commit 639b6c1

Please sign in to comment.