Tags:

FSR Auto Calibration Setup for Duet Controller

By mhackney 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

;*** 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
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.

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.63
Once 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:
  1. Above each probe point (from the bed.g file) lower the nozzle using the paper grip test.
  2. Send a G92 Z0.
  3. Raise the nozzle 5mm.
  4. Send G30 S-1 and write that down.
  5. Read the trigger height (if you did the above from the web interface, read it there, otherwise read from the PanelDue console).
  6. Repat 3 - 5 several times and average the results. I like to do 3 probes.
  7. Repeat 1 - 6 for each probe point from the bed.g file.
  8. Edit the G31 Z parameter in config.g to the trigger height you measured at the bed center: X = Y = 0.
  9. 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.


12 comments to ''FSR Auto Calibration Setup for Duet Controller"

ADD COMMENT
  1. Michael -

    Great writeup. I was able to get the Duet installed, commissioned, calibrated, and printing in a few hours on our K250VS-BSE Delta. Thanks for the link to UltiBots and support of our FSR kits.

    Brad

    ReplyDelete
  2. Glad it helped Brad. I corrected the spelling to "UltiBot", sorry about that. Good products and companies deserve to be called out.

    ReplyDelete
  3. Any chance you could upload the mounts for the Rostock Max V2 to thingiverse. That would be v. helpful.
    Thanks for your guidance it has been super helpful.

    ReplyDelete
  4. Yes, I'll do that when I get home later this week and put a link here.

    ReplyDelete
  5. Ok, I've published the mounts on Thingiverse here: http://www.thingiverse.com/thing:1335095

    ReplyDelete
  6. "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)"

    little confused, I don't see H parameter in the bed.g sample file you have posted. Where do I enter that parameter?

    ReplyDelete
  7. I didn't have the H parameter in my bed.g for simplicity but I've edited the example in the text above to include H0.0 that can be replaced. Basically, you insert H in the G30 line like this:

    G30 P0 X-69.28 Y-40.00 Z-99999 H0.0

    ReplyDelete
  8. Did not know about the jumper for setting the JohnSL board to NC, thanks for the tip. Thought it was causing homing problems (and it might have been), though appearently I had swapped my X and Z motors.

    Question though, when I run the AutoCal, the nozzle drops to the bed and pushes /drags on it through out the entire probing process. In Rich Cattel's Marlin calibration, it would probe the bed from 5mm or so before moving to the next point.

    ReplyDelete
    Replies
    1. Nevermind. In the default gcode, I thought it said to overestimate the bed height which was contrary to what you wrote...bed height minus ten.

      You were right, my bed height is roughly 160 and entering 150 in the config.g file worked perfectly. Overestimating (165) was causing the dragging during the probe.

      Thanks again, glad I found your blog.

      Delete
  9. AH, it sounds like you have your initial M665 "H" value set to high. Do this:

    home the printer and measure the distance from the nozzle to the bed. Subtract 5mm and then enter M665 HNNN where NNN is your height. Here is the comment in David's config.g file:

    ;*** The homed height is deliberately set too high in the following - you will adjust it during calibration
    M665 R105.6 L215.0 B85 H240 ; set delta radius, diagonal rod length, printable radius and homed height

    The behavior should be that the nozzle comes down to within a few mm of the bed, travels to your first probe point, probes, next probe point, probe, etc.

    ReplyDelete
  10. Hi,

    Thank you for the writeup!
    I'd like to point out that link to David's web-based bed.g generator is broken. Your "http://for%20my%20calibration%20above/" should be "http://escher3d.com/pages/wizards/wizardbed.php"

    Regards,
    Mait

    ReplyDelete
  11. Thanks Mait, I'll fix the link in the text. Cheers!

    ReplyDelete