Skip to content

Conversation

@JamesNewton
Copy link
Collaborator

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.

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.
@JamesNewton
Copy link
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})
    ]
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants