FSR Auto Calibration Setup for Duet Controller
By SublimeLayers →
Sunday, January 24, 2016
A lot of folks have pinged me for information about setting up FSRs for auto calibration using the Duet controller and dc42 branch of the RepRapFirmware. So I'll document what I've done here. Please feel free to post questions in the comments section so everyone can learn from them.
By far the easiest way to interface FSRs is with the JohnSL board. Several vendors sell them singly or in a kit with the FSRs and wiring harness. I like the UltiBot FSR Kit as it is competitively priced, the FSRs are the short variety with PRE-ATTACHED connectors (a significant feature), the JohnSL board and the wiring harness. Oh, and there are silicone pads for properly distributing the force on the FSR surface. I've equipped 12 printers with FSRs now and this is by far the easiest route.
I'll leave mounting the FSRs for another post as each printer has it's own requirements. To date, I've created printable mounts for Rostock Max, Mini Kossel, Kossel 250 and TAZ 4 and 5 printers. These can probably be adapted to any other delta or Cartesian printer. If you need them before I add them here, let me know. I also have a little JohnSL board holder to attach the board securely to the printer.
Wiring Up
On to the Duet and wiring...Here's a photo of a Duet 0.8.5 on a Kossel 250. The Duet 0.8.5 has a dedicated connector for Z probes (upper right corner next to the PanelDue connector in the photo) but the folks at Think3DPrint3D recommended using the extruder end stop connector (labeled P above) for this type of probe (which actually makes the FSR output look like a standard mechanical endstop switch to the controller).
The wiring harness that comes with the UltiBot kit to connect the JohnSL to the Duet needs to be modified as the Duet has a different pin ordering than Arduino-based controllers. Take a look at the grey-red-black wires in the photo above. Grey is the Signal, red is 3v3 and black is ground. You can use a needle or thin wire to press the little tab in the connector housing slot to remove and rearrange the pins.
The JohnSL board is connected to the other end of this 3 wire harness. The photo above shows the wire order. The JohnSL also has jumpers to set the sensitivity - but leave those alone for now. There is also a jumper to set the switch behavior NC or NO. The jumper MUST BE installed to make the JohnSL behave like a NC switch. That is documented along with the sensitivity jumpers at the bottom of this page. The three FSR wiring harnesses attach to the two pin connectors at the bottom of the photo - the wire color order does not make a difference. It is good practice to twist the two wires to minimize signal noise.
Configuring Firmware
With the FSRs connected to JohnSL and the JohnSL connected to Duet, you can give your sensors a dry run test. First, edit your config.g file to let Duet know about the "Z probe". It is located near the bottom of the file. (TIP: with the Duet Web Control 1.08 you can edit this file right from the Web UI). Look for the section:
; Z probe and compensation definition
;*** If you have an IR zprobe instead of a switch, change P4 to P1 in the following M558 command
M558 P4 X0 Y0 Z0 ; Z probe is a switch and is not used for homing any axes
G31 X0 Y0 Z-.08 P500 ; Set the zprobe height and threshold (put your own values here)
The above is configured correctly for the FSR probe. Note the G31 line "Z" parameter. We'll come back to that later but for now set it to Z0.
While you are editing config.g, also set the primary delta parameters. Look for the M665 line:
;*** The homed height is deliberately set too high in the following - you will adjust it during calibration
M665 R97.336 L217.71 B85 H210 X0.33 Y-0.11 Z0.00 ; set delta radius, diagonal rod length, printable radius and homed height
M666 X-0.31 Y1.32 Z-1.01 ; put your endstop adjustments here, or let auto calibration find them
Set the delta radius R to a reasonably close value wither by measuring or using the manufacturer's recommendation. Set diagonal rod length L either by measuring your rods or using the lengths from the manufacturer, set the printable radius B, and set the homed height H to the distance from your nozzle tip when homed to the bed surface - 10mm to give a little clearance for calibration later.
Now power up your Duet. Press a finger tip on each of the FSRs one at a time. You should see the corresponding LED on the JohnSL light up and you should also see the LED above the extruder endstop connector on the Duet turn off (it is normally lit up with an NC switch). Once you've verified everything is working correctly, you can mount your FSRs and button up the installation.
In addition to the config.g edits above, you also need to edit your bed.g file. bed.g contains all the auto calibration configuration, mine looks like this (for a Kossel 250):
; Auto calibration routine for delta printers ; Before running this, you should have set up your zprobe Z offset to suit your build, in the G31 command in config.g. ; About the G30 S parameter ; Used to specify what calibration computation to perform. ; ; S=-1 Don't adjust anything, just print the height error at each probe point ; S=0 Equivalent to S=; S=3 Adjust homing switch corrections only ; S=4 Adjust homing switch corrections and delta radius ; S=6 Adjust homing switch corrections, delta radius, and X and Y tower position offsets ; S=7 Adjust homing switch corrections, delta radius, X and Y tower position offsets, and diagonal rod length M561 ; clear any bed transform, otherwise homing may be at the wrong height G31 X0 Y0 ; don't want any probe offset for this G28 ; home the printer ;*** Remove the following line if your Z probe does not need to be deployed ;M98 Pdeployprobe.g ; deploy the mechanical Z probe ; The first time the mechanical probe is used after deployment, it gives slightly different results. ; So do an extra dummy probe here. The value stored gets overwritten later. You can remove this if you use an IR probe. ;G30 P0 X0 Y0 Z-99999 ; Probe the bed and do 6- or 7-factor auto calibration G30 P0 X-69.28 Y-40.00 Z-99999 H0.0 ; X tower G30 P1 X0.00 Y-80.00 Z-99999 H0.0 ; between X-Y towers
G30 P2 X69.28 Y-40.00 Z-99999 H0.0 ; Y tower
G30 P3 X69.28 Y40.00 Z-99999 H0.0 ; between Y-Z towers
G30 P4 X0.00 Y80.00 Z-99999 H0.0 ; Z tower
G30 P5 X-69.28 Y40.00 Z-99999 H0.0 ; between Z-X towers
G30 P6 X-34.64 Y-20.00 Z-99999 H0.0 ; X tower
G30 P7 X0.00 Y-40.00 Z-99999 H0.0 ; between X-Y towers
G30 P8 X34.64 Y-20.00 Z-99999 H0.0 ; Y tower
G30 P9 X34.64 Y20.00 Z-99999 H0.0 ; between Y-Z towers
G30 P10 X0.00 Y40.00 Z-99999 H0.0 ; Z tower
G30 P11 X-34.64 Y20.00 Z-99999 H0.0 ; between Z-X towers
G30 P12 X0 Y0 Z-99999 H0.0 S6 ; center and auto-calibrate 6 factors
There are a couple of important things here. Firstly, read my comments on the S value at the top. I always do S=6 calibration. I don't want auto calibration messing around with my delta arm length as that can affect the part X-Y scaling and is easy enough to figure out and set independently. You can do an S=3 or S=4 once you have the machine calibrated, but since it only takes 30 seconds to do a full S=6 I just use that all the time.;*** Remove the following line if your Z probe does not need to be retracted ;M98 Pretractprobe.g ; retract the mechanical Z probe G1 X0 Y0 Z150 F10000 ; get the head out of the way of the bed
Also note the commented out M98 lines. FSRs do not retract! I left them here commented out as a reminder since the default has them uncommented.
Next, you need to set the bed probe points. David has a nice web-based bed.g file generator here to sett all of this up. I use 13 point, 6 factor with a probing radius = 100 for my calibration above. TIP: it is best to start with a smaller probe radius than your bed actually supports to make sure your hot end, arms, carriages or wiring interferes. You can then sneak up on the maximum probe radius.
Make the edits to bed.g and upload or copy it to the CF card on Duet into the /sys folder.
Commisioning
Everything is ready to go, now what? Now it's time to test and make sure everything is working properly. I recommend doing a dry run with the hot end and bed cold. Once you have things working correctly, you always want to calibrate with the hot end and bed up to printing temperatures.
Power up your printer and Home it. Verify that the FSRs are working properly by tapping gently on the bed - you should see the LEDs blink on the JohnSL board and the endstop LED on Duet blink off-on. Test all three FSRs by tapping directly over them. With everything ready to go, enter G32 into the Web interface G-Code console or press the Auto Cal button on the PanelDue. Be ready to turn off the printer quickly in the event of a problem. The printer should home then descend to about 10mm above the bed. Then it moves out and probes each of your probe points, ending with a probe at 0,0. Finally, the nozzle raises 150 mm off the bed (that's the last line in the bed.g file that says G1 X0 Y0 Z150 F15000. You can change that to anything you'd like.
Presumably the probing worked. You can check the results easily. If you ran from PanelDue, click the Console tab and the auto calibration results will be printed. The deviation value tells you the least means square deviation for the calibration. You'd like to keep this below 0.05 for the best results. If you auto calibrated from the web interface, the output will be in the G-Code Console log output. Here's an example:
Calibrated 6 factors using 12 points, deviation before 0.208 after 0.045
If you issue an M665 command, you'll get the calculated delta radius, homed height, and tower position offsets.
M665
Diagonal 215.53, delta radius 96.64, homed height 208.92, bed radius 85.0, X 1.59°, Y 1.31°, Z 0.00°
M666 shows the end stop adjustments.
M666
Endstop adjustments X0.21 Y1.41 Z-1.63Once you have calibration tested and working, bring the hot end and bed up to temperature and run calibration (G32) again. If your deviation is too high, run auto calibration again. Sometimes 2-3 runs will improve things. If after 3 runs it is still too high, I recommend checking your printer carefully for mechanical issues. In particular, check that the FSRs are triggering reliably with little force.
After you have a good calibration, you can transfer the M665 and M666 values to your config.g file so the next time you start your printer, you are ready to go. I find calibration so quick to perform that I just run G32 everytime I startup my printer. In fact, you can add a shortcut to the Duet Web Control menu for it. Click the Settings menu and the List Items tab. In the Add new G-Code box enter G32 for G-code and Auto Calibrate for the description. Click Add G-Code and Apply Settings. Now you can run Auto Calibrate from the pull-down menu at the top left of the Web Control screen.
Post Script
Once you have FSR based auto calibration working you may find that it needs a little tweaking to set Z=0 properly. FSRs require force to trigger. Depending on how rigid your bed and FSR mounting system is, you may get a little flex before the FSR triggers. This can result in the nozzle being too low - the nozzle will drag on the bed on the first layer or the layer height will be too thin. The G31 line in the config.g file can offset this. I have a very rigid bed and mounting system and find I need -0.05 mm compensation using the Z parameter for Z probe height.
G31 X0 Y0 Z-.05 P500 ; Set the zprobe height and threshold (put your own values here)
In the dc42 firmware, David has built-in some very flexible probe height offset with the G30 H parameter. Basically, this allows you to correct for any offset differences at the probing points. Here's how you go about doing that:
- Above each probe point (from the bed.g file) lower the nozzle using the paper grip test.
- Send a G92 Z0.
- Raise the nozzle 5mm.
- Send G30 S-1 and write that down.
- Read the trigger height (if you did the above from the web interface, read it there, otherwise read from the PanelDue console).
- Repat 3 - 5 several times and average the results. I like to do 3 probes.
- Repeat 1 - 6 for each probe point from the bed.g file.
- Edit the G31 Z parameter in config.g to the trigger height you measured at the bed center: X = Y = 0.
- In bed.g set the H parameter for for each of the probe points like this:
H = (trigger height measured at the point) - (trigger height at the bed center)
I'd like to thank David Crocker (dc42) for his great firmware and guidance in understanding his probing and configuration.