Sunday, 8 February 2015

RepRapFirmware config files

Unlike Marlin and most other firmwares, RepRap Firmware does not require recompilation for different printers. The changes that you would normally make to configuration.h in Marlin are now all made with gcode. At the most basic level you can type gcode commands into pronterface each time you want to setup the printer - however that would quickly get very tedious. Instead the printer configuration is set within /sys/config.g on the SD card.This tutorial will walk through the common parts of config.g for a Mendel90 style printer with dual extruders. If you have a single extruder printer then the comments will highlight what to leave out. It is assumed you are using DC42's fork of the RepRap Firmware and was written while version 1.00f was the most current version.It is helpful if you refer to the gcode page on the reprap wiki as you follow along.The order of the commands is not always strictly important however in some cases it is, for example you should define your tools before setting their offsets.

Gcode format

in general gcodes are formatted in the following manner:

[gcode_letter][number] [switch][information] [switch][information]

example

G1 X10 F3000

So its a "G" command, number "1", with the first switch being "X" with the information "10", the second switch being "F" with the information "3000". This command moves (G1) 10mm in X (X10) at 3000mm/m (F3000)

Another example is

M550 PMendel90

Where The command is an "M" command, with the switch "P" and the information "Mendel90". This sets the printer name to "Mendel90".

Name and Networking

Much of this is similar to the RepRap Ormerod at this point as it is the same for most machines:

; Configuration file for Mendel90 Example

; Think3dprint3d.com

;

M111 S0 ; Debug off

M550 PMendel90 ; Machine name (can be anything you like)

M551 Preprap ; Machine password (currently not used)

M540 PBE:EF:DE:AD:FE:ED ; MAC Address

M552 P192.168.1.14 ; IP address

M553 P255.255.255.0 ; Netmask

M554 P192.168.1.1 ; Gateway

M555 P2 ; Set output to look like Marlin

G21 ; Work in millimetres

G90 ; Send absolute coordinates...

M83 ; ...but relative extruder moves

You should set the IP address to be within the same subnet as your network, and not to an address that could be allocated to something else (eg, outside of your DHCP range). The MAC address should not be the same as one already on your network.M83 sets the extruder to relative extruder moves which is intuitive when sending gcode commands by hand to move the extruder - for example when doing calibration. Cura (and Slic3r by default) expect gcodes to be absolute, rather than relative so I add M82 to the start.gcode to ensure when printing the firmware is in absolute gcode mode.

M566 X600 Y600 Z30 E20 ; Minimum speeds mm/minuteThe Duet and Duex4 have digital control of the stepper current - this is set with M906, note the extruder parameter is delimited with a colon ":", this allows for different currents to be set of each extruder drive. This same delimitation is used for M92, allowing different extruder steps/mm to be set for each drive.M569 sets the axis direction, in this example the printer is wired up in such a manner that X and E0 move in the +'ve direction when a positive movement is send, however Y,Z and E1 move in the negative direction. To correct that the switch "S0" is used, after this command a positive movement to Y,Z or E1 will move them in a positive direction.M566 is the minimum or instantaneous speed change numbers, they are referred to as X,Y or E Jerk in Marlin. In all these cases I have used a single number for E, that sets the same for all extruders. if your extruders have different designs then you may want to set different speeds and accelerations for each one.

Define Tools

RepRap Firmware modifies the concept of a "Tool". No longer does the tool change commands "T0", "T1" etc, select an extruder drive and hotend combination that is designed into the printer with no easy way to change it, other than change the hardware. A tool now consists of any number of extruder drives, and heater combinations. The first line aboveM563 P1 D0 H1 ; Define tool 1defines a tool (number 1, "P1") that uses drive 0 (the first extruder drive, E0), and the second heater ("H1"). It is important to remember that the Heated Bed is the first heater configured in firmware, so the extruder 0 heater is H1. In a similar manner the second lineM563 P2 D1 H2 ; Define tool 2defines tool number 2 which uses the second drive (D1) and the third heater, which is the E1 heater (H2).The third tool define is where it gets interesting and shows off the potential power of this method of defining tools.M563 P3 D0:1 H1 ; Define tool 3This defines tool 3 to use both drive 0 and drive 1, but just heater 1. This sort of tool would fit a hotend like e3d's Cyclops.

Set offsets

RepRap Firmware can use G10 to set temperature and position offsets.G10 P1 S0 R0 ; Set tool 1 operating and standby temperaturesG10 P2 S0 R0 ; Set tool 2 operating and standby temperaturesG10 P2 X18 ; Set tool 2 offset on X axisThe first line sets the active and standby temperature of Tool 1 to 0, the second does the same for tool 2. The third sets the X offset to +18 for Tool 2, the second nozzle on an e3d Chimera is in line on Y but +18 on X, an alternative would be:G10 P2 X-9 ; Set tool 2 offset on X axisG10 P2 X9 ; Set tool 2 offset on X axisWhich would keep the hotends centered around 0,0 - better for a delta printer.That concludes the config.g settings required for a standard cartesian printer.

Other files within the /sys/ directory

The concept of using gcodes to perform all printer functions, rather than precompiled routines extends to homing, probing and tool changes. Also within /sys/ on the SD card are the following files as standard

homeall.ghomex.ghomey.ghomez.gtfree1.gtfree2.gtpost1.gtpost2.gtpre1.gtpre2.gHoming routines are galled in the notmal manner (G28 X for home x for example) however when that command is set, the RepRap Firmware uses the gcode within the relevant "home__.g" file to perform the homing. For example homex.g:G90 ; absolute movementG92 X0 ; set X to 0G1 X300 F6000 S1 ; move fast to a large +'ve value, stop when an endstop is hitG92 X200 ; set X to value of X maxG1 X195 F200 ; move back 5 mmG1 X205 F200 S1 ; move forward again, slowly stop when endstop hitG92 X200 ; set X to value of X maxThis routine will home quickly until the endstop is reached, the back away and home slowly until its reached again. It makes use of the addition "S1" to the G1 command which stops when an endstop is triggered. Note that our mendel90s home to Max on all axis."homeall.g" would normally be a combination of homex.g, homey.g and homez.g:G90 ; absolute movement;home XG92 X0 ; set X to 0G1 X300 F6000 S1 ; move fast to a large +'ve value, stop when an endstop is hitG92 X180 ; set X to value of X maxG1 X175 F200 ; move back 5 mmG1 X185 F200 S1 ; move forward again, slowly stop when endstop hitG92 X180 ; set X to value of X max;home YG92 Y0 ; set Y to 0G1 Y300 F6000 S1 ; move fast to a large +'ve value, stop when an endstop is hitG92 Y190 ; set Y to value of Y maxG1 Y185 F200 ; move back 5 mmG1 Y195 F200 S1 ; move forward again, slowly stop when endstop hitG92 Y190 ; set Y to value of Y maxG1 X100 F6000 ; center the X carriage before homing Z to clear the bowden tubes;home ZG92 Z0 ; set Z to 0G1 Z300 F200 S1 ; move fast to a large +'ve value, stop when an endstop is hitG92 Z200.85 ; set Z to value of Z maxG1 Z195 F200 ; move back 5 mmG1 Z205 F60 S1 ; move forward again, slowly stop when endstop hitG92 Z200.85 ; set Z to value of Z max

Note the "G1 X100 F6000 line before the Z home. This means that the X carriage will be centered before homing Z, ensuring that the bowden tubes pass easily out of the enclosure.

The "Tfree1.g" etc are called on tool change in the following way:

TfreeN.g is run when tool N is freed

TpreN.g is run before tool N is set active

TpostN.g is run after tool N is set active

so for example in Tpost1.g you may have:

M116 P1

to wait for tool 1 to get to temperature before continuing with the print.

Or you may have

G1 X10 Y10 F6000

in Tfree1.g to move the extruder outside of the object being printed before changing tools.

DC42 is working on further macros, specifically for Delta printers and probing. Examples of these can be seen here.

Web Interface Upload

You can use the web interface to upload all the modified files so changes are very quick and easy to make and save: