1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-30 01:30:05 +02:00

$cd works for test_drive.h at least

This commit is contained in:
Mitch Bradley
2021-07-08 14:30:00 -10:00
parent aafa9da283
commit 005dea61f9
21 changed files with 531 additions and 279 deletions

View File

@@ -1,282 +1,482 @@
#include "Grbl.h"
#include "Motors/Motor.h"
#include "Motors/TrinamicDriver.h"
#include "Motors/TrinamicUartDriver.h"
#include "Motors/Dynamixel2.h"
#include "Motors/Servo.h"
#include "Motors/RcServo.h"
#include "Motors/StandardStepper.h"
#include "Motors/UnipolarMotor.h"
#include "Spindles/Spindle.h"
#include "Spindles/NullSpindle.h"
#include "Spindles/DacSpindle.h"
#include "Spindles/10vSpindle.h"
#include "Spindles/BESCSpindle.h"
#include "Spindles/H2ASpindle.h"
#include "Spindles/HuanyangSpindle.h"
#include "Spindles/PWMSpindle.h"
#include "Spindles/RelaySpindle.h"
#include "Spindles/VFDSpindle.h"
#include "Spindles/YL620Spindle.h"
#include "Spindles/Laser.h"
using namespace Motors;
using namespace Spindles;
#define p(...) \ #define p(...) \
do { \ do { \
grbl_sendf(CLIENT_SERIAL, __VA_ARGS__); \ grbl_sendf(CLIENT_SERIAL, __VA_ARGS__); \
grbl_sendf(CLIENT_SERIAL, "\n"); \
} while (0); } while (0);
const char* tf(bool v) { return v ? "true" : "false" }; const char* tf(bool v) {
void print_steps(int axis) { return v ? "true" : "false";
p(" steps_per_mm: %f", axis_settings[axis]->steps_per_mm->get()); };
p(" max_rate: %f", axis_settings[axis]->max_rate->get()); static int indent = 0;
p(" acceleration: %f", axis_settings[axis]->acceleration->get()); void print_indent() {
p(" max_travel: %f", axis_settings[axis]->max_travel->get()); for (int i = 0; i < indent; ++i) {
p(" soft_limits: %s", tf(soft_limits->get())); p(" ");
}
}
void section(const char* name) {
print_indent();
p("%s:\n", name);
indent += 2;
}
void end_section() {
indent -= 2;
}
void item(const char* name, int value) {
print_indent();
p("%s: %d\n", name, value);
}
void item(const char* name, unsigned int value) {
print_indent();
p("%s: %u\n", name, value);
}
void item(const char* name, bool value) {
print_indent();
p("%s: %s\n", name, value ? "true" : "false");
}
void item(const char* name, const char* value) {
print_indent();
p("%s: %s\n", name, value);
}
void item(const char* name, float value) {
print_indent();
p("%s: %0.3f\n", name, value);
}
const char* pinspec(int pin_number, bool active_low = false, bool pullup = false) {
if (pin_number == -1) {
return "UNSPECIFIED";
}
if (pin_number == UNDEFINED_PIN) {
return "NO_PIN";
}
static char temp[50];
temp[0] = '\0';
if (pin_number < I2S_OUT_PIN_BASE) {
sprintf(temp, "gpio.%d", pin_number);
} else {
sprintf(temp, "i2so.%d", pin_number - I2S_OUT_PIN_BASE);
}
if (active_low) {
strcat(temp, ":low");
}
if (pullup) {
strcat(temp, ":pu");
}
return temp;
}
void print_uart(int portnum, uint8_t txd, uint8_t rxd, uint8_t rts, uint32_t baudrate, const char* mode) {
section("uart");
item("txd_pin", pinspec(txd));
item("rxd_pin", pinspec(rxd));
item("rts_pin", pinspec(rts));
item("cts_pin", pinspec(UNDEFINED_PIN)); // Nothing in the old code uses CTS
item("baud", baudrate);
item("mode", mode);
end_section();
}
void print_steps(int axis) {
item("steps_per_mm", axis_settings[axis]->steps_per_mm->get());
item("max_rate", axis_settings[axis]->max_rate->get());
item("acceleration", axis_settings[axis]->acceleration->get());
item("max_travel", axis_settings[axis]->max_travel->get());
item("soft_limits", tf(soft_limits->get()));
} }
void print_homing(int axis) { void print_homing(int axis) {
for (int cycle; cycle < MAX_N_AXIS; cycle++) { int cycle;
if (bitnum_istrue(homing_cycle[cycle], axis)) { for (cycle = 0; cycle < MAX_N_AXIS; cycle++) {
if (bitnum_istrue(homing_cycle[cycle]->get(), axis)) {
break; break;
} }
} }
if (cycle == MAX_N_AXIS) { if (cycle == MAX_N_AXIS) {
// XXX alternative: set cycle to 0
return; return;
} }
p(" homing:") p(" cycle", cycle); section("homing");
p(" positive_direction: %s", tf(bitnum_istrue(homing_dir_mask->get(), axis)));
p(" mpos: %f", axis_settings[axis]->home_mpos->get()); item("cycle", cycle + 1);
p(" debounce: %f", homing_debounce->get()); item("positive_direction", bitnum_istrue(homing_dir_mask->get(), axis));
p(" pulloff: %f", homing_pulloff->get()); item("mpos", axis_settings[axis]->home_mpos->get());
p(" square: %s", tf(bitnum_istrue(homing_squared_axes->get, axis)); item("debounce", homing_debounce->get());
p(" seek_rate: %f", homing_seek_rate->get()); item("pulloff", homing_pulloff->get());
p(" feed_rate: %f", homing_feed_rate->get()); item("square", bitnum_istrue(homing_squared_axes->get(), axis));
p(" seek_scaler: %f", HOMING_AXIS_SEARCH_SCALAR); item("seek_rate", homing_seek_rate->get());
p(" feed_scaler: %f", HOMING_AXIS_LOCATE_SCALAR); item("feed_rate", homing_feed_rate->get());
float hass = 1.1f;
#ifdef HOMING_AXIS_SEARCH_SCALAR
hass = HOMING_AXIS_SEARCH_SCALAR;
#endif
item("seek_scaler", hass);
float hals = 5.0f;
#ifdef HOMING_AXIS_LOCATE_SCALAR
hals = HOMING_AXIS_LOCATE_SCALAR;
#endif
item("feed_scaler", hals);
end_section();
} }
void print_endstops(int axis, int gang) { void print_endstops(int axis, int gang) {
if (limit_pins[axis][gang] != UNDEFINED_PIN) { if (limit_pins[axis][gang] != UNDEFINED_PIN) {
p(" endstops:"); section("endstops");
p(" dual: %s", print_pin(limit_pins[axis][gang], limit_invert->get(), DISABLE_LIMIT_PIN_PULL_UP)); bool dlppu = false;
p(" hard_limits: %s", tf(DEFAULT_HARD_LIMIT_ENABLE)); #ifdef DISABLE_LIMIT_PIN_PULL_UP
dlppu = true;
#endif
item("dual", pinspec(limit_pins[axis][gang], limit_invert->get(), dlppu));
item("hard_limits", bool(DEFAULT_HARD_LIMIT_ENABLE));
end_section();
} }
} }
void print_motor(Motor* m, int axis, int gang) { void print_motor(Motor* m, int axis, int gang, const char* name) {
p(" %s:", m->name()); section(name);
} }
void print_servo(Motor* m, int axis, int gang) { void print_servo(Motor* m, int axis, int gang, const char* name = "servo") {
print_motor(m, axis, gang)); print_motor(m, axis, gang, name);
} }
void print_rc_servo(Motor* m, int axis, int gang) { void print_rc_servo(RcServo* m, int axis, int gang, const char* name = "rc_servo") {
print_servo(m, axis, gang); print_servo(m, axis, gang, name);
p(" cal_min: %f", m->_cal_min); item("cal_min", m->rc_servo_cal_min->get());
p(" cal_max: %f", m->_cal_max); item("cal_max", m->rc_servo_cal_max->get());
p(" pwm: %s" print_pin(m->_pwm_pin, false)) item("pwm", pinspec(m->_pwm_pin, false));
end_section();
} }
void print_solenoid(Motor* m, int axis, int gang) { #if 0
print_rc_servo(m, axis, gang); void print_solenoid(Solenoid* m, int axis, int gang, const char* name = "solenoid") {
p(" transition_point: %f", 1.0f); // Placeholder print_rc_servo(m, axis, gang, name);
item("transition_point", 1.0f); // Placeholder
end_section();
} }
void print_unipolar(Motor* m, int axis, int gang) { #endif
print_motor(m, axis, gang)); void print_unipolar(UnipolarMotor* m, int axis, int gang, const char* name = "unipolar") {
p(" phase0: %s", print_pin(m->_pin_phase0, false)); print_motor(m, axis, gang, name);
p(" phase1: %s", print_pin(m->_pin_phase1, false)); item("phase0", pinspec(m->_pin_phase0, false));
p(" phase2: %s", print_pin(m->_pin_phase2, false)); item("phase1", pinspec(m->_pin_phase1, false));
p(" phase3: %s", print_pin(m->_pin_phase3, false)); item("phase2", pinspec(m->_pin_phase2, false));
p(" half_step: %s", tf(m->_half_step))); item("phase3", pinspec(m->_pin_phase3, false));
item("half_step", tf(m->_half_step));
end_section();
} }
void print_dynamixel(Motor* m, int axis, int gang) { void print_dynamixel(Dynamixel2* m, int axis, int gang, const char* name = "dynamixel2") {
print_servo(m, axis, gang); print_servo(m, axis, gang, name);
p(" invert_direction: %s", tf(bitnum_istrue(dir_invert_mask->get(), axis))); item("invert_direction", bitnum_istrue(dir_invert_mask->get(), axis));
p(" count_min: %d", int(m->dxl_count_min)); item("count_min", m->_dxl_count_min);
p(" count_max: %d", int(m->dxl_count_max)); item("count_max", m->_dxl_count_max);
p(" full_time_move: %d", DYNAMIXEL_FULL_MOVE_TIME); item("id", m->ids[axis][gang]);
p(" id: %d", m->ids[axis][gang]); print_uart(m->_uart_num, m->_tx_pin, m->_rx_pin, m->_rts_pin, DYNAMIXEL_BAUD_RATE, "8n1");
p(" uart:"); end_section();
print_uart(m->_uart_num, m->_tx_pin, m->_rx_pin, m->_rts_pin);
} }
void print_stepstick(Motor* m, int axis, int gang) { void print_stepper(StandardStepper* m, int axis, int gang, const char* name) {
print_motor(m, axis, gang); print_motor(m, axis, gang, name);
p(" direction: %s", print_pin(m->_dir_pin, m->_invert_dir_pin)); item("direction", pinspec(m->_dir_pin, m->_invert_dir_pin));
p(" step: %s", print_pin(m->_step_pin, m->_invert_step_pin)); item("step", pinspec(m->_step_pin, m->_invert_step_pin));
p(" disable: %s", print_pin(m->_disable_pin, false)); item("disable", pinspec(m->_disable_pin, false));
}
void print_stepstick(StandardStepper* m, int axis, int gang, const char* name) {
print_stepper(m, axis, gang, name);
end_section();
} }
const char* trinamicModes(TrinamicMode mode) { const char* trinamicModes(TrinamicMode mode) {
const char* ret;
switch (mode) { switch (mode) {
case TrinamicMode::None:
ret = "ERROR";
case TrinamicMode::CoolStep: case TrinamicMode::CoolStep:
return "CoolStep"; ret = "CoolStep";
case TrinamicMode::StealthChop: case TrinamicMode::StealthChop:
return "StealthChop"; ret = "StealthChop";
case TrinamicMode::Stallguard: case TrinamicMode::StallGuard:
return "Stallguard"; ret = "Stallguard";
} }
return ret;
} }
void print_trinamic_base(Motor* m, int axis, int gang) { void print_trinamic_common(int axis, int gang, TrinamicMode run, TrinamicMode homing) {
print_stepstick(m, axis, gang); item("run_current", axis_settings[axis]->run_current->get());
p(" r_sense: %f", m->_r_sense); item("hold_current", axis_settings[axis]->hold_current->get());
p(" run_current: %f", axis_settings[axis]->run_current->get()); item("microsteps", axis_settings[axis]->microsteps->get());
p(" hold_current: %f", axis_settings[axis]->hold_current->get()); item("stallguard", axis_settings[axis]->stallguard->get());
p(" microsteps: %d", axis_settings[axis]->microsteps->get()); item("stallguardDebugMode", false);
p(" stallguard: %d", axis_settings[axis]->stallguard->get()); item("run_mode", trinamicModes(run));
p(" stallguardDebugMode: %s", tf(false)); item("homing_mode", trinamicModes(homing));
p(" run_mode: %s", _run_mode, trinamicModes(TRINAMIC_RUN_MODE));
p(" homing_mode: %s", _homing_mode, trinamicModes(TRINAMIC_HOMING_MODE));
#ifdef USE_TRINAMIC_ENABLE #ifdef USE_TRINAMIC_ENABLE
p(" use_enable: %s", tf(true)); item("use_enable", tf(true));
p(" toff_disable: %d", TRINAMIC_TOFF_DISABLE); item("toff_disable", TRINAMIC_TOFF_DISABLE);
p(" toff_stealthchop: %d", TRINAMIC_TOFF_STEALTHCHOP); item("toff_stealthchop", TRINAMIC_TOFF_STEALTHCHOP);
p(" toff_coolstep: %d", TRINAMIC_TOFF_COOLSTEP); item("toff_coolstep", TRINAMIC_TOFF_COOLSTEP);
#else #else
p(" use_enable: %s", tf(false)); item("use_enable", tf(false));
#endif #endif
} }
void print_trinamic_spi(Motor* m, int axis, int gang) { void print_trinamic_spi(TrinamicDriver* m, int axis, int gang, const char* name = "trinamic_spi") {
print_trinamic_base(m, axis, gang); print_stepper(m, axis, gang, name);
p(" cs: %s", print_pin(m->_cs_pin, true)); print_trinamic_common(axis, gang, TRINAMIC_RUN_MODE, TRINAMIC_HOMING_MODE);
item("r_sense", m->_r_sense);
item("cs", pinspec(m->_cs_pin, true));
end_section();
} }
void print_trinamic_uart(Motor* m, int axis, int gang) { void print_trinamic_uart(TrinamicUartDriver* m, int axis, int gang, const char* name = "trinamic_uart") {
print_trinamic_base(m, axis, gang); print_stepper(m, axis, gang, name);
p(" uart:"); item("r_sense", m->_r_sense);
print_uart(???); print_trinamic_common(axis, gang, TrinamicMode(TRINAMIC_UART_RUN_MODE), TrinamicMode(TRINAMIC_UART_HOMING_MODE));
print_uart(TMC_UART, TMC_UART_TX, TMC_UART_RX, UNDEFINED_PIN, 115200, "8n1");
end_section();
} }
void print_motor_class(Motor* m, int axis, int gang) { void print_null_motor(Motor* m, int axis, int gang, const char* name) {
print_motor(m, axis, gang, name);
end_section();
}
void print_motor_class(int axis, int gang) {
Motor* m = myMotor[axis][gang];
const char* name = m->name(); const char* name = m->name();
if (!strcmp(name, "null_motor")) { if (!strcasecmp(name, "null_motor")) {
print_motor_name(name); print_null_motor(m, axis, gang, name);
return; return;
} }
if (!strcmp(name, "stepstick")) { if (!strcasecmp(name, "stepstick")) {
print_stepstick(m, axis, gang); print_stepstick((StandardStepper*)m, axis, gang, name);
return; return;
} }
if (!strcmp(name, "solenoid")) { #if 0
print_solenoid(name); if (!strcasecmp(name, "solenoid")) {
print_solenoid((Solenoid*)m, axis, gang, name);
return; return;
} }
if (!strcmp(name, "rc_servo")) { #endif
print_rc_servo(name); if (!strcasecmp(name, "rc_servo")) {
print_rc_servo((RcServo*)m, axis, gang, name);
return; return;
} }
if (!strcmp(name, "dynamixel2")) { if (!strcasecmp(name, "dynamixel2")) {
print_dynamixel(m, axis, gang); print_dynamixel((Dynamixel2*)m, axis, gang, name);
return; return;
} }
if (!strcmp(name, "unipolar")) { if (!strcasecmp(name, "unipolar")) {
print_unipolar(name); print_unipolar((UnipolarMotor*)m, axis, gang, name);
return; return;
} }
if (!strcmp(name, "tmc_2130" || !strcmp(name, "tmc_5160")) { if (!strcasecmp(name, "tmc_2130") || !strcasecmp(name, "tmc_5160")) {
print_trinamic_spi(name); print_trinamic_spi((TrinamicDriver*)m, axis, gang, name);
return; return;
} }
if (!strcmp(name, "tmc_2208" || !strcmp(name, "tmc_2209")) { if (!strcasecmp(name, "tmc_2208") || !strcasecmp(name, "tmc_2209")) {
print_trinamic_uart(name); print_trinamic_uart((TrinamicUartDriver*)m, axis, gang, name);
return; return;
} }
} }
void print_axes() { const char* axis_names[] = { "x", "y", "z", "a", "b", "c" };
p("axes:"); void print_axes() {
for (int axis = 0; axis <= n_axis; axis++) { section("axes");
p(" %c:", "xyzabc"[axis]); for (int axis = 0; axis < number_axis->get(); axis++) {
section(axis_names[axis]);
print_steps(axis); print_steps(axis);
print_homing(axis); print_homing(axis);
for (int gang = 0; gang < 2; gang++) { for (int gang = 0; gang < 2; gang++) {
print_endstops(axis);
p(" gang%d:", gang);
print_endstops(axis, gang); print_endstops(axis, gang);
print_motor_class(myMotor[axis][gang], axis, gang); section(gang ? "gang1" : "gang0");
print_endstops(axis, gang);
print_motor_class(axis, gang);
end_section();
} }
end_section();
} }
end_section();
} }
void print_stepping() { void print_stepping() {
p(" engine: %s", stepper_names[current_stepper]); section("stepping");
p(" idle_ms: %d", stepper_idle_lock_time); item("engine", stepper_names[current_stepper]);
p(" pulse_us: %d", pulse_microseconds); item("idle_ms", stepper_idle_lock_time->get());
p(" dir_delay_us: %d", direction_delay_microseconds); item("pulse_us", pulse_microseconds->get());
p(" disable_delay_us: %d", enable_delay_microseconds); item("dir_delay_us", direction_delay_microseconds->get());
item("disable_delay_us", enable_delay_microseconds->get());
end_section();
} }
void print_i2so() { void print_i2so() {
p("i2so:"); section("i2so");
p(" bck: %s", print_pin(_bck, ); item("bck", pinspec(I2S_OUT_BCK));
p(" data: %s", print_pin(_data, ); item("data", pinspec(I2S_OUT_DATA));
p(" ws: %s", print_pin(_ws, ); item("ws", pinspec(I2S_OUT_WS));
end_section();
} }
void print_spi() { void print_spi() {
p("spi:"); section("spi");
p(" cs: %s", print_pin(_cs, ); // -1 is not the same as UNDEFINED_PIN; -1 means use the hardware default
p(" miso %s", print_pin(_miso, ); item("cs", pinspec(GRBL_SPI_SS == -1 ? GPIO_NUM_5 : GRBL_SPI_SS));
p(" mosi %s", print_pin(_mosi, ); item("miso", pinspec(GRBL_SPI_MISO == -1 ? GPIO_NUM_19 : GRBL_SPI_MISO));
p(" sck %s", print_pin(_sck, ); item("mosi", pinspec(GRBL_SPI_MOSI == -1 ? GPIO_NUM_23 : GRBL_SPI_MOSI));
item("sck", pinspec(GRBL_SPI_SCK == -1 ? GPIO_NUM_18 : GRBL_SPI_SCK));
end_section();
} }
#ifndef CONTROL_SAFETY_DOOR_PIN
# define CONTROL_SAFETY_DOOR_PIN UNDEFINED_PIN
#endif
#ifndef CONTROL_RESET_PIN
# define CONTROL_RESET_PIN UNDEFINED_PIN
#endif
#ifndef CONTROL_FEED_HOLD_PIN
# define CONTROL_FEED_HOLD_PIN UNDEFINED_PIN
#endif
#ifndef CONTROL_CYCLE_START_PIN
# define CONTROL_CYCLE_START_PIN UNDEFINED_PIN
#endif
#ifndef MACRO_BUTTON_0_PIN
# define MACRO_BUTTON_0_PIN UNDEFINED_PIN
#endif
#ifndef MACRO_BUTTON_1_PIN
# define MACRO_BUTTON_1_PIN UNDEFINED_PIN
#endif
#ifndef MACRO_BUTTON_2_PIN
# define MACRO_BUTTON_2_PIN UNDEFINED_PIN
#endif
#ifndef MACRO_BUTTON_3_PIN
# define MACRO_BUTTON_3_PIN UNDEFINED_PIN
#endif
void print_control() { void print_control() {
p("control:"); bool pu = true;
p(" safety_door: %s", print_pin(CONTROL_SAFETY_DOOR_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 0), DISABLE_CONTROL_PIN_PULL_UP); #ifdef DISABLE_CONTROL_PIN_PULL_UP
p(" reset: %s", print_pin(CONTROL_RESET_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 1), DISABLE_CONTROL_PIN_PULL_UP); pu = false;
p(" feed_hold: %s", print_pin(CONTROL_FEED_HOLD_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 2), DISABLE_CONTROL_PIN_PULL_UP); #endif
p(" cycle_start: %s", print_pin(CONTROL_CYCLE_START_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 3), DISABLE_CONTROL_PIN_PULL_UP); section("control");
p(" macro0: %s", print_pin(MACRO_BUTTON_0_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 4), DISABLE_CONTROL_PIN_PULL_UP); item("safety_door", pinspec(CONTROL_SAFETY_DOOR_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 0), pu));
p(" macro1: %s", print_pin(MACRO_BUTTON_1_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 5), DISABLE_CONTROL_PIN_PULL_UP); item("reset", pinspec(CONTROL_RESET_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 1), pu));
p(" macro2: %s", print_pin(MACRO_BUTTON_2_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 6), DISABLE_CONTROL_PIN_PULL_UP); item("cycle_start", pinspec(CONTROL_CYCLE_START_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 3), pu));
p(" macro3: %s", print_pin(MACRO_BUTTON_3_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 7), DISABLE_CONTROL_PIN_PULL_UP); item("macro0", pinspec(MACRO_BUTTON_0_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 4), pu));
item("macro1", pinspec(MACRO_BUTTON_1_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 5), pu));
item("macro2", pinspec(MACRO_BUTTON_2_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 6), pu));
item("macro3", pinspec(MACRO_BUTTON_3_PIN, bitnum_istrue(INVERT_CONTROL_PIN_MASK, 7), pu));
end_section();
} }
#ifndef COOLANT_FLOOD_PIN
# define COOLANT_FLOOD_PIN UNDEFINED_PIN
#endif
#ifndef COOLANT_MIST_PIN
# define COOLANT_MIST_PIN UNDEFINED_PIN
#endif
void print_coolant() { void print_coolant() {
p("coolant:"); section("coolant");
p(" flood: %s", print_pin(COOLANT_FLOOD_PIN, INVERT_COOLANT_FLOOD_PIN)); bool floodlow = false;
p(" mist: %s", print_pin(COOLANT_MIST_PIN, INVERT_COOLANT_MIST_PIN)); #ifdef INVERT_COOLANT_FLOOD_PIN
p(" delay: %f", coolant_start_delay->get()); // XXX should the be int as delay_ms? floodlow = true;
#endif
item("flood", pinspec(COOLANT_FLOOD_PIN, floodlow, floodlow));
bool mistlow = false;
#ifdef INVERT_COOLANT_MIST_PIN
mistlow = true;
#endif
item("mist", pinspec(COOLANT_MIST_PIN, mistlow, mistlow));
item("delay_ms", coolant_start_delay->get() * 1000);
end_section();
} }
void print_probe() { void print_probe() {
p("probe:"); section("probe");
p(" pin: %s", print_pin(PROBE_PIN, probe_invert->get(), DISABLE_PROBE_PIN_INPUT_PULLUP); bool pu = true;
#ifdef DISABLE_PROBE_PIN_INPUT_PULLUP
pu = false;
#endif
item("pin", pinspec(PROBE_PIN, probe_invert->get(), pu));
bool cms = false; bool cms = false;
#ifdef SET_CHECK_MODE_PROBE_TO_START #ifdef SET_CHECK_MODE_PROBE_TO_START
cms = true; cms = true;
#endif #endif
p(" check_mode_start: %s", cms); item("check_mode_start", cms);
end_section();
} }
void print_comms() { void print_comms() {
p("comms:"); section("comms");
// XXX // XXX
end_section();
} }
void print_macros() { void print_macros() {
p("macros:"); section("macros");
p(" n0: %s", startup_line0->get()); item("n0", startup_line_0->get());
p(" n1: %s", startup_line1->get()); item("n1", startup_line_1->get());
p(" macro0: %s", user_macro0->get()); item("macro0", user_macro0->get());
p(" macro1: %s", user_macro1->get()); item("macro1", user_macro1->get());
p(" macro2: %s", user_macro2->get()); item("macro2", user_macro2->get());
p(" macro3: %s", user_macro3->get()); item("macro3", user_macro3->get());
end_section();
}
const char* makeSpeedMap(PWM* s) {
return "0=0% 1000=100%";
} }
void print_spindle(const char* name, Spindle* s) { void print_spindle(const char* name, Spindle* s) {
p("%s:", name); section(name);
p(" spinup_ms: %d", s->_spinup_delay); item("spinup_ms", s->_spinup_delay);
p(" spindown_ms: %d", s->_spindown_delay); item("spindown_ms", s->_spindown_delay);
p(" tool: 0"); item("tool", int(0));
p(" speeds: %s", makeSpeedMap(s)); item("speeds", makeSpeedMap((PWM*)s));
end_section();
} }
void print_onoff_spindle(const char* name, Spindle* s) { void print_onoff_spindle(const char* name, PWM* s) {
print_spindle(name, s); print_spindle(name, s);
p(" output_pin: %s", print_pin(s->_output_pin)); item("output_pin", pinspec(s->_output_pin, s->_invert_pwm, false));
p(" enable_pin: %s", print_pin(s->_enable_pin)); item("enable_pin", pinspec(s->_enable_pin));
p(" direction_pin: %s", print_pin(s->_direction_pin)); item("direction_pin", pinspec(s->_direction_pin));
p(" disable_with_zero_speed: %s", tf(s->_off_with_zero_speed)); item("disable_with_zero_speed", bool(s->_off_with_zero_speed));
p(" zero_speed_with_disable: %s", tf(false)); item("zero_speed_with_disable", false);
end_section();
} }
void print_pwm_spindle(const char* name = "pwm", Spindle* s = &pwmb) { void print_pwm_spindle(const char* name, PWM* s) {
print_onoff_spindle(name, s); print_onoff_spindle(name, s);
p(" pwm_freq: %d", s-?_pwm_freq)'' item("pwm_freq", s->_pwm_freq);
end_section();
} }
void print_relay_spindle() { void print_relay_spindle(Relay* s) {
Spindle* s = &relay;
print_onoff_spindle("relay", s); print_onoff_spindle("relay", s);
end_section();
} }
void print_laser_spindle() { void print_laser_spindle(Laser* s) {
print_pwm_spindle("laser", s); print_pwm_spindle("laser", s);
// XXX should this be just full_power ? end_section();
p(" laser_full_power: %u", laser_full_power->get());
} }
void print_dac_spindle() { void print_dac_spindle(Dac* s) {
print_onoff_spindle("dac", &dac); print_onoff_spindle("dac", s);
end_section();
} }
void print_besc_spindle(BESC* s) {
void print_besc_spindle() {
Spindle* s = &besc;
print_pwm_spindle("besc", s); print_pwm_spindle("besc", s);
// XXX override frequency to BEDC_PWM_FREQ and period to BESC_PULSE_PERIOD // XXX override frequency to BEDC_PWM_FREQ and period to BESC_PULSE_PERIOD
p(" min_pulse_us: %d", int(BESC_MIN_PULSE_SECS * 1000000)); item("min_pulse_us", int(BESC_MIN_PULSE_SECS * 1000000));
p(" max_pulse_us: %d", int(BESC_MAX_PULSE_SECS * 1000000)) item("max_pulse_us", int(BESC_MAX_PULSE_SECS * 1000000));
end_section();
} }
void print_10v_spindle() { void print_10v_spindle(_10v* s) {
Spindle* s = &_10v;
print_pwm_spindle("10v", s); print_pwm_spindle("10v", s);
end_section();
} }
void print_vfd_spindle(const char* name, Spindle* s) { void print_vfd_spindle(const char* name, VFD* s) {
print_spindle(name, s); print_spindle(name, s);
print_uart(VFD_RS485_UART_PORT, print_uart(VFD_RS485_UART_PORT,
#ifdef VFD_RS485_TXD_PIN VFD_RS485_TXD_PIN #ifdef VFD_RS485_TXD_PIN
VFD_RS485_TXD_PIN VFD_RS485_TXD_PIN
#else #else
-1 -1
@@ -304,65 +504,70 @@ void print_vfd_spindle(const char* name, Spindle* s) {
#ifdef VFD_RS485_PARITY #ifdef VFD_RS485_PARITY
# if VFD_RS485_PARITY == Uart::Parity::None # if VFD_RS485_PARITY == Uart::Parity::None
"8n1" "8n1"
# else if VFD_RS485_PARITY == Uart::Parity::Even # elseif VFD_RS485_PARITY == Uart::Parity::Even
"8e1" "8e1"
# else if VFD_RS485_PARITY == Uart::Parity::Odd # else // VFD_RS485_PARITY == Uart::Parity::Odd
"8o1" "8o1"
# endif # endif
#else #else
"8n1" "8n1"
#endif #endif
); );
end_section();
} }
void print_huanyang_spindle() { void print_huanyang_spindle(Huanyang* s) {
print_vfd_spindle("huanyang", &huanyang); print_vfd_spindle("huanyang", s);
end_section();
} }
void print_h2a_spindle() { void print_h2a_spindle(H2A* s) {
print_vfd_spindle("h2a", &h2a); print_vfd_spindle("h2a", s);
end_section();
} }
void print_yl620_spindle() { void print_yl620_spindle(YL620* s) {
print_vfd_spindle("yl620", &yl620); print_vfd_spindle("yl620", s);
end_section();
} }
void print_spindle_class() { void print_spindle_class() {
Spindle* s = spindle;
switch (spindle_type->get()) { switch (spindle_type->get()) {
case SpindleType::NONE: case int8_t(SpindleType::NONE):
break; break;
case SpindleType::PWM: case int8_t(SpindleType::PWM):
print_pwm_spindle(); print_pwm_spindle("pwm", (PWM*)s);
break; break;
case SpindleType::RELAY: case int8_t(SpindleType::RELAY):
print_relay_spindle(); print_relay_spindle((Relay*)s);
break; break;
case SpindleType::LASER: case int8_t(SpindleType::LASER):
print_laser_spindle(); print_laser_spindle((Laser*)s);
break; break;
case SpindleType::DAC: case int8_t(SpindleType::DAC):
print_dac_spindle(); print_dac_spindle((Dac*)s);
break; break;
case SpindleType::HUANYANG: case int8_t(SpindleType::HUANYANG):
print_huanyang_spindle(); print_huanyang_spindle((Huanyang*)s);
break; break;
case SpindleType::BESC: case int8_t(SpindleType::BESC):
print_besc_spindle(); print_besc_spindle((BESC*)s);
break; break;
case SpindleType::_10V: case int8_t(SpindleType::_10V):
print_10v_spindle(); print_10v_spindle((_10v*)s);
break; break;
case SpindleType::H2A: case int8_t(SpindleType::H2A):
print_h2a_spindle(); print_h2a_spindle((H2A*)s);
break; break;
case SpindleType::YL620: case int8_t(SpindleType::YL620):
print_yl620_spindle(); print_yl620_spindle((YL620*)s);
break; break;
} }
} }
void print_machine() { void dump_config() {
p("board", _board); item("board", "unknown");
p("name", _name); item("name", MACHINE_NAME);
print_stepping(); print_stepping();
print_axes(); print_axes();
print_i2so(); print_i2so();
@@ -377,59 +582,61 @@ void print_machine() {
#ifdef ENABLE_SOFTWARE_DEBOUNCE #ifdef ENABLE_SOFTWARE_DEBOUNCE
db = DEBOUNCE_PERIOD; db = DEBOUNCE_PERIOD;
#endif #endif
p("software_debounce_ms", db); item("software_debounce_ms", db);
// TODO: Consider putting these under a gcode: hierarchy level? Or motion control? // TODO: Consider putting these under a gcode: hierarchy level? Or motion control?
p("laser_mode: %", laser_mode->get()); item("laser_mode", laser_mode->get());
p("arc_tolerance: %", arc_tolerance->get()); item("arc_tolerance", arc_tolerance->get());
p("junction_deviation: %", junction_deviation->get()); item("junction_deviation", junction_deviation->get());
p("verbose_errors: %", verbose_errors->get()); item("verbose_errors", verbose_errors->get());
bool hil = false; bool hil = false;
#ifdef HOMING_INIT_LOCK #ifdef HOMING_INIT_LOCK
hil = true; hil = true;
#endif #endif
p("homing_init_lock: %s", tf(hil)); item("homing_init_lock", tf(hil));
p("report_inches: %", report_inches->get()); item("report_inches", report_inches->get());
bool epoc = false; bool epoc = false;
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL #ifdef ENABLE_PARKING_OVERRIDE_CONTROL
epoc = true; epoc = true;
#endif #endif
p("enable_parking_override_control: %", tf(epoc)); item("enable_parking_override_control", tf(epoc));
bool dpoi = false; bool dpoi = false;
#ifdef DEACTIVATE_PARKING_UPON_INIT #ifdef DEACTIVATE_PARKING_UPON_INIT
dpoi = true; dpoi = true;
#endif #endif
p("deactivate_parking_upon_init: %", tf(dpoi)); item("deactivate_parking_upon_init", tf(dpoi));
bool clai = false; bool clai = false;
#ifdef CHECK_LIMITS_AT_INIT #ifdef CHECK_LIMITS_AT_INIT
clai = true; clai = true;
#endif #endif
p("check_limits_at_init: %", tf(clai)); item("check_limits_at_init", tf(clai));
bool l2soa = false; bool l2soa = false;
#ifdef LIMITS_TWO_SWITCHES_ON_AXES #ifdef LIMITS_TWO_SWITCHES_ON_AXES
l2soa = true; l2soa = true;
#endif #endif
p("limits_two_switches_on_axis: %", tf(l2soa)); item("limits_two_switches_on_axis", tf(l2soa));
bool dldh = false; bool dldh = false;
#ifdef DISABLE_LASER_DURING_HOLD #ifdef DISABLE_LASER_DURING_HOLD
dldh = true; dldh = true;
#endif #endif
p("disable_laser_during_hold: %", tf(dldh)); item("disable_laser_during_hold", tf(dldh));
bool uln = false; bool uln = false;
#ifdef USE_LINE_NUMBERS #ifdef USE_LINE_NUMBERS
uln = true; uln = true;
#endif #endif
p("use_line_numbers: %", tf(uln); item("use_line_numbers", uln);
print_spindle_class(); print_spindle_class();
} }
#if 0
void machine_init() { void machine_init() {
print_machine(); print_machine();
} }
#endif

View File

@@ -0,0 +1,2 @@
#pragma once
extern void dump_config();

View File

@@ -945,18 +945,6 @@ int IRAM_ATTR i2s_out_init(i2s_out_init_t& init_param) {
return 0; return 0;
} }
#ifndef I2S_OUT_WS
# define I2S_OUT_WS GPIO_NUM_17
#endif
#ifndef I2S_OUT_BCK
# define I2S_OUT_BCK GPIO_NUM_22
#endif
#ifndef I2S_OUT_DATA
# define I2S_OUT_DATA GPIO_NUM_21
#endif
#ifndef I2S_OUT_INIT_VAL
# define I2S_OUT_INIT_VAL 0
#endif
/* /*
Initialize I2S out by default parameters. Initialize I2S out by default parameters.

View File

@@ -41,18 +41,18 @@
// It should be included at the outset to know the machine configuration. // It should be included at the outset to know the machine configuration.
#include "Config.h" #include "Config.h"
# include <stdint.h> #include <stdint.h>
/* Assert */ /* Assert */
# if defined(I2S_OUT_NUM_BITS) #if defined(I2S_OUT_NUM_BITS)
# if (I2S_OUT_NUM_BITS != 16) && (I2S_OUT_NUM_BITS != 32) # if (I2S_OUT_NUM_BITS != 16) && (I2S_OUT_NUM_BITS != 32)
# error "I2S_OUT_NUM_BITS should be 16 or 32" # error "I2S_OUT_NUM_BITS should be 16 or 32"
# endif
# else
# define I2S_OUT_NUM_BITS 32
# endif # endif
#else
# define I2S_OUT_NUM_BITS 32
#endif
# define I2SO(n) (I2S_OUT_PIN_BASE + n) #define I2SO(n) (I2S_OUT_PIN_BASE + n)
/* 16-bit mode: 1000000 usec / ((160000000 Hz) / 10 / 2) x 16 bit/pulse x 2(stereo) = 4 usec/pulse */ /* 16-bit mode: 1000000 usec / ((160000000 Hz) / 10 / 2) x 16 bit/pulse x 2(stereo) = 4 usec/pulse */
/* 32-bit mode: 1000000 usec / ((160000000 Hz) / 5 / 2) x 32 bit/pulse x 2(stereo) = 4 usec/pulse */ /* 32-bit mode: 1000000 usec / ((160000000 Hz) / 5 / 2) x 32 bit/pulse x 2(stereo) = 4 usec/pulse */
@@ -187,3 +187,15 @@ int i2s_out_reset();
Reference: "ESP32 Technical Reference Manual" by Espressif Systems Reference: "ESP32 Technical Reference Manual" by Espressif Systems
https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf https://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdf
*/ */
#ifndef I2S_OUT_WS
# define I2S_OUT_WS GPIO_NUM_17
#endif
#ifndef I2S_OUT_BCK
# define I2S_OUT_BCK GPIO_NUM_22
#endif
#ifndef I2S_OUT_DATA
# define I2S_OUT_DATA GPIO_NUM_21
#endif
#ifndef I2S_OUT_INIT_VAL
# define I2S_OUT_INIT_VAL 0
#endif

View File

@@ -57,3 +57,5 @@ bool limitsCheckTravel(float* target);
// check if a switch has been defined // check if a switch has been defined
bool limitsSwitchDefined(uint8_t axis, uint8_t gang_index); bool limitsSwitchDefined(uint8_t axis, uint8_t gang_index);
extern uint8_t limit_pins[MAX_N_AXIS][2];

View File

@@ -84,16 +84,26 @@ namespace Motors {
void set_disable(bool disable) override; void set_disable(bool disable) override;
void update() override; void update() override;
const char* name() override { return "Dynamixel2"; }
static bool uart_ready; static bool uart_ready;
static uint8_t ids[MAX_N_AXIS][2]; static uint8_t ids[MAX_N_AXIS][2];
float _dxl_count_min;
float _dxl_count_max;
uint8_t _id;
uint8_t _tx_pin;
uint8_t _rx_pin;
uint8_t _rts_pin;
uart_port_t _uart_num;
protected: protected:
void config_message() override; void config_message() override;
void set_location(); void set_location();
uint8_t _id;
char _dxl_tx_message[50]; // outgoing to dynamixel char _dxl_tx_message[50]; // outgoing to dynamixel
uint8_t _dxl_rx_message[50]; // received from dynamixel uint8_t _dxl_rx_message[50]; // received from dynamixel
@@ -113,14 +123,6 @@ namespace Motors {
float _homing_position; float _homing_position;
float _dxl_count_min;
float _dxl_count_max;
uint8_t _tx_pin;
uint8_t _rx_pin;
uint8_t _rts_pin;
uart_port_t _uart_num;
bool _disabled; bool _disabled;
bool _has_errors; bool _has_errors;
}; };

View File

@@ -94,6 +94,8 @@ namespace Motors {
// called from a periodic task. // called from a periodic task.
virtual void update() {} virtual void update() {}
virtual const char* name() = 0;
protected: protected:
// config_message(), called from init(), displays a message describing // config_message(), called from init(), displays a message describing
// the motor configuration - pins and other motor-specific items // the motor configuration - pins and other motor-specific items
@@ -115,3 +117,4 @@ namespace Motors {
uint8_t _dual_axis_index; // 0 = primary 1=ganged uint8_t _dual_axis_index; // 0 = primary 1=ganged
}; };
} }
extern Motors::Motor* myMotor[MAX_AXES][MAX_GANGED];

View File

@@ -7,5 +7,7 @@ namespace Motors {
public: public:
Nullmotor(uint8_t axis_index); Nullmotor(uint8_t axis_index);
bool set_homing_mode(bool isHoming) { return false; } bool set_homing_mode(bool isHoming) { return false; }
const char* name() override { return "null_motor"; }
}; };
} }

View File

@@ -36,15 +36,19 @@ namespace Motors {
void set_disable(bool disable) override; void set_disable(bool disable) override;
void update() override; void update() override;
const char* name() override { return "rc_servo"; }
void _write_pwm(uint32_t duty); void _write_pwm(uint32_t duty);
uint8_t _pwm_pin;
FloatSetting* rc_servo_cal_min;
FloatSetting* rc_servo_cal_max;
protected: protected:
void config_message() override; void config_message() override;
void set_location(); void set_location();
uint8_t _pwm_pin;
uint8_t _channel_num; uint8_t _channel_num;
uint32_t _current_pwm_duty; uint32_t _current_pwm_duty;
@@ -54,8 +58,5 @@ namespace Motors {
float _pwm_pulse_max; float _pwm_pulse_max;
bool _disabled; bool _disabled;
};
FloatSetting* rc_servo_cal_min;
FloatSetting* rc_servo_cal_max;
};
} }

View File

@@ -36,6 +36,8 @@ namespace Motors {
bool set_homing_mode(bool isHoming) override; bool set_homing_mode(bool isHoming) override;
void set_disable(bool disable) override; void set_disable(bool disable) override;
#endif #endif
const char* name() override { return "servo"; }
virtual void update() = 0; // This must be implemented by derived classes virtual void update() = 0; // This must be implemented by derived classes
protected: protected:

View File

@@ -11,9 +11,11 @@ namespace Motors {
void update() override; void update() override;
void init() override; void init() override;
void set_disable(bool disable) override; void set_disable(bool disable) override;
void name() override { return "unipolar"; }
float _transition_poiont; float _transition_poiont;
protected:
protected:
void config_message() override; void config_message() override;
}; };
} }

View File

@@ -17,6 +17,8 @@ namespace Motors {
void unstep() override; void unstep() override;
void read_settings() override; void read_settings() override;
const char* name() override { return "stepstick"; }
void init_step_dir_pins(); void init_step_dir_pins();
protected: protected:
@@ -25,6 +27,7 @@ namespace Motors {
#ifdef USE_RMT_STEPS #ifdef USE_RMT_STEPS
rmt_channel_t _rmt_chan_num; rmt_channel_t _rmt_chan_num;
#endif #endif
public:
bool _invert_step_pin; bool _invert_step_pin;
bool _invert_dir_pin; bool _invert_dir_pin;
uint8_t _step_pin; uint8_t _step_pin;

View File

@@ -95,6 +95,8 @@ namespace Motors {
bool set_homing_mode(bool ishoming) override; bool set_homing_mode(bool ishoming) override;
void set_disable(bool disable) override; void set_disable(bool disable) override;
const char* name() override { return _driver_part_number == 2130 ? "tmc_2130" : "tmc_5160"; }
void debug_message(); void debug_message();
private: private:
@@ -102,12 +104,20 @@ namespace Motors {
TMC2130Stepper* tmcstepper; // all other driver types are subclasses of this one TMC2130Stepper* tmcstepper; // all other driver types are subclasses of this one
TrinamicMode _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 public:
float _r_sense; uint8_t _cs_pin = UNDEFINED_PIN; // The chip select pin (can be the same for daisy chain)
int8_t _spi_index;
bool _has_errors; private:
bool _disabled; uint16_t _driver_part_number; // example: use 2130 for TMC2130
public:
float _r_sense;
private:
int8_t _spi_index;
bool _has_errors;
bool _disabled;
TrinamicMode _mode = TrinamicMode::None; TrinamicMode _mode = TrinamicMode::None;
bool test(); bool test();

View File

@@ -97,6 +97,8 @@ namespace Motors {
bool set_homing_mode(bool is_homing) override; bool set_homing_mode(bool is_homing) override;
void set_disable(bool disable) override; void set_disable(bool disable) override;
const char* name() override { return _driver_part_number == 2008 ? "tmc_2008" : "tmc_2009"; }
uint8_t addr; uint8_t addr;
private: private:
@@ -105,9 +107,13 @@ namespace Motors {
TMC2209Stepper* tmcstepper; // all other driver types are subclasses of this one TMC2209Stepper* tmcstepper; // all other driver types are subclasses of this one
TrinamicUartMode _homing_mode; TrinamicUartMode _homing_mode;
uint16_t _driver_part_number; // example: use 2209 for TMC2209 uint16_t _driver_part_number; // example: use 2209 for TMC2209
float _r_sense;
bool _has_errors; public:
bool _disabled; float _r_sense;
private:
bool _has_errors;
bool _disabled;
TrinamicUartMode _mode = TrinamicUartMode::None; TrinamicUartMode _mode = TrinamicUartMode::None;
bool test(); bool test();

View File

@@ -14,17 +14,18 @@ namespace Motors {
void set_direction(bool) override; void set_direction(bool) override;
void step() override; void step() override;
private:
uint8_t _pin_phase0; uint8_t _pin_phase0;
uint8_t _pin_phase1; uint8_t _pin_phase1;
uint8_t _pin_phase2; uint8_t _pin_phase2;
uint8_t _pin_phase3; uint8_t _pin_phase3;
uint8_t _current_phase;
bool _half_step; bool _half_step;
private:
uint8_t _current_phase;
bool _enabled; bool _enabled;
bool _dir; bool _dir;
protected: protected:
void config_message() override; void config_message() override;
}; };
} }

View File

@@ -1,6 +1,7 @@
#include "Grbl.h" #include "Grbl.h"
#include <map> #include <map>
#include "Regex.h" #include "Regex.h"
#include "DumpConfig.h"
// WG Readable and writable as guest // WG Readable and writable as guest
// WU Readable and writable as user and admin // WU Readable and writable as user and admin
@@ -290,6 +291,11 @@ Error report_startup_lines(const char* value, WebUI::AuthenticationLevel auth_le
return Error::Ok; return Error::Ok;
} }
Error dump_config_command(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
dump_config();
return Error::Ok;
}
std::map<const char*, uint8_t, cmp_str> restoreCommands = { std::map<const char*, uint8_t, cmp_str> restoreCommands = {
#ifdef ENABLE_RESTORE_DEFAULT_SETTINGS #ifdef ENABLE_RESTORE_DEFAULT_SETTINGS
{ "$", SettingsRestore::Defaults }, { "settings", SettingsRestore::Defaults }, { "$", SettingsRestore::Defaults }, { "settings", SettingsRestore::Defaults },
@@ -461,6 +467,8 @@ void make_grbl_commands() {
new GrblCommand("I", "Build/Info", get_report_build_info, idleOrAlarm); new GrblCommand("I", "Build/Info", get_report_build_info, idleOrAlarm);
new GrblCommand("N", "GCode/StartupLines", report_startup_lines, idleOrAlarm); new GrblCommand("N", "GCode/StartupLines", report_startup_lines, idleOrAlarm);
new GrblCommand("RST", "Settings/Restore", restore_settings, idleOrAlarm, WA); new GrblCommand("RST", "Settings/Restore", restore_settings, idleOrAlarm, WA);
new GrblCommand("CD", "Config/Dump", dump_config_command, anyState);
}; };
// normalize_key puts a key string into canonical form - // normalize_key puts a key string into canonical form -

View File

@@ -36,16 +36,6 @@
const double BESC_PWM_FREQ = 50.0; // Hz const double BESC_PWM_FREQ = 50.0; // Hz
const double BESC_PULSE_PERIOD = (1.0 / BESC_PWM_FREQ); const double BESC_PULSE_PERIOD = (1.0 / BESC_PWM_FREQ);
// Ok to tweak. These are the pulse lengths in seconds
// #define them in your machine definition file if you want different values
#ifndef BESC_MIN_PULSE_SECS
# define BESC_MIN_PULSE_SECS 0.0009f // in seconds
#endif
#ifndef BESC_MAX_PULSE_SECS
# define BESC_MAX_PULSE_SECS 0.0022f // in seconds
#endif
//calculations...don't change //calculations...don't change
const uint16_t BESC_MIN_PULSE_CNT = static_cast<uint16_t>(BESC_MIN_PULSE_SECS / BESC_PULSE_PERIOD * 65535.0); const uint16_t BESC_MIN_PULSE_CNT = static_cast<uint16_t>(BESC_MIN_PULSE_SECS / BESC_PULSE_PERIOD * 65535.0);
const uint16_t BESC_MAX_PULSE_CNT = static_cast<uint16_t>(BESC_MAX_PULSE_SECS / BESC_PULSE_PERIOD * 65535.0); const uint16_t BESC_MAX_PULSE_CNT = static_cast<uint16_t>(BESC_MAX_PULSE_SECS / BESC_PULSE_PERIOD * 65535.0);

View File

@@ -52,3 +52,12 @@ namespace Spindles {
virtual ~BESC() {} virtual ~BESC() {}
}; };
} }
// Ok to tweak. These are the pulse lengths in seconds
// #define them in your machine definition file if you want different values
#ifndef BESC_MIN_PULSE_SECS
# define BESC_MIN_PULSE_SECS 0.0009f // in seconds
#endif
#ifndef BESC_MAX_PULSE_SECS
# define BESC_MAX_PULSE_SECS 0.0022f // in seconds
#endif

View File

@@ -44,7 +44,9 @@ namespace Spindles {
virtual ~PWM() {} virtual ~PWM() {}
protected: protected:
int32_t _current_pwm_duty; int32_t _current_pwm_duty;
public:
uint32_t _min_rpm; uint32_t _min_rpm;
uint32_t _max_rpm; uint32_t _max_rpm;
uint32_t _pwm_off_value; uint32_t _pwm_off_value;
@@ -65,7 +67,7 @@ namespace Spindles {
virtual void set_dir_pin(bool Clockwise); virtual void set_dir_pin(bool Clockwise);
virtual void set_output(uint32_t duty); virtual void set_output(uint32_t duty);
virtual void set_enable_pin(bool enable_pin); virtual void set_enable_pin(bool enable_pin);
virtual void deinit(); void deinit() override;
virtual void get_pins_and_settings(); virtual void get_pins_and_settings();
uint8_t calc_pwm_precision(uint32_t freq); uint8_t calc_pwm_precision(uint32_t freq);

View File

@@ -42,7 +42,6 @@
// be plenty: assuming 9600 8N1, that's roughly 250 chars. A message of 2x16 chars with 4x4 // be plenty: assuming 9600 8N1, that's roughly 250 chars. A message of 2x16 chars with 4x4
// chars buffering is just 40 chars. // chars buffering is just 40 chars.
const int VFD_RS485_UART_PORT = 2; // hard coded for this port right now
const int VFD_RS485_BUF_SIZE = 127; const int VFD_RS485_BUF_SIZE = 127;
const int VFD_RS485_QUEUE_SIZE = 10; // numv\ber of commands that can be queued up. const int VFD_RS485_QUEUE_SIZE = 10; // numv\ber of commands that can be queued up.
const int RESPONSE_WAIT_MILLIS = 1000; // how long to wait for a response in milliseconds const int RESPONSE_WAIT_MILLIS = 1000; // how long to wait for a response in milliseconds

View File

@@ -101,4 +101,5 @@ namespace Spindles {
virtual ~VFD() {} virtual ~VFD() {}
}; };
const int VFD_RS485_UART_PORT = 2; // hard coded for this port right now
} }