MACROLOOP >> MACRO B VARS Populate for UCCNC
Posted: Sat Jan 12, 2019 10:18 pm
MACRO B VARS MACROLOOP for UCCNC
This is just my interpretation of what may be useful from the Fanuc Macro B variables (vars) which also follow Mach3/4 {YMMV}
My intention is to use it with Macro wizards to keep track of and reset the machine back to the original machine and work co-ordinates (allows you to use G92 and also G91 for the wizard gcode and go back to the same machine and work co-ordinates, spindle speed {if you need or are using it} or feedrate, rotation etc should you change it.
Word of CAUTION.... it will ONLY work with the current development release which incorporates exec.Modalcodes and makes it easier (IMO) to extract the modal modes than using
As per discussed here
viewtopic.php?f=11&t=1734
It WILL throw an error if you run it on anything prior to the current development release (2.108).... but hey that's where all the new + good stuff is at the cutting edge of the release
This is just my interpretation of what may be useful from the Fanuc Macro B variables (vars) which also follow Mach3/4 {YMMV}
My intention is to use it with Macro wizards to keep track of and reset the machine back to the original machine and work co-ordinates (allows you to use G92 and also G91 for the wizard gcode and go back to the same machine and work co-ordinates, spindle speed {if you need or are using it} or feedrate, rotation etc should you change it.
Word of CAUTION.... it will ONLY work with the current development release which incorporates exec.Modalcodes and makes it easier (IMO) to extract the modal modes than using
- Code: Select all
AS3.Getfield(877); // Field 877: Activemodal;
As per discussed here
viewtopic.php?f=11&t=1734
It WILL throw an error if you run it on anything prior to the current development release (2.108).... but hey that's where all the new + good stuff is at the cutting edge of the release
- Code: Select all
// MACRO B VARS MACROLOOP for UCCNC
// 12/01/2019
//Robertspark
double Rx, Ry, RAngle; // Rotation coordinates
while(loop)
{
if (AS3.Getbuttonstate(144)) // if machine is in reset no point in trying to update the variables
{
Thread.Sleep(50);
}
else // MACHINE NOT IN RESET / E-STOP, UPDATE VALUES.
{
if (!exec.IsMoving()) // no point updating on the fly as the frontend does not actually know where the machine tool actually is because of the comms buffer, and macroloop timing. These values are not updated in macroB during motion either.
{
exec.Code("#5021=" + exec.GetXmachpos() ); // Machine (ABS) X coordinate
exec.Code("#5022=" + exec.GetYmachpos() ); // Machine (ABS) Y coordinate
exec.Code("#5023=" + exec.GetZmachpos() ); // Machine (ABS) Z coordinate
exec.Code("#5024=" + exec.GetAmachpos() ); // Machine (ABS) A coordinate
exec.Code("#5025=" + exec.GetBmachpos() ); // Machine (ABS) B coordinate
exec.Code("#5026=" + exec.GetCmachpos() ); // Machine (ABS) C Ccoordinate
exec.Code("#5041=" + exec.GetXpos() ); // Work X coordinate
exec.Code("#5042=" + exec.GetYpos() ); // Work Y coordinate
exec.Code("#5043=" + exec.GetZpos() ); // Work Z coordinate
exec.Code("#5044=" + exec.GetApos() ); // Work A coordinate
exec.Code("#5045=" + exec.GetBpos() ); // Work B coordinate
exec.Code("#5046=" + exec.GetCpos() ); // Work C Ccoordinate
}
exec.Code("#4109=" + AS3.Getfield(867) ); // Set FeedRate {F CODE}
exec.Code("#4119=" + AS3.Getfield(869) ); // Set SpindleRate {S CODE}
//exec.Code("#4113=" + AS3.Getfield(867) ); // Set FeedRate {M CODE}
exec.Code("#4114=" + exec.Getcurrgcodelinetext()); // Sequence Number (LINE) {N CODE}
//exec.Code("#4114=" + AS3.Getfield(869) ); // Program Number {O CODE}
exec.Code("#4001=" + exec.Modalcodes[1] ); // Modal Group 1 - MOTION
exec.Code("#4002=" + exec.Modalcodes[2] ); // Modal Group 2 - PLANE SELECTION
exec.Code("#4003=" + exec.Modalcodes[3] ); // Modal Group 3 - DISTANCE MODE
exec.Code("#4005=" + exec.Modalcodes[5] ); // Modal Group 5 - FEEDRATE MODE
exec.Code("#4007=" + exec.Modalcodes[7] ); // Modal Group 7 - CUTTER DIA COMP MODE
exec.Code("#4008=" + exec.Modalcodes[8] ); // Modal Group 8 - TOOL LEN OFFSET
exec.Code("#4010=" + exec.Modalcodes[10] ); // Modal Group 10 - CANNED CYCLE RTN
exec.Code("#4012=" + exec.Modalcodes[12] ); // Modal Group 12 - WORK COORDS
exec.Code("#4013=" + exec.Modalcodes[13] ); // Modal Group 13 - CONTROL MODE
exec.Code("#4016=" + exec.Modalcodes[16] ); // Modal Group 16 - SCALE
exec.Code("#4017=" + exec.Modalcodes[17] ); // Modal Group 17 - COORD ROTATION
// ODD BALL {NON MACRO B} ONES
exec.Code("#4209=" + AS3.Getfield(232) ); // FeedRate Over-Ride
exec.Code("#4219=" + AS3.Getfield(233) ); // SpindleRate Over-Ride
exec.GetRotate(out Rx, out Ry, out RAngle); // returns values into the defined variables Rx, Ry and Angle
exec.Code("#4400=" + Rx ); // Current Rotation Co-ordinate Centre Rx
exec.Code("#4401=" + Ry ); // Current Rotation Co-ordinate Centre Ry
exec.Code("#4402=" + RAngle ); // Current Rotation Angle
Thread.Sleep(50);
}
}