refactored probing rotary

This commit is contained in:
sanjayk03-dev
2024-12-25 14:27:49 +05:30
parent 6f35612f33
commit bebdd2b98a
4 changed files with 41 additions and 72 deletions

View File

@@ -51,6 +51,7 @@ module.exports = {
macrosLoading: false, macrosLoading: false,
show_gcodes: false, show_gcodes: false,
GCodeNotFound: false, GCodeNotFound: false,
show_probe_dialog: false,
filesUploaded: 0, filesUploaded: 0,
totalFiles: 0, totalFiles: 0,
files_sortby: "By Upload Date", files_sortby: "By Upload Date",
@@ -851,7 +852,10 @@ module.exports = {
}, },
showProbeDialog: function (probeType) { showProbeDialog: function (probeType) {
SvelteComponents.showDialog("Probe", { probeType }); if(this.show_probe_dialog){
this.show_probe_dialog = false;
}
SvelteComponents.showDialog("Probe", { probeType, isRotaryActive: this.state["2an"] == 3 });
}, },
run_macro: function (id) { run_macro: function (id) {
if (this.state.macros[id].file_name == "default") { if (this.state.macros[id].file_name == "default") {

View File

@@ -38,6 +38,15 @@ script#control-view-template(type="text/x-template")
button.pure-button.button-error(@click="GCodeNotFound=false") button.pure-button.button-error(@click="GCodeNotFound=false")
| OK | OK
message(:show.sync="show_probe_dialog")
h3(slot="header") Probe Rotary
div(slot="body")
button.pure-button(:class="state['pw'] ? '' : 'load-on'", @click="showProbeDialog('xyz')") Probe XYZ
button.pure-button(:class="state['pw'] ? '' : 'load-on'", @click="showProbeDialog('z')") Probe Z
div(slot="footer")
button.pure-button(@click="show_probe_dialog=false") Cancel
table(style="table-layout: fixed; width: 100%;") table(style="table-layout: fixed; width: 100%;")
tr(style="height: fit-content;") tr(style="height: fit-content;")
td(style="white-space: nowrap; width: 410px;", rowspan="2") td(style="white-space: nowrap; width: 410px;", rowspan="2")
@@ -100,7 +109,7 @@ script#control-view-template(type="text/x-template")
tr(v-if="state['2an'] == 3") tr(v-if="state['2an'] == 3")
td(style="height:100px", align="center", colspan="1") td(style="height:100px", align="center", colspan="1")
button(@click="showProbeDialog('a')") button(@click="show_probe_dialog=true")
| Probe | Probe
br br
| Rotary | Rotary

View File

@@ -22,6 +22,7 @@
type ProbeDialogPropsType = { type ProbeDialogPropsType = {
open: boolean; open: boolean;
probeType: "xyz" | "z"; probeType: "xyz" | "z";
isRotaryActive: boolean;
}; };
const ScreenRotationDialogProps = writable<ScreenRotationDialogPropsType>(); const ScreenRotationDialogProps = writable<ScreenRotationDialogPropsType>();

View File

@@ -70,7 +70,8 @@
]; ];
export let open; export let open;
export let probeType: "xyz" | "z" | "a"; export let probeType: "xyz" | "z";
export let isRotaryActive: Boolean;
let currentStep: Step = "None"; let currentStep: Step = "None";
let cutterDiameterString: string = ""; let cutterDiameterString: string = "";
let cutterDiameterMetric: number; let cutterDiameterMetric: number;
@@ -116,7 +117,7 @@
updateButtons(); updateButtons();
} }
$: if(probeType === 'a'){ $: if(isRotaryActive){
stepLabels["PlaceProbeBlock"] = "Start Probe"; stepLabels["PlaceProbeBlock"] = "Start Probe";
} }
@@ -130,14 +131,14 @@
const enableSafety = $Config.settings["probing-prompts"]; const enableSafety = $Config.settings["probing-prompts"];
steps = [ steps = [
enableSafety && probeType !== "a" ? "CheckProbe" : undefined, enableSafety && !isRotaryActive ? "CheckProbe" : undefined,
probeType === "xyz" || probeType === "a" ? "BitDimensions" : undefined, probeType === "xyz" || isRotaryActive ? "BitDimensions" : undefined,
enableSafety ? "PlaceProbeBlock" : undefined, enableSafety ? "PlaceProbeBlock" : undefined,
"Probe", "Probe",
"Done", "Done",
].filter<Step>(isStep); ].filter<Step>(isStep);
if(probeType != "a"){ if(!isRotaryActive){
await stepCompleted("CheckProbe", probeContacted); await stepCompleted("CheckProbe", probeContacted);
} }
@@ -149,7 +150,7 @@
); );
} }
if (probeType === "a") { if (isRotaryActive) {
await stepCompleted("BitDimensions", userAcknowledged); await stepCompleted("BitDimensions", userAcknowledged);
localStorage.setItem( localStorage.setItem(
"cutterDiameterRotary", "cutterDiameterRotary",
@@ -161,7 +162,7 @@
await stepCompleted("Probe", probingComplete, probingFailed); await stepCompleted("Probe", probingComplete, probingFailed);
await stepCompleted("Done", userAcknowledged); await stepCompleted("Done", userAcknowledged);
if (probeType === "xyz" || probeType === "a") { if (probeType === "xyz" || isRotaryActive) {
ControllerMethods.gotoZero("xy"); ControllerMethods.gotoZero("xy");
} }
} catch (err) { } catch (err) {
@@ -184,7 +185,6 @@
switch (probeType) { switch (probeType) {
case "xyz": case "xyz":
case "z": case "z":
case "a":
break; break;
default: default:
@@ -258,30 +258,22 @@
} }
function executeProbe() { function executeProbe() {
//Probe Block
const probeBlockWidth = $Config.probe["probe-xdim"]; const config = isRotaryActive ? $Config["probe-rotary"] : $Config.probe;
const probeBlockLength = $Config.probe["probe-ydim"];
const probeBlockHeight = $Config.probe["probe-zdim"]; const probeBlockWidth = config["probe-xdim"];
const slowSeek = $Config.probe["probe-slow-seek"]; const probeBlockLength = config["probe-ydim"];
const fastSeek = $Config.probe["probe-fast-seek"]; const probeBlockHeight = config["probe-zdim"];
const slowSeek = config["probe-slow-seek"];
const fastSeek = config["probe-fast-seek"];
const cutterLength = 12.7; const cutterLength = 12.7;
const zLift = 1; const zLift = 1;
const xOffset = probeBlockWidth + cutterDiameterMetric / 2.0; const cutterDiameter = isRotaryActive ? cutterDiameterRotaryMetric : cutterDiameterMetric;
const yOffset = probeBlockLength + cutterDiameterMetric / 2.0; const xOffset = probeBlockWidth + cutterDiameter / 2.0;
const yOffset = probeBlockLength + cutterDiameter / 2.0;
const zOffset = probeBlockHeight; const zOffset = probeBlockHeight;
//Rotary
const probeRotaryWidth = $Config["probe-rotary"]["probe-xdim"];
const probeRotaryLength = $Config["probe-rotary"]["probe-ydim"];
const probeRotaryHeight = $Config["probe-rotary"]["probe-zdim"];
const fastSeekRotary = $Config["probe-rotary"]["probe-fast-seek"];
const slowSeekRotary = $Config["probe-rotary"]["probe-slow-seek"];
const xOffsetRotary = probeRotaryWidth + cutterDiameterRotaryMetric / 2.0;
const yOffsetRotary = probeRotaryLength + cutterDiameterRotaryMetric / 2.0;
const zOffsetRotary = probeRotaryHeight;
if (probeType === "z") { if (probeType === "z") {
ControllerMethods.send(` ControllerMethods.send(`
G21 G21
@@ -294,43 +286,6 @@
G91 G0 Z 25 G91 G0 Z 25
M2
`);
} else if(probeType === "a") {
// After probing Z, we want to drop the bit down:
// Ideally, 12.7mm/0.5in
// And we don't want to be more than 90% down on the probe block
// Also, add zlift to compensate for the fact that we lift after probing Z
const plunge = Math.min(cutterLength, zOffsetRotary * 0.9) + zLift;
ControllerMethods.send(`
G21
G92 X0 Y0 Z0
G38.2 Z -25 F${fastSeekRotary}
G91 G1 Z 1
G38.2 Z -2 F${slowSeekRotary}
G92 Z ${zOffsetRotary}
G91 G0 Z ${zLift}
G91 G0 X 20
G91 G0 Z ${-plunge}
G38.2 X -20 F${fastSeekRotary}
G91 G1 X 1
G38.2 X -2 F${slowSeekRotary}
G92 X ${xOffsetRotary}
G91 G0 X 1
G91 G0 Y 20
G91 G0 X -20
G38.2 Y -20 F${fastSeekRotary}
G91 G1 Y 1
G38.2 Y -2 F${slowSeekRotary}
G92 Y ${yOffsetRotary}
G91 G0 Y 3
G91 G0 Z 25
M2 M2
`); `);
} else { } else {
@@ -403,7 +358,7 @@
Attach the probe magnet to the collet, then touch the probe Attach the probe magnet to the collet, then touch the probe
block to the bit. block to the bit.
</p> </p>
{#if probeType !== "a"} {#if !isRotaryActive}
<Icon <Icon
data={probeType === "xyz" ? CheckXYZ : CheckZ} data={probeType === "xyz" ? CheckXYZ : CheckZ}
size="300px" size="300px"
@@ -443,7 +398,7 @@
{#if probeType === "xyz"} {#if probeType === "xyz"}
Place the probe block face up, on the lower-left corner Place the probe block face up, on the lower-left corner
of your workpiece. of your workpiece.
{:else if probeType === "a"} {:else if isRotaryActive}
You are about to start the probing of rotary. <br/><br/> <strong>Note: </strong><br/>Position the bit above the probe and attach the probe magnet. You are about to start the probing of rotary. <br/><br/> <strong>Note: </strong><br/>Position the bit above the probe and attach the probe magnet.
{:else} {:else}
Place the probe block face down, with the bit above the Place the probe block face down, with the bit above the
@@ -451,7 +406,7 @@
{/if} {/if}
</p> </p>
{#if probeType !== "a"} {#if !isRotaryActive}
<Icon <Icon
data={probeType === "xyz" ? PlaceXYZ : PlaceZ} data={probeType === "xyz" ? PlaceXYZ : PlaceZ}
width="304px" width="304px"
@@ -482,14 +437,14 @@
</p> </p>
{:else} {:else}
<p> <p>
{#if probeType === "a"} {#if isRotaryActive}
Probing complete Probing complete
{:else} {:else}
Don't forget to put away the probe! Don't forget to put away the probe!
{/if} {/if}
</p> </p>
{#if probeType !== "a"} {#if !isRotaryActive}
<Icon <Icon
data={probeType === "xyz" ? PutAwayXYZ : PutAwayZ} data={probeType === "xyz" ? PutAwayXYZ : PutAwayZ}
width="329px" width="329px"
@@ -498,7 +453,7 @@
/> />
{/if} {/if}
{#if probeType === "xyz" || probeType === "a"} {#if probeType === "xyz" || isRotaryActive}
<p>The machine will now move to the XY origin.</p> <p>The machine will now move to the XY origin.</p>
<p>Watch your hands!</p> <p>Watch your hands!</p>