New compile options and inverse time bug fix.
- Apparently inverse time motion were not working for quite some time. Goes to show how many people actually use it. The calculation was bad and is now fixed in this update. It should now work correctly. - `;` comment type is now supported. This is standard on LinuxCNC and common on 3d printers. It was previously not supported due to not existing in the NIST standard, which is out-dated. - New compile-option to ECHO the line received. This should help users experiencing very weird problems and help diagnose if there is something amiss in the communication to Grbl. - New compile-option to use the spindle direction pin D13 as a spindle enable pin with PWM spindle speed on D11. This feature has been requested often from the laser cutter community. Since spindle direction isn’t really of much use, it seemed like good good trade. Note that M4 spindle enable counter-clock-wise support is removed for obvious reasons, while M3 and M5 still work.
This commit is contained in:
@ -24,16 +24,21 @@
|
||||
|
||||
void spindle_init()
|
||||
{
|
||||
// On the Uno, spindle enable and PWM are shared. Other CPUs have seperate enable pin.
|
||||
// Configure variable spindle PWM and enable pin, if requried. On the Uno, PWM and enable are
|
||||
// combined unless configured otherwise.
|
||||
#ifdef VARIABLE_SPINDLE
|
||||
SPINDLE_PWM_DDR |= (1<<SPINDLE_PWM_BIT); // Configure as PWM output pin.
|
||||
#ifndef CPU_MAP_ATMEGA328P
|
||||
#if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN)
|
||||
SPINDLE_ENABLE_DDR |= (1<<SPINDLE_ENABLE_BIT); // Configure as output pin.
|
||||
#endif
|
||||
#else
|
||||
// Configure no variable spindle and only enable pin.
|
||||
#else
|
||||
SPINDLE_ENABLE_DDR |= (1<<SPINDLE_ENABLE_BIT); // Configure as output pin.
|
||||
#endif
|
||||
SPINDLE_DIRECTION_DDR |= (1<<SPINDLE_DIRECTION_BIT); // Configure as output pin.
|
||||
|
||||
#ifndef USE_SPINDLE_DIR_AS_ENABLE_PIN
|
||||
SPINDLE_DIRECTION_DDR |= (1<<SPINDLE_DIRECTION_BIT); // Configure as output pin.
|
||||
#endif
|
||||
spindle_stop();
|
||||
}
|
||||
|
||||
@ -43,7 +48,7 @@ void spindle_stop()
|
||||
// On the Uno, spindle enable and PWM are shared. Other CPUs have seperate enable pin.
|
||||
#ifdef VARIABLE_SPINDLE
|
||||
TCCRA_REGISTER &= ~(1<<COMB_BIT); // Disable PWM. Output voltage is zero.
|
||||
#ifndef CPU_MAP_ATMEGA328P
|
||||
#if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN)
|
||||
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low.
|
||||
#endif
|
||||
#else
|
||||
@ -61,11 +66,13 @@ void spindle_set_state(uint8_t state, float rpm)
|
||||
|
||||
} else {
|
||||
|
||||
if (state == SPINDLE_ENABLE_CW) {
|
||||
SPINDLE_DIRECTION_PORT &= ~(1<<SPINDLE_DIRECTION_BIT);
|
||||
} else {
|
||||
SPINDLE_DIRECTION_PORT |= (1<<SPINDLE_DIRECTION_BIT);
|
||||
}
|
||||
#ifndef USE_SPINDLE_DIR_AS_ENABLE_PIN
|
||||
if (state == SPINDLE_ENABLE_CW) {
|
||||
SPINDLE_DIRECTION_PORT &= ~(1<<SPINDLE_DIRECTION_BIT);
|
||||
} else {
|
||||
SPINDLE_DIRECTION_PORT |= (1<<SPINDLE_DIRECTION_BIT);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VARIABLE_SPINDLE
|
||||
// TODO: Install the optional capability for frequency-based output for servos.
|
||||
@ -92,9 +99,11 @@ void spindle_set_state(uint8_t state, float rpm)
|
||||
#endif
|
||||
OCR_REGISTER = current_pwm; // Set PWM pin output
|
||||
|
||||
#ifdef CPU_MAP_ATMEGA2560 // On the Uno, spindle enable and PWM are shared.
|
||||
// On the Uno, spindle enable and PWM are shared, unless otherwise specified.
|
||||
#if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN)
|
||||
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
|
||||
#endif
|
||||
|
||||
#else
|
||||
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user