Add first layer calibration page w gcode generator

Thanks to Vector76 for assistance.
Also add saving procedure for e-steps.
This commit is contained in:
lawgicau
2020-08-24 14:13:45 +10:00
parent 55ae6937fb
commit 3cb3cf2c7a
6 changed files with 444 additions and 6 deletions

View File

@ -10,6 +10,7 @@
<script src="js/jquery.responsiveTabs.js"></script>
<script src="js/videobox.js"></script>
<script src="js/featherlight.js"></script>
<script src="js/firstlayer.js"></script>
<script src="js/baseline.js"></script>
<script src="js/retraction.js"></script>
<script src="js/temperature.js"></script>
@ -28,6 +29,7 @@
<li><a href="#intro">Introduction</a></li>
<li><a href="#frame">Frame Check</a></li>
<li><a href="#pid">PID Autotune</a></li>
<li><a href="#firstlayer">First Layer</a></li>
<li><a href="#baseline">Baseline Print</a></li>
<li><a href="#esteps">Extruder E-steps Calibration</a></li>
<li><a href="#flow">Slicer Flow Calibration</a></li>
@ -52,6 +54,7 @@
<p>Validation has been built into the forms to only allow sensible min and max values, however this is not foolproof.</p>
<p>The gcode generated by this page has the following general characteristics:</p>
<ul>
<li>Sliced for Marlin firmware, although in most cases will still be compatible with other firmwares.</li>
<li>0.2mm layer height</li>
<li>0.4mm nozzle</li>
<li>Base feedrate of 60mm/sec</li>
@ -59,7 +62,7 @@
<li>Nozzle priming has been turned off to avoid bed clips or problems with deltas</li>
<li>A single layer skirt (except on the acceleration test)</li>
</ul>
<p>To be compatible, your printer should have a miniumum bed size of 100 x 100mm. The largest print is 85x 95 x 30mm.</p>
<p>To be compatible, your printer should have a miniumum bed size of 100 x 100mm. The largest print is 85 x 95 x 30mm.</p>
</div>
</div>
@ -85,8 +88,7 @@
<h4>Lubrication</h4>
<p>Lubrication is an important maintenance task to perform regularly. Compoents that are not adequately lubricated may bind and affect print quality. Use <a href="https://amzn.to/3aqLT0a" target="_blank">SuperLube Synthetic Grease</a>. Lubrication needs to be performed regularly on any hardened rods, <a href="https://www.youtube.com/watch?v=loBHYcifzRM" target="_blank">linear rails</a> and lead screws.</p>
<h4>Bed Levelling</h4>
<p>Probably the most essential part of setting up your 3D printer. Most new users will trip up on this. If you have ABL, this includes making sure your Z offset has been set and saved. My method is included in the above video and this diagram is a handy reference:</p>
<a href="#" data-featherlight="img/firstlayer.jpg"><img class="thumb" src="img/firstlayer.jpg" /></a>
<p>Probably the most essential part of setting up your 3D printer. Most new users will trip up on this. If you have ABL, this includes making sure your Z offset has been set and saved. Dialing in the first layer has now been moved to its <a href="#firstlayer">own tab</a>.</p>
<h4>PTFE Tube</h4>
<p>If your printer has PTFE tube, such as a bowden tube setup for the extruder/hot end, it is essential to make the tube is fully inserted and seated in the coupler. Also ensure the coupler is properly tightened. You may wish to use a small retaining clip on the coupler to prevent the tube working loose: <a href="https://www.thingiverse.com/thing:4268489" target="_blank">Creality PTFE clip by morfidesign</a>.</p>
<h4>Nozzle</h4>
@ -123,6 +125,105 @@
<p>It may be preferable to have the printer as close to printing conditions as possible during these tuning procedures. That means having filament loaded and the part cooling fan on for PLA temperatures.</p>
</div>
<div id="firstlayer">
<div class="exp">
<h2>First Layer</h2>
<h5>Aim:</h5>
<p>To ensure the printer bed is both level and an appropriate distance from the nozzle. In the case of using ABL, to check if compensation is working and the Z offset is correctly set. This will result in a first layer with the correct amount of 'squish', meaning good adhesion, and greatly increasing the chances of the print being successful.</p>
<h5>When required:</h5>
<p>Initial setup of the printer, regular maintainence, if first layer quality diminishes, any time the frame or mechanical components have been disassembled or replaced, any change of bed surface or nozzle, a change in filament that has significantly difference bed/hot end temperatures. There is a lot that can throw the bed level off, but careful use of your printer without any hardware changes should see it remain consistent for an extended period of time.</p>
<h5>Tools:</h5>
<p>The gcode generator on this page. A standard sheet of office paper.</p>
</div>
<h2>General Principles</h2>
<p>Getting a good first layer is an essential part of 3D printing successfully and is probably the number one cause of failed prints for new users.</p>
<p>Firstly, the bed needs to be parallel to the plane the nozzle traverses when moving in X and Y. This is achieved by moving the corners of the bed up and down relative to each other. With manual bed levelling this is achieved by turning the levelling knobs in each corner.</p>
<p>Secondly, the vertical distance between the bed and the nozzle needs to be correct for the first layer to print correctly. In a manual system, this is achieved by turning the levelling knobs in unison to lift or lower each corner the same amount.</p>
<p>If this distance is too far, the filament will not be squished into the bed enough, potentially even printing in mid air, and the print will detach from the bed and fail.</p>
<p>If the nozzle is too close, there will not be enough room for the extruded filament to take the correct shape, and it will be forced to squeeze outwards. In minor cases, the extruded line will be wider than necessary and produce <i>elephant's foot</i>. Prints like this may be quite hard to remove from the bed.</p>
<p>In extreme cases, there will be no way for the filament to exit the nozzle, at best causing extruder stepper motor skipping, and even potentially even jamming the extruder/hot end.</p>
<p>A short animation of these concepts are shown in the following snippet:</p>
<iframe width="480" height="360" src="https://www.youtube.com/embed/T-Z3GmM20JM?start=909&end=962" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<h2>Manual Levelling Procedure</h2>
<p>There are many techniques available, but a common one is to move the nozzle to the various corners of the bed, turning the levelling knobs until a standard piece of office paper can just fit between the bed and nozzle. A 0.1mm feeler gauge can be used, but make sure it doesn't have any oil on it that will contaminate the bed surface. Typically, this procedure is done with the bed at printing temperature (essential), and the nozzle close to printing temperature - just cool enough to prevent filament oozing out (optional).</p>
<p>It is common to follow up with a first layer calibration print, and 'live level' the bed by continuing to adjust the knobs when the print is under way.</p>
<p>This process is depicted in detail in the following snippet, and a gcode generator is provided at the bottom of the page to generate a suitable test print:</p>
<iframe width="480" height="360" src="https://www.youtube.com/embed/T-Z3GmM20JM?start=961&end=1206" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<h2>Auto Bed Levelling and Z offset</h2>
<p>Auto bed levelling automates the procedure to some extent. A sensor such as a BLtouch, EZABL, strain gauge or peizo transducer is used to probe the bed in a grid formation. At each location, it measures the vertical height, building up an array of stored values, called a <i>mesh</i>. Manual mesh bed levelling can also be used to probe such a grid, but is still a manual process and hence not considered 'automatic'. Here is a visual representation of a probed mesh, shown with the <a href="https://plugins.octoprint.org/plugins/bedlevelvisualizer/" target="_blank">Bed level visualizer Octprint plugin</a>:</p>
<a href="#" data-featherlight="img/ablmesh.jpg"><img class="thumb" src="img/ablmesh.jpg" /></a>
<p>During printing, the firmware will reference the mesh and compensate for an angled and/or warped bed by raising and lowering the nozzle using Z axis movement. This means the nozzle can travel up and down to match the contours of the bed, ensuring a good first layer.</p>
<p>In the printer's bed is perfectly flat, it is reasonable to claim ABL is not needed. Some users may still prefer it for the added convenience. In the event that the bed is warped (very common), it can be impossible to get a good first layer without ABL or manual mesh bed levelling. An example of this situation is shown in the following snippet:</p>
<iframe width="480" height="360" src="https://www.youtube.com/embed/T-Z3GmM20JM?start=1206&end=1254" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<p>The bed can be probed at the start of the print with a <b>G29</b> command, with the resulting mesh immediately used to compensate as the initial layers are produced. Alternatively, the bed can also be probed some other time (while not printing), the mesh stored in the EEPROM and then restored with <b>M420 S1</b> at the start of a print. In this case the print will start sooner, since we do not need to wait for a new mesh to be probed, although it may not be as accurate if anything has changed since probing. Either of these gcode commands should come after the <b>G28</b> home command in the start gcode.</p>
<p>Although ABL can compensate for a crooked/non-levelled bed, it is still better to attempt to level manually first and get everything in the ballpark.</p>
<p>Probing the bed and building a mesh only accounts for an uneven or warped bed. Like manual levelling, we still need to set the distance between the nozzle and bed to get a good first layer. This is where the Z offset comes in, which is simply the vertical distance between where the probe triggers vs the nozzle tip. Here are some examples:</p>
<ul>
<li>BLtouch/EZABL/Pinda probe - The nozzle is in mid air when these probes are triggered, which will require a negative Z offset.</li>
<li>Manual mesh bed levelling - The nozzle and bed will be very close when manually probing, requiring a Z offset close to zero.</li>
<li>CR-6 style strain gauge - The nozzle touches the bed and flexes upwards to trigger the probe. This means the trigger poiunt is actually higher than the nozzle tip, and requires a positive Z offset.</li>
</ul>
<p>If <b>BABYSTEP_ZPROBE_OFFSET</b> is enabled in Marlin, setting the Z offset can easily be done as the first layer goes down. Don't forget to save to EEPROM afterwards. This process is depicted in the following snippet:</p>
<iframe width="480" height="360" src="https://www.youtube.com/embed/iAz47riSjLQ?start=889&end=935" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<p>Another advantages of some ABL systems is that once the Z offset is set, you can interchange build surfaces of various thicknesses, with no changes needed for a successful first layer. Assuming the probe is triggered the same way on the bed surface, the Z offset is applied to this trigger point and the first layer height should be the same. On a manually levelled bed, the four corner knobs would need to be turned in unison to raise or lower the bed in accounting for thickness of the new build surface.</p>
<h2>First layer gcode generator</h2>
<p>The following form will create a series of five squares that you can use to live level your bed or set the Z offset. It is quick to print and features one square in the middle of the bed, with four others in the corners. You can use these to turn the levelling knobs in each corner until they are consistent, or ensure your ABL system is working if you have one in place.</p>
<a href="#" data-featherlight="img/firstlayerpreview.jpg"><img class="thumb" src="img/firstlayerpreview.jpg" /></a>
<form name="firstlayerForm" id="firstlayerForm" onsubmit="return false;">
<h4>Additional start gcode</h4>
<p>If you have additional start commands, tick the box and enter the gcode. This will be inserted after temperatures are set and homing/ABL is complete. This can be used to add a hot end purge command. For the majority of users, you can skip this section.</p>
<label>Additional start gcode:<input name="start" type="checkbox" onchange="toggle(!this.checked, '#firstlayerStart')" value="extraStart"></label>
<textarea id="firstlayerStart" name="startgcode"></textarea>
<script>
if(document.firstlayerForm.start.checked == false){
$("#firstlayerStart").hide();
}
</script>
<h4>Bed dimensions</h4>
<p>Inputting the correct number will attempt to move the print into the centre of the bed. If the 0,0 at centre button is checked for a delta, also enter your bed diameter. Please check the gcode to ensure it will fit on your bed.</p>
<label>0,0 at centre of bed (Delta):<input name="centre" type="checkbox" onchange="toggle(this.checked, 'first')" value="centre"></label>
<span id="firstlayerXY"><label>Bed X dimension (mm): <input type="number" name="bedx" value="100" min="100" max="600" step="1"></label>
<label>Bed Y dimension (mm): <input type="number" name="bedy" value="100" min="100" max="600" step="1"></label><br /></span>
<span id="firstlayerdia"><label>Bed diameter dimension (mm): <input type="number" name="beddia" value="100" min="100" max="600" step="1"></label></span>
<script>
if(document.firstlayerForm.centre.checked == false){
$("#firstlayerXY").show();
$("#firstlayerdia").hide();
} else {
$("#firstlayerXY").hide();
$("#firstlayerdia").show();
}
</script>
<h4>Temperatures</h4>
<p>For the hot end and bed respectively, typical PLA temperatures are 200 and 60, PETG 235 and 80, ABS 250 and 100, TPU 230 and 5 (effectively off).</p>
<label>Hot end temperature (deg C): <input type="number" name="hotendtemp" value="200" min="160" max="450"></label>
<label>Bed temperature (deg C): <input type="number" name="bedtemp" value="60" min="5" max="150"></label><br />
<h4>Part Cooling Fan</h4>
<p>Part cooling fans typically don't activate until layer 2. Since this print is only one layer thick, part cooling is not applicable.</p>
<h4>Auto Bed Levelling</h4>
<label for="abl">Select which method of ABL is in place.</label>
<select name="abl">
<option value="0">No ABL</option>
<option value="1">Probe new mesh at the start of print - G29 (BLtouch,EZABL,etc)</option>
<option value="2">Restore saved mesh - M420 S1</option>
<option value="3">Prusa MK3 - G28 W followed by M80</option>
<option value="4">Prusa Mini - Only heat nozzle to 170, then G29</option>
<option value="5">Unified Bed Leveling - Load Saved Mesh then 3 Probe Tilt </option>
</select>
<h4>Retraction</h4>
<p>If you don't know what to enter here, you can leave the retraction speed at 40 mm/sec. For a bowden tube printer, 6mm is a likely retraction distance. For direct drive, a starting value of 1mm may be suitable.</p>
<label>Retraction distance (mm): <input type="number" name="retdist" value="5" min="0" max="20" step="0.1"></label>
<label>Retraction speed (mm/sec): <input type="number" name="retspeed" value="40" min="5" max="150" step="1"></label><br />
<p><input type="button" onclick="processFirstlayer()" value="Download Gcode"></p>
<p><input type="button" onclick="resetFormToDefaults(form)" value="Reset parameters"></p>
</form>
<h2>Interpreting Results:</h2>
<p>The following diagram and reference picture can be useful in determing if your first layer is too close or too far away from the nozzle. The reference image is quite large to aid clarity, you may wish to open it in a new tab to view it at maximum size.</p>
<p>If one side looks too close, but the other too far, adjust the levellng knobs to correct this. It is worth printing this gcode more than once after making adjustments to make sure the result is accurate and repeatable.</p>
<a href="#" data-featherlight="img/firstlayer.jpg"><img class="thumb" src="img/firstlayer.jpg" /></a> <a href="#" data-featherlight="img/firstlayer2.jpg"><img class="thumb" src="img/firstlayer2.jpg" /></a>
</div>
<div id="baseline">
<div class="exp">
<h2>Baseline Print</h2>
@ -238,6 +339,13 @@
</form>
<p>Although starting a new print or power cycling will achieve this, it may be safer to put the printer back into absolute position mode after completing this calibration by sending:</p>
<pre>G90</pre>
<h2>Storing the updated E-steps</h2>
<p>Once you have determined the correct value, it must be saved to the firmware to take effect on subsequent prints. Although it can be hard coded into the firmware by recompiling Marlin, it is far easier to use gcode to achieve this.</p>
<p>In a terminal, enter:</p>
<pre>M92 E[your new value]</pre>
<p>Obviously, you would substitute in your E-steps value after the E. Save to EEPROM with:</p>
<pre>M500</pre>
<p>You can also use the <b>Configuration</b> menu on the LCD to make this change, but with a large change (eg. switch to geared extruder) it may take considerable time to turn the knob enough to reach the desired value. Don't forget to <b>Store Settings</b> to save to EEPROM.</p>
</div>
<div id="flow">

BIN
img/ablmesh.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 71 KiB

BIN
img/firstlayer2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB

BIN
img/firstlayerpreview.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 KiB

193
js/firstlayer.js Normal file
View File

@ -0,0 +1,193 @@
var originalFirstlayerStart = `; G-Code originally generated by Simplify3D(R) Version 4.1.2, based on proposeed code by vector76
G90
M82
M106 S0
M140 S60
M190 S60
M104 S210 T0
M109 S210 T0
G28 ; home all axes
;G29 ; probe ABL
;M420 S1 ; restore ABL mesh
;customstart
; process Color1
; layer 1, Z = 0.200
T0
G92 E0.0000
G1 E-5.0000 F2400
`
var originalskirt =`G1 Z0.400 F1200
G1 X34.636 Y36.314 F6000
G1 Z0.200 F1200
G1 E0.0000 F2400
G92 E0.0000
G1 X36.314 Y34.636 E0.1023 F1800
G1 X63.686 Y34.636 E1.2822
G1 X65.364 Y36.314 E1.3844
G1 X65.364 Y63.686 E2.5643
G1 X63.686 Y65.364 E2.6666
G1 X36.314 Y65.364 E3.8465
G1 X34.636 Y63.686 E3.9487
G1 X34.636 Y36.314 E5.1286
G92 E0.0000
G1 E-5.0000 F2400
G1 Z0.600 F1200
G1 X35.212 Y36.552 F6000
G1 Z0.200 F1200
G1 E0.0000 F2400
G92 E0.0000
G1 X36.552 Y35.212 E0.0817 F1800
G1 X63.448 Y35.212 E1.2410
G1 X64.788 Y36.552 E1.3227
G1 X64.788 Y63.448 E2.4820
G1 X63.448 Y64.788 E2.5637
G1 X36.552 Y64.788 E3.7231
G1 X35.212 Y63.448 E3.8048
G1 X35.212 Y36.552 E4.9641
G92 E0.0000
G1 E-5.0000 F2400
`
var originalSquare = `; feature inner perimeter
G1 Z0.600 F1200
G1 X37.788 Y37.788 F6000
G1 X37.788 Y38.202
G1 X38.940 Y38.940
G1 Z0.200 F1200
G1 E0.0000 F2400
G92 E0.0000
G1 X61.060 Y38.940 E0.9535 F1350
G1 X61.060 Y61.060 E1.9069
G1 X38.940 Y61.060 E2.8604
G1 X38.940 Y38.940 E3.8139
G1 X38.364 Y38.364 F6000
G92 E0.0000
G1 X61.636 Y38.364 E1.0031 F1350
G1 X61.636 Y61.636 E2.0063
G1 X38.364 Y61.636 E3.0094
G1 X38.364 Y38.364 E4.0125
; feature outer perimeter
G1 X37.788 Y37.788 F6000
G92 E0.0000
G1 X62.212 Y37.788 E1.0528 F900
G1 X62.212 Y62.212 E2.1056
G1 X37.788 Y62.212 E3.1584
G1 X37.788 Y37.788 E4.2111
; feature solid layer
G1 X60.465 Y39.286 F6000
G92 E0.0000
G1 X60.714 Y39.535 E0.0152 F1440
G1 X60.714 Y40.350 E0.0503
G1 X59.650 Y39.286 E0.1152
G1 X58.836 Y39.286 E0.1503
G1 X60.714 Y41.164 E0.2648
G1 X60.714 Y41.979 E0.2999
G1 X58.021 Y39.286 E0.4640
G1 X57.207 Y39.286 E0.4992
G1 X60.714 Y42.793 E0.7130
G1 X60.714 Y43.608 E0.7481
G1 X56.392 Y39.286 E1.0116
G1 X55.578 Y39.286 E1.0467
G1 X60.714 Y44.422 E1.3598
G1 X60.714 Y45.237 E1.3949
G1 X54.763 Y39.286 E1.7577
G1 X53.948 Y39.286 E1.7928
G1 X60.714 Y46.052 E2.2053
G1 X60.714 Y46.866 E2.2404
G1 X53.134 Y39.286 E2.7025
G1 X52.319 Y39.286 E2.7376
G1 X60.714 Y47.681 E3.2494
G1 X60.714 Y48.495 E3.2845
G1 X51.505 Y39.286 E3.8459
G1 X50.690 Y39.286 E3.8810
G1 X60.714 Y49.310 E4.4921
G1 X60.714 Y50.125 E4.5272
G1 X49.875 Y39.286 E5.1879
G1 X49.061 Y39.286 E5.2230
G1 X60.714 Y50.939 E5.9334
G1 X60.714 Y51.754 E5.9685
G1 X48.246 Y39.286 E6.7286
G1 X47.432 Y39.286 E6.7637
G1 X60.714 Y52.568 E7.5734
G1 X60.714 Y53.383 E7.6085
G1 X46.617 Y39.286 E8.4679
G1 X45.802 Y39.286 E8.5030
G1 X60.714 Y54.198 E9.4120
G1 X60.714 Y55.012 E9.4471
G1 X44.988 Y39.286 E10.4058
G1 X44.173 Y39.286 E10.4409
G1 X60.714 Y55.827 E11.4492
G1 X60.714 Y56.641 E11.4844
G1 X43.359 Y39.286 E12.5424
G1 X42.544 Y39.286 E12.5775
G1 X60.714 Y57.456 E13.6851
G1 X60.714 Y58.270 E13.7202
G1 X41.730 Y39.286 E14.8775
G1 X40.915 Y39.286 E14.9126
G1 X60.714 Y59.085 E16.1196
G1 X60.714 Y59.900 E16.1547
G1 X40.100 Y39.286 E17.4113
G1 X39.286 Y39.286 E17.4464
G1 X60.714 Y60.714 E18.7527
G1 X59.900 Y60.714 E18.7878
G1 X39.286 Y40.100 E20.0445
G1 X39.286 Y40.915 E20.0796
G1 X59.085 Y60.714 E21.2865
G1 X58.270 Y60.714 E21.3216
G1 X39.286 Y41.730 E22.4789
G1 X39.286 Y42.544 E22.5141
G1 X57.456 Y60.714 E23.6217
G1 X56.641 Y60.714 E23.6568
G1 X39.286 Y43.359 E24.7148
G1 X39.286 Y44.173 E24.7499
G1 X55.827 Y60.714 E25.7583
G1 X55.012 Y60.714 E25.7934
G1 X39.286 Y44.988 E26.7520
G1 X39.286 Y45.802 E26.7872
G1 X54.198 Y60.714 E27.6962
G1 X53.383 Y60.714 E27.7313
G1 X39.286 Y46.617 E28.5907
G1 X39.286 Y47.432 E28.6258
G1 X52.568 Y60.714 E29.4355
G1 X51.754 Y60.714 E29.4706
G1 X39.286 Y48.246 E30.2306
G1 X39.286 Y49.061 E30.2658
G1 X50.939 Y60.714 E30.9761
G1 X50.125 Y60.714 E31.0113
G1 X39.286 Y49.875 E31.6720
G1 X39.286 Y50.690 E31.7071
G1 X49.310 Y60.714 E32.3182
G1 X48.495 Y60.714 E32.3533
G1 X39.286 Y51.505 E32.9147
G1 X39.286 Y52.319 E32.9498
G1 X47.681 Y60.714 E33.4616
G1 X46.866 Y60.714 E33.4967
G1 X39.286 Y53.134 E33.9588
G1 X39.286 Y53.948 E33.9939
G1 X46.052 Y60.714 E34.4064
G1 X45.237 Y60.714 E34.4415
G1 X39.286 Y54.763 E34.8043
G1 X39.286 Y55.577 E34.8394
G1 X44.422 Y60.714 E35.1525
G1 X43.608 Y60.714 E35.1876
G1 X39.286 Y56.392 E35.4511
G1 X39.286 Y57.207 E35.4862
G1 X42.793 Y60.714 E35.7000
G1 X41.979 Y60.714 E35.7352
G1 X39.286 Y58.021 E35.8993
G1 X39.286 Y58.836 E35.9344
G1 X41.164 Y60.714 E36.0489
G1 X40.350 Y60.714 E36.0841
G1 X39.286 Y59.650 E36.1489
G1 X39.286 Y60.465 E36.1840
G1 X39.535 Y60.714 E36.1992
G92 E0.0000
G1 E-5.0000 F2400
`
var originalFirstlayerEnd = `; layer end
G28 X0 ; home X axis
M106 S0 ; turn off cooling fan
M104 S0 ; turn off extruder
M140 S0 ; turn off bed
M84 ; disable motors
`

View File

@ -14,10 +14,20 @@ function downloadFile(filename, contents) {
}
function toggle(ticked, target){
if(ticked == true){
$(target).hide();
if(target == "first"){
if(ticked == false){
$("#firstlayerXY").show();
$("#firstlayerdia").hide();
} else {
$("#firstlayerXY").hide();
$("#firstlayerdia").show();
}
} else {
$(target).show();
if(ticked == true){
$(target).hide();
} else {
$(target).show();
}
}
}
@ -80,6 +90,133 @@ function toggleJ() {
}
}
function processFirstlayer(){
var hotendTemp = document.firstlayerForm.hotendtemp.value;
var bedTemp = document.firstlayerForm.bedtemp.value;
var centre = document.firstlayerForm.centre.checked;
var bedX = document.firstlayerForm.bedx.value - 50;
var bedY = document.firstlayerForm.bedy.value - 50;
var bedRad = Math.round((document.firstlayerForm.beddia.value)/2);
var retDist = document.firstlayerForm.retdist.value;
var retSpeed = document.firstlayerForm.retspeed.value*60;
var abl = document.firstlayerForm.abl.value;
var customStart = document.firstlayerForm.startgcode.value;
var firstlayer = "";
var firstlayerStart = originalFirstlayerStart;
var skirts = "";
var squares = "";
var firstlayerEnd = originalFirstlayerEnd;
var offsets = [0,0,0,0,0,0,0,0,0,0];
var delt = 30;
var xy = 30;
if(centre == true) {
// left
offsets[0] = bedRad*-1 - 50;
offsets[1] = -50;
// bottom
offsets[2] = -50;
offsets[3] = bedRad*-1 - 50;
// centre
offsets[4] = -50;
offsets[5] = -50;
// top
offsets[6] = -50;
offsets[7] = bedRad - 50;
//right
offsets[8] = bedRad - 50;
offsets[9] = -50;
} else {
// bottom left
offsets[0] = 0 + xy - 50;
offsets[1] = 0 + xy - 50;
// top left
offsets[2] = 0 + xy - 50;
offsets[3] = bedY - xy;
// centre
offsets[4] = bedX/2 - 25;
offsets[5] = bedY/2 - 25;
// bottom right
offsets[6] = bedX - xy;
offsets[7] = 0 + xy - 50;
// top right
offsets[8] = bedX - xy;
offsets[9] = bedY - xy;
}
firstlayerStart = firstlayerStart.replace(/M140 S60/g, "M140 S"+bedTemp+" ; custom bed temp");
firstlayerStart = firstlayerStart.replace(/M190 S60/g, "M190 S"+bedTemp+" ; custom bed temp");
if(abl != 4){
firstlayerStart = firstlayerStart.replace(/M104 S210 T0/g, "M104 S"+hotendTemp+" T0 ; custom hot end temp");
firstlayerStart = firstlayerStart.replace(/M109 S210 T0/g, "M109 S"+hotendTemp+" T0 ; custom hot end temp");
} else {
firstlayerStart = firstlayerStart.replace(/M104 S210 T0/g, "; Prusa Mini");
firstlayerStart = firstlayerStart.replace(/M109 S210 T0/g, "; Prusa Mini");
}
if(abl == 1){
firstlayerStart = firstlayerStart.replace(/;G29 ; probe ABL/, "G29 ; probe ABL");
}
if(abl == 2){
firstlayerStart = firstlayerStart.replace(/;M420 S1 ; restore ABL mesh/, "M420 S1 ; restore ABL mesh");
}
if(abl == 3){
firstlayerStart = firstlayerStart.replace(/G28 ; home all axes/, "G28 W ; home all without mesh bed level");
firstlayerStart = firstlayerStart.replace(/;G29 ; probe ABL/, "G80 ; mesh bed leveling");
}
if(abl == 4){
firstlayerStart = firstlayerStart.replace(/G28 ; home all axes/, "M109 S170 T0 ; probing temperature\nG28 ; home all");
firstlayerStart = firstlayerStart.replace(/;G29 ; probe ABL/, "G29 ; probe ABL");
firstlayerStart = firstlayerStart.replace(/;M420 S1 ; restore ABL mesh/, "M109 S"+hotendTemp+" T0 ; custom hot end temp");
}
if(abl == 5){
firstlayerStart = firstlayerStart.replace(/;G29 ; probe ABL/, "G29 L1 ; Load the mesh stored in slot 1\nG29 J ; Probe 3 points to tilt mesh");
}
for(var i = 0; i <= 4; i++){
var skirt = "; skirt "+(i+1)+"\n"+originalskirt;
var firstlayerArray = skirt.split(/\n/g);
var regexp = /X[0-9\.]+/;
firstlayerArray.forEach(function(index, item){
if(firstlayerArray[item].search(/X/) > -1){
var value = parseFloat(firstlayerArray[item].match(regexp)[0].substring(1)) + offsets[i*2];
firstlayerArray[item] = firstlayerArray[item].replace(regexp, "X"+String(value));
}
});
var regexp = /Y[0-9\.]+/;
firstlayerArray.forEach(function(index, item){
if(firstlayerArray[item].search(/Y/) > -1){
var value = parseFloat(firstlayerArray[item].match(regexp)[0].substring(1)) + offsets[i*2+1];
firstlayerArray[item] = firstlayerArray[item].replace(regexp, "Y"+String(value))
}
});
skirt = firstlayerArray.join("\n");
skirts += skirt;
var square = "; square "+(i+1)+"\n"+originalSquare;
var firstlayerArray = square.split(/\n/g);
var regexp = /X[0-9\.]+/;
firstlayerArray.forEach(function(index, item){
if(firstlayerArray[item].search(/X/) > -1){
var value = parseFloat(firstlayerArray[item].match(regexp)[0].substring(1)) + offsets[i*2];
firstlayerArray[item] = firstlayerArray[item].replace(regexp, "X"+String(value));
}
});
var regexp = /Y[0-9\.]+/;
firstlayerArray.forEach(function(index, item){
if(firstlayerArray[item].search(/Y/) > -1){
var value = parseFloat(firstlayerArray[item].match(regexp)[0].substring(1)) + offsets[i*2+1];
firstlayerArray[item] = firstlayerArray[item].replace(regexp, "Y"+String(value))
}
});
square = firstlayerArray.join("\n");
squares += square;
}
var firstlayer = firstlayerStart+skirts+squares+firstlayerEnd;
firstlayer = firstlayer.replace(/G1 E-5.0000 F2400/g, "G1 E-"+retDist+" F"+retSpeed+" ; custom retraction");
firstlayer = firstlayer.replace(/G1 E0.0000 F2400/g, "G1 E0.0000 F"+retSpeed+" ; custom un-retraction/prime");
if(document.firstlayerForm.start.checked == true) {
firstlayer = firstlayer.replace(/;customstart/, "; custom start gcode\n"+customStart);
}
downloadFile('firstlayer.gcode', firstlayer);
}
function processBaseline(){
var hotendTemp = document.baselineForm.hotendtemp.value;
var bedTemp = document.baselineForm.bedtemp.value;