Additional changes to GRBL to facilitate VFD control.
Sept 5, 2018 2:46:43 GMT
Derek the Admin likes this
Post by Bruce on Sept 5, 2018 2:46:43 GMT
I made the following changes to get the control signal labeled SpnDir on the CNC Shield to control the VFD as a Run / Stop command.
Change 1: Setup a start / stop signal to the VFD from the CNC Shield.
I wanted a signal to start / stop the VFD and I wanted to use the Spindle Direction pin to do this for me.
The G-Code M3 will start the VFD and an M5 will stop it. It won’t matter what the speed command S is set at as long as it is 1 or greater.
The “USE_SPINDLE_DIR_AS_ENABLE_PIN” sets this up like I want.
This does make the M4 command (Spindle Direction) unavailable.
This is the section of the Config.h GRBL file is used to setup this control operation:
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
// NOTE: Without a direction pin, M4 will not have a pin output to indicate a difference with M3.
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
#define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.<-- #define USE_SPINDLE_DIR_AS_ENABLE_PIN was uncommented to enable
Change 2: Setup the control signal for an active low signal for the 5V control relay to start / stop VFD.
The 5V relay interface is an active low signal. In other words, to turn on the relay I need a low signal on the control input pin of the 5V relay control board to activate the relay.
The “INVERT_SPINDLE_ENABLE_PIN” switches the output (SpnDir) so that an M3 sends a low signal to turn on the VFD. An M5 sends a high signal to turn off the VFD.
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
// for some pre-built electronic boards.
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
#define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.<----
Change 3: Setup the control signal to stop VFD with a 0 speed command.
I found this command and thought it would be good to use it. The G-Code command of S0 will send an M5 and shut off the drive with the SpnDir relay signal.
Even though this looks obvious this depends on the VFD setup settings as to how the drive will react to an ON command with 0 speed. This is just an extra belt + suspenders approach.
// Alters the behavior of the spindle enable pin with the USE_SPINDLE_DIR_AS_ENABLE_PIN option . By default,
// Grbl will not disable the enable pin if spindle speed is zero and M3/4 is active, but still sets the PWM
// output to zero. This allows the users to know if the spindle is active and use it as an additional control
// input. However, in some use cases, user may want the enable pin to disable with a zero spindle speed and
// re-enable when spindle speed is greater than zero. This option does that.
// NOTE: Requires USE_SPINDLE_DIR_AS_ENABLE_PIN to be enabled.
#define SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED // Default disabled. Uncomment to enable.<-----
Change 1: Setup a start / stop signal to the VFD from the CNC Shield.
I wanted a signal to start / stop the VFD and I wanted to use the Spindle Direction pin to do this for me.
The G-Code M3 will start the VFD and an M5 will stop it. It won’t matter what the speed command S is set at as long as it is 1 or greater.
The “USE_SPINDLE_DIR_AS_ENABLE_PIN” sets this up like I want.
This does make the M4 command (Spindle Direction) unavailable.
This is the section of the Config.h GRBL file is used to setup this control operation:
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help
// preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses
// the spindle direction pin(D13) as a separate spindle enable pin along with spindle speed PWM on pin D11.
// NOTE: This configure option only works with VARIABLE_SPINDLE enabled and a 328p processor (Uno).
// NOTE: Without a direction pin, M4 will not have a pin output to indicate a difference with M3.
// NOTE: BEWARE! The Arduino bootloader toggles the D13 pin when it powers up. If you flash Grbl with
// a programmer (you can use a spare Arduino as "Arduino as ISP". Search the web on how to wire this.),
// this D13 LED toggling should go away. We haven't tested this though. Please report how it goes!
#define USE_SPINDLE_DIR_AS_ENABLE_PIN // Default disabled. Uncomment to enable.<-- #define USE_SPINDLE_DIR_AS_ENABLE_PIN was uncommented to enable
Change 2: Setup the control signal for an active low signal for the 5V control relay to start / stop VFD.
The 5V relay interface is an active low signal. In other words, to turn on the relay I need a low signal on the control input pin of the 5V relay control board to activate the relay.
The “INVERT_SPINDLE_ENABLE_PIN” switches the output (SpnDir) so that an M3 sends a low signal to turn on the VFD. An M5 sends a high signal to turn off the VFD.
// Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful
// for some pre-built electronic boards.
// NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and
// spindle enable are combined to one pin. If you need both this option and spindle speed PWM,
// uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below.
#define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable.<----
Change 3: Setup the control signal to stop VFD with a 0 speed command.
I found this command and thought it would be good to use it. The G-Code command of S0 will send an M5 and shut off the drive with the SpnDir relay signal.
Even though this looks obvious this depends on the VFD setup settings as to how the drive will react to an ON command with 0 speed. This is just an extra belt + suspenders approach.
// Alters the behavior of the spindle enable pin with the USE_SPINDLE_DIR_AS_ENABLE_PIN option . By default,
// Grbl will not disable the enable pin if spindle speed is zero and M3/4 is active, but still sets the PWM
// output to zero. This allows the users to know if the spindle is active and use it as an additional control
// input. However, in some use cases, user may want the enable pin to disable with a zero spindle speed and
// re-enable when spindle speed is greater than zero. This option does that.
// NOTE: Requires USE_SPINDLE_DIR_AS_ENABLE_PIN to be enabled.
#define SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED // Default disabled. Uncomment to enable.<-----