Skip to content

Commit

Permalink
Finished correcting documantation for release.
Browse files Browse the repository at this point in the history
  • Loading branch information
tgolla committed May 28, 2022
1 parent c1f80d7 commit 82177cd
Showing 1 changed file with 32 additions and 16 deletions.
48 changes: 32 additions & 16 deletions G-Code.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ The tgolla/SphereBot fork (https://github.com/tgolla/SphereBot) adds the followi
P2 - Automatically detects which code is responsible for setting the pen height.
M306 - Sets the M300 height adjustment. P0 - Off, P1 - Preset, P2 - Calculated
M307 - Sets the Z height adjustment. P0 - Off, P1 - Preset, P2 - Calculated
M308 - Sets the M300 pen up preset value. S values less than the value
M308 - Sets the M300 pen up preset value. Sxxx values less than the value
move the pen down.
M309 - Sets the Z pen up preset value. Z values less than the value
M309 - Sets the Z pen up preset value. Zxxx values less than the value
move the pen down.
M310 - Sets the XY feedrate preset value. If zero feedrate is initalized with
default value and set through G0, G1, G2 & G3 codes with X or Y values
Expand All @@ -57,23 +57,41 @@ When set to Z mode (P1) the Z parameter in the G0, G1, G2 or G3 commands is resp

When set to Auto mode (P2) the mode is set to the appropriate M or Z mode based on which command is first detected in the G-Code file. For example, if a G0, G1, G2 or G3 command with a Z parameter is read first the mode is set to Z. But if an M300 command is read first the mode is set to M.

### M306 & M307
The M306 and M307 commands determine how the respective M300 command or G0, G1, G2 or G3 command Z parameter pen height value is interpreted.
### M306
The M306 command determine how the M300 command pen height value (Sxxx) is interpreted (adjusted).

- If set to Off (P0) the value provided by the command or parameter is used as the absolute pen height.
- If set to Preset (P1) the pen up preset (M308 or M309) value is used to determine if the pen position is set to the pen up (M304) or pen down (M303) value.
- If set to Off (P0) the Sxxx value provided by the M300 is used to set the pen height. This mode is emulates the behavior of past code.
- If set to Preset (P1) the pen up preset threshold value (M308) is used to determine if the pen position is set to the pen up value (M304) or pen down value (M303).

For example, if the value provided is greater than or equal to the preset value, the pen position is set to the pen up value (M304) and if it is less than the pen position is set to the pen down value (M303).
For example, if the value provided is greater than or equal to the preset threshold value, the pen position is set to the pen up value (M304) and if it is less than the preset threshold value, the pen position is set to the pen down value (M303).

- If set to Calculated (P2) the calculated value is determined by assuming the first height position value (Sxxx) read is the value used to determine if the pen should be positioned up or down.

For example, if the first pen command (M300 S145) value is 145, all subsequent command values equal and greater than will position the pen to the pen up value (M304). Those less than will position the pen to the pen down value (M304).

### M307
The M307 command determine how the G0, G1, G2 or G3 command Z parameter (Zxxx) is interpreted (adjusted).

- If set to Off (P0) the Zxxx value provided by the Z parameter is used to set the pen height.
- If set to Preset (P1) the pen up preset threshold value (M309) is used to determine if the pen position is set to the pen up value (M304) or pen down value (M303).

For example, if the value provided is greater than or equal to the preset threshold value, the pen position is set to the pen up value (M304) and if it is less than the preset threshold value, the pen position is set to the pen down value (M303).

- If set to Calculated (P2) the calculated value is determined by assuming the first height position value read is the value used to determine if the pen should be positioned up or down.

For example, if the first pen position value is 5, all values 5 equal and greater than will position the pen at the pen up value (M304). Those less than will position the pen at the pen down value (M304).

For example, if the first pen command (Z05) value is 5, all subsequent command values equal and greater than will position the pen to the pen up value (M304). Those less than will position the pen to the pen down value (M304).

### 308
The M308 command sets the M300 pen up preset threshold value. When M306 is set to Preset (M306 P1) Sxxx values greater than or equal to the value move the pen up to the to the pen up value (M304). Sxxx values less than the value move the pen down (M303).

### 309
The M309 command sets the Z parameter pen up preset threshold value. When M307 is set to Preset (M307 P1) Zxxx values greater than or equal to the value move the pen up to the to the pen up value (M304). Zxxx values less than the value move the pen down (M303).

### M310
The M310 command allows you to override the XY feed rates set in your G-Code file with a preset value. If set to 0 the feed rate is initialized with the default feed rate and is set through G0, G1, G2 & G3 codes with X or Y values by Fxxx.
The M310 command allows you to override the XY feed rates set in your G-Code file with a preset value. If set to 0 the feed rate is initialized with the default feed rate and is set through G0, G1, G2 & G3 codes with X or Y values by Fxxx. The preference is to set this value to get the optimum speed from your SphereBot.

### M311
The M311 command allows you to override the Z (pen movement) feed rates set in your G-Code file with a preset value. If set to 0 the feed rate is initialized with the default feed rate and is set through the M300 Fxxx or G0, G1, G2 & G3 codes with only Z values by Fxxx. The preference is to set this value as can be unique to either the SphereBot or object being drawn on and prevents the pen from crashing down an egg for example.
The M311 command allows you to override the pen movement feed rates set in your G-Code file with a preset value. If set to 0 the feed rate is initialized with the default feed rate and can be changed through the M300 or G0, G1, G2 & G3 codes with only Z values feedrate setting (Fxxx). The preference is to set this value as can be unique to either the SphereBot or object being drawn on and prevents the pen from crashing down an egg.

### M312
The M312 command sets the pen up federate multiplier. This command allows the SphereBot to move off the object at a faster rate. One means the pen will go up at the same speed (degrees/second) as it goes down. Each increase by one will logarithmically double the pen up speed.
Expand All @@ -83,15 +101,13 @@ Using a file to preset the M301 through M312 values and saving the configuration

- For example, the commands M305 P0 and M306 P0 would configure the SphereBot to operate as it has with past software releases requiring specific G-Code files to be customized for the specific SphereBot.

- Executing the commands M305 P2, M306 P2 and M307 P2 would configure the SphereBot to its most versatile setting where there should be no need to customize a G-Code file.

Both scenarios assume you have set M304 and M303 to the correct heights.
- Executing the commands M305 P2, M306 P2 and M307 P2, setting the M303 and M304 pen heights for you SphereBot along with the M310 and M311 preset feed rates would configure the SphereBot to its most versatile setting where there should be no need to customize a G-Code file.

Although you can easily modify the beginning of each G-Code file with the correct M301 through M312 codes for it to work best it is recommended that you instead create multiple scenario setting files. For example, one for small eggs, one for large eggs and one for ping pong balls.
Although you can easily modify the beginning of each G-Code file with the correct M301 through M312 codes for it to work best it is recommended that you instead create multiple scenario setting files. For example, one for small eggs, one for large eggs and one for ping pong balls specific to old SphereBot files with Mxxx commands or newer InkScape files with Z parameters.

The M999 command is for debugging and can be useful when determining things like pen up/down settings, feed rates and G-Code interpretation behavior. This code is optionally configured in the configuration.h file and it should be noted that in an Arduino Uno configuration the code consumes a large portion of dynamic memory.

For those wanting to try their hand at generating G-Code for the SphereBot there is a solution. InkScape v1.0 comes prepackages with the Gcodetools extension. I go into the process of converting a drawing into a line drawing and then G-Code using this extension elsewhere in the documentation.
For those wanting to try their hand at generating G-Code for the SphereBot there is a solution. InkScape v1.0 comes prepackages with the Gcodetools extension. I go into the process of converting a drawing into a line drawing and then G-Code using this extension in the ```Inkscape.md``` documentation.

## References

Expand Down

0 comments on commit 82177cd

Please sign in to comment.