3D-to-5D-Gcode-php

From RepRap
Revision as of 09:30, 20 July 2009 by ErikDeBruijn (talk | contribs) (Installation)
Jump to: navigation, search

3D-to-5D-Gcode.php is A GPL'd script written and maintained by Erik de Bruijn. It has many features, the primary function is to convert skeinforge's GCode to GCode that the 5D firmware understands. It adds the E-codes and removes M101, M102 and M103 codes. This free's the firmware from having to do square root calculations. The script can also manipulate GCode according to rules that you define and it can compensate for backlash in your cartesian bot.

The code for this script can be found in subversion, here (in /reprap/trunk/users/erik/). You can also use subversion to check out just my files, in the following way:

# svn co http://reprap.svn.sourceforge.net/svnroot/reprap/trunk/users/erik

Feature list

- Make 3D GCode into 5D Gcode
- Backlash compensation
- String replacement
- Rule based GCode manipulation

Feature: Backlash compensation

A picture says a thousand words...

Erik-Backlash-compensation.jpg

On the left, you see a chess pawn printed without backlash compensation. On the right, this "software" setting was turned on. Reducing backlash becomes disproportionately harder when you need to go further. You hit constraints like exceeding a healthy belt tension, running the motors with too much power, etc.

This play is not there on my X axis, because that one doesn't use microstepping and has more resonance/vibrations. My theory is that this vibration causes the XY-carriage to settle closer to where it's supposed to be, instead of lagging a bit behind when it was supposed to move.

Now, the script adds an amount of movement that you can configure per axis. It was actually easier than I thought, so it's definitely something to add to the Java host as well. You need to set up 4 numbers, backlash_X_forward, backlash_X_reverse, backlash_Y_forward, backlash_Y_reverse. I've made the unit milimeters. The compensation simply needs to know the direction in which it was moving, and add the backlash. The static friction seems to be symmetrical, but the length of the belt (that stretches slightly) connecting the pulley to the Y axis, is asymmetrical.

Anti-backlash is configured per axis, as follows:

$setting['anti-backlash'] = array(
       'X'=>array('fwd_dynamic'=>0.10/*mm*/, 'rev_dynamic'=>0.10/*mm*/,'fwd_static'=>0.1/*mm*/, 'rev_static'=>0.1/*mm*/ ), // Backlash on X-axis
       'Y'=>array('fwd_dynamic'=>0.45/*mm*/, 'rev_dynamic'=>0.45/*mm*/,'fwd_static'=>0.1/*mm*/, 'rev_static'=>0.1/*mm*/ ), // Backlash on Y-axis
);

These are the settings on my machine. Adjust experimentally.

Feature: String replacement

It can also do simple find- and replace's on Gcode lines, which I currently use to speed up the raft making (of which the base layer is slow in Skeinforge, with a reason I now learned). All of the features can be turned on or off in a configuration file or in the top section of the php script.

Feature: GCode manipulation

In the configuration header, you will find this example line:

$setting['actions'] = array(
        array('while'=>array('match','F330.0'),'actions'=>array('E_mul'=>7,'F_mul'=>0.7)), // raft making: slow down XY-moves, speed up extrusion.

Once the script finds a line matching the string F330.0, it will perform the actions on that line. There can be several actions, which are applied in that order. E_mul will multiply the E value on that line (the extrusion axis). It accepts, X, Y, Z, E and F. This example slows down XY movements while increasing the amount of extrusion in that area. This is meant to create a better raft.

In addition to a 'while' condition, start and stop conditions are possible.

Installation

On Ubuntu/Debian Linux:

$ sudo apt-get install php5-cli   # if you don't have php
$ svn co http://reprap.svn.sourceforge.net/svnroot/reprap/trunk/users/erik/3D-to-5D-G-code.php

Make it executable:

$ chmod +x 3D-to-5D-G-code.php

On windows. [Download the PHP executable].

Usage

$ ./3D-to-5D-G-code.php {input file.gcode} [--output_file output.gcode]