Content
Several programs have been set up in mods
for use as part of the most common digital fabrication techniques, including:
- Cut (vinyl)
- Cut (laser)
- Mill 2D
- Mill 2.5D
This tutorial focuses on 2D milling and demonstrates how mods
can be used end-to-end.
@TODO: Prepare tutorials for the other techniques.
PCB milling
One of the first HTMAA and Fab Academy assignments for which mods
proves very useful is making an in-circuit programmer during the Electronics Production week.
There is a set of mods
programs that aid you in the process:
- Generate toolpaths and G-code file
machines / G-code / mill 2D png
- Generate toolpaths and G-code file and send commands to a machine
machines / Roland / mill / MDX-20 / PCB png machines / Roland / mill / SRM-20 / PCB png machines / ShopBot / mill 2D png PCB
Notes:
- You could generate toolpaths only using
processes / mill / raster
, though it is not all that useful on its own. The programs mentioned above build on it and go further. - There are
svg
flavors of mostpng
programs. - The industry-standard, and recommended, format for PCB designs is
gbr
— Gerber files, instead of using image files likepng
. Make sure to learn how to generate and handle Gerber files in the Electronics Design week, keeping in mind thatmods
does not currently support importing Gerber files.
Part 1: Generate toolpaths and G-code file
In mods
, open the program (not module) machines / G-code / mill 2D png
then follow these steps, where each refers to a module requiring your input:
-
read png
This is straightforward. You can use any PNG's or use the ones for this particular exercise (download here). Just pay attention that the resolution (dpi: dots per inch) value is preserved when you upload it so as to maintain the correct dimensions for the design.
A chain of modules will then turn the image into black/white, among other steps, before vectorizing it. The output will be fed into a toolpath generator.
-
mill raster 2D
The toolpath generation algorithm will treat white as high (material is kept) and dark as low (material is milled away), and will offset paths from light to dark.
Here is an overview of the available settings:
@TODO: Add visualizations where necessary.
-
tool diameter
Values recommended for flat-end mills:
- 1/64 (0.0156) inches or 0.4 mm — for isolation (traces).
- 1/32 (0.0312) inches or 0.8 mm — for cutting edges.
-
cut depth
How much the tool mills away in the Z axis in one pass.
-
max depth
How much the tool mills away in the Z axis in total.
Should be equal to or larger than the cut depth. If they are equal, there will be only one Z axis pass in total with the depth value specified. If max depth is larger, the total number of Z axis passes will be
passes = ceiling(max/cut)
. -
offset number
How many times the tool should mill around the original traces. The higher the number, the more time the mill job will take, but the better the margin between traces will be (assuming the design allows for it).
Minimum value is 1. Recommended value is 2 to 4. A value of 0 means everything apart from the traces will be milled away.
-
offset stepover
How much the toolpath goes further away from the original traces after each round it makes around the traces, assuming the offset number is larger than 1. The stepover is expressed as a fraction of the tool diameter.
A value of 0 means the tool will go around along the same exact path each time. A value of 1 means it will go out a full tool diameter, i.e. there will in theory be no overlap between any given offset round and the one before/after it. The recommended value is something in between to balance between a nice finish (the lower the stepover, the smoother the surface finish) and time (the lower the stepover, the more time it will take to mill away the same amount of material if compared to a higher stepover). Expressed mathematically:
m = d * (1 + (n - 1) * s) given n > 0 and where: m: total distance milled away measured from edge of traces d: tool diameter n: offset number, integer greater than 0 s: offset stepover, fraction between 0 and 1
-
direction
-
path merge
@TODO: investigate
-
path order
@TODO: investigate
-
sort distance
@TODO: investigate
Once done, do NOT click
calculate
just yet. -
-
path to G-code
Settings (pay attention to the unit being mm/s):
-
cut speed
X-Y feedrate when cutting.
-
plunge speed
Z feedrate. No distinction between cutting and not cutting.
-
jog speed
X-Y feedrate when moving around without cutting (aka rapid feedrate).
@CONFIRM: This number is actually not reflected in the G-code (or does not take effect even if it was). The machine will go at a predefined rapid feedrate that is part of the machine settings and has to be changed there.
-
jog height
Z height when moving around without cutting.
Too low and it may scratch the material if it is uneven. Too high and it will travel distances further than it needs, which leads to more time. Usually 3-5 mm should be fine.
-
spindle speed
Self-explanatory.
-
tool
@TODO: investigate
-
coolant
Makes a difference only if your machine supports coolants. Otherwise, it will be ignored.
-
format
Units. Make sure you choose the correct option used in your designs and mill settings.
Feedrates in this module are not affected, as they are only in mm/s.
@TODO: Check the above and also consider moving this option somewhere more suitable.
@TODO: Check if
jog height
is affected by the unit picked here.
Now you are ready to click
calculate
to generate the paths!After a few seconds, a
.nc
file will be downloaded, which you can then load into the software that comes with the machine or a tool such as UGS (Universal Gcode Sender) to send G-code to a connected machine.Or you can use
mods
to do that. -
Part 2: Send commands to a machine
Background
It is common practice for most digital fabrication machine manufacturers to provide their own, mostly proprietary, software to operate their machines. Desktop software assumes that the machine being operated is connected to the same computer via a serial port (e.g. USB) or to the same network via Ethernet or WiFi.
For mods
to bypass/replace such software and talk to the machine directly, it has to:
-
Have a connection with the machine
Given that
mods
runs in the browser (client side), it does not by default have access to low-level hardware such as serial ports, for security reasons. One way to overcome this is to have a tiny webserver which does have access to serial ports and send messages from the client side to the server side via websockets. -
Send commands in a format the machine understands
G-code is one of the standards, but it is far from sufficient to run a machine. Here, again, most manufacturers choose to keep documentation proprietary.
Through special agreements with a set of manufacturers (@CONFIRM),
mods
has implemented interfaces for the following machines, each of which having its own module/program:- Vinyl Cutter (Roland GX-24)
- Laser Cutter (Epilog, Trotec)
- RNDMC/Honeycomb (@TODO: investigate)
- CNC mill (Roland MDX-20, Roland SRM-20, ShopBot)
Connecting to a machine
Assuming you have set up a local instance on the computer connected to the machine:
-
Open a terminal window at the root directory of the
mods
repo then navigate to thejs
directory and run the relevant webserver.cd js node printserver.js # OR node serialserver.js ::ffff:127.0.0.1 1234
@TODO: Add more details about which script is for which machine.
-
Back to
mods
in the browser, open a program that allows you to connect to the desired machine. The names of such programs typically end withconnect
.machines / Roland / mill / MDX-20 / PCB png machines / Roland / mill / SRM-20 / PCB png machines / ShopBot / mill 2D png PCB
@TODO: Add more details about which script is for which machine.
-
Open a websocket to the server
In the program you just opened, look for a module that allows you to enter an
address
and aport
. Each program may use a different module for this, but the module will typically have the wordWebSocket
in it, e.g.WebSocket print
,WebSocket device
,WebSocket serial
.Here is a list of all available settings (each module has a subset of this list):
-
address
Enter
127.0.0.1
if you are running the mainmods
server (http-server
) and the websocket server(s) on the same computer. If not, enter the IP address of the machine running the websocket server(s). -
port
Enter
1234
or whatever value you specified in the first step, i.e.node serialserver.js ::ffff:127.0.0.1 1234
-
serial device
-
Unix-based OS: something similar to
/dev/ttyUSB0
or/dev/ttyACM0
. One way to figure out which port is by runningdmesg | grep tty
. Note that sometimes you have to enter the entire name (including/dev/
) and sometimes it is taken care of for you. -
Windows: e.g.
COM3
. Use the Device Manager to figure out what port your machine is using.
-
Unix-based OS: something similar to
-
baud rate
@TODO: investigate
-
flow control
@TODO: investigate
Once done, click
Open
. Thestatus
field will showopened
, if successful, or an error message.Depending on the program, a button that says
waiting for file
will turn intosend file
when the workflow has executed and there is data to send over to the machine. -