var zcalmovedistance = 50; var zcaltemplate = `
Step 1: Mark Initial Position
This wizard, will allow you to fine-tune your steps-per-mm for the Z-Axis
To get started, jog your Z-Axis until its near the Z- position.

Then, place a physical mark on your machine to mark where the Z-Carriage currently is
` function applycalibrationz() { var actualdist = $('#zcaltraveldist').val(); var currentstepspermm = parseFloat(grblParams['$102']); // var currentstepspermm = 199.9; // newstepsval = currentsteps * (intended distance / actual distance) var newsteps = (currentstepspermm * (zcalmovedistance / actualdist)).toFixed(2); // alert("New Steps Per MM Value: " + newsteps); // $('#val-102-input').val(newsteps) // checkifchanged(); sendGcode("$102=" + newsteps); setTimeout(function() { sendGcode(String.fromCharCode(0x18)); }, 500); } function zstepscalibrate() { Metro.dialog.create({ title: " Calibrate Steps per mm for Z-Axis ($102)", content: zcaltemplate, width: 750, clsDialog: 'dark', actions: [{ caption: "Cancel", cls: "js-dialog-close", onclick: function() { // } }] }); $("#zcalmovedistance").keyup(function() { zcalmovedistance = $("#zcalmovedistance").val(); $(".zcalmovedistanceval").html(zcalmovedistance); $("#zcaltraveldist").val(zcalmovedistance) var actualdist = $('#zcaltraveldist').val(); var currentstepspermm = parseFloat(grblParams['$102']); // var currentstepspermm = 199.9; // newstepsval = currentsteps * (intended distance / actual distance) var newsteps = (currentstepspermm * (zcalmovedistance / actualdist)).toFixed(2); $("#newsteps").html(newsteps) $("#currentstepspermm").html(currentstepspermm) $("#reqdistance").html(zcalmovedistance) $("#actualdist").html(zcalmovedistance) }); $("#zcaltraveldist").keyup(function() { var actualdist = $('#zcaltraveldist').val(); var currentstepspermm = parseFloat(grblParams['$102']); // var currentstepspermm = 199.9; // newstepsval = currentsteps * (intended distance / actual distance) var newsteps = (currentstepspermm * (zcalmovedistance / actualdist)).toFixed(2); $("#showcalc").show() $("#newsteps").html(newsteps) $("#currentstepspermm").html(currentstepspermm) $("#reqdistance").html(zcalmovedistance) $("#actualdist").html(actualdist) }); } function zcalslide1() { $('#zcalstep1').show(); $('#zcalstep2').hide(); $('#zcalstep3').hide(); } function zcalslide2() { $('#zcal50mm').attr('disabled', false); $('#zcalcontinue2').attr('disabled', true); $('#zcalstep1').hide(); $('#zcalstep2').show(); $('#zcalstep3').hide(); } function zcalslide3() { $('#zcalstep1').hide(); $('#zcalstep2').hide(); $('#zcalstep3').show(); }