DN Solutions
Published

Custom System Variables

Custom macro system variables provide access to many CNC-machine functions not accessible within normal G-code-level programming.

Share

One set of system variables largely overlooked is the #1000 and 1100 series, used for input signal monitoring and output signal generation. These are probably the most difficult to master.
 
Within the machine’s electrical boxes (if the machine is equipped to use these system variables), there are two terminal strips containing 32 connectors each, labeled zero through 31. One set of terminal connectors is for input, the other for output. The #1000 series system variables correspond to the input terminal strip (#1000 to 1031), and the #1100 series variables correspond to the output terminal strip (#1100 to #1131). More specifically, #1000 corresponds to terminal connector number zero on the input terminal strip, and #1100 corresponds to terminal connector number zero on the output terminal strip. The last two digits correspond to the terminal strip connector number (#1006 corresponds to input terminal connector six).
 
Input system variables are used to monitor the current state of each corresponding input signal terminal connector. When a 24-volt signal is present at a given input terminal connector, its corresponding system variable is set to a value of one. If there is no voltage at the connector, the system variable’s number is zero. So if there is no voltage currently at terminal five, the value of #2005 is zero.
 
Output system variables are used to place 24-volt signals at their corresponding output terminal connectors. When an output system variable is set to zero, no voltage is sent to its corresponding terminal connector. When set to one, a 24-volt signal is sent to the terminal connector.
 
These terminal strips, along with their corresponding system variables, enable custom macro to communicate with external devices. The simplest applications use only one of the terminal connectors—most commonly from the input terminal strip.
 
For example, say it is critical that the rotary axis within a horizontal machining center’s table is at the zero-degree position when the program starts. A limit switch can be used to confirm this position. When the table is in the correct place, the limit switch is tripped, and an electrical circuit sends a 24-volt signal to input terminal zero. When the limit switch is not tripped (the table is not correctly positioned), there is no voltage at terminal zero.
 
Knowing this, the programmer can set up the following logic at the beginning of the program:
 
O0001 (Program number)

IF [#2000 EQ 1] GOTO 5

#3000 = 1000 (MISPOSITIONED TABLE)

N5…
 
As long as the value of #2000 is one, the table is correctly positioned, and the program can continue. If not, the value of #2000 is zero, and the program logic catches the problem and generates an alarm. In all applications that use these system variables, the most difficult part of the process is to properly create the electrical circuitry.
 
With the previous application, only an input terminal and system variable are required. Here is an application that also requires an output terminal and system variable: To activate an outside device from within a CNC program—maybe a hydraulic clamping system—an M code is created.
 
A signal is sent to the clamping system to engage the clamp, but a confirmation signal is needed to ensure that the system has properly engaged prior to letting the program continue. To accomplish this, the electrical circuit includes a wire connected to an output terminal connector. When the 24-volt signal is present at this connector, the related electrical circuit activates the clamping system.
 
For the confirmation signal, the electrical circuit must include a way to confirm that the clamping system is engaged—possibly by a limit switch. When the limit switch is engaged, the circuit sends a 24-volt signal to input terminal connector number one. When the clamp is not engaged, no voltage is present at this terminal connector.
 
Assuming the circuit is set up properly, here is the program logic required to activate the clamp. Of course, another set of logic and terminal connectors—and another set of circuitry—is required to disengage the clamp:     
 
.

#2101 = 1 (Activate clamp)

N1 (Blank line to allow retest)

IF [#2001 NE 1] GOTO 1 (Test for confirmation signal)

#2101 = 0 (Remove voltage from terminal connector number zero)

.
 
The first command puts a 24-volt signal on output terminal connector one, which engages the clamp. The next two lines cause the machine to wait for the confirmation signal. In essence, the program loops until the value of #2001 is set to one (when the confirmation signal is sent from the clamp circuitry). A time delay must be included in the circuitry to turn off the voltage at this input terminal connector so it will be ready for the next clamp engagement. The final command removes the voltage from the output terminal connector to ready it for the next clamp engagement. These commands can be put in a subprogram as part of a user-defined M code, meaning the creation of M codes can be simulated using this technique.  
DN Solutions
CHIRON Group, one stop solution for manufacturing.
Koma Precision
To any Measurement Question there is an Answer
OASIS Inspection Systems
Paperless Parts
Hurco
SolidCAM
Kennametal
The view from my shop.
VERISURF
Paperless Parts

Read Next

3 Mistakes That Cause CNC Programs to Fail

Despite enhancements to manufacturing technology, there are still issues today that can cause programs to fail. These failures can cause lost time, scrapped parts, damaged machines and even injured operators.

Read More
Vertical Machining Centers

The Cut Scene: The Finer Details of Large-Format Machining

Small details and features can have an outsized impact on large parts, such as Barbco’s collapsible utility drill head.

Read More
DN Solutions