Addressed optional PWM min value issue. Updated docs.

- [fix] Spindle PWM minimum value had some typos. Fixed the macros to
compile correctly. Only effects users that enable SPINDLE_MINIMUM_PWM.
The name changed to SPINDLE_PWM_MIN_VALUE for consistency sake.

- Updated the laser documentation.
This commit is contained in:
Sonny Jeon 2016-12-18 19:17:55 -07:00
parent af17f0071f
commit d5ed3bdb81
5 changed files with 65 additions and 26 deletions

View File

@ -1,3 +1,18 @@
----------------
Date: 2016-12-12
Author: Sonny Jeon
Subject: Updating steam.py streaming script
- Added push message capability to the stream.py streaming script. It
prints out as a `Debug:` string in the output.
----------------
Date: 2016-12-11
Author: Sonny Jeon
Subject: Updated documentation.
---------------- ----------------
Date: 2016-12-10 Date: 2016-12-10
Author: Sonny Jeon Author: Sonny Jeon

View File

@ -6,13 +6,43 @@
Outlined in this document is how Grbl alters its running conditions for the new laser mode to provide both improved performance and enforcing some basic user safety precautions. Outlined in this document is how Grbl alters its running conditions for the new laser mode to provide both improved performance and enforcing some basic user safety precautions.
## Laser Mode Overview
The main difference between default Grbl operation and the laser mode is how the spindle/laser output is controlled with motions involved. Every time a spindle state `M3 M4 M5` or spindle speed `Sxxx` is altered, Grbl would come to a stop, allow the spindle to change, and then continue. This is the normal operating procedure for a milling machine spindle. It needs time to change speeds. The main difference between default Grbl operation and the laser mode is how the spindle/laser output is controlled with motions involved. Every time a spindle state `M3 M4 M5` or spindle speed `Sxxx` is altered, Grbl would come to a stop, allow the spindle to change, and then continue. This is the normal operating procedure for a milling machine spindle. It needs time to change speeds.
However, if a laser starts and stops like this for every spindle change, this leads to scorching and uneven cutting/engraving! Grbl's new laser mode prevents unnecessary stops whenever possible and adds a new dynamic laser power mode that automagically scales power based on current speed related to programmed rate. So, you can get super clean and crisp results, even on a low-acceleration machine! However, if a laser starts and stops like this for every spindle change, this leads to scorching and uneven cutting/engraving! Grbl's new laser mode prevents unnecessary stops whenever possible and adds a new dynamic laser power mode that automagically scales power based on current speed related to programmed rate. So, you can get super clean and crisp results, even on a low-acceleration machine!
## Laser Mode Details Enabling or disabling Grbl's laser mode is easy. Just alter the **$32** Grbl setting.
- **To Enable**: Send Grbl a `$32=1` command.
- **To Disable:** Send Grbl a `$32=0` command.
When laser mode is enabled: **WARNING:** If you switch back from laser mode to a spindle for milling, you **MUST** disable laser mode by sending Grbl a `$32=0` command. Milling operations require the spindle to get up to the right rpm to cut correctly and to be **safe**, helping to prevent a tool from breaking and flinging metal shards everywhere. With laser mode disabled, Grbl will briefly pause upon any spindle speed or state change to give the spindle a chance to get up to speed before continuing.
## Laser Mode Operation
When laser mode is enabled, Grbl controls laser power by varying the **0-5V** voltage from the spindle PWM D11 pin. **0V** should be treated as disabled, while **5V** is full power. Intermediate output voltages are also assumed to be linear with laser power, such that **2.5V** is approximate 50% laser power. (A compile time option exists to shift this linear model to start at a non-zero voltage.)
By default, the spindle PWM frequency is **1kHz**, which is the recommended PWM frequency for most current Grbl-compatible lasers system. If a different frequency is required, this may be altered by editing the `cpu_map.h` file.
The laser is enabled with the `M3` spindle CW and `M4` spindle CCW commands. These enable two different laser modes that are advantageous for different reasons each.
- **`M3` Constant Laser Power Mode:**
- Constant laser power mode simply keeps the laser power as programmed, regardless if the machine is moving, accelerating, or stopped. This provides better control of the laser state. With a good g-code program, this can lead to more consistent cuts in more difficult materials.
- For a clean cut and prevent scorching with `M3` constant power mode, it's a good idea to add lead-in and lead-out motions around the line you want to cut to give some space for the machine to accelerate and decelerate.
- NOTE: `M3` can be used to keep the laser on for focusing.
- **`M4` Dynamic Laser Power Mode:**
- Dynamic laser power mode will automatically adjust laser power based on the current speed relative to the programmed rate. It'll essentially ensures the amount of laser energy along a cut is consistent even though the machine may be stopped or actively accelerating. This is very useful for clean, precise engraving and cutting on simple materials across a large range of g-code generation methods by CAM programs. It will generally run faster and may be all you need to use.
- Grbl calculates laser power based on the assumption that laser power is linear with speed and the material. Often, this is not the case. Lasers can cut differently at varying power levels and some materials may not cut well at a particular speed and/power. In short, this means that dynamic power mode may not work for all situations. Always do a test piece prior to using this with a new material or machine.
- When not in motion, `M4` dynamic mode turns off the laser. It only turns on when the machine moves. This generally makes the laser safer to operate, because, unlike `M3`, it will never burn a hole through your table, if you stop and forget to turn `M3` off in time.
Describe below are the operational changes to Grbl when laser mode is enabled. Please read these carefully and understand them fully, because nothing is worse than a garage _**fire**_.
- Grbl will move continuously through **consecutive** motion commands when programmed with a new `S` spindle speed (laser power). The spindle PWM pin will be updated instantaneously through each motion without stopping. - Grbl will move continuously through **consecutive** motion commands when programmed with a new `S` spindle speed (laser power). The spindle PWM pin will be updated instantaneously through each motion without stopping.
- Example: The following set of g-code commands will not pause between each of them when laser mode is enabled, but will pause when disabled. - Example: The following set of g-code commands will not pause between each of them when laser mode is enabled, but will pause when disabled.
@ -25,9 +55,9 @@ When laser mode is enabled:
- Grbl will enforce a laser mode motion stop in a few circumstances. Primarily to ensure alterations stay in sync with the g-code program. - Grbl will enforce a laser mode motion stop in a few circumstances. Primarily to ensure alterations stay in sync with the g-code program.
- Any `M3`, `M4`, `M5` spindle state _change_. - Any `M3`, `M4`, `M5` spindle state _change_.
- A `S` spindle speed _change_ when `M3` is active and there is no motion programmed. - `M3` only and no motion programmed: A `S` spindle speed _change_.
- A `G1 G2 G3` laser powered state _change_ to `G0 G80` laser disabled state when `M3` is active and there is no motion programmed. - `M3` only and no motion programmed: A `G1 G2 G3` laser powered state _change_ to `G0 G80` laser disabled state.
- NOTE: `M4` does not stop for anything but a spindle state _change_.
- The laser will only turn on when Grbl is in a `G1`, `G2`, or `G3` motion mode. - The laser will only turn on when Grbl is in a `G1`, `G2`, or `G3` motion mode.
@ -37,16 +67,8 @@ When laser mode is enabled:
- Example: `G0 M3 S1000` will not turn on the laser, but will set the laser modal state to `M3` enabled and power of `S1000`. A following `G1` command will then immediately be set to `M3` and `S1000`. - Example: `G0 M3 S1000` will not turn on the laser, but will set the laser modal state to `M3` enabled and power of `S1000`. A following `G1` command will then immediately be set to `M3` and `S1000`.
- Grbl supports two different laser modes with the `M3` spindle CW and `M4` spindle CCW commands. These are both advantageous for different reasons. - To have the laser powered during a jog motion, first enable a valid motion mode and spindle state. The following jog motions will inherit and maintain the previous laser state. Please use with caution though. This ability is primarily to allow turning on the laser on a _very low_ power to use the laser dot to jog and visibly locate the start position of a job.
- `M3` enables constant laser power mode. Constant laser power mode simply keeps the laser power as programmed, regardless if the machine is moving, accelerating, or stopped. This provides better control of the laser state. With a good g-code program, this can lead to more consistent cuts in more difficult materials.
- NOTE: Use `M3` to keep the laser on for focusing.
- For a clean cut, you generally want to add lead-in and lead-out motions around the line you want to cut to give some space for the machine to accelerate and decelerate.
- `M4` enables dynamic laser power mode. Dynamic laser power mode will automatically adjust laser power based on the current speed relative to the programmed rate. It'll essentially ensures the amount of laser energy along a cut is consistent even though the machine may be stopped or actively accelerating. This is very useful for clean, precise engraving and cutting on simple materials across a large range of g-code generation methods by CAM programs. It will generally run faster and may be all you need to use*.
- NOTE: Grbl calculates laser power based on the assumption that laser power is linear with speed and the material. Often, this is not the case. Lasers can cut differently at varying power levels and some materials may not cut well at a particular speed and/power. In short, this means that dynamic power mode may not work for all situations. Always do a test piece prior to using this with a new material or machine.
- When not in motion, `M4` dynamic mode turns off the laser. It only turns on when the machine moves. This generally makes the laser safer to operate, because, unlike `M3`, it will never burn a hole through your table, if you stop and forget to turn `M3` off in time.
- A `S0` spindle speed of zero will turn off the laser. When programmed with a valid laser motion, Grbl will disable the laser instantaneously without stopping for the duration of that motion and future motions until set greater than zero.. - A `S0` spindle speed of zero will turn off the laser. When programmed with a valid laser motion, Grbl will disable the laser instantaneously without stopping for the duration of that motion and future motions until set greater than zero..
@ -60,4 +82,8 @@ TODO: Add some suggestions on how to write laser g-code for Grbl.
- When using `M3` constant laser power mode, try to avoid force-sync conditions during a job whenever possible. Basically every spindle speed change must be accompanied by a valid motion. Any motion is fine, since Grbl will automatically enable and disable the laser based on the modal state. Avoid a `G0` and `G1` command with no axis words in this mode and in the middle of a job. - When using `M3` constant laser power mode, try to avoid force-sync conditions during a job whenever possible. Basically every spindle speed change must be accompanied by a valid motion. Any motion is fine, since Grbl will automatically enable and disable the laser based on the modal state. Avoid a `G0` and `G1` command with no axis words in this mode and in the middle of a job.
- When using `M4` dynamic laser power mode, the only force-sync condition is changing `M3 M4 M5` spindle states. There are no others because dynamic power mode automatically disables the laser whenever it is not in motion. - Ensure smooth motions throughout by turning the laser on and off without an `M3 M4 M5` spindle state command. There are two ways to do this:
- _Program a zero spindle speed `S0`_: `S0` is valid g-code and turns off the spindle/laser without changing the spindle state. In laser mode, Grbl will smoothly move through consecutive motions and turn off the spindle. Conversely, you can turn on the laser with a spindle speed `S` greater than zero. Remember that `M3` constant power mode requires any spindle speed `S` change to be programmed with a motion to allow continuous motion, while `M4` dynamic power mode does not.
- _Program an unpowered motion between powered motions_: If you are traversing between parts of a raster job that don't need to have the laser powered, program a `G0` rapid between them. `G0` enforces the laser to be disabled automatically. The last spindle speed programmed doesn't change, so if a valid powered motion, like a `G1` is executed after, it'll immediately re-power the laser with the last programmed spindle speed when executing that motion.

View File

@ -345,9 +345,9 @@
// and the voltage set by the minimum PWM for minimum rpm. This difference is 0.02V per PWM value. So, when // and the voltage set by the minimum PWM for minimum rpm. This difference is 0.02V per PWM value. So, when
// minimum PWM is at 1, only 0.02 volts separate enabled and disabled. At PWM 5, this would be 0.1V. Keep // minimum PWM is at 1, only 0.02 volts separate enabled and disabled. At PWM 5, this would be 0.1V. Keep
// in mind that you will begin to lose PWM resolution with increased minimum PWM values, since you have less // in mind that you will begin to lose PWM resolution with increased minimum PWM values, since you have less
// and less range over the total 256 PWM levels to signal different spindle speeds. // and less range over the total 255 PWM levels to signal different spindle speeds.
// NOTE: Compute duty cycle at the minimum PWM by this equation: (% duty cycle)=(SPINDLE_MINIMUM_PWM/256)*100 // NOTE: Compute duty cycle at the minimum PWM by this equation: (% duty cycle)=(SPINDLE_PWM_MIN_VALUE/255)*100
// #define SPINDLE_MINIMUM_PWM_VALUE 5 // Default disabled. Uncomment to enable. Must be greater than zero. Integer (1-255). // #define SPINDLE_PWM_MIN_VALUE 5 // Default disabled. Uncomment to enable. Must be greater than zero. Integer (1-255).
// By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help // 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 // preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses

View File

@ -125,9 +125,7 @@
// Variable spindle configuration below. Do not change unless you know what you are doing. // Variable spindle configuration below. Do not change unless you know what you are doing.
// NOTE: Only used when variable spindle is enabled. // NOTE: Only used when variable spindle is enabled.
#define SPINDLE_PWM_MAX_VALUE 255 // Don't change. 328p fast PWM mode fixes top value as 255. #define SPINDLE_PWM_MAX_VALUE 255 // Don't change. 328p fast PWM mode fixes top value as 255.
#ifdef SPINDLE_MINIMUM_PWM #ifndef SPINDLE_PWM_MIN_VALUE
#define SPINDLE_PWM_MIN_VALUE SPINDLE_MINIMUM_PWM
#else
#define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero. #define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.
#endif #endif
#define SPINDLE_PWM_OFF_VALUE 0 #define SPINDLE_PWM_OFF_VALUE 0

View File

@ -23,7 +23,7 @@
// Grbl versioning system // Grbl versioning system
#define GRBL_VERSION "1.1e" #define GRBL_VERSION "1.1e"
#define GRBL_VERSION_BUILD "20161208" #define GRBL_VERSION_BUILD "20161218"
// Define standard libraries used by Grbl. // Define standard libraries used by Grbl.
#include <avr/io.h> #include <avr/io.h>
@ -82,9 +82,9 @@
#endif #endif
#endif #endif
#if defined(SPINDLE_MINIMUM_PWM) #if defined(SPINDLE_PWM_MIN_VALUE)
#if !(SPINDLE_MINIMUM_PWM > 0) #if !(SPINDLE_PWM_MIN_VALUE > 0)
#error "SPINDLE_MINIMUM_PWM must be greater than zero." #error "SPINDLE_PWM_MIN_VALUE must be greater than zero."
#endif #endif
#endif #endif