Hello All:
I have implemented a major change in the Macro functionallity, so the next
version has the Macro execution as a separate Windows thread (till now I
thought it was..it wasn't). It means that code such as the following will
function properly...
N = Question ("Number of Holes")
D= Question ("Diameter of hole pattern")
Z = Question ("What it the hole Depth")
A = Question ("Offset start angle")
Q = Question ("Peck Depth")
R = Question ("Rapid Plane")
F = Question ("Feed Rate")
Nc = 1
PI = 3.1415926535898
A = (A*PI)/180
An = 2*PI/N
Y = (D/2)*Sin (A)
X = (D/2)*Cos (A)
Do
While IsMoving
Wend
Code ("G91")
Code ("G00 X"&X&"Y"&Y)
Code ("G90")
Code ("G83 Z"&Z&"Q"&Q&"R"&R&"F" &F)
Code ("G80")
Y = ((D/2)*Sin (A+An*N)) - Y
X = ((D/2)*Cos (A+An*N)) - X
Nc = Nc+1
Loop While N >= Nc
(This is a users code, it is flawed (Sorry Brian) by the fact that
entering a zero strt angle will not do anything. A bit of work is needed on
the math, but you get the idea. A script like this would peck drill a series
of holes in a manifold configuration.)
This change is important in that it means the engine is still running
while the script is running. It will make it much more versatile in its use.
When a macro is encountered, the currently running program is suspended
while the macro executes. Any commands send via the macro script to the
engine are interpreted and run as they go in. When the macro exits, the
running program continues...
This is in preperation for more complex wizardry functions. Sorry for any
bugs encountered, or for any scripts it affects, but it should cure many
ill's as well. You can see the new command
IsMoving in use in the example. This function when used in the way it is
above:
Do
While IsMoving
Wend
will stop the script from adding anything more to the queue until the
previous code has finished execution. While not necessary, it will be
necessary to make sure you do not overflow the 1000 commands or so you can
put in to be executed. The Do/While statement will keep the buffer from
filling until it is empty. Used stategically, it is a valuable tool to make
a macro more stable. This combined with the new Portin Portout macro's make
it possible to control fairly complex tool changers and external devices
from a second port or IO card. With this change a macro COULD take control
forever and do a continuous movement that lasts for hours before ending and
passing control back to Mach2. Or, in the case of a toolchanger, it can
start movment, wait for the appropriate feedback from external devices and
then continue the program.
(For those Macro heads emailing me lately, let me know if you need more....)
Just a heads up. I can't release yet as I find myself in a spurt of
post-vacation productivity. Probably this weekend or earlier...
Art
www.artofcnc.ca