From 7b1ace3e08ab173b45930ef9b5e2da6ccf216fdf Mon Sep 17 00:00:00 2001 From: Bart Dring Date: Mon, 13 Sep 2021 17:49:51 -0500 Subject: [PATCH 1/9] WIP moved pins around --- FluidNC/src/Machine/SPIBus.cpp | 23 ++++++++++++----------- FluidNC/src/Machine/SPIBus.h | 2 +- FluidNC/src/SDCard.cpp | 13 ++++++++++++- FluidNC/src/SDCard.h | 8 +++++++- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/FluidNC/src/Machine/SPIBus.cpp b/FluidNC/src/Machine/SPIBus.cpp index a7b352de6..7e7ed3d35 100644 --- a/FluidNC/src/Machine/SPIBus.cpp +++ b/FluidNC/src/Machine/SPIBus.cpp @@ -8,8 +8,8 @@ namespace Machine { void SPIBus::validate() const { - if (_cs.defined() || _miso.defined() || _mosi.defined() || _sck.defined()) { - Assert(_cs.defined(), "SPI CS pin should be configured once"); + if (_miso.defined() || _mosi.defined() || _sck.defined()) { + //Assert(_cs.defined(), "SPI CS pin should be configured once"); Assert(_miso.defined(), "SPI MISO pin should be configured once"); Assert(_mosi.defined(), "SPI MOSI pin should be configured once"); Assert(_sck.defined(), "SPI SCK pin should be configured once"); @@ -17,12 +17,13 @@ namespace Machine { } void SPIBus::init() { - if (_cs.defined()) { // validation ensures the rest is also defined. - log_info("SPI SCK:" << _sck.name() << " MOSI:" << _mosi.name() << " MISO:" << _miso.name() << " CS:" << _cs.name()); + if (_sck.defined()) { // validation ensures the rest is also defined. + //log_info("SPI SCK:" << _sck.name() << " MOSI:" << _mosi.name() << " MISO:" << _miso.name() << " CS:" << _cs.name()); + log_info("SPI SCK:" << _sck.name() << " MOSI:" << _mosi.name() << " MISO:" << _miso.name()); - _cs.setAttr(Pin::Attr::Output); + //_cs.setAttr(Pin::Attr::Output); - auto csPin = _cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); + //auto csPin = _cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); auto mosiPin = _mosi.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); auto sckPin = _sck.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); auto misoPin = _miso.getNative(Pin::Capabilities::Input | Pin::Capabilities::Native); @@ -30,12 +31,12 @@ namespace Machine { // Start the SPI bus with the pins defined here. Once it has been started, // those pins "stick" and subsequent attempts to restart it with defaults // for the miso, mosi, and sck pins are ignored - SPI.begin(sckPin, misoPin, mosiPin, csPin); + SPI.begin(sckPin, misoPin, mosiPin); } } void SPIBus::group(Configuration::HandlerBase& handler) { - handler.item("cs", _cs); + //handler.item("cs", _cs); handler.item("miso", _miso); handler.item("mosi", _mosi); handler.item("sck", _sck); @@ -43,9 +44,9 @@ namespace Machine { // XXX it would be nice to have some way to turn off SPI entirely void SPIBus::afterParse() { - if (_cs.undefined()) { - _cs = Pin::create("gpio.5"); - } + // if (_cs.undefined()) { + // _cs = Pin::create("gpio.5"); + // } if (_miso.undefined()) { _miso = Pin::create("gpio.19"); } diff --git a/FluidNC/src/Machine/SPIBus.h b/FluidNC/src/Machine/SPIBus.h index cbb8d186f..4df6c38d3 100644 --- a/FluidNC/src/Machine/SPIBus.h +++ b/FluidNC/src/Machine/SPIBus.h @@ -11,7 +11,7 @@ namespace Machine { public: SPIBus() = default; - Pin _cs; + //Pin _cs; Pin _miso; Pin _mosi; Pin _sck; diff --git a/FluidNC/src/SDCard.cpp b/FluidNC/src/SDCard.cpp index 9945a3ea9..5e8dc9006 100644 --- a/FluidNC/src/SDCard.cpp +++ b/FluidNC/src/SDCard.cpp @@ -121,16 +121,19 @@ uint32_t SDCard::lineNumber() { // 4. The SD card is not plugged in and we have to discover that by trying to read it. // 5. The SD card is plugged in but its filesystem cannot be read SDCard::State SDCard::test_or_open(bool refresh) { + //log_info("SDCard::test_or_open"); auto spiConfig = config->_spi; if (spiConfig == nullptr) { return SDCard::State::NotPresent; } - auto csPin = spiConfig->_cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); + //auto csPin = spiConfig->_cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); + auto csPin = config->_sdCard->_cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); //no need to go further if SD detect is not correct if (config->_sdCard->_cardDetect.defined() && !config->_sdCard->_cardDetect.read()) { + log_debug("SD Card not detected"); _state = SDCard::State::NotPresent; return _state; } @@ -182,6 +185,8 @@ const char* SDCard::filename() { void SDCard::init() { static bool init_message = true; // used to show messages only once. + log_info("SD Card CS:" << _cs.name() << " Card Detect:" << _cardDetect.name()); + if (init_message) { _cardDetect.report("SD Card Detect"); init_message = false; @@ -190,6 +195,12 @@ void SDCard::init() { _cardDetect.setAttr(Pin::Attr::Output); } +void SDCard::afterParse() { + if (_cs.undefined()) { + _cs = Pin::create("gpio.5"); + } +} + SDCard::~SDCard() { delete _pImpl; } diff --git a/FluidNC/src/SDCard.h b/FluidNC/src/SDCard.h index 5b1215931..a5c2483c0 100644 --- a/FluidNC/src/SDCard.h +++ b/FluidNC/src/SDCard.h @@ -57,6 +57,7 @@ class SDCard : public Configuration::Configurable { State _state; Pin _cardDetect; + Pin _cs; SDCard::State test_or_open(bool refresh); Print& _client; WebUI::AuthenticationLevel _auth_level; @@ -87,8 +88,13 @@ class SDCard : public Configuration::Configurable { // Initializes pins. void init(); + void afterParse() override; + // Configuration handlers. - void group(Configuration::HandlerBase& handler) override { handler.item("card_detect", _cardDetect); } + void group(Configuration::HandlerBase& handler) override { + handler.item("card_detect", _cardDetect); + handler.item("cs", _cs); + } ~SDCard(); }; From 3491efd1fede09c845c6754a44fbb32b9e757146 Mon Sep 17 00:00:00 2001 From: Bart Dring Date: Tue, 14 Sep 2021 07:47:38 -0500 Subject: [PATCH 2/9] Update SDCard.cpp --- FluidNC/src/SDCard.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/FluidNC/src/SDCard.cpp b/FluidNC/src/SDCard.cpp index 5e8dc9006..4de51d758 100644 --- a/FluidNC/src/SDCard.cpp +++ b/FluidNC/src/SDCard.cpp @@ -125,21 +125,23 @@ SDCard::State SDCard::test_or_open(bool refresh) { auto spiConfig = config->_spi; if (spiConfig == nullptr) { + log_info("spiConfig == nullptr"); return SDCard::State::NotPresent; } //auto csPin = spiConfig->_cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); - auto csPin = config->_sdCard->_cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); + auto csPin = _cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); //no need to go further if SD detect is not correct if (config->_sdCard->_cardDetect.defined() && !config->_sdCard->_cardDetect.read()) { - log_debug("SD Card not detected"); + log_info("SD Card not detected"); _state = SDCard::State::NotPresent; return _state; } //if busy doing something return state if (_state >= SDCard::State::Busy) { + log_info("SDCard::State::Busy"); return _state; } @@ -154,9 +156,14 @@ SDCard::State SDCard::test_or_open(bool refresh) { //refresh content if card was removed if (SD.begin(csPin, SPI, SPIfreq, "/sd", 2)) { - if (SD.cardSize() > 0) { + log_info("SD.begin"); + if (SD.cardSize() > 0) { _state = SDCard::State::Idle; + } else { + log_info("SD not > 0"); } + } else { + log_info("SD Failed begin"); } return _state; } From 10263d8e43c8059a311a2254f57952877e0f0384 Mon Sep 17 00:00:00 2001 From: Bart Dring Date: Tue, 14 Sep 2021 10:29:10 -0500 Subject: [PATCH 3/9] WIP working but hardwired in some areas --- FluidNC/src/Machine/SPIBus.cpp | 9 ++++----- FluidNC/src/Machine/SPIBus.h | 2 +- FluidNC/src/SDCard.cpp | 29 +++++++++++------------------ FluidNC/src/SDCard.h | 3 +-- 4 files changed, 17 insertions(+), 26 deletions(-) diff --git a/FluidNC/src/Machine/SPIBus.cpp b/FluidNC/src/Machine/SPIBus.cpp index 7e7ed3d35..76a98c337 100644 --- a/FluidNC/src/Machine/SPIBus.cpp +++ b/FluidNC/src/Machine/SPIBus.cpp @@ -18,10 +18,9 @@ namespace Machine { void SPIBus::init() { if (_sck.defined()) { // validation ensures the rest is also defined. - //log_info("SPI SCK:" << _sck.name() << " MOSI:" << _mosi.name() << " MISO:" << _miso.name() << " CS:" << _cs.name()); log_info("SPI SCK:" << _sck.name() << " MOSI:" << _mosi.name() << " MISO:" << _miso.name()); - //_cs.setAttr(Pin::Attr::Output); + _cs.setAttr(Pin::Attr::Output); //auto csPin = _cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); auto mosiPin = _mosi.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); @@ -44,9 +43,9 @@ namespace Machine { // XXX it would be nice to have some way to turn off SPI entirely void SPIBus::afterParse() { - // if (_cs.undefined()) { - // _cs = Pin::create("gpio.5"); - // } + if (_cs.undefined()) { + _cs = Pin::create("gpio.5"); + } if (_miso.undefined()) { _miso = Pin::create("gpio.19"); } diff --git a/FluidNC/src/Machine/SPIBus.h b/FluidNC/src/Machine/SPIBus.h index 4df6c38d3..cbb8d186f 100644 --- a/FluidNC/src/Machine/SPIBus.h +++ b/FluidNC/src/Machine/SPIBus.h @@ -11,7 +11,7 @@ namespace Machine { public: SPIBus() = default; - //Pin _cs; + Pin _cs; Pin _miso; Pin _mosi; Pin _sck; diff --git a/FluidNC/src/SDCard.cpp b/FluidNC/src/SDCard.cpp index 4de51d758..6d6c172ea 100644 --- a/FluidNC/src/SDCard.cpp +++ b/FluidNC/src/SDCard.cpp @@ -121,27 +121,22 @@ uint32_t SDCard::lineNumber() { // 4. The SD card is not plugged in and we have to discover that by trying to read it. // 5. The SD card is plugged in but its filesystem cannot be read SDCard::State SDCard::test_or_open(bool refresh) { - //log_info("SDCard::test_or_open"); auto spiConfig = config->_spi; - if (spiConfig == nullptr) { - log_info("spiConfig == nullptr"); + if (spiConfig == nullptr || _cs.undefined()) { return SDCard::State::NotPresent; } //auto csPin = spiConfig->_cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); - auto csPin = _cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); //no need to go further if SD detect is not correct - if (config->_sdCard->_cardDetect.defined() && !config->_sdCard->_cardDetect.read()) { - log_info("SD Card not detected"); + if (_cardDetect.defined() && !_cardDetect.read()) { _state = SDCard::State::NotPresent; return _state; } //if busy doing something return state if (_state >= SDCard::State::Busy) { - log_info("SDCard::State::Busy"); return _state; } @@ -155,15 +150,10 @@ SDCard::State SDCard::test_or_open(bool refresh) { _state = SDCard::State::NotPresent; //refresh content if card was removed - if (SD.begin(csPin, SPI, SPIfreq, "/sd", 2)) { - log_info("SD.begin"); - if (SD.cardSize() > 0) { + if (SD.begin(GPIO_NUM_5, SPI, SPIfreq, "/sd", 2)) { + if (SD.cardSize() > 0) { _state = SDCard::State::Idle; - } else { - log_info("SD not > 0"); } - } else { - log_info("SD Failed begin"); } return _state; } @@ -192,7 +182,10 @@ const char* SDCard::filename() { void SDCard::init() { static bool init_message = true; // used to show messages only once. - log_info("SD Card CS:" << _cs.name() << " Card Detect:" << _cardDetect.name()); + if (_cs.defined()) { + log_info("SD CS:" << _cs.name() << " Detect:" << _cardDetect.name()); + return; + } if (init_message) { _cardDetect.report("SD Card Detect"); @@ -203,9 +196,9 @@ void SDCard::init() { } void SDCard::afterParse() { - if (_cs.undefined()) { - _cs = Pin::create("gpio.5"); - } + if (_cs.undefined()) { + _cs = Pin::create("gpio.14"); + } } SDCard::~SDCard() { diff --git a/FluidNC/src/SDCard.h b/FluidNC/src/SDCard.h index a5c2483c0..d1aa63d7e 100644 --- a/FluidNC/src/SDCard.h +++ b/FluidNC/src/SDCard.h @@ -79,6 +79,7 @@ class SDCard : public Configuration::Configurable { Error readFileLine(char* line, int len); float report_perc_complete(); uint32_t lineNumber(); + void afterParse() override; Print& getClient() { return _client; } WebUI::AuthenticationLevel getAuthLevel() { return _auth_level; } @@ -88,8 +89,6 @@ class SDCard : public Configuration::Configurable { // Initializes pins. void init(); - void afterParse() override; - // Configuration handlers. void group(Configuration::HandlerBase& handler) override { handler.item("card_detect", _cardDetect); From 32e2062b4323970ce35a230a86eebf32a5d0eb41 Mon Sep 17 00:00:00 2001 From: Bart Dring Date: Tue, 14 Sep 2021 20:03:09 -0500 Subject: [PATCH 4/9] Works now - cs moved to sdcard: --- FluidNC/src/Machine/SPIBus.cpp | 11 ++--------- FluidNC/src/Machine/SPIBus.h | 1 - FluidNC/src/SDCard.cpp | 8 +++++--- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/FluidNC/src/Machine/SPIBus.cpp b/FluidNC/src/Machine/SPIBus.cpp index 76a98c337..ffee457b7 100644 --- a/FluidNC/src/Machine/SPIBus.cpp +++ b/FluidNC/src/Machine/SPIBus.cpp @@ -1,5 +1,6 @@ // Copyright (c) 2021 - Stefan de Bruijn // Copyright (c) 2021 - Mitch Bradley +// Copyright (c) 2021 - Bart Dring // Use of this source code is governed by a GPLv3 license that can be found in the LICENSE file. #include "SPIBus.h" @@ -9,7 +10,6 @@ namespace Machine { void SPIBus::validate() const { if (_miso.defined() || _mosi.defined() || _sck.defined()) { - //Assert(_cs.defined(), "SPI CS pin should be configured once"); Assert(_miso.defined(), "SPI MISO pin should be configured once"); Assert(_mosi.defined(), "SPI MOSI pin should be configured once"); Assert(_sck.defined(), "SPI SCK pin should be configured once"); @@ -20,9 +20,6 @@ namespace Machine { if (_sck.defined()) { // validation ensures the rest is also defined. log_info("SPI SCK:" << _sck.name() << " MOSI:" << _mosi.name() << " MISO:" << _miso.name()); - _cs.setAttr(Pin::Attr::Output); - - //auto csPin = _cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); auto mosiPin = _mosi.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); auto sckPin = _sck.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); auto misoPin = _miso.getNative(Pin::Capabilities::Input | Pin::Capabilities::Native); @@ -30,12 +27,11 @@ namespace Machine { // Start the SPI bus with the pins defined here. Once it has been started, // those pins "stick" and subsequent attempts to restart it with defaults // for the miso, mosi, and sck pins are ignored - SPI.begin(sckPin, misoPin, mosiPin); + SPI.begin(sckPin, misoPin, mosiPin); // CS is defined by each device } } void SPIBus::group(Configuration::HandlerBase& handler) { - //handler.item("cs", _cs); handler.item("miso", _miso); handler.item("mosi", _mosi); handler.item("sck", _sck); @@ -43,9 +39,6 @@ namespace Machine { // XXX it would be nice to have some way to turn off SPI entirely void SPIBus::afterParse() { - if (_cs.undefined()) { - _cs = Pin::create("gpio.5"); - } if (_miso.undefined()) { _miso = Pin::create("gpio.19"); } diff --git a/FluidNC/src/Machine/SPIBus.h b/FluidNC/src/Machine/SPIBus.h index cbb8d186f..b2aa2a66a 100644 --- a/FluidNC/src/Machine/SPIBus.h +++ b/FluidNC/src/Machine/SPIBus.h @@ -11,7 +11,6 @@ namespace Machine { public: SPIBus() = default; - Pin _cs; Pin _miso; Pin _mosi; Pin _sck; diff --git a/FluidNC/src/SDCard.cpp b/FluidNC/src/SDCard.cpp index 6d6c172ea..8fc834959 100644 --- a/FluidNC/src/SDCard.cpp +++ b/FluidNC/src/SDCard.cpp @@ -149,8 +149,10 @@ SDCard::State SDCard::test_or_open(bool refresh) { _state = SDCard::State::NotPresent; + auto csPin = _cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); + //refresh content if card was removed - if (SD.begin(GPIO_NUM_5, SPI, SPIfreq, "/sd", 2)) { + if (SD.begin(csPin, SPI, SPIfreq, "/sd", 2)) { if (SD.cardSize() > 0) { _state = SDCard::State::Idle; } @@ -184,7 +186,6 @@ void SDCard::init() { if (_cs.defined()) { log_info("SD CS:" << _cs.name() << " Detect:" << _cardDetect.name()); - return; } if (init_message) { @@ -192,12 +193,13 @@ void SDCard::init() { init_message = false; } + _cs.setAttr(Pin::Attr::Output); _cardDetect.setAttr(Pin::Attr::Output); } void SDCard::afterParse() { if (_cs.undefined()) { - _cs = Pin::create("gpio.14"); + _cs = Pin::create("gpio.5"); } } From 94f62881c2cf61c71743e8f8728a47afa5f9e790 Mon Sep 17 00:00:00 2001 From: Bart Dring Date: Tue, 14 Sep 2021 21:11:56 -0500 Subject: [PATCH 5/9] WIP removing default SPI - Need to make sure TMC SPI Stepper check for SPI --- FluidNC/data/TMC2130_pen.yaml | 31 +++++++++++++++++++++++++++++++ FluidNC/src/Machine/SPIBus.cpp | 23 +++++++++++++---------- FluidNC/src/Machine/SPIBus.h | 4 ++++ FluidNC/src/SDCard.cpp | 14 +++++++++----- platformio.ini | 2 +- 5 files changed, 58 insertions(+), 16 deletions(-) create mode 100644 FluidNC/data/TMC2130_pen.yaml diff --git a/FluidNC/data/TMC2130_pen.yaml b/FluidNC/data/TMC2130_pen.yaml new file mode 100644 index 000000000..be934ef99 --- /dev/null +++ b/FluidNC/data/TMC2130_pen.yaml @@ -0,0 +1,31 @@ +name: "TMC2130 Pen/Laser" +board: "TMC2130 Pen/Laser" + +stepping: + engine: RMT + idle_ms: 255 + dir_delay_us: 1 + pulse_us: 2 + disable_delay_us: 0 + +axes: + shared_stepper_disable: gpio.13:high + +spi: + miso: NO_PIN + mosi: NO_PIN + sck: NO_PIN + +coolant: + flood: NO_PIN + mist: NO_PIN + +comms: + wifi_ap: + ip_address: "192.168.0.1" + ssid: FluidNC + +probe: + pin: NO_PIN + + diff --git a/FluidNC/src/Machine/SPIBus.cpp b/FluidNC/src/Machine/SPIBus.cpp index ffee457b7..04b354d5b 100644 --- a/FluidNC/src/Machine/SPIBus.cpp +++ b/FluidNC/src/Machine/SPIBus.cpp @@ -27,7 +27,8 @@ namespace Machine { // Start the SPI bus with the pins defined here. Once it has been started, // those pins "stick" and subsequent attempts to restart it with defaults // for the miso, mosi, and sck pins are ignored - SPI.begin(sckPin, misoPin, mosiPin); // CS is defined by each device + SPI.begin(sckPin, misoPin, mosiPin); // CS is defined by each device + _defined = true; } } @@ -39,14 +40,16 @@ namespace Machine { // XXX it would be nice to have some way to turn off SPI entirely void SPIBus::afterParse() { - if (_miso.undefined()) { - _miso = Pin::create("gpio.19"); - } - if (_mosi.undefined()) { - _mosi = Pin::create("gpio.23"); - } - if (_sck.undefined()) { - _sck = Pin::create("gpio.18"); - } + // if (_miso.undefined()) { + // _miso = Pin::create("gpio.19"); + // } + // if (_mosi.undefined()) { + // _mosi = Pin::create("gpio.23"); + // } + // if (_sck.undefined()) { + // _sck = Pin::create("gpio.18"); + // } } + + bool SPIBus::defined() { return _defined; } } diff --git a/FluidNC/src/Machine/SPIBus.h b/FluidNC/src/Machine/SPIBus.h index b2aa2a66a..9b388fca1 100644 --- a/FluidNC/src/Machine/SPIBus.h +++ b/FluidNC/src/Machine/SPIBus.h @@ -21,6 +21,10 @@ namespace Machine { void init(); + bool defined(); + ~SPIBus() = default; + private: + bool _defined = false; }; } diff --git a/FluidNC/src/SDCard.cpp b/FluidNC/src/SDCard.cpp index 8fc834959..094b90f8f 100644 --- a/FluidNC/src/SDCard.cpp +++ b/FluidNC/src/SDCard.cpp @@ -123,11 +123,15 @@ uint32_t SDCard::lineNumber() { SDCard::State SDCard::test_or_open(bool refresh) { auto spiConfig = config->_spi; - if (spiConfig == nullptr || _cs.undefined()) { + if (spiConfig == nullptr || !spiConfig->defined()) { + log_debug("SPI not defined"); return SDCard::State::NotPresent; } - //auto csPin = spiConfig->_cs.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); + if (spiConfig == nullptr || _cs.undefined()) { + log_debug("SD cs not defined"); + return SDCard::State::NotPresent; + } //no need to go further if SD detect is not correct if (_cardDetect.defined() && !_cardDetect.read()) { @@ -198,9 +202,9 @@ void SDCard::init() { } void SDCard::afterParse() { - if (_cs.undefined()) { - _cs = Pin::create("gpio.5"); - } + // if (_cs.undefined()) { + // _cs = Pin::create("gpio.5"); + // } } SDCard::~SDCard() { diff --git a/platformio.ini b/platformio.ini index 06ecb6838..72f5930c3 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,7 +14,7 @@ include_dir = FluidNC lib_dir = libraries test_dir = FluidNC/test data_dir = FluidNC/data -default_envs = wifi +default_envs = noradio ;extra_configs=debug.ini [common_env_data] From ca1a50871b0ae3627fadc00a672fdae140dedb92 Mon Sep 17 00:00:00 2001 From: Bart Dring Date: Wed, 15 Sep 2021 09:21:35 -0500 Subject: [PATCH 6/9] Wip stash --- FluidNC/data/15.yaml | 180 +++++++++++++++++++++++++++++++++++++++++ FluidNC/src/Report.cpp | 16 +++- platformio.ini | 2 +- 3 files changed, 196 insertions(+), 2 deletions(-) create mode 100644 FluidNC/data/15.yaml diff --git a/FluidNC/data/15.yaml b/FluidNC/data/15.yaml new file mode 100644 index 000000000..3d1ad3210 --- /dev/null +++ b/FluidNC/data/15.yaml @@ -0,0 +1,180 @@ +board: "Test" +name: "Test" +stepping: + engine: I2S_stream + idle_ms: 250 + pulse_us: 4 + dir_delay_us: 0 + disable_delay_us: 0 + +axes: + shared_stepper_disable: gpio.13:low + x: + steps_per_mm: 800.000 + max_rate: 2000.000 + acceleration: 25.000 + max_travel: 200.000 + soft_limits: false + motor0: + limit_neg: NO_PIN + limit_pos: gpio.18 + limit_all: NO_PIN + hard_limits: true + pulloff: 1.000 + stepstick: + step: I2SO.13 + direction: I2SO.12 + disable: NO_PIN + ms1: NO_PIN + ms2: NO_PIN + ms3: NO_PIN + reset: NO_PIN + + y: + steps_per_mm: 800.000 + max_rate: 2000.000 + acceleration: 25.000 + max_travel: 200.000 + soft_limits: false + motor0: + limit_neg: NO_PIN + limit_pos: gpio.23 + limit_all: NO_PIN + hard_limits: true + pulloff: 1.000 + stepstick: + step: I2SO.10 + direction: I2SO.5 + disable: NO_PIN + ms1: NO_PIN + ms2: NO_PIN + ms3: NO_PIN + reset: NO_PIN + + z: + steps_per_mm: 800.000 + max_rate: 2000.000 + acceleration: 25.000 + max_travel: 200.000 + soft_limits: false + motor0: + limit_neg: NO_PIN + limit_pos: gpio.19 + limit_all: NO_PIN + hard_limits: true + pulloff: 1.000 + stepstick: + step: I2SO.4 + direction: I2SO.3 + disable: NO_PIN + ms1: NO_PIN + ms2: NO_PIN + ms3: NO_PIN + reset: NO_PIN + + a: + steps_per_mm: 800.000 + max_rate: 2000.000 + acceleration: 25.000 + max_travel: 200.000 + soft_limits: false + motor0: + limit_neg: NO_PIN + limit_pos: gpio.22 + limit_all: NO_PIN + hard_limits: true + pulloff: 1.000 + stepstick: + step: I2SO.2 + direction: I2SO.1 + disable: NO_PIN + ms1: NO_PIN + ms2: NO_PIN + ms3: NO_PIN + reset: NO_PIN + +i2so: + bck: gpio.2 + data: gpio.15 + ws: gpio.14 + +spi: + miso: NO_PIN + mosi: NO_PIN + sck: NO_PIN + +control: + safety_door: NO_PIN + reset: NO_PIN + feed_hold: NO_PIN + cycle_start: NO_PIN + macro0: NO_PIN + macro1: NO_PIN + macro2: NO_PIN + macro3: NO_PIN + +coolant: + flood: I2SO.11 + mist: I2SO.15 + delay_ms: 0 + +probe: + pin: NO_PIN + check_mode_start: true + +comms: + telnet_enable: true + telnet_port: 23 + http_enable: true + http_port: 80 + hostname: fluidnc + wifi_ap: + ssid: FluidNC + ip_address: 10.0.0.1 + gateway: 10.0.0.1 + netmask: 255.255.0.0 + dhcp: true + channel: 1 + wifi_sta: + ssid: Barts-WLAN + +macros: + n0: + n1: + macro0: + macro1: + macro2: + macro3: + +user_outputs: + analog0: NO_PIN + analog1: NO_PIN + analog2: NO_PIN + analog3: NO_PIN + analog_frequency0: 5000 + analog_frequency1: 5000 + analog_frequency2: 5000 + analog_frequency3: 5000 + digital0: NO_PIN + digital1: NO_PIN + digital2: NO_PIN + digital3: NO_PIN + +sdcard: + cs: gpio.5 + card_detect: NO_PIN + +software_debounce_ms: 0 +laser_mode: false +arc_tolerance: 0.002 +junction_deviation: 0.010 +verbose_errors: false +report_inches: false +homing_init_lock: true +enable_parking_override_control: false +deactivate_parking_upon_init: false +check_limits_at_init: true +limits_two_switches_on_axis: false +disable_laser_during_hold: true +use_line_numbers: false +NoSpindle: diff --git a/FluidNC/src/Report.cpp b/FluidNC/src/Report.cpp index ee8129dd9..200da7f54 100644 --- a/FluidNC/src/Report.cpp +++ b/FluidNC/src/Report.cpp @@ -206,7 +206,21 @@ void report_feedback_message(Message message) { // ok to send to all clients #include "Uart.h" // Welcome message void report_init_message(Print& client) { - client << "\r\nGrbl " << GRBL_VERSION << " [FluidNC " << GIT_TAG << GIT_REV << " '$' for help]\n"; + client << "\r\nGrbl " << GRBL_VERSION << " [FluidNC " << GIT_TAG << GIT_REV << " ("; + +#if defined(ENABLE_WIFI) || defined(ENABLE_BLUETOOTH) +# ifdef ENABLE_WIFI + client << "wifi"; +# endif + +# ifdef ENABLE_BLUETOOTH + client << "bt"; +# endif +#else + client << "noradio"; +#endif + + client << ") '$' for help]\n"; } // Prints current probe parameters. Upon a probe command, these parameters are updated upon a diff --git a/platformio.ini b/platformio.ini index 72f5930c3..06ecb6838 100644 --- a/platformio.ini +++ b/platformio.ini @@ -14,7 +14,7 @@ include_dir = FluidNC lib_dir = libraries test_dir = FluidNC/test data_dir = FluidNC/data -default_envs = noradio +default_envs = wifi ;extra_configs=debug.ini [common_env_data] From 58ed0193a13b00948a7dceb39f3a2c7b1559041f Mon Sep 17 00:00:00 2001 From: Bart Dring Date: Wed, 15 Sep 2021 12:25:35 -0500 Subject: [PATCH 7/9] WIP made sure SPI users can deal with undefined SPI - Fixed some messages - Fixed config files that would be broken --- FluidNC/data/15.yaml | 180 ---------------------- FluidNC/data/TMC2130_pen.yaml | 31 ---- FluidNC/src/Configuration/ParserHandler.h | 2 +- FluidNC/src/Machine/MachineConfig.cpp | 2 +- FluidNC/src/Machine/SPIBus.cpp | 5 +- FluidNC/src/Main.cpp | 2 +- FluidNC/src/Motors/TrinamicDriver.cpp | 13 +- FluidNC/src/SDCard.cpp | 14 +- FluidNC/src/SDCard.h | 2 +- example_configs/3axis_DAC.yaml | 111 ------------- example_configs/3axis_v4.yaml | 60 +++++--- example_configs/6_pack_TMC2130.yaml | 8 +- example_configs/6_pack_TMC5160.yaml | 8 +- example_configs/TMC2130_pen.yaml | 9 ++ example_configs/TMC2209.yaml | 8 +- example_configs/dac.yaml | 119 -------------- example_configs/test_drive_SD.yaml | 98 ++++++++++++ example_configs/tmc2209_10V.yaml | 9 ++ example_configs/tmc2209_BESC.yaml | 9 ++ example_configs/tmc2209_huanyang.yml | 9 ++ example_configs/tmc2209_laser.yaml | 9 ++ example_configs/tmc2209_relay.yaml | 9 ++ 22 files changed, 225 insertions(+), 492 deletions(-) delete mode 100644 FluidNC/data/15.yaml delete mode 100644 FluidNC/data/TMC2130_pen.yaml delete mode 100644 example_configs/3axis_DAC.yaml delete mode 100644 example_configs/dac.yaml create mode 100644 example_configs/test_drive_SD.yaml diff --git a/FluidNC/data/15.yaml b/FluidNC/data/15.yaml deleted file mode 100644 index 3d1ad3210..000000000 --- a/FluidNC/data/15.yaml +++ /dev/null @@ -1,180 +0,0 @@ -board: "Test" -name: "Test" -stepping: - engine: I2S_stream - idle_ms: 250 - pulse_us: 4 - dir_delay_us: 0 - disable_delay_us: 0 - -axes: - shared_stepper_disable: gpio.13:low - x: - steps_per_mm: 800.000 - max_rate: 2000.000 - acceleration: 25.000 - max_travel: 200.000 - soft_limits: false - motor0: - limit_neg: NO_PIN - limit_pos: gpio.18 - limit_all: NO_PIN - hard_limits: true - pulloff: 1.000 - stepstick: - step: I2SO.13 - direction: I2SO.12 - disable: NO_PIN - ms1: NO_PIN - ms2: NO_PIN - ms3: NO_PIN - reset: NO_PIN - - y: - steps_per_mm: 800.000 - max_rate: 2000.000 - acceleration: 25.000 - max_travel: 200.000 - soft_limits: false - motor0: - limit_neg: NO_PIN - limit_pos: gpio.23 - limit_all: NO_PIN - hard_limits: true - pulloff: 1.000 - stepstick: - step: I2SO.10 - direction: I2SO.5 - disable: NO_PIN - ms1: NO_PIN - ms2: NO_PIN - ms3: NO_PIN - reset: NO_PIN - - z: - steps_per_mm: 800.000 - max_rate: 2000.000 - acceleration: 25.000 - max_travel: 200.000 - soft_limits: false - motor0: - limit_neg: NO_PIN - limit_pos: gpio.19 - limit_all: NO_PIN - hard_limits: true - pulloff: 1.000 - stepstick: - step: I2SO.4 - direction: I2SO.3 - disable: NO_PIN - ms1: NO_PIN - ms2: NO_PIN - ms3: NO_PIN - reset: NO_PIN - - a: - steps_per_mm: 800.000 - max_rate: 2000.000 - acceleration: 25.000 - max_travel: 200.000 - soft_limits: false - motor0: - limit_neg: NO_PIN - limit_pos: gpio.22 - limit_all: NO_PIN - hard_limits: true - pulloff: 1.000 - stepstick: - step: I2SO.2 - direction: I2SO.1 - disable: NO_PIN - ms1: NO_PIN - ms2: NO_PIN - ms3: NO_PIN - reset: NO_PIN - -i2so: - bck: gpio.2 - data: gpio.15 - ws: gpio.14 - -spi: - miso: NO_PIN - mosi: NO_PIN - sck: NO_PIN - -control: - safety_door: NO_PIN - reset: NO_PIN - feed_hold: NO_PIN - cycle_start: NO_PIN - macro0: NO_PIN - macro1: NO_PIN - macro2: NO_PIN - macro3: NO_PIN - -coolant: - flood: I2SO.11 - mist: I2SO.15 - delay_ms: 0 - -probe: - pin: NO_PIN - check_mode_start: true - -comms: - telnet_enable: true - telnet_port: 23 - http_enable: true - http_port: 80 - hostname: fluidnc - wifi_ap: - ssid: FluidNC - ip_address: 10.0.0.1 - gateway: 10.0.0.1 - netmask: 255.255.0.0 - dhcp: true - channel: 1 - wifi_sta: - ssid: Barts-WLAN - -macros: - n0: - n1: - macro0: - macro1: - macro2: - macro3: - -user_outputs: - analog0: NO_PIN - analog1: NO_PIN - analog2: NO_PIN - analog3: NO_PIN - analog_frequency0: 5000 - analog_frequency1: 5000 - analog_frequency2: 5000 - analog_frequency3: 5000 - digital0: NO_PIN - digital1: NO_PIN - digital2: NO_PIN - digital3: NO_PIN - -sdcard: - cs: gpio.5 - card_detect: NO_PIN - -software_debounce_ms: 0 -laser_mode: false -arc_tolerance: 0.002 -junction_deviation: 0.010 -verbose_errors: false -report_inches: false -homing_init_lock: true -enable_parking_override_control: false -deactivate_parking_upon_init: false -check_limits_at_init: true -limits_two_switches_on_axis: false -disable_laser_during_hold: true -use_line_numbers: false -NoSpindle: diff --git a/FluidNC/data/TMC2130_pen.yaml b/FluidNC/data/TMC2130_pen.yaml deleted file mode 100644 index be934ef99..000000000 --- a/FluidNC/data/TMC2130_pen.yaml +++ /dev/null @@ -1,31 +0,0 @@ -name: "TMC2130 Pen/Laser" -board: "TMC2130 Pen/Laser" - -stepping: - engine: RMT - idle_ms: 255 - dir_delay_us: 1 - pulse_us: 2 - disable_delay_us: 0 - -axes: - shared_stepper_disable: gpio.13:high - -spi: - miso: NO_PIN - mosi: NO_PIN - sck: NO_PIN - -coolant: - flood: NO_PIN - mist: NO_PIN - -comms: - wifi_ap: - ip_address: "192.168.0.1" - ssid: FluidNC - -probe: - pin: NO_PIN - - diff --git a/FluidNC/src/Configuration/ParserHandler.h b/FluidNC/src/Configuration/ParserHandler.h index 6e50920c4..787e00b51 100644 --- a/FluidNC/src/Configuration/ParserHandler.h +++ b/FluidNC/src/Configuration/ParserHandler.h @@ -68,7 +68,7 @@ namespace Configuration { } if (_parser.token_.state == TokenState::Matching) { - log_error("Ignored key " << _parser.key().str()); + log_warn("Ignored key " << _parser.key().str()); } #ifdef DEBUG_CHATTY_YAML_PARSER if (_parser.token_.state == Configuration::TokenState::Matched) { diff --git a/FluidNC/src/Machine/MachineConfig.cpp b/FluidNC/src/Machine/MachineConfig.cpp index a3111b9d2..253aeedd5 100644 --- a/FluidNC/src/Machine/MachineConfig.cpp +++ b/FluidNC/src/Machine/MachineConfig.cpp @@ -36,6 +36,7 @@ namespace Machine { handler.section("axes", _axes); handler.section("i2so", _i2so); handler.section("spi", _spi); + handler.section("sdcard", _sdCard); handler.section("control", _control); handler.section("coolant", _coolant); handler.section("probe", _probe); @@ -43,7 +44,6 @@ namespace Machine { handler.section("macros", _macros); handler.section("user_outputs", _userOutputs); - handler.section("sdcard", _sdCard); handler.item("software_debounce_ms", _softwareDebounceMs); // TODO: Consider putting these under a gcode: hierarchy level? Or motion control? handler.item("laser_mode", _laserMode); diff --git a/FluidNC/src/Machine/SPIBus.cpp b/FluidNC/src/Machine/SPIBus.cpp index 04b354d5b..d6d2951f3 100644 --- a/FluidNC/src/Machine/SPIBus.cpp +++ b/FluidNC/src/Machine/SPIBus.cpp @@ -17,7 +17,7 @@ namespace Machine { } void SPIBus::init() { - if (_sck.defined()) { // validation ensures the rest is also defined. + if (_miso.defined() || _mosi.defined() || _sck.defined()) { // validation ensures the rest is also defined. log_info("SPI SCK:" << _sck.name() << " MOSI:" << _mosi.name() << " MISO:" << _miso.name()); auto mosiPin = _mosi.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); @@ -29,6 +29,9 @@ namespace Machine { // for the miso, mosi, and sck pins are ignored SPI.begin(sckPin, misoPin, mosiPin); // CS is defined by each device _defined = true; + } else { + _defined = false; + log_info("SPI not defined"); } } diff --git a/FluidNC/src/Main.cpp b/FluidNC/src/Main.cpp index 61ea155d5..f3fecbf2b 100644 --- a/FluidNC/src/Main.cpp +++ b/FluidNC/src/Main.cpp @@ -133,7 +133,7 @@ void setup() { WebUI::inputBuffer.begin(); } catch (const AssertionFailed& ex) { // This means something is terribly broken: - log_info("Critical error in main_init: " << ex.what()); + log_error("Critical error in main_init: " << ex.what()); sys.state = State::ConfigAlarm; } } diff --git a/FluidNC/src/Motors/TrinamicDriver.cpp b/FluidNC/src/Motors/TrinamicDriver.cpp index 5932a8348..f220c41c7 100644 --- a/FluidNC/src/Motors/TrinamicDriver.cpp +++ b/FluidNC/src/Motors/TrinamicDriver.cpp @@ -19,7 +19,10 @@ namespace MotorDrivers { uint8_t daisy_chain_cs = -1; void TrinamicDriver::init() { - _has_errors = false; + _has_errors = false; + auto spiConfig = config->_spi; + + Assert(spiConfig->defined(), "SPI bus is not configured. Cannot initialize TMC driver."); _cs_pin.setAttr(Pin::Attr::Output | Pin::Attr::InitialOn); _cs_mapping = PinMapper(_cs_pin); @@ -57,8 +60,7 @@ namespace MotorDrivers { config_message(); - auto spiConfig = config->_spi; - if (spiConfig != nullptr) { + if (spiConfig != nullptr || !spiConfig->defined()) { auto csPin = _cs_pin.getNative(Pin::Capabilities::Output); auto mosiPin = spiConfig->_mosi.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); auto sckPin = spiConfig->_sck.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native); @@ -96,9 +98,8 @@ namespace MotorDrivers { This is the startup message showing the basic definition */ void TrinamicDriver::config_message() { - log_info(" Trinamic TMC" << _driver_part_number << " Step:" << _step_pin.name() << " Dir:" << _dir_pin.name() - << " CS:" << _cs_pin.name() << " Disable:" << _disable_pin.name() << " Index:" << _spi_index - << " R:" << _r_sense); + log_info(" Trinamic TMC" << _driver_part_number << " Step:" << _step_pin.name() << " Dir:" << _dir_pin.name() << " CS:" + << _cs_pin.name() << " Disable:" << _disable_pin.name() << " Index:" << _spi_index << " R:" << _r_sense); } bool TrinamicDriver::test() { diff --git a/FluidNC/src/SDCard.cpp b/FluidNC/src/SDCard.cpp index 094b90f8f..be57b3cf2 100644 --- a/FluidNC/src/SDCard.cpp +++ b/FluidNC/src/SDCard.cpp @@ -124,12 +124,12 @@ SDCard::State SDCard::test_or_open(bool refresh) { auto spiConfig = config->_spi; if (spiConfig == nullptr || !spiConfig->defined()) { - log_debug("SPI not defined"); + //log_debug("SPI not defined"); return SDCard::State::NotPresent; } if (spiConfig == nullptr || _cs.undefined()) { - log_debug("SD cs not defined"); + //log_debug("SD cs not defined"); return SDCard::State::NotPresent; } @@ -188,13 +188,13 @@ const char* SDCard::filename() { void SDCard::init() { static bool init_message = true; // used to show messages only once. - if (_cs.defined()) { - log_info("SD CS:" << _cs.name() << " Detect:" << _cardDetect.name()); - } - - if (init_message) { + if (!config->_spi->defined()) { + log_error("SD needs SPI defined"); + } else { + if (init_message) { _cardDetect.report("SD Card Detect"); init_message = false; + } } _cs.setAttr(Pin::Attr::Output); diff --git a/FluidNC/src/SDCard.h b/FluidNC/src/SDCard.h index d1aa63d7e..b7085de5c 100644 --- a/FluidNC/src/SDCard.h +++ b/FluidNC/src/SDCard.h @@ -91,8 +91,8 @@ class SDCard : public Configuration::Configurable { // Configuration handlers. void group(Configuration::HandlerBase& handler) override { - handler.item("card_detect", _cardDetect); handler.item("cs", _cs); + handler.item("card_detect", _cardDetect); } ~SDCard(); diff --git a/example_configs/3axis_DAC.yaml b/example_configs/3axis_DAC.yaml deleted file mode 100644 index 67701d2a7..000000000 --- a/example_configs/3axis_DAC.yaml +++ /dev/null @@ -1,111 +0,0 @@ -name: "ESP32 Dev Controller V4" -board: "ESP32 Dev Controller V4" - -stepping: - engine: RMT - idle_ms: 250 - dir_delay_us: 1 - pulse_us: 2 - disable_delay_us: 0 - -axes: - shared_stepper_disable: gpio.13:low - - x: - steps_per_mm: 800 - max_rate: 2000 - acceleration: 25 - max_travel: 1000 - steps_per_mm: 800.000 - max_rate: 5000.000 - acceleration: 100.000 - max_travel: 300.000 - soft_limits: false - homing: - cycle: 2 - positive_direction: false - mpos: 150.000 - feed_rate: 100.000 - seek_rate: 200.000 - debounce_ms: 500 - seek_scaler: 1.100 - feed_scaler: 1.100 - - motor0: - limit_all: gpio.17:low:pu - stepstick: - direction: gpio.14 - step: gpio.12 - motor1: - null_motor: - - y: - steps_per_mm: 800 - max_rate: 2000 - acceleration: 25 - max_travel: 1000 - steps_per_mm: 800.000 - max_rate: 5000.000 - acceleration: 100.000 - max_travel: 300.000 - soft_limits: false - homing: - cycle: 2 - positive_direction: false - mpos: 150.000 - feed_rate: 100.000 - seek_rate: 200.000 - debounce_ms: 500 - seek_scaler: 1.100 - feed_scaler: 1.100 - - motor0: - limit_all: gpio.4:low:pu - stepstick: - direction: gpio.15 - step: gpio.26 - motor1: - null_motor: - - z: - steps_per_mm: 800 - max_rate: 2000 - acceleration: 25 - max_travel: 1000 - steps_per_mm: 800.000 - max_rate: 5000.000 - acceleration: 100.000 - max_travel: 300.000 - soft_limits: false - homing: - cycle: 1 - positive_direction: false - mpos: 150.000 - feed_rate: 100.000 - seek_rate: 200.000 - debounce_ms: 500 - seek_scaler: 1.100 - feed_scaler: 1.100 - - motor0: - limit_all: gpio.16:low:pu - stepstick: - direction: gpio.33 - step: gpio.27 - motor1: - null_motor: - -coolant: - flood: NO_PIN - mist: NO_PIN - -comms: - wifi_ap: - ip_address: "192.168.0.1" - ssid: FluidNC - -probe: - pin: gpio.32:low:pu - -DAC: - output_pin: gpio.25 diff --git a/example_configs/3axis_v4.yaml b/example_configs/3axis_v4.yaml index 2e3b4b4fa..b6d7f80b6 100644 --- a/example_configs/3axis_v4.yaml +++ b/example_configs/3axis_v4.yaml @@ -1,16 +1,14 @@ name: "ESP32 Dev Controller V4" board: "ESP32 Dev Controller V4" -yaml_wiki: "https://github.com/bdring/FluidNC/wiki/YAML-Config-File" -idle_time: 250 -step_type: rmt -dir_delay_microseconds: 1 -pulse_microseconds: 2 -disable_delay_us: 0 -homing_init_lock: false +stepping: + engine: RMT + idle_ms: 250 + dir_delay_us: 1 + pulse_us: 2 + disable_delay_us: 0 axes: - number_axis: 3 shared_stepper_disable: gpio.13:low x: @@ -19,6 +17,7 @@ axes: acceleration: 25 max_travel: 1000 homing: + cycle: 2 mpos: 10 positive_direction: false @@ -36,6 +35,7 @@ axes: acceleration: 25 max_travel: 1000 homing: + cycle: 2 mpos: 10 positive_direction: false @@ -53,6 +53,7 @@ axes: acceleration: 25 max_travel: 1000 homing: + cycle: 1 mpos: 10 positive_direction: true @@ -64,27 +65,44 @@ axes: motor1: null_motor: +spi: + miso: gpio.19 + mosi: gpio.23 + sck: gpio.18 + +sdcard: + cs: gpio.5 + card_detect: NO_PIN coolant: flood: gpio.25 mist: gpio.21 comms: - wifi_sta: - ssid: Barts-WLAN - - wifi_ap: - ip_address: "192.168.0.1" - ssid: FluidNC + telnet_enable: true + telnet_port: 23 + http_enable: true + http_port: 80 + hostname: fluidnc + wifi_ap: + ssid: FluidNC + ip_address: 10.0.0.1 + gateway: 10.0.0.1 + netmask: 255.255.0.0 + dhcp: true + channel: 1 probe: - pin: gpio.32:low:pu + pin: gpio.32:low:pu -pwm: +PWM: + pwm_freq: 5000 output_pin: gpio.2 enable_pin: gpio.22 - pwm_off: 0.0 - pwm_min: 0.0 - pwm_max: 100.0 - min_rpm: 0 - max_rpm: 1000 + direction_pin: NO_PIN + disable_with_zero_speed: false + zero_speed_with_disable: true + spinup_ms: 0 + spindown_ms: 0 + tool: 0 + speeds: 0=0% 10000=100% diff --git a/example_configs/6_pack_TMC2130.yaml b/example_configs/6_pack_TMC2130.yaml index c25f5b05b..c6ff13d1e 100644 --- a/example_configs/6_pack_TMC2130.yaml +++ b/example_configs/6_pack_TMC2130.yaml @@ -135,11 +135,14 @@ i2so: ws: gpio.17 spi: - cs: gpio.5 miso: gpio.19 mosi: gpio.23 sck: gpio.18 +sdcard: + card_detect: NO_PIN + cs: gpio.5 + control: safety_door: NO_PIN reset: NO_PIN @@ -196,9 +199,6 @@ user_outputs: digital2: NO_PIN digital3: NO_PIN -sdcard: - card_detect: NO_PIN - software_debounce_ms: 0 laser_mode: false arc_tolerance: 0.002 diff --git a/example_configs/6_pack_TMC5160.yaml b/example_configs/6_pack_TMC5160.yaml index 898cd5e02..bdb9ebfa6 100644 --- a/example_configs/6_pack_TMC5160.yaml +++ b/example_configs/6_pack_TMC5160.yaml @@ -135,11 +135,14 @@ i2so: ws: gpio.17 spi: - cs: gpio.5 miso: gpio.19 mosi: gpio.23 sck: gpio.18 +sdcard: + cs: gpio.5 + card_detect: NO_PIN + control: safety_door: NO_PIN reset: NO_PIN @@ -196,9 +199,6 @@ user_outputs: digital2: NO_PIN digital3: NO_PIN -sdcard: - card_detect: NO_PIN - software_debounce_ms: 0 laser_mode: false arc_tolerance: 0.002 diff --git a/example_configs/TMC2130_pen.yaml b/example_configs/TMC2130_pen.yaml index 0c1162e09..ca7621f6b 100644 --- a/example_configs/TMC2130_pen.yaml +++ b/example_configs/TMC2130_pen.yaml @@ -107,6 +107,15 @@ axes: output_pin: gpio.27 min_pulse_us: 2100 max_pulse_us: 1000 + +spi: + miso: gpio.19 + mosi: gpio.23 + sck: gpio.18 + +sdcard: + cs: gpio.5 + card_detect: NO_PIN coolant: flood: NO_PIN diff --git a/example_configs/TMC2209.yaml b/example_configs/TMC2209.yaml index 3b2a1bb73..33dbec4b4 100644 --- a/example_configs/TMC2209.yaml +++ b/example_configs/TMC2209.yaml @@ -114,11 +114,14 @@ a: direction: gpio.15 spi: - cs: gpio.5 miso: gpio.19 mosi: gpio.23 sck: gpio.18 +sdcard: + cs: gpio.5 + card_detect: NO_PIN + control: safety_door: NO_PIN reset: NO_PIN @@ -175,9 +178,6 @@ user_outputs: digital2: NO_PIN digital3: NO_PIN -sdcard: - card_detect: NO_PIN - software_debounce_ms: 0 laser_mode: false arc_tolerance: 0.002 diff --git a/example_configs/dac.yaml b/example_configs/dac.yaml deleted file mode 100644 index a58c5c98d..000000000 --- a/example_configs/dac.yaml +++ /dev/null @@ -1,119 +0,0 @@ -name: "ESP32 Dev Controller V4" -board: "ESP32 Dev Controller V4" - -stepping: - engine: RMT - idle_ms: 250 - dir_delay_us: 1 - pulse_us: 2 - disable_delay_us: 0 - -axes: - shared_stepper_disable: gpio.13:low - - x: - steps_per_mm: 800 - max_rate: 2000 - acceleration: 25 - max_travel: 1000 - steps_per_mm: 800.000 - max_rate: 5000.000 - acceleration: 100.000 - max_travel: 300.000 - soft_limits: false - homing: - cycle: 2 - positive_direction: false - mpos: 150.000 - feed_rate: 100.000 - seek_rate: 200.000 - debounce_ms: 500 - seek_scaler: 1.100 - feed_scaler: 1.100 - - motor0: - limit_all: gpio.17:low:pu - stepstick: - direction: gpio.14 - step: gpio.12 - motor1: - null_motor: - - y: - steps_per_mm: 800 - max_rate: 2000 - acceleration: 25 - max_travel: 1000 - steps_per_mm: 800.000 - max_rate: 5000.000 - acceleration: 100.000 - max_travel: 300.000 - soft_limits: false - homing: - cycle: 2 - positive_direction: false - mpos: 150.000 - feed_rate: 100.000 - seek_rate: 200.000 - debounce_ms: 500 - seek_scaler: 1.100 - feed_scaler: 1.100 - - motor0: - limit_all: gpio.4:low:pu - stepstick: - direction: gpio.15 - step: gpio.26 - motor1: - null_motor: - - z: - steps_per_mm: 800 - max_rate: 2000 - acceleration: 25 - max_travel: 1000 - steps_per_mm: 800.000 - max_rate: 5000.000 - acceleration: 100.000 - max_travel: 300.000 - soft_limits: false - homing: - cycle: 1 - positive_direction: false - mpos: 150.000 - feed_rate: 100.000 - seek_rate: 200.000 - debounce_ms: 500 - seek_scaler: 1.100 - feed_scaler: 1.100 - - motor0: - limit_all: gpio.16:low:pu - stepstick: - direction: gpio.33 - step: gpio.27 - motor1: - null_motor: - -coolant: - flood: NO_PIN - mist: NO_PIN - -comms: - wifi_ap: - ip_address: "192.168.0.1" - ssid: FluidNC - -probe: - pin: gpio.32:low:pu - -DAC: - output_pin: gpio.25 - enable_pin: NO_PIN - direction_pin: NO_PIN - disable_with_zero_speed: false - zero_speed_with_disable: true - spinup_ms: 0 - spindown_ms: 0 - tool: 100 - speeds: 0=0.000% 10000=100.000% diff --git a/example_configs/test_drive_SD.yaml b/example_configs/test_drive_SD.yaml new file mode 100644 index 000000000..ae020744f --- /dev/null +++ b/example_configs/test_drive_SD.yaml @@ -0,0 +1,98 @@ +board: None +name: Default (Test Drive) +stepping: + engine: RMT + idle_ms: 255 + pulse_us: 4 + dir_delay_us: 0 + disable_delay_us: 0 + +axes: + shared_stepper_disable: NO_PIN + x: + steps_per_mm: 320.000 + max_rate: 1000.000 + acceleration: 25.000 + max_travel: 200.000 + soft_limits: false + + y: + steps_per_mm: 320.000 + max_rate: 1000.000 + acceleration: 25.000 + max_travel: 200.000 + soft_limits: false + + z: + steps_per_mm: 320.000 + max_rate: 1000.000 + acceleration: 25.000 + max_travel: 200.000 + soft_limits: false + +spi: + miso: NO_PIN + mosi: NO_PIN + sck: NO_PIN + +control: + safety_door: NO_PIN + reset: NO_PIN + feed_hold: NO_PIN + cycle_start: NO_PIN + macro0: NO_PIN + macro1: NO_PIN + macro2: NO_PIN + macro3: NO_PIN + +coolant: + flood: NO_PIN + mist: NO_PIN + delay_ms: 0 + +probe: + pin: NO_PIN + check_mode_start: true + +comms: + +macros: + n0: + n1: + macro0: + macro1: + macro2: + macro3: + +user_outputs: + analog0: NO_PIN + analog1: NO_PIN + analog2: NO_PIN + analog3: NO_PIN + analog_frequency0: 5000 + analog_frequency1: 5000 + analog_frequency2: 5000 + analog_frequency3: 5000 + digital0: NO_PIN + digital1: NO_PIN + digital2: NO_PIN + digital3: NO_PIN + +sdcard: + card_detect: NO_PIN + cs: gpio.5 + +software_debounce_ms: 0 +laser_mode: false +arc_tolerance: 0.002 +junction_deviation: 0.010 +verbose_errors: false +report_inches: false +homing_init_lock: true +enable_parking_override_control: false +deactivate_parking_upon_init: false +check_limits_at_init: true +limits_two_switches_on_axis: false +disable_laser_during_hold: true +use_line_numbers: false +NoSpindle: diff --git a/example_configs/tmc2209_10V.yaml b/example_configs/tmc2209_10V.yaml index 7529a6937..2bfaed7f4 100644 --- a/example_configs/tmc2209_10V.yaml +++ b/example_configs/tmc2209_10V.yaml @@ -141,6 +141,15 @@ axes: motor1: null_motor: + +spi: + miso: gpio.19 + mosi: gpio.23 + sck: gpio.18 + +sdcard: + cs: gpio.5 + card_detect: NO_PIN comms: wifi_ap: diff --git a/example_configs/tmc2209_BESC.yaml b/example_configs/tmc2209_BESC.yaml index 4b069bee8..405c9bc20 100644 --- a/example_configs/tmc2209_BESC.yaml +++ b/example_configs/tmc2209_BESC.yaml @@ -141,6 +141,15 @@ axes: motor1: null_motor: + +spi: + miso: gpio.19 + mosi: gpio.23 + sck: gpio.18 + +sdcard: + cs: gpio.5 + card_detect: NO_PIN comms: wifi_ap: diff --git a/example_configs/tmc2209_huanyang.yml b/example_configs/tmc2209_huanyang.yml index dd84a7577..8fe49e0c4 100644 --- a/example_configs/tmc2209_huanyang.yml +++ b/example_configs/tmc2209_huanyang.yml @@ -140,6 +140,15 @@ axes: motor1: null_motor: + +spi: + miso: gpio.19 + mosi: gpio.23 + sck: gpio.18 + +sdcard: + cs: gpio.5 + card_detect: NO_PIN comms: wifi_ap: diff --git a/example_configs/tmc2209_laser.yaml b/example_configs/tmc2209_laser.yaml index 115e63363..a5b1652b5 100644 --- a/example_configs/tmc2209_laser.yaml +++ b/example_configs/tmc2209_laser.yaml @@ -141,6 +141,15 @@ axes: motor1: null_motor: + +spi: + miso: gpio.19 + mosi: gpio.23 + sck: gpio.18 + +sdcard: + card_detect: NO_PIN + cs: gpio.5 comms: wifi_ap: diff --git a/example_configs/tmc2209_relay.yaml b/example_configs/tmc2209_relay.yaml index 7457f1a67..f70e1a772 100644 --- a/example_configs/tmc2209_relay.yaml +++ b/example_configs/tmc2209_relay.yaml @@ -141,6 +141,15 @@ axes: motor1: null_motor: + +spi: + miso: gpio.19 + mosi: gpio.23 + sck: gpio.18 + +sdcard: + cs: gpio.5 + card_detect: NO_PIN comms: wifi_ap: From 80d18b9031f8f9353813f6c1cde7569e6a9d83bb Mon Sep 17 00:00:00 2001 From: Bart Dring Date: Wed, 15 Sep 2021 13:53:57 -0500 Subject: [PATCH 8/9] Rename Trinamic Spi driver class, fix SD config message --- ...inamicDriver.cpp => TrinamicSpiDriver.cpp} | 20 +++++++++---------- .../{TrinamicDriver.h => TrinamicSpiDriver.h} | 14 ++++++------- FluidNC/src/SDCard.cpp | 1 + 3 files changed, 18 insertions(+), 17 deletions(-) rename FluidNC/src/Motors/{TrinamicDriver.cpp => TrinamicSpiDriver.cpp} (95%) rename FluidNC/src/Motors/{TrinamicDriver.h => TrinamicSpiDriver.h} (84%) diff --git a/FluidNC/src/Motors/TrinamicDriver.cpp b/FluidNC/src/Motors/TrinamicSpiDriver.cpp similarity index 95% rename from FluidNC/src/Motors/TrinamicDriver.cpp rename to FluidNC/src/Motors/TrinamicSpiDriver.cpp index f220c41c7..ad2cb8116 100644 --- a/FluidNC/src/Motors/TrinamicDriver.cpp +++ b/FluidNC/src/Motors/TrinamicSpiDriver.cpp @@ -5,7 +5,7 @@ This is used for Trinamic SPI controlled stepper motor drivers. */ -#include "TrinamicDriver.h" +#include "TrinamicSpiDriver.h" #include "../Machine/MachineConfig.h" @@ -13,12 +13,12 @@ #include namespace MotorDrivers { - TrinamicDriver::TrinamicDriver(uint16_t driver_part_number, int8_t spi_index) : + TrinamicSpiDriver::TrinamicSpiDriver(uint16_t driver_part_number, int8_t spi_index) : TrinamicBase(driver_part_number), _spi_index(spi_index) {} uint8_t daisy_chain_cs = -1; - void TrinamicDriver::init() { + void TrinamicSpiDriver::init() { _has_errors = false; auto spiConfig = config->_spi; @@ -97,12 +97,12 @@ namespace MotorDrivers { /* This is the startup message showing the basic definition */ - void TrinamicDriver::config_message() { + void TrinamicSpiDriver::config_message() { log_info(" Trinamic TMC" << _driver_part_number << " Step:" << _step_pin.name() << " Dir:" << _dir_pin.name() << " CS:" << _cs_pin.name() << " Disable:" << _disable_pin.name() << " Index:" << _spi_index << " R:" << _r_sense); } - bool TrinamicDriver::test() { + bool TrinamicSpiDriver::test() { if (_has_errors) { return false; } @@ -152,7 +152,7 @@ namespace MotorDrivers { uint16_t run (mA) float hold (as a percentage of run) */ - void TrinamicDriver::read_settings() { + void TrinamicSpiDriver::read_settings() { if (_has_errors) { return; } @@ -173,7 +173,7 @@ namespace MotorDrivers { tmcstepper->rms_current(run_i_ma, hold_i_percent); } - bool TrinamicDriver::set_homing_mode(bool isHoming) { + bool TrinamicSpiDriver::set_homing_mode(bool isHoming) { set_mode(isHoming); return true; } @@ -183,7 +183,7 @@ namespace MotorDrivers { Many people will want quiet and stallguard homing. Stallguard only run in Coolstep mode, so it will need to switch to Coolstep when homing */ - void TrinamicDriver::set_mode(bool isHoming) { + void TrinamicSpiDriver::set_mode(bool isHoming) { if (_has_errors) { return; } @@ -232,7 +232,7 @@ namespace MotorDrivers { /* This is the stallguard tuning info. It is call debug, so it could be generic across all classes. */ - void TrinamicDriver::debug_message() { + void TrinamicSpiDriver::debug_message() { if (_has_errors) { return; } @@ -263,7 +263,7 @@ namespace MotorDrivers { // this can use the enable feature over SPI. The dedicated pin must be in the enable mode, // but that can be hardwired that way. - void IRAM_ATTR TrinamicDriver::set_disable(bool disable) { + void IRAM_ATTR TrinamicSpiDriver::set_disable(bool disable) { if (_has_errors) { return; } diff --git a/FluidNC/src/Motors/TrinamicDriver.h b/FluidNC/src/Motors/TrinamicSpiDriver.h similarity index 84% rename from FluidNC/src/Motors/TrinamicDriver.h rename to FluidNC/src/Motors/TrinamicSpiDriver.h index 5125a97ad..ee77bfc32 100644 --- a/FluidNC/src/Motors/TrinamicDriver.h +++ b/FluidNC/src/Motors/TrinamicSpiDriver.h @@ -19,7 +19,7 @@ class TMC2130Stepper; // Forward declaration namespace MotorDrivers { - class TrinamicDriver : public TrinamicBase { + class TrinamicSpiDriver : public TrinamicBase { private: const int _spi_freq = 100000; @@ -39,9 +39,9 @@ namespace MotorDrivers { void config_message() override; public: - TrinamicDriver(uint16_t driver_part_number) : TrinamicDriver(driver_part_number, -1) {} + TrinamicSpiDriver(uint16_t driver_part_number) : TrinamicSpiDriver(driver_part_number, -1) {} - TrinamicDriver(uint16_t driver_part_number, int8_t spi_index); + TrinamicSpiDriver(uint16_t driver_part_number, int8_t spi_index); // Overrides for inherited methods void init() override; @@ -67,17 +67,17 @@ namespace MotorDrivers { const char* name() const override { return "trinamic_spi"; } }; - class TMC2130 : public TrinamicDriver { + class TMC2130 : public TrinamicSpiDriver { public: - TMC2130() : TrinamicDriver(2130) {} + TMC2130() : TrinamicSpiDriver(2130) {} // Name of the configurable. Must match the name registered in the cpp file. const char* name() const override { return "tmc_2130"; } }; - class TMC5160 : public TrinamicDriver { + class TMC5160 : public TrinamicSpiDriver { public: - TMC5160() : TrinamicDriver(5160) {} + TMC5160() : TrinamicSpiDriver(5160) {} // Name of the configurable. Must match the name registered in the cpp file. const char* name() const override { return "tmc_5160"; } diff --git a/FluidNC/src/SDCard.cpp b/FluidNC/src/SDCard.cpp index be57b3cf2..e6730d95e 100644 --- a/FluidNC/src/SDCard.cpp +++ b/FluidNC/src/SDCard.cpp @@ -195,6 +195,7 @@ void SDCard::init() { _cardDetect.report("SD Card Detect"); init_message = false; } + log_info("SD Card cs:" << _cs.name() << " dectect:" << _cardDetect.name()); } _cs.setAttr(Pin::Attr::Output); From 12cf00003755bd2d4b9b7ac396d7dc9e73909a79 Mon Sep 17 00:00:00 2001 From: Bart Dring Date: Wed, 15 Sep 2021 14:06:21 -0500 Subject: [PATCH 9/9] Fixed SD config message so it only shows when a cs is defined --- FluidNC/src/SDCard.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/FluidNC/src/SDCard.cpp b/FluidNC/src/SDCard.cpp index e6730d95e..1cd60cb3c 100644 --- a/FluidNC/src/SDCard.cpp +++ b/FluidNC/src/SDCard.cpp @@ -188,14 +188,16 @@ const char* SDCard::filename() { void SDCard::init() { static bool init_message = true; // used to show messages only once. - if (!config->_spi->defined()) { - log_error("SD needs SPI defined"); - } else { - if (init_message) { - _cardDetect.report("SD Card Detect"); - init_message = false; + if (_cs.defined()) { + if (!config->_spi->defined()) { + log_error("SD needs SPI defined"); + } else { + if (init_message) { + _cardDetect.report("SD Card Detect"); + init_message = false; + } + log_info("SD Card cs:" << _cs.name() << " dectect:" << _cardDetect.name()); } - log_info("SD Card cs:" << _cs.name() << " dectect:" << _cardDetect.name()); } _cs.setAttr(Pin::Attr::Output);