Hi,
I have a working 4-axis coordinated control system working under linux. I'll briefly summarize the project and post more if there is interest.
The system takes simple files that list x,y,z,w coordinates in an ascii file - one coordinate per line. For example, a simple rectangular cut might look like this:
Code:
------ cut here and save as "square.path"-----
0 0 0 # scripts always start at zero point
0 0 0.1 # move tool up for clearance
-1 -1 0.1 # jump to start
-1 -1 -0.1 # cutting
-1 1 -0.1
1 1 -0.1
1 -1 -0.1
-1 -1 -0.1
-1 -1 0.1 # up for clearance
0 0 0.1 # back home
------- cut here -----------
You can then send this file to the velocity profiler program "velo" with acceleration, velocity, stepper resolution and lookahead parameters.
Code:
velo -a 10 -v .2 -n 7 -r .0001 < square.path > square.steps
velo then does a (in this case) 7 segment lookahead, coordinated trapezoidal path generation with velocity and acceleration limits and produces a step file with all the steps and timings needed for the cut.
The step file is simply a sequence of bytes. The bytes encode several commands. You can think of these bytes as kind of a compressed low-level assembly language for stepper control. The first command is the DIR command which sets the default direction for all four axes. The second is a STEP command which commands a step on any combination of the four axes. The last major command is the DELAY command which programs 1-128 delay ticks between STEP commands.
These byte codes are designed to be drip-fed by the "feed" program into a P18F4525 pic through a USB interface at 200kbaud rate. The pic saves the raw step codes in a circular fifo using a high-priority interrupt. The drip feed uses flow control so that the computer keeps the fifo fill, but can't overrun the buffer. The main routine in the pic unpacks the fifo and interprets these byte codes, expanding them into delay commands. The output of the interpreted codes go into a second fifo that gets unloaded into a parallel port at a precise 20KHz interrupt rate.
So the whole tool chain could be run in realtime like this:
Code:
velo -a 10 -v .2 -n 7 -r .0001 < square.path | feed
If you have a really slow computer, you might opt to precompute the tool path and run it from a file like
Code:
feed < square.steps
I am getting error-free coordinated control of my CNC3040 from a 5-year old HP laptop. I also have a variant of the board which talks to a sparkfun quadstepper. This works real nicely for general factory control. It is easy to write programs to generate the step file for 4 arbitrary pulley velocities, or to control syringes in chemical processes. The latency is fairly low, so the control program can monitor the process and adjust the pulse spacing in real time with a PID loop.
Conceptually, this system is just like a sound card. In a sound card, the player program streams audio samples to the card and the card manages to send them at a precise 44 KHz sampling rate. In this program, the "feed" dripfeeder sends compressed step commands to the PIC, which interprets and outputs them at a precise master clock rate. The buffers and flow control ensure that even on a multi-tasking laptop that no glitches occur in the coordinated stepper pulse output.
I also have a program "jog" which lets you use the arrow keys to move the gantry around. The "feed" program always assumes that the current gantry position is at 0,0,0,0.
I've also modified the NIST G-code interpreter to output path files. Then you can do something like:
Code:
cat step.gcode | rs274 | velo | feed
and run a gcode file. This is currently at just a hacked "proof of concept" stage, but it does work.
I have linux c code, ccsc c PIC code, schematics and PCB layouts in kicad.
I would love to know if there is any interest in this beast... It's not a GUI g-code system, but it is more flexible in some ways for scientific 4-axis coordinated stepper control. One is free to approach a job in terms of an awk or python script rather than always going to a CAD package.
The step files are also instantly plottable in any 2d ascii plotting program. I use my own program
PDPlot X11 graphing tool for viewing and my 2d hierarchical cad program
Piglet Drawing Editor for doing path generation, but most any graphing/drawing programs will work.
--
Rick Walker
[email protected]