Posted on 2 Comments

Duet WiFi/Eth – Use M584 to autolevel or sync Z-axis using 2 or more motors

I originally planned to use 3 seperate Z-motors for my BeTrue3D Printer project back last christmas, but since I’m using some special hollow Nema 17 and bespoke 1204 Ballscrews + top-fixing blocks the price would be like $100 for one extra motor on the Z-axis.

The money was just one concern. One which I could have overcome (by waiting some) if I wanted to, but it would also cause the printer to be much deeper without giving me larger printing area, and so it wouldn’t fit on my desk.. which was a primary requirment!

A rather big issue was how the RepRapFirmware at the time did not support this form for autolevel and there was no date for when it might be available.

Anyway, here’s a blog-post about it. I’ll at some later date make some youtube video to show how it works, so stay tuned! ūüôā

  1. Independent Z-Motors
  2. Is this autolevel?
    1. Autocompensation
    2. Autolevel
  3. My usage of 2x Z-motors
    1. What am I going to do here exactly?
    2. Why? Is it even needed?
    3. How is this going to work in practice?
  4. Motor remapping for dual Z
    1. Physical Drive Connection
    2. Use M584 to remap the drives
    3. Configure Drives
    4. Endstop setup
  5. Example setup for non-duex user
  6. New Homing files

1) Independent Z Motors

It all ended up with me using 2 independent Z-motors.

I started out driving both from the same Z-driver but installed a limit-switch at each motor, which would be at Z-max, and planned how to trigger them using identical screws on both sides, mounted down through a threadded m3 hole in the Z-gantry for just this purpose.

The screws can of course be turned some, if fineadjustment is needed. I used some Loctite Threadlocker¬†(open UK Ebay) to make sure it didn’t rattle loose.

2) Is this autolevel?

You might ask if this is autolevel by now, as it looks completely different than what you are used to see with a probe or sensor or similar..

Autocompensation

We normally see some sort of sensor near the hotend, which probes places around the bed and then compensate according to how uneven the printbed is.

This sort of automation is more correctly called autocompensation as it can compensate for various erros, most often just for a non-flat printbed though.

The compensation for non-flat surface is achieved by compensating for these errors by gradually, over the first xx layers flattening out the area on which it is printing. Ie, some areas are printed with a thicker layer than on others. After xx layers it can start printing normally

There are more to this, and different methods to compensate for non-square frame and axes etc, but this is beyond this blog-post

Autolevel

Autolevel on the other hand is when one or more sensors determine the posistion of the printbed and by using 2 or more motors makes it completely level compared to the XY axes.

You would want to use 3 or more motors to make most out of this Autolevel function.

A short note on using Autolevel: functions with RepRapFirmware: The M320 autolevel gcode is not currently implemented in the firmware, and seems it’s not going to be either, as the current functions G29-G32 is fullfilling the same functions more or less. Currently only Repetier firmware is making use of the M320-322 gcodes.

3) My usage of 2x Z-motors

As I talked about previously I selected to only use 2 Z-motors and the function to use these for Autolevelfunctions were recently made available in the RepRapFirmware via the¬†M584: Set drive mapping, so now I’m in business!

In all fairness, the M584 has been around for some time, but I’ve been waiting for a finished sort of system for autolevel, which, as it turns out (see note above) is not going to be implemented, so here I am!

What am I going to do here exactly?

I’m going to home my Z-axis to Z-max and make each motor make use of it’s own endstop in order to make sure each end of the Z-axis is synchronized.

Why? Is it even needed?

In my optics, yes! Asolutely. Any machine using more than 1 z-screw should have this implemented.

Problem with multiple independent z-motors, yes, and even multiple axes driven by a single belt, is that one or more of the axes might get turned a bit. It can happen if you accidentially push on the plate or turn the screw, if you happens to move the z faster than it likes and one motor or screw skips a step or belt etc.

It might also be that your axes aren’t 100% to begin with, so you need to synch them up before each print, which you can do with this method.

How is this going to work in practice?

I’m going to use 2 different drivers for my Z-motors and use the associated Endstop connectors for these drivers as well. This is accomplished by using the M584 to define virtual axes.

It means we include both Z-motors in the original Z and then make a virtual axis for one of these motors in order for them to be able to move as one, but also make use of each motors’ own limit switch in order to make sure they are synchronized.

Motor remapping for dual Z

Before we get down to using M854, we need to use the M569 to define/check our physical setup.

Physical Drive Connection

My setup/explanation:
  • Drive 0-1 as X and Y, which are standard.
  • Drive 2 as left motor, which is normal Z
  • Drive 3 as Right Z-motor, which is normal Extruder0
  • Drive 4 – Standard Extruder1 – I am not using this, as all my extruders are on Duex5
  • Drive 5-9 – My extruders on Duex5


; Define Drives
; Physical Drive connection
M569 P0 S1 ; Drive 0 X
M569 P1 S0 ; Drive 1 Y
M569 P2 S0 ; Left z-motor (original Z)
M569 P3 S0 ; Right z-motor (Ex0)
; M569 P4 S0 ; EX1 - unused
M569 P5 S1 ; Extruder0 - Physical Tool 0
M569 P6 S1 ; Extruder1 - Physical Tool 1
M569 P7 S1 ; Extruder2 - Physical Tool 2
M569 P8 S1 ; Extruder3 - Physical Tool 3
M569 P9 S1 ; Extruder4 - Physical Tool 4

Use M584 to remap the drives

To make this all work, we need to tell the controller how we have conencted our physical connectors:

How to do this:
  • We are starting the new line, which we place under our M569 section above, by issuing the M584 gcode.
  • Then simply go through and use the definitions we made above.
  • X0 – Using Driver 0 as X
  • Y1 – Using Driver 1 as Y
  • Z2:3 – This is the new part, where we define that we are using both Driver 2 and 3 for our Z. This means both are used when hitting the move Z buttons.
  • U3 – We assign driveletter U to our second Z motor, using Drive 3.
    • When using virtual drivenumbers we can’t just come up with some random letters.
    • As of firmware 1.19, we can use¬†UVWABC letters – in that order!
  • E5:6:7:8:9 – Defines how all drivers on the Duex5 are Extruders.
  • P3 – This defines the number of visible axes in our GUI, starting from the first, meaning the visible ones are: XYZ, while the 4th axis U is not shown up in the GUI.
    • You might want to have U visible at first in order to verify your new setup.

; Motor remapping for dual Z
M584 X0 Y1 Z2:3 U3 E5:6:7:8:9 P3 ; Driver 0 For X, 1 for Y, Z=2:3 U=3, Extruder 5-9

Configure Drives

Next step is to configure our machine to use 2 drivers instead of just 1 and to add the new U drive to our Drives configurations.

What you need to do now, is setup microstepping, steps/mm and all other such settings as if you have 2x Z-drives and 1x U-drive

Endstop Setup

Last item in our config.g we need to change is the Endstop configuration. Contrary to above, we do not define a second Z here (As we only have 1 z endstop), but instead just add the U endstop. It’s important that Z and U homes to same end; in this case at Z-max.

Example configuration for non-duex users

This section is a cleaned up section for all the non-duex owners, so you don’t have to sit and sort out my Duex5 config.

Just use the explanations for the Configure Drivers and Endstop Setup just above here.

Explanation:
  • Drive 0-1 as X and Y, which are standard.
  • Drive 2 as 1st Z-motor, which is normal Z
  • Drive 3 as Extruder0
  • Drive 4 as 2nd Z-motor – this is normally Extruder1


; Define Drives
; Physical Drive connection
M569 P0 S1 ; Drive 0 X
M569 P1 S0 ; Drive 1 Y
M569 P2 S0 ; 1st z-motor (original Z)
M569 P3 S0 ; Extruder0
M569 P4 S0 ; 2nd Z-motor - Normally used as Extruder 1

 

  • X0 – Using Driver 0 as X
  • Y1 – Using Driver 1 as Y
  • Z2:4 – This is the new part, where we define that we are using both Driver 2 and 4 for our Z.
    • This means both are used when hitting the move Z buttons.
  • U4 – We assign driveletter U to our second Z motor, using Drive 4.
    • When using virtual drivenumbers we can’t just come up with some random letters.
    • As of firmware 1.19, we can use¬†UVWABC letters – in that order!
  • E3 – Defines Extruder0 as our extruder.
  • P3 – This defines the number of visible axes in our GUI, starting from the first, meaning the visible ones are: XYZ, while the 4th axis U is not shown up in the GUI.
    • You might want to have U visible at first in order to verify your new setup.

And the code to copy/paste:

; Motor remapping for dual Z
M584 X0 Y1 Z2:4 U4 E3 P3 ; Driver 0 For X, 1 for Y, Z=2:4 U=4, Extruder 3

New Homing files

It’s important we remember to create new/modify our homing files to match our new setup.

In particular we need a new Homez.g and a modified Homeall.g.


And the code for easy copy/paste:

G91 ; Relative mode
M584 Z2 ; Split Z into 2 (Z+U)
G1 Z250 U250 F2000 S1 ; Move up to 250mm in the +Z direction. S1 to stop if endstop is triggered
G1 Z-2 U-2 F600 S2 ; Move 2mm in the -Z direction - (I'm not sure what S2 is for?)
G1 Z3 U3 F100 S1 ; Move slowly 3mm in the +Z direction, stopping at the homing switch
M584 Z2:4 ; Join U to Z again (pay attention to drive numbers used)
G1 Z-5 F3000 ; Move back again 5mm in the -Z direction
G90 ; Back to absolute mode

You need to update your Homeall.g files accordingly as well.

Posted on Leave a comment

BeTrue3D Printer – Setting up 5-way Diamond firmware

Wow, been a while since I last wrote… seems like I always start by writing that, hehe.

As always I’ve been through a lot of iterations of various brackets and other mechanics, but this post is going to be about setting up the RepRapFirmware for use with the 5-way Diamond Fullcolor Hotend.

I’ve been building 3D Printers some years, but this is actually my first venture into multi-color printing, which has proven a rather steep learning curve for me.

Luckily for me, I’ve had help and inspiration from the great blogpost¬†Using the Diamond Hotend with DuetWifi found on Think3DPrint3D.

Drives

First I need to setup my Drives and axes, which includes X, Y, Z and all my extruders. There’s not much to this really, once you get to know what’s going on.

The first 3 lines configures X, Y and Z, while the next 5 defines my extruder motors.

Next two lines defines microstepping and steps/mm.

; Drives
M569 P0 S1 ; Drive 0 goes forwards A
M569 P1 S1 ; Drive 1 goes forwards B
M569 P2 S0 ; Drive 2 goes forwards Z-both motor on 1 driver for now.
M569 P3 S0 ; Tool 0
M569 P4 S0 ; Tool 1
M569 P5 S0 ; Tool 2
M569 P6 S0 ; Tool 3
M569 P7 S0 ; Tool 4
M350 X16 Y16 Z16 E16:16:16:16:16 I1 ; Configure microstepping with interpolation
M92 X160 Y160 Z800 E1025:1025:1025:1025:1025 ; Set steps per mm

Heaters

While this section isn’t unique to the Diamond hotend I’m still including it, as it’s really crucial to have done the PID tuning.

As you can see, I like to comment in my config.g file in order to figure out what and how I did what I did.

Notice how the Heated Bed is using a Thermistor, where I needed to include the parameters for it, along with the PID parameters I got from the PID Tuning.

The Diamond Hotend also has PID parameters but is using a Thermocoupler instead of Thermistor, so here I’ve defined the use of the first channel on my Daughterboard.

; Heaters
; M305 Sensor P0 Bed. P1 Hotend
; M307 Heater
; Test Hotend: M303 H1 P0.3 S200
; Test Bed M303 H0 P0.1 S100
; BED
M143 H0 S140 ; set the maximum bed temperature to 140C
M307 H0 A44.1 C127.7 D3.0 S1 B0 ; Heated Bed Pid settings
M305 P0 T100000 B3950 C0 R4700 ; BED Thermistor
; Hotend
M143 S260 ; Set maximum hotend temperature to 240C
M307 H1 A1073.8 C407.8 D3.5 S1 B0 ; PID Heater - 5-way Diamond
M305 P1 X100 ; Use thermocoupler for heater P1/H1 on first channel

BLTouch

Just as a sidenote: I’ve prepared the use of BLTouch Sensor, which I wrote a seperate blogpost about.

In order to free up a PWM channel to controll it, I disabled the last heater as follows:

; Disabled heaters
M307 H7 A-1 C-1 D-1 ; Disable heater 7 for BLTouch

Tools

Now we get down to it; defining all the tools we need.

In a nutshell we need to define each Extruder + an extra, which amounts to 6 in all.

Remember the first tool is Tool 0 so we go from Tool 0-4 for the physical extruders.

What is going on here is that we define each Tool to include all 5 extruders, enable mixing and use 1 extruder as the primary extruder and the other 4 as slight additions.

It really seems odd at first, to mix everything a bit all the time, but unless the colors are moving forward some the same filament end up being retracted back and forth a lot and risk degrading and ultimately clogging up the nozzle, or at least the unused channels.

You can read a larger explanation at the blogpost¬†I mentioned previously. For me it’s just theory so far.

The final Tool has an even mixration which we can override by editing the Gcode files, to create a large variety of colors.

Note: The mixing ratios should be changed – I’m still working on perfect ratio, but the secondary should be down to like 0.005 instead of 0.025 – change primary accordingly.

; Tools
; P tool number
; D Extruder drive
; H Heater
M563 P0 D0:1:2:3:4 H1 ; Define tool 0
G10 P0 X0 Y0 Z0 ; Set tool 0 axis offsets
G10 P0 R0 S0 ; Set initial tool 0 active and standby temperatures to 0C
M568 P0 S1 ; Enable mixing for tool 0
M567 P0 E0.9:0.025:0.025:0.025:0.025 ; Set mixing ratios for tool 0

M563 P1 D0:1:2:3:4 H1 ; Define tool 1
G10 P1 X0 Y0 Z0 ; Set tool 1 axis offsets
G10 P1 R0 S0 ; Set initial tool 1 active and standby temperatures to 0C
M568 P1 S1 ; Enable mixing for tool 1
M567 P1 E0.025:0.9:0.025:0.025:0.025 ; Set mixing ratios for tool 1

M563 P2 D0:1:2:3:4 H1 ; Define tool 2
G10 P2 X0 Y0 Z0 ; Set tool 2 axis offsets
G10 P2 R0 S0 ; Set initial tool 2 active and standby temperatures to 0C
M568 P2 S1 ; Enable mixing for tool 2
M567 P2 E0.025:0.025:0.9:0.025:0.025 ; Set mixing ratios for tool 2

M563 P3 D0:1:2:3:4 H1 ; Define tool 3
G10 P3 X0 Y0 Z0 ; Set tool 3 axis offsets
G10 P3 R0 S0 ; Set initial tool 3 active and standby temperatures to 0C
M568 P3 S1 ; Enable mixing for tool 3
M567 P3 E0.025:0.025:0.025:0.9:0.025 ; Set mixing ratios for tool 3

M563 P4 D0:1:2:3:4 H1 ; Define tool 4
G10 P4 X0 Y0 Z0 ; Set tool 4 axis offsets
G10 P4 R0 S0 ; Set initial tool 4 active and standby temperatures to 0C
M568 P4 S1 ; Enable mixing for tool 4
M567 P4 E0.025:0.025:0.025:0.025:0.9 ; Set mixing ratios for tool 4

M563 P5 D0:1:2:3:4 H1 ; Define tool 5
G10 P5 X0 Y0 Z0 ; Set tool 5 axis offsets
G10 P5 R0 S0 ; Set initial tool 5 active and standby temperatures to 0C
M568 P5 S1 ; Enable mixing for tool 5
M567 P5 E0.20:0.20:0.20:0.20:0.20 ; Set mixing ratios for tool 5

Firmware Retraction

To make it work at all, we need to enable firmware retraction in our firmware and enable it in our Slizer.

I’ve put in a lot of notes here, but I’ve really only setup length and speed and of course enabled it by issuing the M207 Gcode command.

We need to enable firmware retract as all our extruders must retract at the same time instead of just the active one. If only one of the extruders are extracting, it will just suck up the filament in the melting chamber/from the other colors, but not the filament at the tip of the nozzle.

By enabling firmware retracting in firmware and in slizer, the Slizer is going to insert G10 to retract and G11 to unretract, which triggers the firmware retract option.

; Enable Firmware retraction
; https://duet3d.com/wiki/G-code#M207:_Set_retract_length
; Snnn positive length to retract, in mm
; Rnnn positive or negative additional length to un-retract, in mm
; Znnn additional zlift/hop
M207 S1.5 F3000 ;set firmware retraction

Heating and Standby temperature

Aside from the firmware settings we need to do a large deal of changes in our Slizer profile. I can’t go into all of them obviously, but one of the universal ones are defining Standby temperature in the startup gcode file using the G10 G-command.

G10 P0 S205 R205     ; Set tool 0 Active and standby temperatures
G10 P1 S205 R205     ; Set tool 1 Active and standby temperatures
G10 P2 S205 R205     ; Set tool 2 Active and standby temperatures
G10 P3 S205 R205     ; Set tool 3 Active and standby temperatures
G10 P4 S205 R205     ; Set tool 4 Active and standby temperatures
G10 P5 S205 R205     ; Set tool 5 Active and standby temperatures

Setup up Cura

Be sure to read my new blog-post to correctly setup Cura for this.

Posted on 2 Comments

Duet Wifi – Getting started

Welcome to the very first post in a long serie about the Duet Wifi controller.

This first Blog post contains:

  1. Download and install drivers
    1. Installing USB drivers
  2. Activate WiFi
    1. Download Printrun/Pronterface
    2. Activate WiFi using Pronterface
  3. Duet WiFi web interface
    1. Log on to the web interface for the first time
    2. Set WiFi to enabled automatic on startup
  4. Setup IP Address and name of controller
    1. Setup IP Address
    2. Specify a Name and password

Looking at the Duet Wifi Controller, we can see how it has a micro USB connector

A nice subtle usb cable is included with out Duet Wifi, which we’ll use to get started.

Download and install drivers

Before we do anything we head over to the Github repository cotaining the RepRapFirmware.

Here we click on Clone or download and then Download Zip.

Take the downloaded file, which is about 10MB, and extract it to a practical location.

Installing USB drivers

In order to use the Duet Wifi via USB we need to install some drivers. My windows 10 laptop actually installed some drivers on it’s own, and listed the device as generic COM port.

I didn’t test wheter communications worked ok or not, as I proceeded to install the drivers from Github.

Locate your drivers, which are located in RepRapFirmware-dev – Driver

Right-click the Duet.inf file and click Install

Now you say yes and accept any windows popping up on your screen untill it is done installing.

When finished you can see your Duet Wifi listed as Duet 3D printer control electronics in your device manager. Note the number listed after COM. In this case 3. We are going to use this in future steps.


Activate WiFi

 

Download Printrun/Pronterface

In order to activate WiFi, which we need in order to update firmware, we are going to use Printrun/Pronterface.

Note: You can use Repetier host, or any other host software you might like. I just like to use Printrun/Pronterface as it is extremely light and starts up very fast, so very usefull for faultfinding.

Click the Get it icon in the first box, or just click download in the top menu.

Now click the Windows & OSX binaries and find the newest file for Win or Mac, as fits your system. In my case I download the file Printrun-Win-Slic3r-03Feb2015.zip and unzip it somewhere practical.

You do not need to install it, and just start it by double-clicking pronterface.exe, which we do now.

Activate WiFi Using Printrun/Pronterface

  1. Plug in your USB cable to the Duet Wifi and to your computer. Do not turn on your main power source yet.
  2. Open Pronterface and check COM port. It should automatically choose the COM port available. Select manually if needed. In Baudrate you can just select the fastest option and then click Connect.
  3. In the right-hand window you can now see that your printer i Connected / Online.

    Connecting…
    Printer is now online.

  4. Optional: Use the Gcode M503 to get a read out of your config.g file. This file is located on the SD card, so a readout means success.
  5. Enable WiFi by issuing the Gcode command: M552 S1
  6. After up to 30 seconds, you get the following message:

    Now you can see the Duet Wifi access point on your computer.
  7. If you are connected to your network using network cable, you need to disconnect this before connecting to the DuetWiFi network.
  8. Now connect to the DuetWiFi network and go to 192.168.1.1 address in a browser.
    1) Select your Wlan and type in the password for the network.
    2) Specify a hostname, if you want a different name than duetwifi.
    3) Hit Save and reboot button.


  9. Don’t reboot by unplugging USB, but instead issue M552 S0 to turn off Wifi and then M552 S1 to turn it on again.
    You can see how my Duet WiFi were assigned the IP 192.168.1.19

    1. Note: If you need to check the status of the WiFi you can just issue the M522 Gcode command without parameters.
      Here we can see wifi is disabled and our IP address is 192.168.1.10 right now.
    2. Lets turn on the WiFi by issuing the M552 S1 Gcode command.
      The WiFi is now turned on and IP changed to 192.168.1.19 – IP changed as I haven’t yet defined a static IP address.
      Note: It is not possible (as of january 2017) to define a staic IP on the device. You need to assign a static IP via your router

Duet WiFi web interface

Logging on to the web interface for the first time

Now we log onto the Web GUI using the IP address assigned to our Duet WiFi

Here we can see the aweseome web gui of the Duet WiFi from where you can setup and control all aspects of the controller!

Set WiFi to enabled automatic on startup

In order to configure our WiFi to be enabled every time we power up the Duet WiFi we need to edit some config files. Instead of the “usual” way of doing it by editing files in a compiler, like Arduino IDE, and then spend a lot of time compiling and uploading it, we can edit the files directly from Web Gui and just apply the changes without any compiling taking place. Nice ehh? ūüôā

  1. Click on Settings -> System Editor and the Pencil in the config.g file row.
  2. Find the line containin ; M552 S1 and remove the ;
    A semicolon in the start of a line means it is¬†uncommented. This means the line isn’t executed. When we remove the semicolon we changed the uncommented state and enabled the line.
    Note: We can see which file we are editing in the top left corner. In this case config.g
  3. Click Save Changes when done.
  4. Go back to the General tab and click Apply Settings.

 

Setup IP address and Name

 

Setup IP Address

Setting up a static IP address using the M552 Gcode command, or any other way, is not possible with the current firmware:  Known firmware issues

Only way to fix the IP is to setup a static DHCP address in your Router, based on the MAC address of your Duet WiFi Controller.

If you setup a static IP address and do a readout, you will see something like this message, where .100 is the IP I specificed, and .19 is the actual one issued by the DHCP server in my Router.

If specifying static IP worked

When the firmware it fixed you can setup the IP by editing the config.g file, as we did above.

Then insert the following data marked up with the square.

Specify a Name and password

By editing the config.g file, as we allready did a few times above, you can change the name of your machine.

  1. Machine name is defined using the Gcode M550 Pxxxx. It is important to remember to use the P.
    1. Changing machine name is actually the Netbios name and also the name displayed at the top center of the web interface.
  2. While at it, you might also want to change the password to something only you know.
    1. Using the Gcode M551 I have changed it to mypassword – again, you need to remember to use the P for parameter.
    2. By changing the password you will now be met with a password dialogue if you want to manage your printer using the webinterface.
      This is not a high level security measure and should not be used as such. Users are going to have access to the interface but just can’t modify anything.
    3. Change password back to reprap to avoid the security popups like this: M551 Preprap
  3. Now just Save Settings and Apply Settings in the General Tab.