extras:codikon:p5js:cnc-helper
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| extras:codikon:p5js:cnc-helper [2025/11/29 19:59] – Felix Hardmood Beck | extras:codikon:p5js:cnc-helper [2025/11/29 20:05] (current) – Felix Hardmood Beck | ||
|---|---|---|---|
| Line 420: | Line 420: | ||
| - | ===== html ===== | ||
| ===== html ===== | ===== html ===== | ||
| - | < | + | < |
| < | < | ||
| <html lang=" | <html lang=" | ||
| Line 599: | Line 599: | ||
| </ | </ | ||
| - | <!-- Der komplette p5.js-Sketch wird wie oben im P5.JS-Block eingefügt | + | <script> |
| - | <script src="sketch.js"></ | + | // CNC feed suggestion helper with adjustable bit diameter |
| + | // Includes spindle speed and chip load calculation | ||
| + | // Version 1.01 – angepasst auf DeWalt D26200 Drehzahlstufen | ||
| + | |||
| + | let materialSelect; | ||
| + | let thicknessInput; | ||
| + | let bitDiameterInput; | ||
| + | let bitTypeSelect; | ||
| + | let calcButton; | ||
| + | let resultDiv; | ||
| + | |||
| + | function applyCustomStyles() { | ||
| + | // Styles sind im < | ||
| + | } | ||
| + | |||
| + | function setup() { | ||
| + | applyCustomStyles(); | ||
| + | |||
| + | createCanvas(1, | ||
| + | noLoop(); | ||
| + | select(' | ||
| + | |||
| + | const container = select('# | ||
| + | |||
| + | const title = createDiv(' | ||
| + | title.addClass(' | ||
| + | title.parent(container); | ||
| + | |||
| + | const subtitle = createDiv( | ||
| + | ' | ||
| + | ); | ||
| + | subtitle.addClass(' | ||
| + | subtitle.parent(container); | ||
| + | |||
| + | const layout = createDiv(); | ||
| + | layout.addClass(' | ||
| + | layout.parent(container); | ||
| + | |||
| + | const inputPanel = createDiv(); | ||
| + | inputPanel.addClass(' | ||
| + | inputPanel.parent(layout); | ||
| + | |||
| + | const inputTitle = createDiv(' | ||
| + | inputTitle.addClass(' | ||
| + | inputTitle.parent(inputPanel); | ||
| + | |||
| + | const matGroup = createDiv(); | ||
| + | matGroup.addClass(' | ||
| + | matGroup.parent(inputPanel); | ||
| + | |||
| + | const matLabel = createSpan(' | ||
| + | matLabel.addClass(' | ||
| + | matLabel.parent(matGroup); | ||
| + | |||
| + | materialSelect = createSelect(); | ||
| + | materialSelect.parent(matGroup); | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | materialSelect.option(' | ||
| + | |||
| + | const thickGroup = createDiv(); | ||
| + | thickGroup.addClass(' | ||
| + | thickGroup.parent(inputPanel); | ||
| + | |||
| + | const thickLabel = createSpan(' | ||
| + | thickLabel.addClass(' | ||
| + | thickLabel.parent(thickGroup); | ||
| + | |||
| + | thicknessInput = createInput('' | ||
| + | thicknessInput.attribute(' | ||
| + | thicknessInput.attribute(' | ||
| + | thicknessInput.attribute(' | ||
| + | thicknessInput.parent(thickGroup); | ||
| + | |||
| + | const thickHint = createDiv(' | ||
| + | thickHint.addClass(' | ||
| + | thickHint.parent(thickGroup); | ||
| + | |||
| + | const toolRow = createDiv(); | ||
| + | toolRow.addClass(' | ||
| + | toolRow.parent(inputPanel); | ||
| + | |||
| + | const bitGroup = createDiv(); | ||
| + | bitGroup.addClass(' | ||
| + | bitGroup.parent(toolRow); | ||
| + | |||
| + | const bitLabel = createSpan(' | ||
| + | bitLabel.addClass(' | ||
| + | bitLabel.parent(bitGroup); | ||
| + | |||
| + | bitDiameterInput = createInput(' | ||
| + | bitDiameterInput.attribute(' | ||
| + | bitDiameterInput.attribute(' | ||
| + | bitDiameterInput.attribute(' | ||
| + | bitDiameterInput.parent(bitGroup); | ||
| + | |||
| + | const typeGroup = createDiv(); | ||
| + | typeGroup.addClass(' | ||
| + | typeGroup.parent(toolRow); | ||
| + | |||
| + | const typeLabel = createSpan(' | ||
| + | typeLabel.addClass(' | ||
| + | typeLabel.parent(typeGroup); | ||
| + | |||
| + | bitTypeSelect = createSelect(); | ||
| + | bitTypeSelect.parent(typeGroup); | ||
| + | bitTypeSelect.option(' | ||
| + | bitTypeSelect.option(' | ||
| + | |||
| + | const typeHint = createDiv( | ||
| + | ' | ||
| + | ); | ||
| + | typeHint.addClass(' | ||
| + | typeHint.parent(inputPanel); | ||
| + | |||
| + | calcButton = createButton(' | ||
| + | calcButton.parent(inputPanel); | ||
| + | calcButton.mousePressed(updateSettings); | ||
| + | |||
| + | const btnHint = createDiv( | ||
| + | 'Alle Werte sind Startpunkte. Bei Geräusch, Vibration oder Brandspuren Parameter anpassen.' | ||
| + | ); | ||
| + | btnHint.addClass(' | ||
| + | btnHint.parent(inputPanel); | ||
| + | |||
| + | const outputPanel = createDiv(); | ||
| + | outputPanel.addClass(' | ||
| + | outputPanel.parent(container); | ||
| + | |||
| + | const outputTitle = createDiv(' | ||
| + | outputTitle.addClass(' | ||
| + | outputTitle.parent(outputPanel); | ||
| + | |||
| + | resultDiv = createDiv(' | ||
| + | resultDiv.parent(outputPanel); | ||
| + | |||
| + | const licenseDiv = createDiv( | ||
| + | ' | ||
| + | '<a href=" | ||
| + | ' | ||
| + | ' | ||
| + | ); | ||
| + | licenseDiv.addClass(' | ||
| + | licenseDiv.parent(container); | ||
| + | } | ||
| + | |||
| + | function updateSettings() { | ||
| + | const mat = materialSelect.value(); | ||
| + | const t = parseFloat(thicknessInput.value()); | ||
| + | const bitD = parseFloat(bitDiameterInput.value()); | ||
| + | const bitType = bitTypeSelect.value(); | ||
| + | |||
| + | if (isNaN(t) || t <= 0) { | ||
| + | resultDiv.html( | ||
| + | '< | ||
| + | ); | ||
| + | return; | ||
| + | } | ||
| + | if (isNaN(bitD) || bitD <= 0) { | ||
| + | resultDiv.html( | ||
| + | '< | ||
| + | ); | ||
| + | return; | ||
| + | } | ||
| + | |||
| + | const settings = computeSettings(mat, | ||
| + | const passes = Math.ceil(t / settings.depthPerPass); | ||
| + | const chipLoad = settings.feedRate / (settings.spindleRPM * settings.flutes); | ||
| + | |||
| + | const summaryHtml = | ||
| + | '< | ||
| + | `<div class=" | ||
| + | `<div class=" | ||
| + | `<div class=" | ||
| + | `<div class=" | ||
| + | `<div class=" | ||
| + | `<div class=" | ||
| + | '</ | ||
| + | |||
| + | const tableHtml = | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '< | ||
| + | '</ | ||
| + | '< | ||
| + | `< | ||
| + | `< | ||
| + | `< | ||
| + | `< | ||
| + | `< | ||
| + | `< | ||
| + | `< | ||
| + | `< | ||
| + | `< | ||
| + | `< | ||
| + | `< | ||
| + | `< | ||
| + | '</ | ||
| + | '</ | ||
| + | |||
| + | resultDiv.html(summaryHtml + tableHtml); | ||
| + | } | ||
| + | |||
| + | // Zuordnung DeWalt D26200 Drehzahl zu Reglerstufe 1–6 | ||
| + | function dewaltDialForRPM(rpm) { | ||
| + | const table = [ | ||
| + | { dial: 1, rpm: 16000 }, | ||
| + | { dial: 2, rpm: 18200 }, | ||
| + | { dial: 3, rpm: 20400 }, | ||
| + | { dial: 4, rpm: 22600 }, | ||
| + | { dial: 5, rpm: 24800 }, | ||
| + | { dial: 6, rpm: 27000 } | ||
| + | ]; | ||
| + | |||
| + | let best = table[0]; | ||
| + | let bestDiff = Math.abs(rpm - best.rpm); | ||
| + | |||
| + | for (let i = 1; i < table.length; | ||
| + | const d = Math.abs(rpm - table[i].rpm); | ||
| + | if (d < bestDiff) { | ||
| + | bestDiff = d; | ||
| + | best = table[i]; | ||
| + | } | ||
| + | } | ||
| + | return best.dial; | ||
| + | } | ||
| + | |||
| + | // Berechnung der Parameter | ||
| + | function computeSettings(material, | ||
| + | let baseFeed; | ||
| + | let plunge; | ||
| + | let depthFactor; | ||
| + | let spindleRPM; | ||
| + | let flutes; | ||
| + | let plungeType = 'Rampe 5° (Ramp 5°)'; | ||
| + | let notes; | ||
| + | |||
| + | switch (material) { | ||
| + | case ' | ||
| + | case ' | ||
| + | case 'MDF (MDF)': | ||
| + | case ' | ||
| + | baseFeed = 1800; | ||
| + | plunge = 600; | ||
| + | depthFactor = 0.32; | ||
| + | spindleRPM = 16000; // DeWalt Stufe 1 | ||
| + | flutes = 2; | ||
| + | notes = | ||
| + | ' | ||
| + | break; | ||
| + | case ' | ||
| + | baseFeed = 1900; | ||
| + | plunge = 650; | ||
| + | depthFactor = 0.32; | ||
| + | spindleRPM = 16000; // weiches Holz, Stufe 1 ausreichend | ||
| + | flutes = 2; | ||
| + | notes = ' | ||
| + | break; | ||
| + | case ' | ||
| + | case ' | ||
| + | baseFeed = 1300; | ||
| + | plunge = 400; | ||
| + | depthFactor = 0.24; | ||
| + | spindleRPM = 16000; // konservativ, | ||
| + | flutes = 2; | ||
| + | notes = | ||
| + | ' | ||
| + | break; | ||
| + | case 'HDPE (HDPE)': | ||
| + | case ' | ||
| + | case ' | ||
| + | case 'ABS (ABS)': | ||
| + | baseFeed = 2200; | ||
| + | plunge = 700; | ||
| + | depthFactor = 0.32; | ||
| + | spindleRPM = 18000; // nahe Stufe 2 (≈18200 U/min) | ||
| + | flutes = 2; | ||
| + | notes = | ||
| + | ' | ||
| + | break; | ||
| + | case ' | ||
| + | case ' | ||
| + | baseFeed = 1200; | ||
| + | plunge = 400; | ||
| + | depthFactor = 0.24; | ||
| + | spindleRPM = 16000; // eher niedrige Drehzahl für Acryl | ||
| + | flutes = 1; | ||
| + | notes = | ||
| + | ' | ||
| + | break; | ||
| + | case ' | ||
| + | baseFeed = 1200; | ||
| + | plunge = 400; | ||
| + | depthFactor = 0.24; | ||
| + | spindleRPM = 16000; | ||
| + | flutes = 2; | ||
| + | notes = ' | ||
| + | break; | ||
| + | case ' | ||
| + | baseFeed = 1900; | ||
| + | plunge = 650; | ||
| + | depthFactor = 0.4; | ||
| + | spindleRPM = 16000; | ||
| + | flutes = 2; | ||
| + | notes = ' | ||
| + | break; | ||
| + | case ' | ||
| + | baseFeed = 800; | ||
| + | plunge = 250; | ||
| + | depthFactor = 0.12; | ||
| + | spindleRPM = 18000; // kleine Einzahnwerkzeuge, | ||
| + | flutes = 1; | ||
| + | notes = | ||
| + | ' | ||
| + | break; | ||
| + | case ' | ||
| + | baseFeed = 700; | ||
| + | plunge = 220; | ||
| + | depthFactor = 0.1; | ||
| + | spindleRPM = 16000; // auf DeWalt-Minimum angehoben (Stufe 1) | ||
| + | flutes = 2; | ||
| + | notes = | ||
| + | ' | ||
| + | break; | ||
| + | default: | ||
| + | baseFeed = 1500; | ||
| + | plunge = 500; | ||
| + | depthFactor = 0.28; | ||
| + | spindleRPM = 16000; | ||
| + | flutes = 2; | ||
| + | notes = ' | ||
| + | break; | ||
| + | } | ||
| + | |||
| + | const refDiameter = 2.5; | ||
| + | const feedScale = Math.sqrt(bitDiameter / refDiameter); | ||
| + | let feed = baseFeed * feedScale; | ||
| + | |||
| + | let depth = depthFactor * bitDiameter; | ||
| + | depth = constrain(depth, | ||
| + | |||
| + | if (thickness < 4) { | ||
| + | feed *= 1.05; | ||
| + | notes += ' Dünnes Material: Feed leicht erhöht.'; | ||
| + | } else if (thickness > 12 && thickness <= 20) { | ||
| + | feed *= 0.9; | ||
| + | notes += ' Dickes Material: Feed leicht reduziert.'; | ||
| + | } else if (thickness > 20) { | ||
| + | feed *= 0.85; | ||
| + | notes += | ||
| + | ' Sehr dickes Material: eher in mehreren Stufen bearbeiten, ggf. von beiden Seiten.'; | ||
| + | } | ||
| + | |||
| + | if (bitType === ' | ||
| + | notes += ' Gewählter Fräser: Upcut; sehr guter Spanabtransport, | ||
| + | } else if (bitType === ' | ||
| + | notes += | ||
| + | ' Gewählter Fräser: gerade Schneide; gute Kantenqualität in Holz/ | ||
| + | } | ||
| + | |||
| + | if (bitDiameter < 1.0 && flutes > 1) { | ||
| + | flutes = 1; | ||
| + | notes = | ||
| + | ' | ||
| + | notes; | ||
| + | } | ||
| + | |||
| + | const dial = dewaltDialForRPM(spindleRPM); | ||
| + | |||
| + | return { | ||
| + | feedRate: feed, | ||
| + | plungeRate: plunge, | ||
| + | depthPerPass: | ||
| + | spindleRPM: spindleRPM, | ||
| + | flutes: flutes, | ||
| + | plungeType: plungeType, | ||
| + | notes: notes, | ||
| + | dial: dial | ||
| + | }; | ||
| + | } | ||
| + | |||
| + | function roundTo(value, | ||
| + | return Number(value.toFixed(decimals)); | ||
| + | } | ||
| + | </ | ||
| </ | </ | ||
| </ | </ | ||
| </ | </ | ||
/var/www/vhosts/ct-lab.info/wiki.ct-lab.info/data/pages/extras/codikon/p5js/cnc-helper.txt · Last modified: by Felix Hardmood Beck
