A small Python application for using an FLSUN Q5 as an XY pen plotter.
Instead of a normal print head, the printer carries a pen. The application converts SVG vector artwork into Marlin-compatible G-code, previews the result on a postcard-sized work area, and can send the plot directly to the printer over USB.
The default target is an A6 / postcard-sized sheet: 148 × 105 mm.
- SVG → Marlin G-code conversion
- Direct USB connection to the FLSUN Q5
- Postcard preview and automatic fit/centering
- Configurable paper size and machine-coordinate center
- 0°, 90°, 180° and 270° rotation
- Configurable drawing margin
- Configurable pen-up and pen-down Z heights
- Dedicated Z calibration interface
- 10 / 1 / 0.1 / 0.05 mm Z jogging
- 10 mm test-line function
- Pen-up-only postcard frame check
- Dry-run mode
- Emergency stop using
M112 - Repeated postcard workflow with Plot Again
- Persistent calibration/settings
- Command-line SVG → G-code conversion
- Python 3
- Tkinter
pyserialfor direct USB printer control- FLSUN Q5 or another Marlin-compatible printer configured as a pen plotter
If Tkinter is not available:
brew install [email protected]Verify it with:
python3 -m tkinterA small Tk window should appear.
Create a virtual environment from the project root:
python3 -m venv .venv
source .venv/bin/activateInstall the Python dependency:
python -m pip install -r src/requirements.txtFor an editable application install with the flsun-q5-plotter command:
python -m pip install -e .Then start the application:
python src/flsun_q5_svg_plotter.pyor, after the editable install:
flsun-q5-plotterConnect the FLSUN Q5 to the laptop using USB.
Click Connect & Home to connect, verify the printer, home it, and read its position. Use the adjacent dropdown's Connect option to connect without motion; homing is then available from the calibration tab.
Open the Printer / Z Calibration tab and select the printer serial port. On macOS it will normally look similar to:
/dev/cu.usbserial-...
/dev/cu.wchusbserial-...
The GUI supports the common Marlin baud rates:
115200
250000
Start with the baud rate already configured for the printer.
Opening a serial connection can reset some printer controller boards. For this reason, the application considers the printer unhomed after every new USB connection.
Always home the printer again before jogging or plotting.
Do not assume Z=0 is the correct drawing height.
The original Q5 nozzle and the replacement pen do not necessarily have the same physical tip height. The correct pen-down position must therefore be calibrated.
Use a scrap postcard or sheet of paper for the first calibration.
- Connect the printer over USB.
- Open Printer / Z Calibration.
- Remove the pen and click Home and Read Position. Wait for completion.
- Put a postcard in the jig.
- Adjust the empty holder height with the Up / Down buttons:
10,1,0.1, or0.05 mm. - Insert and secure the pen so its tip touches the paper.
- Click Read Position and Set PEN DOWN. This queries the printer again rather than using the last displayed position.
- Pen Up is set automatically above Pen Down using the clearance (default
3 mm). - Run Test 10 mm Line and adjust the heights if needed.
- Click Save Calibration / Settings.
Position reads wait for pending movement to finish. Homing and movement completion allow
five minutes of silence; firmware busy: replies extend the wait up to a 30-minute cap.
Position reports reflect firmware-tracked coordinates. If an axis is physically pushed
or slips, the printer may not detect the change; remove the pen, home, and repeat calibration.
For example:
First paper contact: Z = 4.20 mm
Pen Down: Z = 4.10 mm
Pen Up: Z = 7.10 mm
With a spring-loaded pen holder, a small amount of compression can improve line consistency. With a rigid pen holder, stay very close to the first-contact height.
The calibration GUI intentionally refuses to jog below Z=0.
Settings are stored automatically in:
~/.flsun_q5_penplotter.json
This includes the pen calibration, postcard dimensions, placement, serial settings and motion settings.
Save Pen Up Home stores the current Pen Up Z for the X0 Y0 start position. The saved height is restored when the application opens and used when generating plots. Capturing pen heights or applying pen-up clearance also saves immediately. Settings are saved on normal exit, and file updates replace the previous settings only after the new file has been written. Connection/homing state is never restored from storage; each USB connection starts unhomed until homing succeeds.
As long as the pen, pen holder and postcard jig do not move mechanically, the saved Z values can be reused for multiple postcards.
Recalibrate after changing the pen, holder, bed/jig position or anything that changes the pen-tip height.
After calibration:
- Open the SVG / Plot tab.
- Click Open SVG…
- Check the preview.
- Select the required rotation.
- Adjust scale, margin or offsets if necessary.
- Run Frame Check (pen up).
- Verify that the pen travels around the expected postcard area without touching the paper.
- Click Plot SVG to Printer.
- Wait until the plot completes and the pen is raised.
- Remove the finished postcard.
- Insert the next postcard into the jig.
- Click Plot Again.
The application does not automatically start the next postcard. This is intentional so the printer stays stationary while the postcard is being replaced.
The paper is positioned using its machine-coordinate center, which is useful for the circular build area of a delta printer such as the FLSUN Q5.
For example:
+Y
^
|
+-------------+
| |
| X,Y |
| center |
| |
+-------------+
|
+------------> +X
The default paper size is:
Width: 148 mm
Height: 105 mm
The physical postcard jig should place every postcard at the same machine-coordinate center. Once the jig is fixed, postcards can be swapped without recalculating the artwork position.
Frame Check (pen up) moves around the outer postcard boundary while keeping the pen raised.
Use it before the first real plot after:
- repositioning the jig
- changing postcard size
- modifying the paper center
- changing offsets
- reconnecting or reconfiguring the machine
It is a quick way to check that the software coordinate system matches the physical postcard position.
The FLSUN Q5 is a delta printer and therefore does not have a simple rectangular XY build area.
The GUI uses a configurable XY safe radius, defaulting to:
95 mm
Before sending a plot, every drawing point is checked against this radius.
If the drawing exceeds the configured radius, plotting is refused.
Only increase this value after confirming the usable XY range of the actual machine and pen mount.
Supported SVG geometry:
pathlinepolylinepolygonrectcircleellipse
Supported path commands:
M L H V C S Q T A Z
Common SVG transform attributes are also supported.
The application is intended for vector line plotting.
Currently:
- filled objects are plotted as outlines
- fills are not automatically hatched
- SVG text should be converted to paths first
- raster/embedded images are not vectorized
- clipping paths and masks are not fully expanded
<use>references are not expanded- complex CSS-defined SVG geometry may not be interpreted
For reliable results, prepare artwork as simple vector paths before importing it.
Generated output uses standard Marlin-style commands such as:
G21 ; millimeters
G90 ; absolute positioning
G1 Z7.100 ; pen up
G0 X0 Y0 ; pen up home (start position)
G0 X10 Y20 ; travel
G1 Z4.100 ; pen down
G1 X30 Y20 ; draw
G1 Z7.100 ; pen upThe actual Z values come from the saved calibration.
Each plot starts at pen up home: X0 Y0 at the configured Pen Up Z,
raising the pen before moving in XY. This position is independent of the paper
center and drawing offsets. Home the printer once after connecting, before
starting plots. Per-plot G28 homing is disabled by default; it remains available
through Home with G28 before each plot or CLI --home. If an existing saved
configuration has that checkbox enabled, uncheck it to use pen up home without G28.
Enable:
Dry run: never lower the pen
to generate/send the complete XY movement while keeping the pen raised.
Use a dry run when testing:
- a new jig
- new paper dimensions
- a new SVG
- changed center coordinates
- unfamiliar offsets or rotation
The GUI contains an EMERGENCY STOP button.
It sends:
M112to Marlin.
After an emergency stop, reset/reconnect the printer and home it again before continuing.
Do not rely on software alone for physical safety. Keep access to the printer's power switch during calibration and initial testing.
The script can also convert an SVG directly to G-code without opening the GUI.
Example:
python src/flsun_q5_svg_plotter.py drawing.svgAfter an editable install, the package entry point is equivalent:
python -m flsun_q5_plotter drawing.svgThis writes:
drawing.gcode
Specify an output file:
python src/flsun_q5_svg_plotter.py drawing.svg -o postcard.gcodeExample with custom postcard placement and calibrated Z values:
python src/flsun_q5_svg_plotter.py drawing.svg \
--paper-width 148 \
--paper-height 105 \
--center-x 0 \
--center-y 0 \
--margin 5 \
--rotation 0 \
--pen-up-z 7.1 \
--pen-down-z 4.1 \
--draw-feed 1800 \
--travel-feed 4000Available command-line options:
--paper-width
--paper-height
--center-x
--center-y
--margin
--rotation {0,90,180,270}
--no-flip-y
--scale
--offset-x
--offset-y
--pen-up-z
--pen-down-z
--draw-feed
--travel-feed
--z-feed
--home
--no-home
--no-return-center
--dry-run
Show the complete CLI help:
python src/flsun_q5_svg_plotter.py --helpor:
python -m flsun_q5_plotter --helpBefore plotting a real postcard:
- Use scrap paper.
- Calibrate Z.
- Save calibration.
- Load a very small SVG.
- Run Frame Check.
- Run a Dry Run.
- Disable Dry Run.
- Plot at a conservative speed.
- Check pen pressure and line quality.
- Only then move on to repeated postcard plotting.
This software directly controls physical machine movement.
Before using it:
- make sure the pen mount is mechanically secure
- make sure the postcard/jig cannot move
- home the printer after connecting
- start Z calibration well above the paper
- lower Z progressively
- never assume a previous calibration is still correct after mechanical changes
- use Frame Check and Dry Run when changing placement
- keep hands clear while the machine is moving
- keep the printer's power switch accessible
The pen should be raised before inserting or removing postcards.