|
|
66ba5e |
|
|
|
66ba5e |
simu - is the program for generation and simulation gcode (track) files for CNC
|
|
|
66ba5e |
|
|
|
66ba5e |
simu - is the public domain
|
|
|
66ba5e |
|
|
|
66ba5e |
|
|
|
66ba5e |
currently implemented only 4-axis milling (rotate model around X axis)
|
|
|
66ba5e |
simulator simulates all four axes, but generator uses only three: X, Z and Angle
|
|
|
66ba5e |
|
|
|
66ba5e |
in the world exists a lot of opensource XYZ generators but XZA is the rare,
|
|
|
66ba5e |
so i implement it first for my CNC
|
|
|
66ba5e |
|
|
|
66ba5e |
i hope it will easy to implement classic XYZ miling (basreliefs), can you?
|
|
|
66ba5e |
|
|
|
66ba5e |
|
|
|
66ba5e |
requirements:
|
|
|
66ba5e |
SDL2
|
|
|
66ba5e |
|
|
|
66ba5e |
build:
|
|
|
66ba5e |
just run build.sh
|
|
|
66ba5e |
executable file is ./simu
|
|
|
66ba5e |
|
|
|
66ba5e |
if you want to build it for windows (i have not tried)
|
|
|
66ba5e |
you need to compile and link all *.cpp files in current folder
|
|
|
66ba5e |
and link libSDL2
|
|
|
66ba5e |
|
|
|
66ba5e |
run:
|
|
|
66ba5e |
./simu <file-to-simulate.tap|.> [<model.stl|.> [output-generated-file.tap|.]]</model.stl|.></file-to-simulate.tap|.>
|
|
|
66ba5e |
|
|
|
66ba5e |
in other words first argument is always filename of input gcode for simulation,
|
|
|
66ba5e |
if you does not need this just set the dot as first arg
|
|
|
66ba5e |
|
|
|
66ba5e |
second argument is always input model in binary STL format,
|
|
|
66ba5e |
you may set the dot to do not load model
|
|
|
66ba5e |
|
|
|
66ba5e |
third argument is always filename for output gcode,
|
|
|
66ba5e |
you may set the dot too
|
|
|
66ba5e |
|
|
|
66ba5e |
|
|
|
66ba5e |
you cannot generate something without a model
|
|
|
66ba5e |
you cannot generate something if you use simulaton arg
|
|
|
66ba5e |
|
|
|
66ba5e |
examples:
|
|
|
66ba5e |
simulate already generated gcode:
|
|
|
66ba5e |
./simu file.tap
|
|
|
66ba5e |
|
|
|
66ba5e |
simulate already generated gcode and show the target model:
|
|
|
66ba5e |
./simu file.tap model.stl
|
|
|
66ba5e |
|
|
|
66ba5e |
just show the model:
|
|
|
66ba5e |
./simu . model.stl
|
|
|
66ba5e |
in this mode you can move the tool by W, S, A, D keys
|
|
|
66ba5e |
to check how collision detection works
|
|
|
66ba5e |
|
|
|
66ba5e |
generate gcode from model:
|
|
|
66ba5e |
./simu . model.stl newfile.tap
|
|
|
66ba5e |
|
|
|
66ba5e |
|
|
|
66ba5e |
in all modes use the left mouse button to rotate camera,
|
|
|
66ba5e |
right button to zoom and middle button to translate
|
|
|
66ba5e |
|
|
|
66ba5e |
options:
|
|
|
66ba5e |
- looks easy but where the other options - cutter shape, strateg, layers etc?
|
|
|
66ba5e |
- in the code
|
|
|
66ba5e |
|
|
|
66ba5e |
first look function main() in main.cpp
|
|
|
66ba5e |
this line sets the simulatior options:
|
|
|
66ba5e |
SimulatorXYZA simulator_xyza(400, 360);
|
|
|
66ba5e |
- simulatior is XYZA with resolution along X axis is 400 samples,
|
|
|
66ba5e |
angular resolution is 360 samples per round
|
|
|
66ba5e |
see: simulator.h, simulator.cpp
|
|
|
66ba5e |
|
|
|
66ba5e |
these lines configure a tool:
|
|
|
66ba5e |
//FlatTool tool(1.5);
|
|
|
66ba5e |
ConeTool tool(1.25, 10, 0.75);
|
|
|
66ba5e |
- base radius, height of cone part, small radius at the end of cone (can be zero)
|
|
|
66ba5e |
see: tool.h, tool.cpp
|
|
|
66ba5e |
|
|
|
66ba5e |
direction of the tool for testing:
|
|
|
66ba5e |
Vector3 dir(1, 3, -3);
|
|
|
66ba5e |
- when you pass only model as argument (./simu . model.stl)
|
|
|
66ba5e |
you can move the tool manually (by WSAD) and see how collision detector works
|
|
|
66ba5e |
this line determines direction (angle) of the tool
|
|
|
66ba5e |
|
|
|
66ba5e |
look down in parsing third arg there is lines to configure generator:
|
|
|
66ba5e |
GeneratorRowsZAX generator;
|
|
|
66ba5e |
//generator.step_z = 1.5;
|
|
|
66ba5e |
generator.step_z = 0;
|
|
|
66ba5e |
//generator.step_a = 2*tool.radius*0.5;
|
|
|
66ba5e |
generator.step_a = 0.5*1.5;
|
|
|
66ba5e |
generator.step_x = 0.5;
|
|
|
66ba5e |
//generator.skip_middle_layers = true;
|
|
|
66ba5e |
generator.feed_speed = 150;
|
|
|
66ba5e |
|
|
|
66ba5e |
generator supports layered milling (output/example-tux-p1.tap)
|
|
|
66ba5e |
|
|
|
66ba5e |
step_z, mm - determines a maximum height of layer (zero for no layers, output/example-tux-p3.tap)
|
|
|
66ba5e |
step_a, mm - step along rotation in millimeters! generator will calculate degrees
|
|
|
66ba5e |
|
|
|
66ba5e |
combination of step_z and skip_middle_layers helps to optimize final processing
|
|
|
66ba5e |
model splits to several layers (layer heigth is near to step_z) and for each layer determines an angular step
|
|
|
66ba5e |
for points near to axis of rotation angular step is bigger than for that points far from axis
|
|
|
66ba5e |
(output/example-tux-p2.tap)
|
|
|
66ba5e |
|
|
|
66ba5e |
- see: generator.h, generator.cpp
|
|
|
66ba5e |
|
|
|
66ba5e |
|
|
|
66ba5e |
also look constructor Scene::Scene() in scene.cpp
|
|
|
66ba5e |
here you can set:
|
|
|
66ba5e |
time_forward, seconds - draw path to the future for some seconds while path animation
|
|
|
66ba5e |
time_backward, seconds - draw path to the past for some seconds while path animation
|
|
|
66ba5e |
time_speed, positive float - amplifier of animation speed (10 - is 10x time speed)
|
|
|
66ba5e |
move_tool, bool - move or do not move the tool while animation
|
|
|
66ba5e |
rotate_model, bool - rotate or do not rotate the model while animation
|
|
|
66ba5e |
|
|
|
66ba5e |
example files:
|
|
|
66ba5e |
models:
|
|
|
66ba5e |
input/example-pyramid.stl - simple shapes
|
|
|
66ba5e |
input/example-triangle.stl - single triangle
|
|
|
66ba5e |
input/example-tux-small.stl - Tux model
|
|
|
66ba5e |
gcode:
|
|
|
66ba5e |
output/example-tux-p1.tap - preprocessing of tux-small.stl for FlatTool(1.5)
|
|
|
66ba5e |
output/example-tux-p2.tap - optimized final processing of tux-small.stl for ConeTool(1.25, 10, 0.75)
|
|
|
66ba5e |
output/example-tux-p3.tap - final processing of tux-small.stl for ConeTool(1.25, 10, 0.75)
|
|
|
66ba5e |
|