Skip to content

Commit

Permalink
Merge pull request #664 from bdring/Devt
Browse files Browse the repository at this point in the history
Devt
  • Loading branch information
bdring authored Oct 30, 2022
2 parents aff7f17 + c236e42 commit b129708
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 41 deletions.
34 changes: 15 additions & 19 deletions .github/ISSUE_TEMPLATE/problem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,27 @@ labels: ["triage"]
body:
- type: markdown
attributes:
value: Please fill in the forms below. The better the information you provide, the better we can help you. Information that you might think is irrelevant is often the key to solving the problem.
value: Please fill in the forms below. The better the information you provide, the better we can help you. Information that you might think is irrelevant is often the key to solving the problem. **If we have to keep asking for information that you should have provided at the outset, we will become annoyed fairly quickly.** The amount of information that we ask for might seem excessive; it is not. We handle several issues a day. We cannot solve problems efficiently if we have to keep going back and forth for the basic information that we need.
- type: textarea
id: controller-board
attributes:
label: Controller Board
description: |
Tell us which controller board you are using, for example 6-pack, MPCNC, MKS DLC32, XPro V5, etc.
Tell us which controller board you are using, for example 6-pack, MKS DLC32, XPro V5, etc.
If it listed at https://github.com/bdring/FluidNC/wiki/Hardware-that-Runs-FluidNC , just give
the name. If it is not, provide a photo and a link to documentation. If it a custom board of
your own design, tell us all about it and, if possible, provide a photo and a link to schematics.
the name and version. If it is not, **provide a photo** and documentation. If it a custom
board of your own design, you need to give us **a lot** of information. Do not expect us to
guess.
value: 6-pack
validations:
required: true
- type: checkboxes
id: vendor-help
attributes:
label: Help From Board Vendor
description: If the board is not one of Bart Dring's designs, have you asked the board vendor for help?
options:
- label: "Yes"
- label: "No"
- label: "Not Applicable"
- type: textarea
id: machine-description
attributes:
label: Machine Description
description: Tell us about your machine - is it a mill, router, laser engraver, or what?
description: |
Tell us about your machine and provide detailed photos, especially of parts of the machine
you are having trouble with.
placeholder: Gantry router with external DM542 stepper drivers, dual Y motors, optical endstops on all axes. Spindle is a DeWalt DW618M router.
validations:
required: true
Expand All @@ -41,10 +35,11 @@ body:
label: Input Circuits
description: |
If your problem is in any way related to input pins, limits, or homing, please supply
schematics for the corresponding circuits. You can supply a link to a schematic for
schematics and photos for the corresponding circuits. You can supply a link to a schematic for
a third party board, a hand-drawn schematic, or anything that will let us understand
the circuits. If you are using one of Bart's modular boards, also indicate which
input module you are using.
input module you are using. We need to know what is on both ends of the circuit - the
switch end, the controller end, and everything in between.
placeholder: <Input pin circuit>
render: yaml
validations:
Expand All @@ -65,7 +60,8 @@ body:
description: |
Paste the startup messages here. You can see them by sending "$ss" from FluidTerm, WebUI Console, or any sender's console.
Look through the messages for any MSG:ERR or MSG:WARN lines. They indicate problems in your config file. You might be able
to solve the problem yourself.
to solve the problem yourself. **Do not excerpt just the messages you think are revelant.
We need to see everything.**
placeholder: <Paste startup messages here>
render: text
validations:
Expand All @@ -74,13 +70,13 @@ body:
id: user-interface
attributes:
label: User Interface Software
description: What user interface software are you using when the problem happens? List all that you have tried.
description: What user interface software are you using when the problem happens? List all that you have tried. We will be able to help you better if you can reproduce the problem with FluidTerm.
placeholder: E.g. WebUI, FluidTerm, UGS, Candle, ...
- type: textarea
id: what-happened
attributes:
label: What happened?
description: Tell use exactly what you did, what you expected to happen, and what happened instead. The more detail, the better.
description: Tell use exactly what you did, what you expected to happen, and what happened instead. The more detail, the better. **Do not summarize by saying, for example, "I tried to jog". Tell us step by step which commands you typed or which buttons you pushed**
placeholder: I did something, expected this, and that happened
validations:
required: true
Expand Down
4 changes: 4 additions & 0 deletions FluidNC/src/I2SOut.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
/* 32-bit mode: 1000000 usec / ((160000000 Hz) / 5 / 2) x 32 bit/pulse x 2(stereo) = 4 usec/pulse */
const uint32_t I2S_OUT_USEC_PER_PULSE = 4;

// This value is empirically determined. It might depend on I2S_OUT_USEC_PULSE but
// the root cause of the limitation has not been analyzed so that is just a guess.
const uint32_t I2S_STREAM_MAX_USEC_PER_PULSE = 20;

constexpr uint32_t i2s_out_max_steps_per_sec = 1000000 / (2 * I2S_OUT_USEC_PER_PULSE);

const int I2S_OUT_DMABUF_COUNT = 5; /* number of DMA buffers to store data */
Expand Down
9 changes: 9 additions & 0 deletions FluidNC/src/Machine/Homing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,15 @@ namespace Machine {
_phaseAxes = _cycleAxes;
_phaseMotors = _cycleMotors;

// _phaseMotors can be 0 if set_homing_mode() either rejected all the
// motors or handled them independently. In that case we do not have
// to run a conventional move-to-limit cycle. Just skip to the end.
if (!_phaseMotors) {
_phase = static_cast<Phase>(static_cast<int>(Phase::CycleDone) - 1);
nextPhase();
return;
}

if (_phase == Phase::PrePulloff) {
if (!(limited() & _phaseMotors)) {
// No initial pulloff needed
Expand Down
2 changes: 1 addition & 1 deletion FluidNC/src/Motors/RcServo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ namespace MotorDrivers {

// Homing justs sets the new system position and the servo will move there
bool RcServo::set_homing_mode(bool isHoming) {
//log_info("Servo homing:" << isHoming);
log_debug("Servo homing:" << isHoming);
if (_has_errors)
return false;

Expand Down
40 changes: 23 additions & 17 deletions FluidNC/src/Motors/StandardStepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,35 @@ namespace MotorDrivers {
next_RMT_chan_num = static_cast<rmt_channel_t>(static_cast<int>(next_RMT_chan_num) + 1);
}

rmt_config_t rmtConfig;
rmtConfig.rmt_mode = RMT_MODE_TX;
rmtConfig.clk_div = 20;
rmtConfig.mem_block_num = 2;
rmtConfig.tx_config.loop_en = false;
rmtConfig.tx_config.carrier_en = false;
rmtConfig.tx_config.carrier_freq_hz = 0;
rmtConfig.tx_config.carrier_duty_percent = 50;
rmtConfig.tx_config.carrier_level = RMT_CARRIER_LEVEL_LOW;
rmtConfig.tx_config.idle_output_en = true;
auto step_pin_gpio = step_pin.getNative(Pin::Capabilities::Output);

rmt_config_t rmtConfig = { .rmt_mode = RMT_MODE_TX,
.channel = rmt_chan_num,
.gpio_num = gpio_num_t(step_pin_gpio),
.clk_div = 20,
.mem_block_num = 2,
.flags = 0,
.tx_config = {
.carrier_freq_hz = 0,
.carrier_level = RMT_CARRIER_LEVEL_LOW,
.idle_level = invert_step ? RMT_IDLE_LEVEL_HIGH : RMT_IDLE_LEVEL_LOW,
.carrier_duty_percent = 50,
#if SOC_RMT_SUPPORT_TX_LOOP_COUNT
.loop_count = DONT_KNOW_YET_SINCE_ESP32_DOES_NOT_HAVE_IT,
#endif
.carrier_en = false,
.loop_en = false,
.idle_output_en = true,
} };

rmt_item32_t rmtItem[2];
rmtItem[0].duration0 = dir_delay_ms ? dir_delay_ms * 4 : 1;
rmtItem[0].duration1 = 4 * pulse_us;
rmtItem[1].duration0 = 0;
rmtItem[1].duration1 = 0;

auto step_pin_gpio = step_pin.getNative(Pin::Capabilities::Output);
rmt_set_source_clk(rmt_chan_num, RMT_BASECLK_APB);
rmtConfig.channel = rmt_chan_num;
rmtConfig.tx_config.idle_level = invert_step ? RMT_IDLE_LEVEL_HIGH : RMT_IDLE_LEVEL_LOW;
rmtConfig.gpio_num = gpio_num_t(step_pin_gpio);
rmtItem[0].level0 = rmtConfig.tx_config.idle_level;
rmtItem[0].level1 = !rmtConfig.tx_config.idle_level;
rmtItem[0].level0 = rmtConfig.tx_config.idle_level;
rmtItem[0].level1 = !rmtConfig.tx_config.idle_level;
rmt_config(&rmtConfig);
rmt_fill_tx_items(rmtConfig.channel, &rmtItem[0], rmtConfig.mem_block_num, 0);
}
Expand Down Expand Up @@ -88,6 +93,7 @@ namespace MotorDrivers {
void IRAM_ATTR StandardStepper::step() {
if (config->_stepping->_engine == Stepping::RMT && _rmt_chan_num != RMT_CHANNEL_MAX) {
RMT.conf_ch[_rmt_chan_num].conf1.mem_rd_rst = 1;
RMT.conf_ch[_rmt_chan_num].conf1.mem_rd_rst = 0;
RMT.conf_ch[_rmt_chan_num].conf1.tx_start = 1;
} else {
_step_pin.on();
Expand Down
8 changes: 6 additions & 2 deletions FluidNC/src/Stepping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ namespace Machine {
void Stepping::group(Configuration::HandlerBase& handler) {
handler.item("engine", _engine, stepTypes);
handler.item("idle_ms", _idleMsecs, 0, 10000000); // full range
handler.item("pulse_us", _pulseUsecs, 0, 10);
handler.item("pulse_us", _pulseUsecs, 0, 30);
handler.item("dir_delay_us", _directionDelayUsecs, 0, 10);
handler.item("disable_delay_us", _disableDelayUsecs, 0, 10);
handler.item("segments", _segments, 6, 20);
Expand All @@ -146,9 +146,13 @@ namespace Machine {
if (_engine == I2S_STREAM || _engine == I2S_STATIC) {
Assert(config->_i2so, "I2SO bus must be configured for this stepping type");
if (_pulseUsecs < I2S_OUT_USEC_PER_PULSE) {
log_info("Increasing stepping/pulse_us to the IS2 minimum value " << I2S_OUT_USEC_PER_PULSE);
log_warn("Increasing stepping/pulse_us to the IS2 minimum value " << I2S_OUT_USEC_PER_PULSE);
_pulseUsecs = I2S_OUT_USEC_PER_PULSE;
}
if (_engine == I2S_STREAM && _pulseUsecs > I2S_STREAM_MAX_USEC_PER_PULSE) {
log_warn("Decreasing stepping/pulse_us to " << I2S_STREAM_MAX_USEC_PER_PULSE << ", the maximum value for I2S_STREAM");
_pulseUsecs = I2S_STREAM_MAX_USEC_PER_PULSE;
}
}
}

Expand Down
11 changes: 9 additions & 2 deletions FluidNC/src/Uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "Uart.h"

#include <driver/uart.h>
#include <esp_ipc.h>

Uart::Uart(int uart_num, bool addCR) : Channel("uart", addCR) {
// Auto-assign Uart harware engine numbers; the pins will be
Expand Down Expand Up @@ -43,6 +44,10 @@ void Uart::begin() {
begin(static_cast<unsigned long>(baud));
}

static void uart_driver_n_install(void* arg) {
uart_driver_install((uart_port_t)arg, 256, 0, 0, NULL, ESP_INTR_FLAG_IRAM);
}

void Uart::begin(unsigned long baudrate, UartData dataBits, UartStop stopBits, UartParity parity) {
// uart_driver_delete(_uart_num);
uart_config_t conf;
Expand All @@ -56,7 +61,10 @@ void Uart::begin(unsigned long baudrate, UartData dataBits, UartStop stopBits, U
// TODO FIXME - should this throw an error?
return;
};
uart_driver_install(_uart_num, 256, 0, 0, NULL, 0);

// We init the UART on core 0 so the interrupt handler runs there,
// thus avoiding conflict with the StepTimer interrupt
esp_ipc_call_blocking(0, uart_driver_n_install, (void*)_uart_num);
}

int Uart::available() {
Expand Down Expand Up @@ -186,7 +194,6 @@ bool Uart::flushTxTimed(TickType_t ticks) {
Uart Uart0(0, true); // Primary serial channel with LF to CRLF conversion

void uartInit() {
// Uart0.setPins(GPIO_NUM_1, GPIO_NUM_3); // Tx 1, Rx 3 - standard hardware pins
Uart0.begin(BAUD_RATE, UartData::Bits8, UartStop::Bits1, UartParity::None);
}

Expand Down

0 comments on commit b129708

Please sign in to comment.