This is the firmware for Motöri the Plotter. It consists of basic ATmega644 I/O configuration code, low-level motor and pen control, basic linear motion algorithms and a scanner/parser that can understand a limited subset of HPGL and translate it into motor steps. Linear motion is achieved by the means of Bresenham's line algorithm.
To prevent shaking and mechanical oscillations motor speed is ramped up and down smoothly.
In my hardware the motors are very different (one from a Canon printer, other from Epson). The Y-axis motor has lower resolution, or more travel per step. This is why there are not only separate scale coefficients for X and Y axes, but X and Y maximal speeds are also different.
Since plotter is a very slow device, the communication with computer requires flow control. This implementation uses RTS/CTS flow control, although the plotter wouldn't bother if the host PC can't accept data.
- motori.h, motori.c this is the main module with I/O, main loop, interrupts etc
- line.h has the Bresenham's
- arc.h converts an arc description into a series of chords
- hpgl.h scans the input and parses commands
- usrat.h serial i/o
- shvars.h global variables shared among modules
- configs.h global defines
BSD License. Just use it. It will burn your motors though.
This documentation, source code and other files can be found at http://sensi.org/~svo