Using Auxillary Inputs in a Macro
This section explains how to test to make sure an input is working properly and with the proper polarity on Wincnc. In this case, we will be testing the spindle actuated signal.
Example 1: ATC Drawbar Actuate Signal
On an automatic tool changing spindle used in CNC routing, there is usually a sensor on the spindle which detects when the drawbar is actuated. This sensor can be wired so that a signal comes back to WinCnc. This way, Wincnc can use that information in its MACRO commands. The commands that can be used to interrogate wincnc's inputs are as follows:
| Wincnc M-Code | In Plain English |
|---|---|
| M17 | Pause until input turns on. |
| M17.1 | Run the next line of the file only if the input is on. |
| M18 | Pause until input turns off. |
| M18.1 | Run the next line of the file only if the input is off. |
In Wincnc, each input channel is assigned a number. In the case of this example, we will use input channel number 2 (C2).
- Check to see if input C2 is on.
- If not…
- Go ahead and actuate the toolchange drawbar.
- Wait for input to go high.
- If so…
- Tell the user the mechanizm was already actuated.
- Then exit.
- If not…
[ TestActuatedSignal.mac ]
[ This is a sample file to test
[ the "spindle actuated"
[ input signal.
M17.1 C2 [ run next line if C2 is on ]
G4 [ Spindle already Actuated ]
M17.1 C2 [ run next line if C2 is on ]
M99 [ exit program ]
M18.1 C2 [ run next line if C2 is off ]
M98 TestActuatedSignalSub.mac
[ TestActuatedSignalSub.mac ]
M52 [ Send command to actuate drawbar. ]
M17 C2 [ Wait for the input to "go high", or turn on. ]
G4 X3 [ Wait 3 seconds. ]
M17.1 C2 [ Run next line if input C2 is now active (turned on). ]
g4 [ Drawbar Actuated Successfully ]
Example 2: ATC Drawbar Clamped Signal
Also, there is usually a sensor on an ATC spindle which detects when the drawbar is clamped. Just like the "actuated" sensor mentioned in example 1, this sensor can be wired so that a signal comes back to WinCnc for use in a Wincnc macro command. Once again, the commands that can be used to interrogate wincnc's inputs are as follows:
| Wincnc M-Code | In Plain English |
|---|---|
| M17 | Pause until input turns on. |
| M17.1 | Run the next line of the file only if the input is on. |
| M18 | Pause until input turns off. |
| M18.1 | Run the next line of the file only if the input is off. |
In Wincnc, each input channel is assigned a number. In the case of this example, we will use input channel number 3 (C3).
- Check to see if input C3 is on.
- If not…
- Go ahead and clamp the toolchange drawbar.
- Wait for input to go high.
- If so…
- Tell the user the mechanizm was already clamped.
- Then exit.
- If not…
[ TestClampedSignal.mac ]
[ This is a sample file to test
[ the "spindle clamped"
[ input signal.
M17.1 C3 [ run next line if C3 is on ]
G4 [ Spindle already Clamped ]
M17.1 C3 [ run next line if C3 is on ]
M99 [ exit program ]
M18.1 C3 [ run next line if C3 is off ]
M98 TestClampedSignalSub.mac
[ TestClampedSignalSub.mac ]
M53 [ Send command to clamp the drawbar. ]
M17 C3 [ Wait for the input to "go high", or turn on. ]
G4 X3 [ Wait 3 seconds. ]
M17.1 C3 [ Run next line if input C3 is now active (turned on). ]
g4 [ Drawbar Clamped Successfully ]





