On 10 February, 2014 Sebastian Kuzminsky wrote:
> As an alternate to your system design, try to make Mathematica write the
> gcode out to a file, and then use 'axis-remote newfile.ngc'. That avoids the
> multi-gui problem, while still maintaining the "give axis new gcode from an
> external program" pattern.
>
Thank you for this suggestion. The "axis-remote" python script imports ngc
files in Axis and updates the display exactly as advertised when run on the
linuxcnc host, or a remote Ubuntu machine via ssh -X . Not sure why but when
run remotely from a Mac OS X machine I found that the DISPLAY environment
variable must be set, as you can see in the commands that follow. These
commands build a tool path with the latest Mathematica, secure copy the ngc
file to the linuxcnc host, start linuxcnc on the remote machine with an ini
file, then use axis-remote to load the file, after a pause to let linuxcnc get
installed. SSH has been set up with an empty password. Apologies for long post
- rest is only of interest to Mathematica users.
WriteModel::usage =
"WriteModel[data,opts] writes a text file in NGC format of a tool \
path. The output file
name is given by the option OutputFileName. The options include \
Prolog, and Epilog which specify strings to place at the start and \
end of the file. The path data is a list of coordinates
of the cutter datum. Here is an example:
WriteModel[path,Prolog->\"G90 G21 G1 F200 S1 M3\",Epilog->\"M5 M2\
\"]";
StartLocation::usage =
"StartLocation is an Option of WriteModel which specifies a list of \
one or more initial positions of the cutter datum before the first \
point of the path. Use to safely start at the home location, move \
above the work piece, and move to the initial cutter location.";
StopLocation::usage =
"StopLocation is an Option of WriteModel which specifies a list of \
one or more final positions of the datum after the last point of the \
path. Use to safely park the cutter above the work piece.";
Options[WriteModel] = {Epilog -> "", Prolog -> "",
OutputFileName -> "part.ngc",
StartLocation -> {}, StopLocation -> {}};
WriteModel[indata_List, opts___] :=
Module[{out, data, prolog, epilog, file, start}, (
{prolog, epilog, file, start,
stop} = {Prolog, Epilog, OutputFileName, StartLocation,
StopLocation} /. Flatten[{opts}] /. Options[WriteModel];
data = Partition[Flatten[Join[{start}, indata, {stop}]], 3];
out = StringJoin["%\n" <> prolog <> "\n", Map[Apply[Sequence, {
"X " <> ToString[
NumberForm[Chop[#[[1]], 10^-4], {5, 3}]] <>
" Y " <> ToString[
NumberForm[Chop[#[[2]], 10^-4], {5, 3}]] <>
" Z " <>
ToString[NumberForm[Chop[#[[3]], 10^-4], {5, 3}]] <>
"\n"}] &, data], epilog <> "M2\n%\n"];
Export[file, out, "Text"])]
(* build a demo tool path - a circle with wiggles *)
pts = Table[(100 + 20 Sin[7 t] ) {Cos[t], Sin[t], 0}, {t, 0,
2 Pi, .02 Pi}] ;
outfile =
WriteModel[pts,
Prolog -> "G90 G21 G1 F450 S100 M3",
StartLocation -> {{0, 0, 0}, {0, 0, 10}, {0, 0, 10} + First[pts]},
StopLocation -> {{0, 0, 10} + Last[pts], {0, 0,
10}}]; (* build the ngc file *)
host = "192.168.3.10"; (* the linuxcnc host *)
Run["scp " <> outfile <> " " <> host <>
":"]; (* transfer the file to the linuxcnc host, users top directory *)
StartProcess[{"ssh", host, "DISPLAY=:0;export DISPLAY;",
"/usr/bin/linuxcnc \
~/linuxcnc/configs/Replicator3Axis/Replicator3Axis.ini"}]; (* start linuxcnc on
remote host with my .ini file *)
Pause[4.0];(* with INTRO-TIME =0 in the .ini file, still must wait until
linuxcnc ready *)
StartProcess[{"ssh", host, "DISPLAY=:0;export DISPLAY;",
"axis-remote", outfile}]; (* load the ngc file into Axis *)
[email protected]
Dartmouth, NS
------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience. Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users