Mattroberts' Firmware
Release status: Beta
Description | Firmware
|
License | |
Author | |
Contributors | |
Based-on | |
Categories | |
CAD Models | |
External Link |
Contents
Introduction
This code describes my firmware. My intention is simply to document (with working code) the various tricks that I think I've done first (or best).
Download
The license for the firmware is CC-by-3.0. And it can be downloaded from this link...
In order to compile it, you'll also need to install two supporting libraries (MIT licenced)...
What File Does What?
- config.h contains the description of the printer (in terms of steps/mm, maximum feedrate, baud rate to use, etc.)
- parse.c contains the gcode parser
- cmd.c contains the command interpretor
- dda.c contains the line drawing algorithm
- divide.c, log.c, dist.c contain supporting functions for dda.c
- hw/ contains the real implementation of all the various things that the hardware does. All the AVR specific code is here.
- hw/pins.h contains a description of the motherboard (which pin drives what thing)
- sim.c contains a simple implementation of all the hardware functions. This allows one to test a firmware before uploading to a printer.
- host.c contains a simple terminal program that can send gcode files to the printer.
Pressure Management
The unique feature of this firmware is the pressure management code. This code is contained in dda.c.
The basic idea is to model the extruder as a spring driving an incompressible fluid through the nozzle. This means that one can calculate the displacement to apply to the spring to achieve the desire flow rate. In the code: this displacement is called advance, is meassured in steps and added to E axis position.
The mathematics behind the calculation is described in config.h, repeated below:
// extruder advance constant (s2/mm3) // // advance (steps) = STEPS_PER_CUBIC_MM_E * EXTRUDER_ADVANCE_K * cubic mm per second ^ 2 // // model the extruder as a spring followed by an incompressible fluid... // hooke's law says: force = k * distance // bernoulli's priniciple says: v ^ 2 / 2 + g . h + pressure / density = constant // ...so: v ^ 2 is proportional to number of steps we 'advance' the extruder #define EXTRUDER_ADVANCE_K 0.010
The value of EXTRUDER_ADVANCE_K can be set by using the M200 command. For example:
M200 S0.015
Supported G and M codes
(look in cmd.c)
- G00, G01 - linear move to specified position (feedrate is interpreted as maximum allowed speed)
- G04 - dwell
- G20, G21 - set units to inches/mm
- G90, G91 - switch to absolute/relative positioning
- G92 - set current position
- M101, M103 - turn on/off auto-extruding. When auto-extruding is enabled, any move command (G0 or G1) without an E parameter is assumes to have an E parameter that will move the E axis by the distance of the movement in the X, Y and Z axes.
- M100 set area for E axis.
- M200 set EXTRUDER_ADVANCE_K
- M104 - set extruder temperature
- M109, M140 - set heated bed target temperature
- M105 - report temperatures
- M6, M116 - wait for temperatures to be reached
- M106, M107 - switch fan on/off
- M126, M127 - open/close the valve
- M112 - emergency stop