Particles – Framework for FabLabs in Lua
Status: Currently in alpha. Feel free to test and help-out with work on the source code or documentation!
Install
1. Install Lua. It is really easy and should be done on any system in just 3 minutes. Go to lua.org for download and installation instructions.
2. Pull Particles-framework. The sources can be found on github. It is located under http://www.github.com/nodepond/particles. If you are using git, just type:
git clone https://github.com/nodepond/particles.git
And you’re done. That’s all needed to start scripting your CNC directly on the machine.
Example
This is an Particles-example script. To run the script, just open the console, switch to the directory, where Particles is installed. And then type:
lua test.lua
That’s it! This generates a g-code file with .ngc extension and an .html-file, that works as a “preview” of the path that the machine will “draw”. The html-file is html5-canvas ready and should work on any modern standard web browser.
And this is the example-script:
require("particles")
particles.init("test", true)
-- jump straight into the fun!
particles.line(0, 0, 100, 100)
particles.line(0, 100, 100, 0)
particles.circleAt(50, 50, 12)
particles.setPencilDownPosition(-5)
particles.circleAt(50, 50, 12, true)
particles.setPencilDownPosition(-10)
particles.circleAt(50, 50, 8, true)
particles.circleAt(0, 0, 50, true)
particles.circleAt(0, 0, 10, true)
particles.close()
This is the html5-preview of the script. Imagine the preview like a top-down view on the machine. This is the path the machine would “draw” if looked upside down. You currently can’t see the changes on the z-axis at this preview.

This is the generated G-Code:
G40 (disable tool radius compensation)
G49 (disable_tool_length_compensation)
G80 (cancel_modal_motion)
G54 (select_coordinate_system_1)
G90 (Absolute distance mode)
G21 (metric)
G61 (exact path mode)
F1200
G1 z30
G1 x0 y0
G1 z0
G1 x100 y100
G1 z30
G1 x0 y100
G1 z0
G1 x100 y0
G1 z30
G1 x50 y38
G1 z0
G2 J12
G1 z30
G1 x50 y38
G1 z-5
G3 J12
G1 z30
G1 x50 y42
G1 z-10
G3 J8
G1 z30
G1 x0 y-50
G1 z-10
G3 J50
G1 z30
G1 x0 y-10
G1 z-10
G3 J10
M2
Particles Design Goals
Here are some thoughts about the approach and the design-goals of Particles. Still very work in progress, but maybe important to understand the project better.
- Make the framework-core most minimal in its design in order to easily apply it to new areas of operation (i.e. gcode, html5, postscript etc…).
- Make the library itself easy to extend.
- Let the project allow to evolve.
- Try to enable work directly on the machines – try to cut down toolchains as much as possible.
- Try to add complexity to the framework, but not to the wrapper class (see 1., right now only lines and circles are supported).
- Why lua? Lua is open source, easy to add upon, well documentated and simply compiles and runs on every possible piece of technology: from PC / Mac to even iOS, Android and Arduino!
F.A.Q.
Q: I have problems installing lua on Ubuntu/Linux. Stuff like “can’t find assert.h, math.h and string.h”. What can I do?
A: It seems that you need to fresh up your packages on Ubuntu. Refer to this thread: http://ubuntuforums.org/showthread.php?t=719141
This project originated and is heavily supported by the Dingfabrik FabLab Cologne.