Fully configurable pins for NO or NC switches.
- All pins, which include limits, control command, and probe pins, can now all be configured to trigger as active-low or active-high and whether the pin has its internal pull-up resistor enabled. This should allow for just about all types of NO and NC switch configurations. - The probe pin invert setting hasn’t been added to the Grbl settings, like the others, and will have to wait until v1.0. But for now, it’s available as a compile-time option in config.h. - Fixed a variable spindle bug.
This commit is contained in:
parent
9be7b3d930
commit
bf37ab7e7b
21
config.h
21
config.h
@ -143,6 +143,11 @@
|
||||
// have the same steps per mm internally.
|
||||
// #define COREXY // Default disabled. Uncomment to enable.
|
||||
|
||||
// Inverts pin logic of the control command pins. This essentially means when this option is enabled
|
||||
// you can use normally-closed switches, rather than the default normally-open switches.
|
||||
// NOTE: Will eventually be added to Grbl settings in v1.0.
|
||||
// #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable.
|
||||
|
||||
// ---------------------------------------------------------------------------------------
|
||||
// ADVANCED CONFIGURATION OPTIONS:
|
||||
|
||||
@ -162,6 +167,22 @@
|
||||
// step smoothing. See stepper.c for more details on the AMASS system works.
|
||||
#define ADAPTIVE_MULTI_AXIS_STEP_SMOOTHING // Default enabled. Comment to disable.
|
||||
|
||||
// By default, Grbl sets all input pins to normal-high operation with their internal pull-up resistors
|
||||
// enabled. This simplifies the wiring for users by requiring only a switch connected to ground,
|
||||
// although its recommended that users take the extra step of wiring in low-pass filter to reduce
|
||||
// electrical noise detected by the pin. If the user inverts the pin in Grbl settings, this just flips
|
||||
// which high or low reading indicates an active signal. In normal operation, this means the user
|
||||
// needs to connect a normal-open switch, but if inverted, this means the user should connect a
|
||||
// normal-closed switch.
|
||||
// The following options disable the internal pull-up resistors, sets the pins to a normal-low
|
||||
// operation, and switches much be now connect to Vcc instead of ground. This also flips the meaning
|
||||
// of the invert pin Grbl setting, where an inverted setting now means the user should connect a
|
||||
// normal-open switch and vice versa.
|
||||
// WARNING: When the pull-ups are disabled, this requires additional wiring with pull-down resistors!
|
||||
//#define DISABLE_LIMIT_PIN_PULL_UP
|
||||
//#define DISABLE_PROBE_PIN_PULL_UP
|
||||
//#define DISABLE_CONTROL_PIN_PULL_UP
|
||||
|
||||
// Sets which axis the tool length offset is applied. Assumes the spindle is always parallel with
|
||||
// the selected axis with the tool oriented toward the negative direction. In other words, a positive
|
||||
// tool length offset value is subtracted from the current location.
|
||||
|
50
cpu_map.h
50
cpu_map.h
@ -60,7 +60,7 @@
|
||||
#define STEPPERS_DISABLE_MASK (1<<STEPPERS_DISABLE_BIT)
|
||||
|
||||
// Define homing/hard limit switch input pins and limit interrupt vectors.
|
||||
// NOTE: All limit bit pins must be on the same port, but not on a port with other input pins (pinout).
|
||||
// NOTE: All limit bit pins must be on the same port, but not on a port with other input pins (CONTROL).
|
||||
#define LIMIT_DDR DDRB
|
||||
#define LIMIT_PIN PINB
|
||||
#define LIMIT_PORT PORTB
|
||||
@ -100,18 +100,18 @@
|
||||
#define COOLANT_MIST_BIT 4 // Uno Analog Pin 4
|
||||
#endif
|
||||
|
||||
// Define user-control pinouts (cycle start, reset, feed hold) input pins.
|
||||
// NOTE: All pinouts pins must be on the same port and not on a port with other input pins (limits).
|
||||
#define PINOUT_DDR DDRC
|
||||
#define PINOUT_PIN PINC
|
||||
#define PINOUT_PORT PORTC
|
||||
#define PIN_RESET 0 // Uno Analog Pin 0
|
||||
#define PIN_FEED_HOLD 1 // Uno Analog Pin 1
|
||||
#define PIN_CYCLE_START 2 // Uno Analog Pin 2
|
||||
#define PINOUT_INT PCIE1 // Pin change interrupt enable pin
|
||||
#define PINOUT_INT_vect PCINT1_vect
|
||||
#define PINOUT_PCMSK PCMSK1 // Pin change interrupt register
|
||||
#define PINOUT_MASK ((1<<PIN_RESET)|(1<<PIN_FEED_HOLD)|(1<<PIN_CYCLE_START))
|
||||
// Define user-control controls (cycle start, reset, feed hold) input pins.
|
||||
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
|
||||
#define CONTROL_DDR DDRC
|
||||
#define CONTROL_PIN PINC
|
||||
#define CONTROL_PORT PORTC
|
||||
#define RESET_BIT 0 // Uno Analog Pin 0
|
||||
#define FEED_HOLD_BIT 1 // Uno Analog Pin 1
|
||||
#define CYCLE_START_BIT 2 // Uno Analog Pin 2
|
||||
#define CONTROL_INT PCIE1 // Pin change interrupt enable pin
|
||||
#define CONTROL_INT_vect PCINT1_vect
|
||||
#define CONTROL_PCMSK PCMSK1 // Pin change interrupt register
|
||||
#define CONTROL_MASK ((1<<RESET_BIT)|(1<<FEED_HOLD_BIT)|(1<<CYCLE_START_BIT))
|
||||
|
||||
// Define probe switch input pin.
|
||||
#define PROBE_DDR DDRC
|
||||
@ -213,18 +213,18 @@
|
||||
#define COOLANT_MIST_BIT 6 // MEGA2560 Digital Pin 9
|
||||
#endif
|
||||
|
||||
// Define user-control pinouts (cycle start, reset, feed hold) input pins.
|
||||
// NOTE: All pinouts pins must be on the same port and not on a port with other input pins (limits).
|
||||
#define PINOUT_DDR DDRK
|
||||
#define PINOUT_PIN PINK
|
||||
#define PINOUT_PORT PORTK
|
||||
#define PIN_RESET 0 // MEGA2560 Analog Pin 8
|
||||
#define PIN_FEED_HOLD 1 // MEGA2560 Analog Pin 9
|
||||
#define PIN_CYCLE_START 2 // MEGA2560 Analog Pin 10
|
||||
#define PINOUT_INT PCIE2 // Pin change interrupt enable pin
|
||||
#define PINOUT_INT_vect PCINT2_vect
|
||||
#define PINOUT_PCMSK PCMSK2 // Pin change interrupt register
|
||||
#define PINOUT_MASK ((1<<PIN_RESET)|(1<<PIN_FEED_HOLD)|(1<<PIN_CYCLE_START))
|
||||
// Define user-control CONTROLs (cycle start, reset, feed hold) input pins.
|
||||
// NOTE: All CONTROLs pins must be on the same port and not on a port with other input pins (limits).
|
||||
#define CONTROL_DDR DDRK
|
||||
#define CONTROL_PIN PINK
|
||||
#define CONTROL_PORT PORTK
|
||||
#define RESET_BIT 0 // MEGA2560 Analog Pin 8
|
||||
#define FEED_HOLD_BIT 1 // MEGA2560 Analog Pin 9
|
||||
#define CYCLE_START_BIT 2 // MEGA2560 Analog Pin 10
|
||||
#define CONTROL_INT PCIE2 // Pin change interrupt enable pin
|
||||
#define CONTROL_INT_vect PCINT2_vect
|
||||
#define CONTROL_PCMSK PCMSK2 // Pin change interrupt register
|
||||
#define CONTROL_MASK ((1<<RESET_BIT)|(1<<FEED_HOLD_BIT)|(1<<CYCLE_START_BIT))
|
||||
|
||||
// Define probe switch input pin.
|
||||
#define PROBE_DDR DDRK
|
||||
|
@ -43,7 +43,7 @@
|
||||
#define DEFAULT_Z_MAX_TRAVEL 200.0 // mm
|
||||
#define DEFAULT_STEP_PULSE_MICROSECONDS 10
|
||||
#define DEFAULT_STEPPING_INVERT_MASK 0
|
||||
#define DEFAULT_DIRECTION_INVERT_MASK ((1<<Y_AXIS)|(1<<Z_AXIS))
|
||||
#define DEFAULT_DIRECTION_INVERT_MASK 0
|
||||
#define DEFAULT_STEPPER_IDLE_LOCK_TIME 25 // msec (0-254, 255 keeps steppers enabled)
|
||||
#define DEFAULT_STATUS_REPORT_MASK ((BITFLAG_RT_STATUS_MACHINE_POSITION)|(BITFLAG_RT_STATUS_WORK_POSITION))
|
||||
#define DEFAULT_JUNCTION_DEVIATION 0.02 // mm
|
||||
|
8
limits.c
8
limits.c
@ -41,11 +41,11 @@ void limits_init()
|
||||
{
|
||||
LIMIT_DDR &= ~(LIMIT_MASK); // Set as input pins
|
||||
|
||||
if (bit_istrue(settings.flags,BITFLAG_INVERT_LIMIT_PINS)) {
|
||||
#ifdef DISABLE_LIMIT_PIN_PULL_UP
|
||||
LIMIT_PORT &= ~(LIMIT_MASK); // Normal low operation. Requires external pull-down.
|
||||
} else {
|
||||
#else
|
||||
LIMIT_PORT |= (LIMIT_MASK); // Enable internal pull-up resistors. Normal high operation.
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) {
|
||||
LIMIT_PCMSK |= LIMIT_MASK; // Enable specific pins of the Pin Change Interrupt
|
||||
@ -224,7 +224,7 @@ void limits_go_home(uint8_t cycle_mask)
|
||||
} while (n_cycle-- > 0);
|
||||
|
||||
// The active cycle axes should now be homed and machine limits have been located. By
|
||||
// default, grbl defines machine space as all negative, as do most CNCs. Since limit switches
|
||||
// default, Grbl defines machine space as all negative, as do most CNCs. Since limit switches
|
||||
// can be on either side of an axes, check and set axes machine zero appropriately. Also,
|
||||
// set up pull-off maneuver from axes limit switches that have been homed. This provides
|
||||
// some initial clearance off the switches and should also help prevent them from falsely
|
||||
|
2
main.c
2
main.c
@ -47,7 +47,7 @@ int main(void)
|
||||
{
|
||||
// Initialize system upon power-up.
|
||||
serial_init(); // Setup serial baud rate and interrupts
|
||||
settings_init(); // Load grbl settings from EEPROM
|
||||
settings_init(); // Load Grbl settings from EEPROM
|
||||
stepper_init(); // Configure stepper pins and interrupt timers
|
||||
system_init(); // Configure pinout pins and pin-change interrupt
|
||||
|
||||
|
@ -371,7 +371,7 @@ uint8_t plan_check_full_buffer()
|
||||
colinear with the circle center. The circular segment joining the two paths represents the
|
||||
path of centripetal acceleration. Solve for max velocity based on max acceleration about the
|
||||
radius of the circle, defined indirectly by junction deviation. This may be also viewed as
|
||||
path width or max_jerk in the previous grbl version. This approach does not actually deviate
|
||||
path width or max_jerk in the previous Grbl version. This approach does not actually deviate
|
||||
from path, but used as a robust way to compute cornering speeds, as it takes into account the
|
||||
nonlinearities of both the junction angle and junction velocity.
|
||||
|
||||
|
6
probe.c
6
probe.c
@ -30,11 +30,11 @@ uint8_t probe_invert_mask;
|
||||
void probe_init()
|
||||
{
|
||||
PROBE_DDR &= ~(PROBE_MASK); // Configure as input pins
|
||||
if (bit_istrue(settings.flags,BITFLAG_INVERT_PROBE_PIN)) {
|
||||
#ifdef DISABLE_PROBE_PIN_PULL_UP
|
||||
PROBE_PORT &= ~(PROBE_MASK); // Normal low operation. Requires external pull-down.
|
||||
} else {
|
||||
#else
|
||||
PROBE_PORT |= PROBE_MASK; // Enable internal pull-up resistors. Normal high operation.
|
||||
}
|
||||
#endif
|
||||
// probe_configure_invert_mask(false); // Initialize invert mask. Not required. Updated when in-use.
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
|
||||
#define GRBL_VERSION "0.9h"
|
||||
#define GRBL_VERSION_BUILD "20150114"
|
||||
#define GRBL_VERSION_BUILD "20150117"
|
||||
|
||||
// Version of the EEPROM data. Will be used to migrate existing data from older versions of Grbl
|
||||
// when firmware is upgraded. Always stored in byte 0 of eeprom
|
||||
|
@ -113,7 +113,7 @@ void spindle_set_state(uint8_t state, float rpm)
|
||||
|
||||
void spindle_run(uint8_t state, float rpm)
|
||||
{
|
||||
if (sys.state != STATE_CHECK_MODE) { return; }
|
||||
if (sys.state == STATE_CHECK_MODE) { return; }
|
||||
protocol_buffer_synchronize(); // Empty planner buffer to ensure spindle is set when programmed.
|
||||
spindle_set_state(state, rpm);
|
||||
}
|
||||
|
38
system.c
38
system.c
@ -30,10 +30,14 @@
|
||||
|
||||
void system_init()
|
||||
{
|
||||
PINOUT_DDR &= ~(PINOUT_MASK); // Configure as input pins
|
||||
PINOUT_PORT |= PINOUT_MASK; // Enable internal pull-up resistors. Normal high operation.
|
||||
PINOUT_PCMSK |= PINOUT_MASK; // Enable specific pins of the Pin Change Interrupt
|
||||
PCICR |= (1 << PINOUT_INT); // Enable Pin Change Interrupt
|
||||
CONTROL_DDR &= ~(CONTROL_MASK); // Configure as input pins
|
||||
#ifdef DISABLE_CONTROL_PIN_PULL_UP
|
||||
CONTROL_PORT &= ~(CONTROL_MASK); // Normal low operation. Requires external pull-down.
|
||||
#else
|
||||
CONTROL_PORT |= CONTROL_MASK; // Enable internal pull-up resistors. Normal high operation.
|
||||
#endif
|
||||
CONTROL_PCMSK |= CONTROL_MASK; // Enable specific pins of the Pin Change Interrupt
|
||||
PCICR |= (1 << CONTROL_INT); // Enable Pin Change Interrupt
|
||||
}
|
||||
|
||||
|
||||
@ -41,15 +45,19 @@ void system_init()
|
||||
// only the realtime command execute variable to have the main program execute these when
|
||||
// its ready. This works exactly like the character-based realtime commands when picked off
|
||||
// directly from the incoming serial data stream.
|
||||
ISR(PINOUT_INT_vect)
|
||||
ISR(CONTROL_INT_vect)
|
||||
{
|
||||
// Enter only if any pinout pin is actively low.
|
||||
if ((PINOUT_PIN & PINOUT_MASK) ^ PINOUT_MASK) {
|
||||
if (bit_isfalse(PINOUT_PIN,bit(PIN_RESET))) {
|
||||
uint8_t pin = (CONTROL_PIN & CONTROL_MASK);
|
||||
#ifndef INVERT_CONTROL_PIN
|
||||
pin ^= CONTROL_MASK;
|
||||
#endif
|
||||
// Enter only if any CONTROL pin is detected as active.
|
||||
if (pin) {
|
||||
if (bit_istrue(pin,bit(RESET_BIT))) {
|
||||
mc_reset();
|
||||
} else if (bit_isfalse(PINOUT_PIN,bit(PIN_FEED_HOLD))) {
|
||||
} else if (bit_istrue(pin,bit(FEED_HOLD_BIT))) {
|
||||
bit_true(sys.rt_exec_state, EXEC_FEED_HOLD);
|
||||
} else if (bit_isfalse(PINOUT_PIN,bit(PIN_CYCLE_START))) {
|
||||
} else if (bit_istrue(pin,bit(CYCLE_START_BIT))) {
|
||||
bit_true(sys.rt_exec_state, EXEC_CYCLE_START);
|
||||
}
|
||||
}
|
||||
@ -208,15 +216,17 @@ uint8_t system_execute_line(char *line)
|
||||
|
||||
float system_convert_axis_steps_to_mpos(int32_t *steps, uint8_t idx)
|
||||
{
|
||||
float pos;
|
||||
#ifdef COREXY
|
||||
if (idx==A_MOTOR) {
|
||||
return((0.5*(steps[A_MOTOR] + steps[B_MOTOR]))/settings.steps_per_mm[idx]);
|
||||
} else if (idx==B_MOTOR) {
|
||||
return((0.5*(steps[A_MOTOR] - steps[B_MOTOR]))/settings.steps_per_mm[idx]);
|
||||
pos = 0.5*((steps[A_MOTOR] + steps[B_MOTOR])/settings.steps_per_mm[idx]);
|
||||
} else { // (idx==B_MOTOR)
|
||||
pos = 0.5*((steps[A_MOTOR] - steps[B_MOTOR])/settings.steps_per_mm[idx]);
|
||||
}
|
||||
#else
|
||||
return((float)steps[idx]/settings.steps_per_mm[idx]);
|
||||
pos = steps[idx]/settings.steps_per_mm[idx];
|
||||
#endif
|
||||
return(pos);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user