7266
« on: December 31, 2016, 11:26:29 PM »
Hi tapio,
my CE scripting is very poor, I've changed to Mach4 recently and am starting to gain some fluency in LUA.
A broad sketch:
1) your gcode job would look something like this
G0 X0 Y0 Z0 A0 --your initial setup moves
.... -- "
.... -- "
M150 -- this is your macro which is going to do the majority of the work, M150 is just a random name, any unused
-- macro number could be chosen, recommend 100 or greater but less than 200 as there are some useful
-- macros that ship with Mach3 starting at M200, would be a shame to overwrite them.
G0 X0 Y0 Z0 A0 -- your final 'parking' moves
M30 -- end of job
2) M150 -- your macro
inputvalue=getOEMDRO(nnn) -- where nnn is the DRO number of your single bit input, will need to re-read the documentation
-- to find nnn
if inputvalue then
code ("G1 X5 Y2 A0 F20") -- an example of the first move instruction to pick up a red ball
code (".......") -- second move
code (".......") -- third move and so on...
else
code("G1 X.....") -- first move instruction to pickup a non red ball
code(".......") -- second move and so on..
end
As you can see really the macro only reads your single bit input and the does one bunch of moves or another bunch
depending on the value of the bit. A statement like:
code("G1 X0.....F30") is simply a way of executing G code lines from within a macro.
One thing to be aware of is that a move say code("X5.5") will cause the x axis to move but while that is happening the
CE interpreter will already be reading subsequent lines of code and queue the moves up. Mostly that's OK but sometimes
you need to ensure a move completes before doing the next one. If that's the case follow the critical move with:
code("G1....") -- your move
while IsMoving()
wend
code("G1....") -- your next move
The while loop just trundles along until the first move completes before it will do the next instruction.
Take advantage of the documentation available from Artsoft re CE scripting and there are a lot of examples which you
can study as well.
If I can help with specific problems within my limited CE ability I will, and there are plenty of CNCers on the forum who
are masters of CE.
Craig