Repository for CNC Config's and Macro's
-
@chimaeragh said in Repository for CNC Config's and Macro's:
M98 Pcustomconfig.g
Try M98 P"customconfig.g"
AFAIK there have to be "" around the filename...//edit It depends on your FW:
1 In RRF_2.x and earlier, string can be enclosed in quotes if required, see Quoted Strings for details. In RRF_3, quotation marks around the filename are mandatory.
-
@o_lampe Thanks
-
anyone have a CNC running on RRF3.3?... would be handy to see a recent config uploaded as people get their machines upgraded over time.
-
@thekm Here you go….
; Configuration file for Duet WiFi (firmware version 3.3) ; executed by the firmware on start-up ; General preferences G90 ; send absolute coordinates... M83 ; ...but relative extruder moves M550 P"AlphaCNC" ; set printer name ; Network ;M551 ; set password M552 P192.168.0.9 S1 ; enable network and set IP address M553 P255.255.255.0 ; set netmask M554 P192.168.0.1 ; set gateway M586 P0 S1 ; enable HTTP ;M586 P1 S1 ; enable FTP ;M586 P2 S1 ; enable Telnet ; Drives M569 P0 S0 ; physical drive 0 goes backwards M569 P1 S0 ; physical drive 1 goes backwards M569 P2 S0 ; physical drive 2 goes backwards M584 X0 Y1 Z2 ; set drive mapping M350 X256 Y256 Z256 I0 ; configure microstepping without interpolation ;M92 X6400.00 Y6400.00 Z6400.00 ; set steps per mm (Nominal) M92 X6372.34 Y6380.86 Z6376.35 ; set steps per mm (After calibration) M566 X900.00 Y900.00 Z12.00 ; set maximum instantaneous speed changes (mm/min) M203 X2400.00 Y2400.00 Z240.00 ; set maximum speeds (mm/min) M201 X200.00 Y200.00 Z20.00 ; set accelerations (mm/s^2) M906 X1200 Y1200 Z1200 I30 ; set motor currents (mA) and motor idle factor in per cent M84 S30 ; Set idle timeout ; Axis Limits M208 S1 X-102 Y-85 Z-100 ; set axis minima (S1) M208 S0 X102 Y85 Z80 ; set axis maxima (S0) ; Endstops M574 X1 S1 P"!xstop" ; configure active-low endstop for low end on X via pin !xstop M574 Y1 S1 P"!ystop" ; configure active-low endstop for low end on Y via pin !ystop M574 Z2 S1 P"!zstop" ; configure active-low endstop for high end on Z via pin !zstop ; Z-Probe M558 P5 C"^!e0stop" H10 F120 T1800 ; set Z probe on e0stop, pull up, normally open, type=switch, dive speeds = 120mm/min G31 P25 X0 Y0 Z19.2 ; set Z probe trigger value, offset and trigger height ;M557 X15:205 Y15:170 S40 ; define mesh grid ; Heaters M140 H-1 ; disable heated bed (overrides default heater mapping) M950 H3 C"nil" ; disable heater3 (pin exp.8 on the expansion connector) M950 H4 C"nil" ; disable heater4 (pin exp.13 on the expansion connector) ; Fans ;M950 F0 C"nil" ; disable fan 0 M950 F0 C"!fan0+^exp.pb6" Q1000 ; Fan 0 uses the Fan0 output. inverted for PWM, and PB6 as a tacho input with pullup resistor enabled for VFD speed feedback M950 F1 C"nil" ; disable fan 1 M950 F2 C"nil" ; disable fan 2 ; Custom settings ; M591 D0 C3 P2 E6.0 ;This is the command for filament monitoring using an optical on/off switch ; PanelDue M575 P1 B57600 S0 ; allow commands without checksums to be sent ;Scale cartesian axes M579 X1.000 Y1.000 ; CNC Mode (Firmware 3.3) M453 ; CNC Mode ;Configure Tool 0 as the CNC Spindle M950 R0 C"exp.13+exp.8+exp.9" Q2000 L0:25400 ; Create spindle index 0, PWM frequency 2KHz, max rpm = 25.4K ( tweaked to yield 24K) ; and the following connections: ; spindle speed PWM pin : exp.13 pin ; spindle run pin : exp.8 ; spindle direction pin : exp.9 M563 P0 R0 S"Spindle" ; Create Tool 0 with Spindle 0 and call it Spindle G10 P0 X0 Y0 Z0 ; Set Tool 0 axis offsets M568 P0 F0 ; Set Tool 0 to default RPM of 0 T0 ; Select Tool 0 ; CNC Emergency Stop M950 J0 C"exp.4" ; Define exp.4 as input pin 0 (P0) for use as an emergency stop input M581 T0 P0 S1 R0 ; Trigger an emergency stop (T0) when input pin 0 (P0) edge occurs ; Miscellaneous M911 S10 R11 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000" ; set voltage thresholds and actions to run on power loss
-
@cjm thanks! I'm sure that more just myself will find it handy.
-
Edit (2021-10-08) : I re-wrote the script because the structure of the GCode wiki pages changed, and now includes downloading the content to re-create the mega-page.
_
Browsing other people's gcode is super handy, particularly for custom setups and going your own way. However, it's a genuine hassle to both read someone else's GCode while trying to bounce around the gcode dictionary docco... and the new wiki structure is great, and necessary for the maintainers, but a challenge to bounce around efficiently.So here is a script that re-creates the mega-gcode docco page, and sets up a gcode browser in place of the menu.
- open the gcode dictionary site: https://duet3d.dozuki.com/Wiki/Gcode
- show the javascript console ("web developer tools" > "console")
ctrl + shift + J
in chrome,ctrl + shift + i
in FireFox. - copy and paste in the following code and hit return
(someone else can feel free to code review to ensure there's no evil)...
// ==UserScript== // @name GCode Wiki script // @version 1 // @include https://duet3d.dozuki.com/Wiki/Gcode* // ==/UserScript== /** for processing injected menu clicks, gets changed * to proper implementation when needed */ let processMegaPage = () => {}; let crossLinkDoc = () => {}; let setupGcodeBrowser = () => {}; let codeMap = {}; let crossLinked = false; // for identifying gcode references let codeRx = /[GM]+[0-9]+(.[0-9])?/g; /** Helper function with finding things, so I don't need a framework */ let docE = (f, inp) => { if (Array.isArray(inp)) { return (inp.map(i => docE(f, i))).flat(); } let seek = document[f](inp); if (!seek || seek instanceof HTMLElement) return seek; let tmp = []; for (let t of seek) tmp.push(t); return tmp; }; let content = document.getElementById('content'); let isInContent = function (e) { if (!e) return false; if (!e.parentElement || e.parentElement === document.body) return false; if (e.parentElement === content) return true; return isInContent(e.parentElement); } /** Handler to take input and process links in gcode browser */ let ref = null; let paster = () => { if (ref) clearTimeout(ref); ref = setTimeout(() => { let linkStyle = 'all:unset;cursor:pointer;text-decoration:underline;color:blue;'; let v = docE('getElementById', 'gcode-paste-input').value; v = v.replace(codeRx, (s) => { if (codeMap[s]) return '<a href="#' + codeMap[s] + '" style="' + linkStyle + '">' + s + '</a>'; return s; }); docE('getElementById', 'gcode-paste').innerHTML = '<pre style="text-align:left">' + v + '</pre>'; }, 500); }; // check to see if this page is the one we want, otherwise do nothing let loc = null; let pos = null; let hash = null; let qstring = null; const evalLocation = () => { loc = document.location + ''; pos = loc.indexOf('#'); hash = null; if (pos > -1) { hash = loc.substring(pos); loc = loc.substring(0, pos); } qstring = ''; pos = loc.indexOf('?'); if (pos > -1) { qstring = loc.substring(pos + 1); loc = loc.substring(0, pos); } }; const moveToHash = () => { if (hash) { document.location = hash; } }; // current location details... evalLocation(); if (loc.endsWith('/Wiki/Gcode')) { // current page is the gcode wiki... // find the menu let topTitle = docE('getElementsByClassName', 'toc-title')[0]; // add the link to run the mega-page import... let squirt = document.createElement('div'); squirt.innerHTML = '<a id="create-mega-page-link" href="javascript:;">Create Mega-Page</a>'; topTitle.parentElement.insertBefore(squirt, topTitle.nextSibling); setTimeout(() => { // take a beat, wire the event clicker (greasemonkey complication)... let tmp = null; (tmp = document.getElementById('create-mega-page-link')) ? tmp.addEventListener('click', () => processMegaPage()) : null; }, 50); // function handler for the click... processMegaPage = () => { squirt.innerHTML = ''; // find all the specific links let glinks = docE('getElementsByTagName', 'a').filter(a => { let t = a.innerText; let h = '' + a.href; h = h.substring(h.indexOf('/', 10)); return (t.match(codeRx) && !h.startsWith('/Wiki/Gcode') && (h.startsWith('/Wiki/M') || h.startsWith('/Wiki/G'))); }); // a function that represents the work for a page download let processor = a => { return new Promise((resolve, reject) => { // download... fetch(a.href).then(async response => { // the document dext... let t = await response.text(); // pull out the good stuff... let from = t.indexOf('<div id="Wiki_Details">'); let to = t.lastIndexOf('<div class="clearer">', t.lastIndexOf('<div itemprop="author"')); t = t.substring(from, to); // dont need this link in there now... t = t.replace('<p>Back to the <a href="/Wiki/Gcode">Gcode Dictionary</a></p>', ''); // make a div for it const d = document.createElement('div'); d.innerHTML = t; // replace the link tag's parent <p> let p = a.parentElement; p.parentNode.replaceChild(d, p); // end of task resolve(); }).catch(reject); }); }; let count = 0; // a function that represents a processing thread so we can start N of them let runner = async () => { while (glinks.length > 0) { count++; if (count % 25 === 0) console.log(count); let x = glinks.shift(); try { await processor(x); } catch (e) { console.log(e); } } }; // start the runners... let runnerCount = 1; (async () => { let time = new Date().getTime(); console.log('links to process: ' + glinks.length); let runners = []; for (let i = 0; i < runnerCount; i++) runners.push(runner()); await Promise.all(runners); console.log('DONE!!! (' + ((new Date().getTime() - time) / 1000) + ' seconds)'); moveToHash(); squirt.innerHTML = '<a id="cross-linker-link" href="javascript:;">Cross-link gcodes</a><br>' + '<a id="setup-gcode-browser-link" href="javascript:;">Setup GCode Browser</a><br><br>'; setTimeout(() => { // take a beat, wire the event clicker (greasemonkey complication)... let tmp = null; (tmp = document.getElementById('cross-linker-link')) ? tmp.addEventListener('click', () => crossLinkDoc()) : null; (tmp = document.getElementById('setup-gcode-browser-link')) ? tmp.addEventListener('click', () => setupGcodeBrowser()) : null; }, 50); })(); crossLinkDoc = () => { if (crossLinked) return; crossLinked = true; let link = document.getElementById('cross-linker-link'); link.parentElement.removeChild(link); /** Parse the references out of the document */ docE('getElementsByClassName', 'header').forEach(sect => { let s = sect.id + ''; s.replace(codeRx, sx => { sx = sx.replace('_', '.'); if (!codeMap[sx]) { codeMap[sx] = s; } }); }); /** Cross-link gcode references through the document */ docE('getElementsByTagName', ['p', 'li', 'pre', 'strong']).forEach(tag => { if (!tag) return; if (!isInContent(tag)) return; let linkStyle = 'all:unset;cursor:pointer;text-decoration:underline;color:blue;'; let h = ('' + tag.innerHTML).trim(); if (h.startsWith('<div/')) return; tag.innerHTML = h.replace(/(?<!_)([GM]+[0-9]+(.[0-9])?)/g, (s) => { if (codeMap[s]) return '<a href="#' + codeMap[s] + '" style="' + linkStyle + '" class="crosslink">' + s + '</a>'; return s; }); }); evalLocation(); moveToHash(); }; setupGcodeBrowser = () => { crossLinkDoc(); if (squirt) { squirt.parentElement.removeChild(squirt); squirt = null; } /** Strip the main wrapper element of styling */ let wrap = docE('getElementById', 'page'); wrap.className = ''; wrap.id = 'gnavPage'; /** Remove styling of sidebar nested element */ docE('getElementById', 'sidebar-wiki-toc').className = ''; docE('getElementById', 'sidebar-wiki-toc').id = 'gnavSidebar'; /** Strip the sidebar */ let sb = null; sb = docE('getElementById', 'page-sidebar'); sb.innerHTML = ''; sb.id = 'gnavSidebar'; /** Strip the main area */ let main = docE('getElementById', 'main'); main.id = 'gnavMain'; docE('getElementsByClassName', 'articleContainer')[0].className = ''; /** Clear our other elements not needed */ let mb = docE('getElementById', 'mainBody'); for (let kid of mb.children) { if (kid.id !== 'contentFloat') mb.removeChild(kid); } let bg = docE('getElementById', 'background'); for (let kid of bg.children) { if (kid.id === 'gnavPage') break; else bg.removeChild(kid); } for (let kid of document.body.children) { if (kid.id !== 'background') document.body.removeChild(kid); } docE('getElementById', 'content').id = 'offContent'; /** Apply new styles to the wrapper, sidebar and main areas */ wrap.setAttribute('style', 'display:flex;gap:1em;'); sb.setAttribute('style', 'flex: 1 1 45%; height: 100vh;'); main.setAttribute('style', 'flex: 1 1 50%; height: 100vh'); /** Input field to paste the gcode */ sb.innerHTML = ` <div style="width: 45vw; height: 100vh; position: fixed;overflow: scroll;"> <textarea id="gcode-paste-input"></textArea> <hr /> <pre id="gcode-paste" style="text-align: left"><center>( paste gcode above )</center></pre> </div>`; setTimeout(() => { // take a beat, wire the event clicker (greasemonkey complication)... let tmp = null; (tmp = document.getElementById('gcode-paste-input')) ? tmp.addEventListener('keyup', () => paster()) : null; }, 50); }; }; } // auto-trigger... if (qstring === 'inflateContent') { processMegaPage(); }
...with the script run, you will get a link on the top of the left hand menu to create the mega-page...
- click it
...this will process all the links and download all the content and inject it into the page. When completed the download and setting up the content, this link will change to "Setup GCode Browser"...
- click it
...the script will hide the current menu, strip the page down so it's two side-by-side panels, and provide a place to paste gcode. Paste in any chunck of Gcode (like entire contents of 'config.g' ) and click "Run". It will then put the Gcode in place of the menu with all the codes changed to links in the document.
Much easier to browse what's happening without losing concentration with bouncing around.
_
CROSS LINKING: The docco frequently references other codes in the document, but it's a hassle to browse to them and back to where you were. This cross linker runs through the doc to find the gcode references, adds the links... so now you can click on the link, see what it was referencing and click back in the browser as the browser remembers scroll positions when clicking, just like it used to._
Greasemonkey/Tampermonkey
If you want it to simply be around without having to paste in, blah blah... install Greasemonkey browser plugin (Chrome's is called Tampermonkey), and install the script above. The browser will execute it when you visit the gcode page automagically. And if you hit it with "?inflateContent" on the end of the URL (https://duet3d.dozuki.com/Wiki/Gcode?inflateContent
), it will automatically create the mega-page without needing to click anything. -
-
@thekm
Has someone tested this java plugin with the new gcode structure? -
This post is deleted! -
@o_lampe ...I originally replied that the script no longer works, but then I re-wrote it to include a content downloader that re-creates the previous structure of the single mega-page before setting up the gcode browser.
The updated script and details are above if you want to give it a go (I edited the post to reflect the new changes).
-
@thekm That script is fantastic! Works a treat for me. Please create a post of it's own if you haven't already.
Edit: Oh you already did. Very nicely done!
-
-
-