Firmware/FiveD on Arduino

From RepRap
Revision as of 15:17, 5 October 2010 by Traumflug (talk | contribs) (Point to the newer page.)
Jump to: navigation, search
This page has been flagged as containing duplicate material that FiveD on Arduino also attempts to cover.
These pages should be merged such that both pages do not attempt to cover the duplicate topics.

FiveD on Arduino is a complete rewrite of the FiveD firmware by Triffid Hunter, which happens to fit into an ATmega168-based board, i.e. the Arduino Diecimila, just as well as into bigger sized controllers. It's main advantage is better performance.

This firmware is loosely based on the official FiveD Firmware, however it avoids C++ in favour of plain C, uses 100% integer math, and works very hard to minimize/eliminate long math operations in interrupt context.

Constant Acceleration

The official FiveD firmware changes speed by a fixed amount each step, however this also alters the step time. acceleration = dv/dt, so with a fixed dv but a changing dt, acceleration changes during a move. This makes high speeds quite unattainable as the acceleration quickly outstrips the motor's ability to keep up.

FiveD on Arduino contains a constant acceleration implementation.

Acceleration, RepRap Style

This is the default and matches the strategy of the official firmware. Each movement starts at the speed of the previous command and accelerates or decelerates to reach target speed at the end of the movement.

Goal of this strategy is to allow calculation of smooth movements in the host software. If communication between host and controller gets delayed, hard stops and starts are to be expected. This strategy isn't useful for commands issued by hand, either.

You can disable this behaviour in machine.h by commenting out

#define ACCELERATION_REPRAP

Acceleration, Start/Stop Ramping

This variation guarantees always smooth starts and stops, as all acceleration and deceleration is calculated in firmware (and actually uses less code than the above). Each movement starts at (almost) no speed, linearly accelerates to target speed and decelerates just in time to smoothly stop at the target. The steepness of acceleration and deceleration is configurable.

A drawback of the current implementation is, it stops after each move. This means slow average speeds in case of many short moves. It'll be possible to improve this situation by taking the next move into account when ramping down. A not-so-trivial task though, predestined for a hacking week sometimes in the future.

Please note real-world machines in fact can't gain full speed instantly. Trying to do so results in bending and early wear out of the mechanical parts. Also, if acceleration is reliable, you can approximately double the speed of stepper motors without risking loss of steps. In tests with my setup I got over 1000 rpm with an ordinary NEMA-23 stepper!

As most current GCode generators expect RepRap-style acceleration and you can use only one style of acceleration, this feature is turned off by default. To use it, turn off ACCELERATION_REPRAP in machine.h and turn on:

#define ACCELERATION_RAMPING

This is enough for first tests (always recompile and re-upload the firmware, btw.), but to get best results, you should adjust ramping steppness as well:

#define ACCELERATION_STEEPNESS	500000

Smaller values give quicker acceleration. Tune it to what you think your machine can achieve. Sturdier machines with powerful motors can accelerate quick, weak machines with light motors need a bigger value.

Transmission of Multiple Commands

FiveD on Arduino has the capability to receive additional commands while working on the first one. This avoids short stops between commands and will allow for even more smooth transitions from one movement to the next in the future.

XON/XOFF Flow Control

FiveD on Arduino has XON/XOFF flow control implemented. This is not needed when sending GCode files via RepRap Host software, but quite helpful when sending files with a serial terminal emulator (GtkTerm, CoolTerm, HyperTerminal, etc.).

This feature is off by default, turn it on in machine.h by uncommenting

#define XONXOFF

Patches, Enhancements

If you have a change or a patch you want to discuss, or if you don't have github commit access, please upload the patch here.

To apply patches, type git apply in your terminal, inside your local copy of git repo, then copy the text given here into the terminal and hit ctrl-d. Well, I think it works that way.

If you work with git on FiveD on Arduino, please do commits in small pieces, one topic/bug at a time. This helps a lot in reviewing patches. That done, you can create a set of patches easily:

git format-patch --keep-subject -o out origin

You'll find each of your patches in the out/ directory, nicely equipped with a mail header and a proper file name.