g-code defaults to mm not meters, allow offset#110
Open
JamesNewton wants to merge 1 commit intodde4from
Open
Conversation
g-code generally defaults to millimeters, but Dexter takes in meters. A default value for a scale factor of 0.001 corrects this issue and allows scaling to be changed. Also include an offset in x, y, and z to help it work in a better area.
Collaborator
Author
|
The following will run in the current DDE4, backfill this change, and includes simple g-code to demo the functionality by having the arm draw a square on the floor. Gcode.move_it = function(){
let y_pos = this.state.Y
y_pos += this.state.Y_offset
if(y_pos === 0) { y_pos = 1e-10 }//to avoid singularity
let xyz = [ ( this.state.X + this.offset[0] ) * this.scale
, ( y_pos + this.offset[1] ) * this.scale
, ( this.state.Z + this.offset[2] ) * this.scale
]
//debugger
return [ function() { Gcode.extrude()},
Dexter.move_to(xyz)
]
}
Gcode.scale = .001 //units are mm, convert to meters
Gcode.offset = [0,100,80] //xyz offset in mm
var gcode = `
; G-Code to print a test object coded by hand
G21 ; set units to millimeters
G28 ; home all axes (if no X,Y,Z, all are assumed)
G0 Z5 ; quickly lift nozzle 5mm
M109 S195 ; wait for temperature to be reached
G90 ; use absolute coordinates
G92 E0 ; Set current extruder position as home
M82 ; use absolute distances for extrusion
G0 Z0.4 ; drop to first layer height
G0 X100 Y100 ; move to starting point @10,10
G1 X100 Y200 F540 E0.2 ; slow extrude to next point.
G1 X200 Y200 E0.4 ; slow extrude to next point.
G1 X200 Y100 E0.6 ; slow extrude to next point.
G1 X100 Y100 E0.8 ; slow extrude to starting point.
`
gcode = gcode.replace(/;[^\n]+[\n]/gm, '\n'); //remove comment lines (starting with ';')
gcode = gcode.replace(/M117 [^\n]+[\n]/gm, '\n'); //remove LCD update lines
new Job({
name: "my_job_gcode",
do_list: [
Dexter.run_gcode({gcode:gcode})
]
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
g-code generally defaults to millimeters, but Dexter takes in meters. A default value for a scale factor of 0.001 corrects this issue and allows scaling to be changed. Also include an offset in x, y, and z to help it work in a better area.