Showing posts with label firmware. Show all posts
Showing posts with label firmware. Show all posts

Saturday, June 16, 2018

Configuring the Duet Board

Once all the wiring was done, it was time to get everything hooked up and running.  I found some things a little confusing, made a couple errors, but in the end it wasn't too difficult to switch from the SmoothieBoard to the Duet Ethernet controller.

First things first: Configure


I used the on-line configurator to generate the config files and uploaded them to the Duet board via the web interface (DWC).  I ran into a few issues with the configurator, some of which was confusing labeling and other things which were just not right.  It seems the configurator has not quite kept up with firmware advances.  More on this later...

Next up: Motion Testing


I checked the motor connections and found they were essentially the same between the two controller boards, so all I had to do was plug the motor cables into the appropriate connectors.  UMMD had both a Z=0 and Zmax endstop switches but the Duet board doesn't have maximum and minimum endstop inputs, so I used the Z=0 switch and left the Zmax switch unconnected for now.

I used NC snap action switches for all the endstops in UMMD.  Both SmoothieBoard and Duet use 3 pin connections for the end stop switches, but be careful!  On the SmoothieBoard, the NC switch connections are made between adjacent pins in the connectors and on the Duet board, the NC connections are made using the two outside pins.  After moving the wires within the endstop connectors, I plugged them in and verified operation by watching the readout on the web interface.

With motors and endstops connected, I moved the A and B motors individually to see which way the extruder carriage moved and found that I needed to reverse the direction on the B motor which was a simple change in the config.g file.

The Z axis set up was one of the confusing points in the online configurator.  I use a simple Z=0 switch to zero the bed, which is apparently not very common in machines that use the Duet boards.  In the configurator there are multiple options for "Z probe", including "none" and "switch".  I looked at switch and there were a couple offset values and a threshold value listed, which didn't seem appropriate for a simple Z=0 switch, so I figured it must be for some sort of extruder carriage mounted switch that is used to probe the bed.  So I selected "none" and kept going.

When I tried to get the Z axis working, since I had selected "none" in the Z probe section of the configurator, it assumed there was no switch, and the DWC and the touch panel both wanted me to manually zero the bed.  The problem was I couldn't get the bed to move because the Z axis had not been homed (it nicely displayed an error message to that effect).

That's what we call a "catch-22" situation.  I was trying to home the bed but I couldn't move it because it hadn't been homed.  I later found out there had been a firmware update a few days before I tried to configure that fixed that problem, but I had not updated the firmware since the update I did the day after I received the board.

So since I couldn't get it working that way, I reconfigured for Z using the "switch" option, assuming that the default 2.5mm offset was going to put the nozzle 2.5 mm above the bed after homing.  Big mistake!  2.5 mm offset meant that the nozzle was going to be 2.5 mm below the bed surface.  At some point after it was all moving I loaded a gcode file and hit go and it slammed the bed into the nozzle and then dragged the nozzle across the PEI surface, leaving a deep gouge about 100mm long before I hit the stop button.  When using the "switch" option, the offsets should be set to "0" or negative values.  I reconfigured using the "switch" option again and set the offsets to "0" and it worked fine after that.

The "switch" option is selected and offsets default to 2.5 mm, which means if you don't change the value to "0" it will drive the bed into the extruder nozzle.  I learned that the hard way.

I used the 256:1 microstepping interpolation for all the motors, and copied the accelerations and steps/mm from the Smoothieboard configuration to the Duet config.g file.  Everything worked fine, and the machine is much quieter now that it used to be.  SmoothieWare uses something called "junction deviation" instead of the "jerk" that is used in RRF, so I started with the default jerk value and will tune for acceptable performance, a trade between print speed and ringing in the print surface.

Configuring Heaters


UMMD has three heaters, one each for the extruder, bed, and chamber.  The chamber and bed heaters are both line powered and use SSRs to switch power.  The Duet board has three heater connections, all screw terminals.  There's a "bed heater" connection that uses very large screw terminals so it can switch a lot of current for a DC powered heater.  The other two heater outputs use smaller screw terminal connections, labeled E0 and E1.  This is where things start to get confusing.

When you use the online configurator, it is difficult to understand when the configurator is referring to a device, or the connection on the circuit board, and when you look at the config.g file, it gets worse.  The E0 and E1 motor and heater connections are normally used for the first and second extruders, though reassignment is possible.  Here's a breakdown of the default connections:


Physical DeviceConnections on Duet boardFirmware
first extruderE0 motor, E0 heaterT0 (tool), H1 (heater), E0 (motor)
second extruder (or chamber heater)E1 motor, E1 heaterT1 (tool), H2 (heater), E1 (motor)
bed heaterbed heaterH0

Once I had sorted all this out and mentally translated the connections on the configurator to the physical devices and the board connections, I was able to get everything working, but I ran into some problems with PID tuning and ended up on the forum looking for some help.  The configurator was inserting M301 commands in the config.g file which have been superceeded by M307 commands.  I made the recommended changes and was able to get the heaters working.  I believe they'll be updating the configurator soon.

Even more confusing than I thought- if you check the "chamber heater present" box, the first extruder heater gets assigned to the E1 screw terminals and the chamber heater gets assigned to the E0 heater terminals.  Ugh!

Along the way I tried swapping the bed and extruder heater connections, an option in the configurator.  That didn't work out for me because the Panel Due does not understand the swapped connections.  I wanted full control using the Panel Due so I swapped back to the default connections and it is all working as expected.

Finally, I was ready to make a test print!  I sliced a simple file for some Maker Faire give-aways (left hand threaded nuts and bolts, just to mess with peoples' minds), then uploaded the gcode to the Duet board and started the print.  Results were excellent and the machine was very quiet.  Here's a short video snippet:

UMMD: First test print with Duet controller from Mark Rehorst on Vimeo.


Compare the sound level in the video above, with the Duet board, to the sound level in this video, made using the SmoothieBoard:

UMMD ringing test #1 from Mark Rehorst on Vimeo.

Monday, April 23, 2018

UMMD: Migrating from SmoothieBoard to Duet Ethernet, Part 2

Configuration

Part of the conversion from SmoothieBoard to Duet involves deciding what has to connect to what and then configuring the board appropriately.

This table lists which items in UMMD will connect to which I/Os on the Duet board:

UMMD Duet connection Note
A motor Drive 0 part of XY stage
B motor Drive 1 part of XY stage
Z motor Drive 2 Rino motor
extruder motor Drive 3
X endstop X stop switch located at Xmax
Y endstop Y stop switch located at Ymax
Z min endstop Z stop Z=0 switch
Z max endstop E1 stop
bed thermistor Thermistor 0
hotend thermistor Thermistor E0
chamber thermistor Thermistor E1
bed heater Heated Bed drives SSR
extruder heater E0 heater
chamber heater E1 heater drives SSR
extruder cooling fan Fan 0 will leave off until hotend temperature reaches 45C
print cooling fan Fan 1 PWM
chamber heater fan Fan 2 not sure about this

The Duet board wiring diagram is located here.

The Zmax switch located at the bottom of UMMD's Z axis prevents the high torque drive from trying to move the bed lower than the bottom of the axis, which might cause some damage to the belts or pulleys.  I'm not sure how I'm going to handle that yet.

The line powered 500W chamber heater has a fan to prevent the temperature of the heater bar from getting too high and to circulate the warm air inside the chamber.  Right now the fan is driven by the signal that drives the SSR switching power to the heater, which uses PWM under PID control.  It might be better to operate the 24V fan at some constant, but <100% duty cycle (not trying to create a tempest, just stir the air in the enclosure a bit), whenever the heater is in use as opposed to switching the fan on and off with the heater bar.

UMMD uses a 24V, 200W, fanless power supply, and has two dc-dc converters that power white and UV LEDs.  Those LEDs are switched manually with a DPDT switch.  There is currently a fan that blows air over the SmoothieBoard and the power supply to keep things cool.  None of that will affect the configuration of the Duet board.

I have two options for the print cooling fan- the small squirrel cage blower that mounts on the extruder carriage and the remote CPAP blower that is powered by its own driver board under PWM drive from the controller.  Whichever I settle on will use one of the PWM fan outputs.

Electronics Considerations


UMMD has electronics mounted on the top of the enclosure, at eye level, so I don't have to bend over when working on the machine.  Most of the wiring has to connect to the XY stage on the printer, so putting the controller on top keeps most of the wires shorter.  With the Duet conversion, I may move the 117VAC fuses and distribution, 24V power supply, and bed heater SSR to the bottom of the printer.  That will considerably reduce clutter on the top of the machine.  The power supply and SSR are pretty reliable so I shouldn't have to do a lot of work involving those.

The biggest problem is deciding how to mount the LCD panel.  The easiest thing is to just stand it upright on the top front of the printer and be done with it.  That would be reasonably safe when transporting the printer, but doesn't address the problem of curious fingers messing with it at events like Maker Faires.  The Panel Due doesn't currently support a PIN for access (though I posted a request for it on the forum), so covering it is the best way to control access.

Panel Due details are located here, but more up-to-date info appears to be here.

Getting It Talking On the Network and Update Firmware


It took a bit of searching (the web site has a lot if info, but isn't optimally organized), but I found out how to get the Duet board onto my network so I could take a look at the web control interface and configure it for UMMD's hardware.  Here is the procedure.

I powered the board using a USB cable and connected the network cable and followed the procedure, but couldn't get the web interface to show up in my browser because there was another device on my network that had the same IP address that the Duet was reporting.

My Duet board was configured with an IP address of 192.168.1.14 (in the config.g file on the Duet uSD card), and that happened to already be assigned to a device on my network.  Once I figured out what was going on I edited the config.g file and set the assignment to 0.0.0.0 so that my router would assign an unused IP address.

After that the web control was accessible through my browser.

Next step- update firmware and web server.  I downloaded the firmware (DuetEthernetFirmware.bin) and the web server (DuetWebControl.zip)here, and then installed them, firmware first, then the web server, via the web control page in my browser.  Both updated with no trouble at all to versions 1.21

Configuring

The first thing you see after connecting to the web control is that the firmware wants you to configure your printer.  I went to the configurator and did that based on the contents of the table, above.  There were a few things I had to guess at, such as motor rotation directions, so we'll see when I actually hook the printer to the board what I actually end up with.

Connecting Panel Due 7i and Updating Its Firmware


I took out the supplied 4 wire serial cable and hooked the LCD panel to the Duet board, then connected the USB cable to the Duet board to power things up and the Panel Due worked fine without any messing around.  The setup screen indicated that the firmware was version 1.17, and I checked the website here and found that there is a newer version of the firmware available.

I updated the firmware and added a custom splash screen.  You have to gather things in different places, but if I could do it, you can too.

Get latest firmware here
Get instructions for flashing the firmware via USB here
Get Bossa (used to flash the new firmware)here

Adding a Splash Screen (optional)


Create an 800x480 x 24 bit per pixel bmp file in whatever graphics program you like.
Get the compression program here
Follow procedure at bottom of page here to compress the splashscreen file and append it to the firmware file.

Finally, burn the new firmware using Bossa.  I found the GUI for Bossa worked fine on my Win 10 machine with a QHD display.

Custom Splash Screen for Panel Due from Mark Rehorst on Vimeo.


Local Connection via Network Cable


A day or two after all the above was done, I realized that when I go to Maker Faires and other public venues, there isn't usually a wired network to connect to.  Also, there are no wired ethernet drops in my basement workshop or the garage.  In planning the new electronics enclosure for the Duet and Panel Due, I couldn't come up with an easy means of accessing the uSD cards in either device- the Duet will be too deeply buried in the enclosure with too many cables in the way, and the position of the uSD card slot on the bottom edge of Panel Due makes it a little difficult for me to access on my machine, so I need to be able to connect a computer directly to the Duet board to do things like change the machine's configuration and upload gcode files to print.

The Duet board has both USB and ethernet connections.  In order to use the USB port for anything other than powering the board while testing, you need the driver files which you get here.  Grab the file called "DuetWindowsDriverFiles.zip".  Install in your Windows PC and I assume you're good to go.  I'm not a huge fan of USB connections, so I prefer to use the ethernet connection, even if file transfer is a bit slower.

I did a little digging and it turns out getting a computer to talk directly to another device over a network port (no routers or switches) is pretty easy to do.  I'm no networking expert, so if I can figure it out, so can you.  I started with a search at the Duet forums, and followed along.  I am using an Acer netbook computer (there's still plenty of life left in old computers!) running Linux Mint.

The first thing I did was to edit the config.g file on the Duet's uSD card.  I commented out the line that said "M552 P0.0.0.0 S1" which enable networking and tells it to get an IP address via DHCP, and replaced it with "M552 P192.168.1.3 S1" which forces it to use IP address 192.168.1.3.

I put the uSD card back into the Duet board and connected it to the netbook via a short ethernet cable, powered up the Duet board with a USB cable, and powered on the netbook.  Some older computers require a crossover cable to swap Tx and Rx connections to allow them to do this sort of thing, but my 2007 era netbook is new enough that it automatically switches, so a regular network cable worked just fine.

In the netbook I went into the network configuration and set up a new wired connection using address 192.168.1.2, netmask 255.255.255.0, and gateway 192.168.1.1, DNS servers 1.1.1.1, search domains nameserver, 1.1.1.1.  The DNS server stuff shouldn't matter, but I had to enter something because the network manager wouldn't let me save the connection without putting some values in there.

So now both the Duet board and the computer are in the same subnet and assigned sequential addresses.  I verified the connection by opening a terminal and entering "sudo nmap -sn 192.168.1.0/24" and it indicated that there was a connection to the Duet board at 192.168.1.3.  Then I opened a web browser and entered 192.168.1.3 and it brought up the Duet Web Control pages.

I tried uploading a 30 MB gcode file from the computer to the Duet board and it ran at about 500-600 kB/s.  It took about a minute- not super fast, but fast enough.


Next up: Electronics enclosure

Saturday, August 5, 2017

Setting Up a CoreXY Printer's Origin and EndStops

In this explanation, I'm going to use SmoothieWare as an example for the config file entries, but there are similar entries for whatever firmware you are using. Look them up!

If your printer is not a coreXY type, please refer to this post for setting up its origin and end stops.

I will refer to the motor that connects to the X or alpha output on the controller as the alpha motor, and the motor connecting to the Y or beta output as the beta motor.  The Z axis motor connects to the Z or gamma output. I will largely ignore the Z axis because it's pretty straightforward- you're going to have an endstop at the Z=0 position at the top of the Z axis (where the bed touches the nozzle).

CoreXY motion can be a little confusing when trying to set up endstops and motor direction in firmware. The printer's firmware needs to know:
  1. That a corexy mechanism is being used
  2. The locations of the printer's endstop switches and origin
  3. The length of each axis
  4. The direction to spin each motor


Step by step CoreXY firmware setup

  1. Build your printer, and mount the motors and limit switches.
  2. Choose origin location
  3. Set home_to direction for each axis, plug in the endstops
  4. Assign appropriate ordinate values for each axis
  5. Set motor rotation directions for all three motors.

Mounting Motors and Switches

You can mount the motors either pulley-up or pulley-down or one up and one down - it doesn't matter.  You can put limit switches at either end of either axis, but you have to make appropriate assignments in the firmware and plug the switches into the appropriate inputs on the controller board. We'll get to that in a minute.


Example corexy layout, viewed from the top of the printer, that will be used to illustrate firmware configuration.  Motors are at the front of the machine, origin is at the left-front (L-F) corner, X axis endstop is at the right (bright green box), Y axis endstop is at the rear (red box).


First things first: you have to tell the controller that your printer uses a corexy mechanism.  You do that in SmoothieWare by using this line in the config file:

arm_solution corexy

In RepRap Firmware (Duet board):

         M667   S1 ;  set up corexy kinematics

Origin Location

The printer's origin (0,0,0) can be located literally anywhere but the directions of increasing ordinate values must be in the proper orientation for right-hand-rule coordinates or your prints will come out mirrored because the CAD software that designed the print used right-hand-rule coordinates. People typically set the origin up at the left-front (L-F) corner (X increases as the extruder moves to the right and Y increases as the extruder moves to the rear) or the right-rear (R-R) corner of the bed or printer (where X increases as the extruder moves left and Y increases as the extruder moves toward the front of the machine), but there are some significant advantages to setting it up at the center of the bed. Continue reading this post, and once you understand it, see the newer post, here, about setting the origin at the center of the bed.

Slicers commonly default to showing the origin at the left-front, and the jog controls in Pronterface assume a left-front origin, so you can save yourself some mental gymnastics by doing the same. There is no explicit statement in the config file that tells the controller where the origin is- its location is implied by the homing directions and endstops used.

The Z=0 position is at the level of the bed surface. Z increases as the nozzle goes up relative to the bed (the bed moves down relative to the nozzle). 

Setting "home_to" Direction for Each Axis


If the switch is at the origin end of its axis, you'll set that axis for home_to_min.  If it's at the far end, set that axis for home_to_max.  

Printer
Origin
X axis
Y axis
endstop location
alpha home-to
endstop location
beta home-to
L-F
left
min
front
min
L-F
right
max
front
min
L-F
left
min
rear
max
L-F
right
max
rear
max
R-R
left
max
front
max
R-R
right
min
front
max
R-R
left
max
rear
min
R-R
right
min
rear
min

Let's say that the origin is at the L-F and the switches are located at the right and rear.  In SmoothieWare, you'll have entries like this:

corexy_homing true
alpha_homing_direction home_to_max
beta_homing_direction home_to_max
gamma_homing_direction home_to_min
In the example above, the alpha and beta endstop switches are both located at the maximum ends of the X and Y axes, so you have to plug the endstop switches into the Xmax and Ymax endstop inputs on the controller board.  The Z endstop should plug into the Zmin endstop input, assuming you have positioned the Z limit switch at the physical top of the Z axis, at the level of the extruder nozzle.

In RepRap Firmware (Duet board) it will look like this:

          M574 X2 Y2 Z1 S1              ; Set active high endstops

X2 and Y2 define the positions of the endstops at the maximum end of the X and Y axes.  Z1 means the Z axis endstop is at the minimum end of the Z axis.  S1 sets them as active high.  The endstop switches will be plugged into the X, Y, and Z endstop inputs (there are no min and max inputs, just a single input for each axis).

Set Ordinate Values for Each Axis


Measure the length of the X axis by manually moving the extruder carriage from the far left to the far right.  Do the same for the Y axis by measuring the distance the extruder nozzle moves from the front to the back of the machine.  And, of course, measure the usable Z range of motion.

Let's say the X axis range of motion is 380 mm, the Y axis is 340 mm, and the Z axis is 400 mm.  In SmoothieWare you'll have entries like this:

alpha_min 0
alpha_max 380
beta_min 0
beta_max 340
gamma_min 0
gamma_max 400
In RepRap Firmware (Duet board) the assignments will look like this:

          M208 X0:380 Y0:340 Z0:400          ; Set axis minima:maxima

Setting Direction of Rotation


Setting direction of rotation is done either by reversing the connectors at the motors or controller board (only with power off or you may destroy the motor driver chip!), or by inverting the direction logic via the firmware.  

Here is how the mechanism works, ignoring any of the electrical stuff (rotation of the drive pulleys, viewed from above, motors at the front of the mechanism):

Left Motor
(alpha)
Right Motor
(beta)
Extruder Motion
Toward:
CW
CW
left
CW
CCW
front
CCW
CW
rear
CCW
CCW
right
CW
off
left-front
CCW
off
right-rear
off
CW
left-rear
off
CCW
right-front

Remember, when homing the mechanism, the location of the switches are important, not the location of the origin.  Homing should always send the extruder carriage toward the switches. Using the table above, just the top four entries, notice that, when homing, if the switches are at the
  • left and front, the alpha motor must turn CW.  
  • left and rear, the beta motor must turn CW.
  • right and front, the beta motor turns CCW
  • right and rear, the alpha motor turns CCW
In Smoothieware, the motor rotation direction is set by these lines in the config file:

alpha_dir_pin 0.5 
beta_dir_pin 0.11
gamma_dir_pin 0.20
We can use the table to easily set the motor rotation directions.  For example, if the switches are located at the right and rear, manually push the extruder carriage to the center of the build area, tell the controller to home all axes (G28), and watch the rotation of the alpha motor.  It should turn CCW.  If it doesn't, reverse its direction either by shutting off power and reversing the cable connection to the motor, or by appending a "!" in the config file, like this:

alpha_dir_pin 0.5!

Once the alpha motor is turning the right way, push the extruder carriage to the center of the XY space, send another home-all-axes command (G28), and watch the mechanism.  If it moves toward both switches, both motors are turning in the right directions.  If not, reverse the beta motor direction like this:
beta_dir_pin 0.11!
The Z motor should likewise move the bed toward the limit switch, normally at the level of the extruder nozzle.  If you have positioned the switch at that location, Z is homing to minimum (Z=0) and the G28 command should drive the bed upward, toward the switch.

In RepRap Firmware (Duet board), P selects the driver and S sets the rotation direction:

          M569 P0 S1          ; motor A goes forward
          M569 P1 S0          ; motor B goes backward
          M569 P2 S1          ; Z motor goes forward

Endstop wiring


If you are using simple, reliable, snap-action switches for the endstops, they can be wired either normally open (NO) or normally closed (NC).  For safety, it is best to wire them NC. That way, if a wire breaks or becomes disconnected the controller will interpret that as a switch closure and it will quickly become apparent that something is wrong.

The SmoothieBoard config file defaults to NC. If you wire any of the switch(es) NO, you have to invert their inputs in the config file.  Refer to the SmoothieWare endstop configuration documentation here.

Be sure to plug the endstop switches into the appropriate inputs on the controller board.  For example, if the Y axis endstop is at the maximum end of the Y axis, plug that endstop switch into the Ymax endstop input.

The Duet controller boards have only one endstop input per axis, and it is defined as a minimum or maximum using the M574 command as above.

Tuesday, August 1, 2017

Setting Up a 3D Printer's Origins in Firmware and Slicers

Update:  This post explains, among other thing, how to set up a printer with the origin at one corner of the bed.  I have since decided that placing the origin at the center of the bed is a better idea.  I wrote another blog post on how to do that.  I suggest you read through both posts and decide for yourself which way you prefer.



If you build your own 3D printer design, one of the confusing things about configuring its firmware is the limit switches on each axis, homing the printer, and setting up the printer description in slicing software.

One of the first things you need to do when you finish building your printer is measure its limits of motion.  Move each axis as far as it can go and physically measure how far it went.  Write down the numbers.

Three main considerations for homing and slicing:
  1. The printer's origin and limits
  2. The bed's dimensions
  3. The bed's origin

Note: if your printer is a coreXY type, I wrote a separate blog post on setting up its origin and endstops, here.

The Printer's Origin:

First principle: the home position - i.e. the place the extruder ends up when you (or the gcode) issues a home-all-axes command - is not necessarily the printer's origin.  If you read through the material below this will make sense.

Simplifying assumptions:

  • CAD software and slicing software use right-hand-rule coordinate space.  Your printer should, too, or your prints will come out mirrored. For FDM printers, that means that the printer's origin, the (0,0,0) point, must be located at the left-front or right-rear corner of the printer with the extruder nozzle at bed level.
  • The Z axis limit switch is almost always placed at the Z=0 position at the bottom of the Z axis if the extruder moves up, like in a Prusa i3, or at the top of the Z axis if the bed moves down.  For the discussion below I'll assume that the Z axis switch is located at Z=0 and we'll simply ignore the Z axis.
Right hand rule says origin must be at left-front or right-rear corner of printer.  Note- they are equivalent- one is just a rotation of the other.



Slicer's and host software have default views of the print bed that they present to the user.  Slic3r, Cura, and Pronterface all default to show the printer's origin at the left-front corner of the bed.  If you set your printer up that way, the view presented in the slicer and host will match what you see when you look at your printer.  If the printer's origin is at the right-rear of the printer, the slicer view will show the view of the bed from the back of the printer.

Setting up the printer's origin involves multiple settings in the controller's firmware.  You can control the motor rotation direction for each axis, whether the motor is to move toward maximum or minimum when executing a home instruction, and finally, the ordinate value to set for each axis after a home instruction has been executed.

3D printers typically have one limit switch on each of the 3 axes, though you can have two on each, one for minimum and one for maximum.  The Z axis limit switch is almost always set at Z=0, so we'll ignore it for now.  Everything that applies to the X and Y axes also applies to the Z axis.  For simplicity, we'll assume there's one limit switch for each axis.

Basic rules and sequence for establishing printer origin in the controller's firmware:
  1. Mount your limit switches at whichever end of each axis is most convenient
  2. Set the motor rotation direction to drive the mechanism toward the limit switches when a home command is executed.
  3. Set home to min or max depending on where you put the switches and where you want the printer's origin to be (see the table)
  4. Assign the ordinate values for X and Y after a homing instruction depending on where you want the printer's origin to be.
  5. Make sure you plug the limit switches into the appropriate inputs on the controller board. 

When the printer is ordered to home the extruder via the gcode or via a command from a host computer, the motors should drive the mechanism toward the limit switches in each axis.  If the mechanism moves away from the switches in any axis, you have to reverse that motor's direction of rotation either by changing a firmware definition or by powering down the printer and physically reversing the connector on the motor or the controller board.

Once the motors are all turning in the right directions, you can assign ordinate values.  Assuming the most common configuration in which there is one limit switch per axis, you may put the switches at either end of each axis, depending on where it is most convenient.  You might want to keep cables short, or have other specific reasons for placing switches at one end or the other.  It doesn't matter.  The Z axis limit switch is normally put at the Z=0 position and we'll assume that for the examples, below.

Here are a few examples of different set-ups to illustrate how to configure the firmware.  In all examples, we'll assume that the printer's limits of motion are 310 mm x 248 mm x 215 mm measured by jogging or manually pushing the extruder carriage, Y, and Z axis as far as they will go and measuring the distances traveled.

Consult your firmware documentation for the exact syntax required to set motor rotation direction, home to min/max, and ordinate values.

Example:  bed moves in Y, origin is at left-front of printer

If you put a limit switch at the left end of the X axis, you must plug the limit switch into the Xmin limit switch input, set the motor to move the extruder carriage toward the switch, and specify that the X axis homes to minimum in the firmware configuration, and assign an ordinate value of 0 to X after homing.

If you put a limit switch at the right end of the X axis, you must plug the switch into the Xmax limit switch input, tell the firmware to rotate the motor in the right direction- i.e. the extruder carriage should move toward the switch, and tell it to "home to max" in X, then once it has done so, assign an ordinate value of 310 mm to X.



If you put the Y axis limit switch at the back of the printer, you plug the limit switch into the Ymin input, tell the firmware to spin the motor to move the bed toward the switch, and set the Y axis as "home to min" in the configuration file, (because the switch will be activated when the extruder is near the front edge of the bed), and set Y=0 when the bed bumps the limit switch.



Example 2: bed moves in Z (extruder moves in X and Y), origin is at left-front of printer

Using the same limits of motion for the printer, and the left-front of the printer as the origin, placing the switches at the left end of the X axis and at the back of the machine for Y, will require setting firmware to "home to min" in X and "home to max" in Y, then assign ordinate values of 0 for X and 248 for Y.  The limit switches will plug into the Xmin and Ymax inputs on the controller board.

Example 3: bed moves in Z, origin is at right-rear of printer

Placing the X axis limit switch on the left side of the X axis and the Y limit switch at the front of the printer will require that both axes "home to max" and you'll assign ordinate values of 310 to X and 248 to Y.  You will plug the switches into the Xmax and Y max inputs on the controller board.

This table summarizes all the possibilities for FDM printers (using the 310 x 248 mm limits from the examples, above):

Bed
Homing Switch

Controller
Motion Printer’s Switch Location Home Ordinate Limit Switch
Axis Origin Axis on Axis to: Value Input







Y Left-Front X Left min 0 Xmin
Y Left-Front X Right max 310 Xmax
Y Left-Front Y Front max 248 Ymax
Y Left-Front Y Rear min 0 Ymin







Y Right-Rear X Left max 310 Xmax
Y Right-Rear X Right min 0 Xmin
Y Right-Rear Y Front min 0 Ymin
Y Right-Rear Y Rear max 248 Ymax







Z Left-Front X Left min 0 Xmin
Z Left-Front X Right max 310 Xmax
Z Left-Front Y Front min 0 Ymin
Z Left-Front Y Rear max 248 Ymax







Z Right-Rear X Left max 310 Xmax
Z Right-Rear X Right min 0 Xmin
Z Right-Rear Y Front max 248 Ymax
Z Right-Rear Y Rear min 0 Ymin

Slicer setup - the print bed's dimensions


Your printer's bed is all that matters to the slicer.  It doesn't know or care about the limits of the printer's motion, except as they may limit the printable area of the bed.  The slicer needs to know two things: the printable size of the bed and the bed's offset from the printer's origin.

When you enter the print bed size in the slicer, you want to enter the printable dimensions which are not necessarily the same as the physical dimensions of the bed.  If the nozzle can't go there, it can't print there, so you don't want to tell the slicer it can.  By entering the printable dimensions and the offset from the printer's origin, the slicer will be able to set prints at the center of the printable area.

In the examples below, we'll use the X and Y travel limits above (310 x 248 mm) with a bed plate that is 200 x 200 mm and is shown with the printer in the home position.


Just 4 of infinite possible variations, example A being the most common.




Example A is the most common situation where the entire bed surface is within the printer's limits of motion.  In this example, you would tell the slicer that the bed size is 200 x 200 mm.

Example B would only be printable over 180 x 175 mm, so those are the dimensions you set in the slicer.

Example C is printable over 165 x 170 mm, so those are the dimensions you set in the slicer.

Example D is printable over 200 x 180 mm, so those are the dimensions you set in the slicer.

If the bed is larger than the printer's limits of motion, you simply tell the slicer the bed dimensions are the same as the printer's limits.

Slicer setup - the print bed's origin


Slicers default to dropping the your print at the center of the print bed.  This is a good thing for several reasons.  Even if you have an unflat, unlevel, unevenly heated bed, the center is where prints are most likely to stick.  If you're printing multiple parts that are going to use a large portion of the printer's bed, having them centered makes it less likely that any of them are going to end up outside the printable area.

The slicer uses XY coordinates on the bed, and the bed's origin is normally the closest point on the bed to the printer's origin.  The bed occupies the first quadrant of the coordinate space, so the printer's origin is in the 3rd quadrant of the bed's coordinate space and the offsets are 0 or negative.  So when you enter the offset in the slicer, the values entered are normally zero or negative.

The slicer's view of the bed's origin.  The origin is left-front, but it could just as well be right-rear.

In example A, above, the printer's origin is at bed coordinates (-50, -30), so that's the offset you enter in the slicer.

Example B shows a situation with no offset, so you enter (0,0).

Example C shows an offset of (-145,-78).

Example D shows an offset in only the X axis, so the offset is (-50,0).

If you are trying to use the center of the bed for the origin, just use the appropriate offsets, and be sure to tell the slicer that the origin is at the center of the bed.  Of course, you want to specify the center of the printable area, which may not be the same as the dimensions of the bed plate.

What about Cura?


Cura is a little different.  It assumes that the home position puts the nozzle on the bed.  If that isn't true in your printer you have to play some tricks with custom gcode when you set up the printer in Cura.

When you set up the custom printer description in Cura, you tell it the size of the printable area of the bed.  In my printer, UMMD, I tell Cura that the bed is 298 x 300 x 695 mm.  The machine homes to max in both X and Y, landing at extruder nozzle at coordinates (300,330,0) as set by the controller's firmware.  The bed's origin is at (2, -27, 0).  I get Cura to place prints on the center of the bed by using custom gcode.  After homing the printer, which takes it to (300, 330, 0), I drop the bed 15 mm, then use a G92 command to set the coordinates at (300,330,15), then send the extruder to (2,27,15), then use the G92 command to reset the printer's coordinate system to (0,0,15) at that point.  Now the print will be placed in the same position that Cura set it when it was sliced.  The first G92 command ensures that the printer coordinates are correct if I run a second print after the first without resetting the controller.

Here's the start gcode for UMMD:
G28    ;Home
G0 Z15 F1200   ; drop bed 15 mm
G92 X300 Y330 Z15  ; set printer's coordinates to (300, 330, 15)
G0 X2 Y27 F12000; go to left-front corner of bed
G92 X0 Y0 Z15 ; set printer's coordinates to (0,0,15)
G92 E0   ; set extruder to 0

Summary

  • The home position is not necessarily the printer's origin.
  • Limit switches can be placed at either end of the X and Y axes.
  • The firmware needs to turn the motors to move the mechanism toward the limit switch in each axis.
  • The firmware needs to know where the origin of the printer is (left-front or right-rear corner).
  • The firmware needs to know the machine's limits of motion in each axis.
  • The slicer needs to know the printable dimensions of the bed, which are not necessarily the physical dimensions of the bed plate.
  • The slicer needs to know the offset of the printer's origin from the bed plate's origin.
  • With proper setup, the slicer will arrange prints around the center of the printable area of the bed plate.