Centroid cnc12 PLC Programming Manual
Centroid cnc12 PLC Programming Manual
Centroid cnc12 PLC Programming Manual
Revision 20180820
Table of Contents
• Keyboard Keys are in Arial font at 12 pt. size and bold. An example is ALT-Q.
• Commands entered in the command line of a prompt window are in italicized
Consolas font at 11 point size. An example of this is mpucomp ProgramName.src
mpu.plc.
• On and SET are interchangeable, as are Off and RST.
• System Variable may be written as SV, which is interchangeable and means the same
thing.
• PLC Program and program are used interchangeably and mean the same thing.
• Data Type and type are used interchangeably and mean the same thing.
Programming Conventions
It is helpful when debugging and reading a program to know what type a variable is without
having to constantly search through the multiple uses of a name to get to the definition at the
top of the program. Following is a table of basic suggestions of ways the types can be named
to reduce confusion. Inputs and Outputs are typically named to indicate the purpose rather
than applying an extra label to them. The basic idea is to put something like the code specific
type name at the end of the declaration. Whether you put an underscore between the name
and type, add the letters in all Caps, or capitalize the first letter is up to you.
Type Example Name Comments
Constants AXIS_FLT_CLR_MSG All Caps, end with MSG
Input EstopOk
Output LubeOut
Memory Bit SpinFault_M Alternatively use M or Mem
Word Axis3FiberOk_W Alternatively use W or
Word
Double Word BigCounter_DW
Floating-point Word SpindleRangeMultiplier_FW
Double-Floating-point Word PreciseNumber_DFW
Timer Fault_Clear_T Alternatively use Timer
One-Shot SlowFast_PD PD is Positive
Differential, meaning
rising edge
Stage InitialStage Alternatively use STG
Fast Stage CountSomething_FSTG
SV_PLC_* System variables
PLC to CNC11 System are not named, so the
Variable DoToolCheck function is prefixed with
an action word 'Do' or
'Select' and named for the
function it tells CNC11 to
do.
Keyboard Keys Kb_a Kb is short for Keyboard
M-Codes M6 Start with Capital M
While technically no Stages are required to be explicitly used for a program to compile, they
should be used. The benefits include allowing debug of small sections of code by turning off
other stages, reduced Program running time by running only certain things all the time, and
In this example, EstopOk is the name given to the INP data type. Similarly, Lube is the name
given to the OUT data type. In both cases, the keyword IS is part of the syntax for defining a
name.
Data Types
The kind of information that a variable can hold is defined at compile time by the data type
when it was declared. All of the types below can be used in a PLC program. Typically Words
and Floating-point Words have enough precision to achieve the desired results versus Double
Words and Double Floating-point Words.
Important Note
It is critical to understand when specific Data Types are updated during the execution of a
PLC program. The execution of a PLC program occurs approximately 1000 times a second,
but only PLC program code inside a fast stage ( FSTG type) or outside of any stage is actually
executed 1000 times a second. PLC program code inside a regular stage ( STG type) is
executed 50 times a second. The execution of a PLC program from top to bottom as it has
been written is referred to as a PLC “pass”.
A question that quickly emerges when writing PLC programs is, “If I change the value of a
variable in the PLC program, when does it actually take effect?” The answer to this question
is that it depends upon the data type being changed. Timers, Inputs and Outputs are all
buffered at the beginning of the program. This means that a snapshot is taken of the state of
them and that image does not change during the pass of the PLC program. In other
words, Timers have the same value at the start of the pass as they do at the end. The same is
true for Inputs and Outputs as far as the real-world physical state is concerned. The snapshot
of the Inputs never change, but the image of the Outputs can be changed on any line and that
brings us to the other category of when things update. Memory Bits, all Words, One-Shots,
both kinds of Stages, System Variables, and the image of the Outputs are changed
immediately and on the next line of the program will be at the value they were assigned to on
the previous line.
Another important thing to note is that the Live PLC Diagnostic screen (ALT-I) does not show
every transition of every variable. What you see is a snapshot of PLC data that is updated
about 20 times a second.
Input – INP
Inputs are physical switches or buttons that can be either on or off. When defining an Input, it
is written as Limit_Switch IS INP2. Inputs can be logically combined with Outputs, Memory
Bits, Timers, One-Shots, Stages, Fast-Stages and System Variables that are bits using
Logical Operators, but not Relational Operators. Limit switches, Jog Panel keys and Inverter
signals such as fault or at speed are all examples of inputs. Analog voltage comes into the
system, but it must be read into any of the Word type variables.
Output – OUT
Outputs are physical, real-world outputs such as relay contacts, relay driver signals, or analog
signals that can be on or off. Analog voltages are converted from Bits in the PLC program to
analog voltage at the header. They can be used to control other relays, lube pumps, spindle
enable, inverter analog speed control, coolant, Jog Panel LEDs, etc. The standard way of
specifying an output is Lube IS OUT2 or AutoCoolantLED IS JPO21. Outputs can be logically
combined the same way as Inputs.
Timer – 32-bit – T
Timers are counters with the special ability to be compared with both Relational and Logical
Operators. This means that you can check IF T1 THEN SET OUT1 to see if the Timer has
reached its set point or IF T1 > 1000 THEN SET OUT2 to see if the Timer has counted past 1000
milliseconds (one second). Timers are initialized with a 32-bit positive Integer number that is
interpreted as the number of milliseconds to count before evaluating to true when checked
with Logical Operators.
The value is typically stored in the Timer during the InitalStage. To start a Timer counting use
SET T1. To reset the Timer so that it is waiting to count again use RST T1. Note that you do not
need to store a value into a Timer each time it is RST unless you want to change the value to
One-Shot – PD
One-Shots or Positive Differentials are used to detect the first rising edge of an event
occurring. A One-Shot can only be turned on and off using a Coil. Because of this a One-Shot
should only ever be SET/RST on one line of the PLC Program. It can be checked anywhere, but
not SET/RST. Once the PD has been SET by the IF test, the conditional section must evaluate to
false and thus RST the PD before it can be used again. This means that you cannot hold a
button down and cause the One-Shot to trigger more than once. Using this in combination
with Debounce allows safer detection of key presses to prevent multiple actions when only
one is intended. One-Shots are often used on Jog Panel keys and M-Codes. One-Shots may
not be desired in certain circumstances such as the Override +/- buttons for Spindle Speed.
Typically one wants to hold down the button and have the Override value change as long as
the button is held down. An example definition and usage of a One-Shot follows.
KeyPressPD IS PD1 ;define the One-Shot
IF JPI1 THEN (KeyPressPD) ;if Jog Panel Input 1 is pushed, set the One-Shot
If KeyPressPD THEN SET MEM300 ;if the One-Shot is set, turn on a memory bit
Stage – STG
Stages are useful in many ways. First, they are used to break up different sections of the
program to allow easier debugging and testing. Conventional programming dictates that there
is at least an InitialStage and a MainStage in any PLC program, but Stages are not required to
Keywords
Keywords are reserved words in the PLC programming language that cannot be used except
for the defined purpose. Often attempting to use the keyword in an undefined way will cause
the program to fail compilation. In example code they will always be capitalized by convention
and should not be confused with constant defined variables or System Variables.
Defining variables – IS
This keyword is used to setup labels for all the data types. It is only used in the definition
section at the top of the program. It is not used in the actual PLC program that gets executed.
When the program is compiled all the labels are replaced with what they refer to from the
definition section of the PLC program. For example the E-stop Input is defined like:
EStopOK IS INP11.
IS is used on every data type to define a name for that variable. There is also a built in
functionality for defining constant data to have a name. Math can be done in the definition and
previous definitions of constants can be used as long as the entire assignment is in
parentheses. An example is:
DEFINED_CONSTANT IS (1+2+5*7)
SECOND_CONST IS (DEFINED_CONSTANT*10)
It is easiest and less error prone to write the message number once by defining a Constant to
store to a word before messaging it out. Below are the defines used in both Asynchronous
and Synchronous messages for the example program.
INP13_GREEN_MSG IS (2 + 1*256) ;258
INP13_RED_MSG IS (2 + 2*256) ;514
INP14_GREEN_MSG IS (1 + 3*256) ;769
NO_SYNC_MSG IS (1 + 99*256) ;25345
NO_ASYNC_MSG IS (2 + 100*256) ;25602
EStopOk IS INP11
Async_O IS OUT13
Sync_O IS OUT14
Sync_Cleared_M IS MEM1
Stop IS MEM2
Sync_W IS W1
Async_W IS W2
InitialStage IS STG1
MainStage IS STG2
SetError IS STG3
;=============================================================================
InitialStage
;=============================================================================
;setup default Word values
IF 1==1 THEN Sync_W = NO_SYNC_MSG, Async_W = NO_ASYNC_MSG,
RST InitialStage, SET MainStage
;=============================================================================
MainStage
;=============================================================================
IF !EStopOk THEN SET SV_STOP
IF SV_STOP THEN (Stop)
;sync
;--if the Input is green, set the Sync message and override the Async messages
IF Sync_I THEN Sync_W = INP14_GREEN_MSG, SET SV_STOP, SET SetError, SET Sync_O
;async
;--show a message if the Input changes
IF Async_I THEN Async_W = INP13_GREEN_MSG, MSG Async_W, SET Async_O
IF !Async_I THEN Async_W = INP13_RED_MSG , MSG Async_W, RST Async_O
;=============================================================================
SetErrorStage
;=============================================================================
IF 1==1 THEN MSG Sync_W
;if the message has been cleared, reset this stage to allow Async messages
IF Sync_W == NO_SYNC_MSG && Sync_Cleared_M THEN RST SetError
The sample plcmsg.txt file use for the above example is:
1 9001 Input 13 Green
2 9002 Input 13 Red
3 9003 Input 14 Green
99 9099 No SYNC Message
100 9010 No ASYNC Message
plcmsg.txt
The plcmsg.txt file contains a list of all the messages that the PLC can send to CNC11. This
facility is used to notify the user of status changes and fault conditions. The typical messages
should not be overwritten by new custom messages, rather new numbers should be added.
The format for each line of the plcmsg.txt file is as follows.
MessageNumber MessageLogNumber Message
There are three fields separated by one space each that must be setup for a line to be valid
and usable. If the line is not formed correctly, you will not know it until the message is trying to
display. The MessageNumber field is exactly the same number as the Message Number in
the above table. The MessageLogNumber causes the printed message to be put in the
msglog.txt file so that problems can be diagnosed by Tech. Support. The 9xxx series
messages are reserved for PLC program usage. Make sure the Log Level is set to 4 in
parameter 140 to ensure the messages are logged. Message is the useful text that will be
printed along with the MessageLogNumber. It should contain a pithy message that informs
the user about the change that occurred. All text to the end of the line is printed so no
comments are allowed in this file. The standard plcmsg.txt file is listed below.
1 9001 PLC Execution Fault
5 9005 Axis 1 Communication In Fault
6 9006 Axis 2 Communication In Fault
7 9007 Axis 3 Communication In Fault
DUMP
The DUMP command causes the PLC program to dump the values stored in all of the first 64
Words, Double Words, Floating-point Words, and Double-Floating-point Words to
debug_dump0.txt in the cncm or cnct directory. DUMP should only be used sparingly and then
only when debugging the initial implementation of a PLC program because of the cost of
writing data to a file on the hard disk. This is useful for making sure Floating-point variables
are correct. The PLC Detective utility and the Live PLC IO display in CNC software have the
ability to monitor and display The first 44 W and FW types and the first 11 DW and DFW
types. In CNC12 v4.14, the first 88 W types can be displayed.
An example of using this is as follows.
IF JPI1 THEN (PD1)
IF PD1 THEN DUMP
Operators
The operators in a PLC program are used to compare data, to set one piece of data equal to
another, invert the data, etc. There are both unary and binary operators. The unary operators
only require one variable or piece of data to operate on. An example of this is inverting a
memory bit like this !MEM1 or turning a Memory Bit on like SET MEM1. A binary operator requires
Assignment – =
The equals sign is used to set a Word or Timer on the left of the equals sign to a Word, Timer
or numerical value on the right of the equals sign. Some examples are listed below.
IF 1==1 THEN W1 = 10 ;Word1 is set to an integer value of 10
IF 1==1 THEN T1 = W1 ;Timer1 is also set to an integer value of 10 representing 10 ms
IF 1==1 THEN FW1 = 2.5 ;Floating-point Word1 is set to 2.5
Set – SET
SET turns on any of the Bit variables. The bit value is set to 1 and evaluates to true when
checked. That is to say that any of the Outputs, Memory Bits, Timers, Stages, Fast-Stages
and System Variables that are bits can have this keyword used on them. One-Shots cannot
be SET. An example of using this is IF 1==1 then SET MEM1.
Data Types that can be used with SET Example of using SET
Memory Bits IF 1==1 THEN SET MEM2
Outputs IF 1==1 THEN SET OUT2
Inputs IF 1==1 THEN SET INP2
Timers IF 1==1 THEN SET T2
Stages IF 1==1 THEN SET STG2
Fast Stages IF 1==1 THEN SET FSTG2
One-Shots IF 1==1 THEN SET PD2
Reset – RST
Reset turns off any of the Bit variables. The bit value is set to 0 and evaluates to false when
checked. That is to say that any of the Outputs, Memory Bits, Timers, Stages, Fast-Stages
and System Variables that are bits can have this keyword used on them. One-Shots cannot
be RST. An example of using this is IF 1==1 then RST MEM2.
Output Coil – ()
Output Coils are used to SET or RST any bit output based on the conditions before the THEN. If
the test in the IF is true the output is SET, whereas if the test is false then the output is RST. The
use of parenthesis does not constitute Output Coils unless they are used to the right of THEN
on any program line. Output Coils cannot be used on Words. Be careful when using Coils
because they can cause logical problems in your program. Do not put a variable in Coils on
one line and then try to SET or RST it somewhere else in the program as well because it will
change while moving through the PLC program and may have surprising results. If you are
going to use a variable in Coils, all of the logic to turn it on or off must be on the same line to
avoid trouble. Coils cannot be used on Timer Data types to start them counting because they
are generally guaranteed to be turned off again on the very next pass of the PLC program.
Some examples are shown below to illustrate some Coil concepts.
;basic Coil usage
IF 1==1 THEN (OUT1) ;always turn on OUT1
IF MEM1 THEN (OUT2); SET OUT2 if MEM1 is SET and RST OUT2 if MEM1 is RST
Jump – JMP
Jump RSTs the current Stage and SETs another one. See Stages for the effects of turning on
or off a stage. Execution does not jump around in the PLC program as in Assembler, but
typically the stages are written one after the other so in essence it will move to that one. A
sample usage of Jump is IF 1==1 THEN JMP STG3. If a JMP is called such that the current Stage
is the stage being jumped to, then the Stage will still be set next time through the PLC
|| is the operator for OR. This means that only one side of the operator needs to be true for
the statement to evaluate to true.
Left Side Right Side Result
0 0 0
0 1 1
1 0 1
1 1 1
XORor ^ are the operators for Exclusive OR. This means that one of the sides of the operator
must be true and the other false to have the statement evaluate to true.
The ! is a unary operator for NOT that inverts the state of a bit whether it is true or false.
Bit Value Result
0 1
1 0
Logical Operators cannot be used on Word Type variables. The results of multiple Relational
checks can be combined with Logical checks for more complex statements, however. All of
the following lines are valid PLC code. Often it increases readability to use parentheses
around conditions to ensure correct interpretations.
IF MEM1 && INP2 THEN (OUT1)
IF (W1 > W2) || !MEM4 THEN (OUT5)
IF !MEM1 && INP2 || STG1 || FSTG1 && OUT3 XOR PD1 && T3 XOR SV_PC_POWER_AXIS_1 THEN (OUT6)
PI IS 3.1415926535897932384626433832795
DEG_TO_RAD IS (PI/180)
RAD_TO_DEG IS (180/PI)
InitialStage IS STG1
MainStage IS STG2
;======================================================================
InitialStage
;======================================================================
IF 1==1 THEN rad_deg1_FW = 30 * DEG_TO_RAD ;sample degree values must -
;calc arcsin
IF 1==1 THEN calc_asin_FW = ASIN (calc_sin_FW)
;calc arccos
IF 1==1 THEN calc_acos_FW = ACOS (calc_cos_FW)
;calc atan2
IF 1==1 THEN calc_atan2_FW = ATAN2 (calc_tan_FW, calc_tan_FW)
;======================================================================
MainStage
;======================================================================
IF JPI1 THEN (PD1)
IF PD1 THEN DUMP, RST MainStage
The following list shows what the results are from the above calculations. You can follow
along on your PC with the calculator as long as you enter the first three values in Radians.
PLC Dump Start
FW1: 0.52359879 FW2: 1.04719758
FW3: 0.78539819 FW4: 0.50000000
FW5: 0.49999997 FW6: 1.00000012
FW7:30.00000000 FW8:60.00000000
FW9:45.00000000
Defining Variables
Any variable is defined by having the label set to a valid data type using the keyword IS.
Further examples can be seen for each data type under Data Types.
Initial-Condition Setup
The on/off state of various modes of operation such as Auto/Manual Coolant, Fast/Slow
Jogging, etc. must be set by the PLC program because everything defaults to off. It is
desirable to do this without having to push the buttons to set the states the first time because
being off means something as much as being on. For example, if the Fast/Slow Jog mode is
not actively set, it defaults to Fast Jog. The convention is to use a Memory Bit called
OnAtPowerUp. It is SET in the InitialStage and RST at the end of the MainStage. This means that
;--actual code
IF (SpinAutoManPD && !SpinAutoModeLED) || OnAtPowerUp
THEN SET SpinAutoModeLED
Software Ready
The SV_PC_SOFTWARE_READY Bit is checked to see if CNC software is running. This is mostly
used if CNC software crashes to prevent motion, too changes, etc. SV_STOP is set which will
cause E-Stop be activated. When the software starts again, E-Stop must be cycled and then
motion can be commanded again. SV_STOP is SET and the InitialStage is run whenever the
software starts up again.
; Handle PLC executor faults. The only way to reset a PLC executor fault
; is to reboot the MPU11.
IF SV_PLC_FAULT_STATUS != 0
THEN PLC_Fault_W = SV_PLC_FAULT_STATUS,
PLCFaultAddr_W = SV_PLC_FAULT_ADDRESS,
ErrorCode_W = PLC_EXECUTOR_FLT_MSG, MSG ErrorCode_W,
SET PLCExecutorFault_M, RST SetErrorStage, SET SV_STOP
Axis Enable
The axes are checked for motion related fault conditions including a drive fault, stall error and
fiber connections.
MiniPLCBus Checking
This section should be added to any PLC program that uses the PLCADD1616 or
ADD4AD4DA expansion boards. Specifically the checking should be added to the
CheckCycloneStatusStage. Only the MiniPLCBus Online bits are checked in this section, but
they should be added to the original Stage. Only the Expansion headers that are used should
be checked. There is no equivalent to the SV_Axis_Valid_1 - _7 System Variables. Looking in
the mpu_info.txt file will show what expansion boards are plugged in to the headers.
;add to Constant Defines
MINI_PLC_1_FLT_MSG IS (1 + 256*60); 15361
;add to CheckCycloneStatusStage
;check the first Expansion board
IF 1==1 THEN BITTST SV_PC_MINI_PLC_ONLINE 0 ADD1616ok1_M
IF !ADD1616ok1_M && PLCBus_Oe_M THEN
ErrorCode_W = MINI_PLC_1_FLT_MSG, SET SetErrorStage, SET PLCFault_M
LubeTimers
There are two options for setting up automatic lubing in the basic PLC program. The first type
Feedrate Override
Feedrate Override allows changing the master feedrate or commanded velocity if it is
enabled. The basic feedrate override starts by reading the Feedrate potentiometer then
scaling it to 0% to 200% from 0 to 256. The program then determines whether the Feedrate
knob or the keyboard feedrate keys should be applied to CNC software. The maximum value
is limited by parameter 39. Parameter 78 allows the feedrate value to be adjusted down if the
spindle speed does not keep up with the command so CNC software gets to see if it wants to
modify the Feedrate Override. Finally the PLC program has one last chance to change the
new value coming back from the CNC software, though typically it should not.
There is now a feature that allows using keyboard and Knob override at the same time. By
default the Knob is used, but if the Feedrate Override keyboard keys are used, then the
Feedrate override displayed is based on the Keyboard value and not the Knob value. When
the Knob is turned again more than 3%, however that value is displayed.
Spindle Functionality
MPG Operation
The MPG or Manual Pulse Generator can be used to supplement Jog buttons. This section is
used to enable the MPG mode control in CNC software for the standard Centroid CNC MPG.
This includes provisions for up to 4 axis in the basic PLC program with three step amounts.
Note that when the MPG is active, with the way this is programmed, jogging will not work. It
can be written into the PLC program that when a Jog Key is pushed to turn off MPG mode
temporarily. Windup mode is used to make sure that the motor moves all of the commanded
steps that the MPG sent. This is not desirable in x100 mode because turning the MPG fast
enough will result in motion well after the MPG has stopped turning.
;=============================================================================
MPGStage
;=============================================================================
; MPG Functions
; Turn on/off Jog Panel MPG LED & on the MPG
IF MPGKey THEN (MpgPD)
IF MpgPD && MPGLED THEN SET MPGManOffFlag_M
IF !SV_MPG_1_ENABLED || (MpgPD && !MPGLED) THEN RST MPGManOffFlag_M
;--X10
IF x10JogKey THEN (x10JogPD)
IF x10JogPD || X10_M || (MPG_Inc_X_10 && MPGLED)
THEN RST x1JogLED, SET x10JogLED, RST x100JogLED
;--X100
IF x100JogKey THEN (x100JogPD)
IF x100JogPD || X100_M || (MPG_Inc_X_100 && MPGLED)
THEN RST x1JogLED, RST x10JogLED, SET x100JogLED
;--MPG 1 Enable
IF MPG_AXIS_1 || MPG_AXIS_2 || MPG_AXIS_3 || MPG_AXIS_4 ||
MPG_AXIS_5 || MPG_AXIS_6 || MPG_AXIS_7 || MPG_AXIS_8
THEN (SV_MPG_1_ENABLED)
Coolant Control
Coolant refers to the Flood and Mist control. Automatic coolant does not allow turning on the
outputs unless the M7/M8 macros are used. Pushing the key to turn off Automatic coolant will
then allow manual only control where a button must be pushed to turn on/off the coolant.
;--Coolant Functions
Probe Protection
There is some minimal protection built into the default PLC program to try and protect against
crashing a probe. If the Mechanical probe trips while jogging, a probe fault is triggered.
Jogging is not allowed in the direction that was being commanded when the probe tripped
until the probe is cleared.
;----------------------------------------------------------------
; Probe protection while jogging
;----------------------------------------------------------------
IF MechanicalProbe && !JogProbeFault_M && (DoAx1PlusJog || DoAx1MinusJog ||
DoAx2PlusJog || DoAx2MinusJog || DoAx3PlusJog || DoAx3MinusJog ||
DoAx4PlusJog || DoAx4MinusJog || DoAx5PlusJog || DoAx5MinusJog)
THEN (JogProbeFaultPD)
The default values for all of the Debounce Inputs is listed below.
Default Debounce Default Debounce Default Debounce
Setting Value Time Value Time (ms)
PLC Inputs 1 24 1.5
Jog Panel Inputs 1 24 18
MPU11 Local I/O 1* 24 1.5
*Input 770 for the DSP Probe Defaults to 0. Do not change this value.
Each group of System Variables is broken up into two sections. The majority of the System
Variables are used for Debounce Setting to apply to the Inputs and the last few are for setting
up the Debounce Time. This means that there is not a separately named SV for the time and
selecting what Input is used, just a different number. The following table illustrates which
System Variables are for Inputs and which are for setting up the time.
System Variable Range Function
SV_PLC_DEBOUNCE_1 to _60 Select Debounce time to use for each
Input
SV_PLC_DEBOUNCE_61 to _64 Choose number of scans to Debounce
SV_JOG_LINK_DEBOUNCE_1 to _28 Select Debounce time to use for each
Input
SV_JOG_LINK_DEBOUNCE_29 to _32 Choose number of scans to Debounce
For each of the three types of Debounced Input there are seven different times that can be
used in total. This means that any Input can have one of seven different times applied to it for
Debounce.
Each of the System Variables to setup Inputs are broken up into four 8 bit sections devoted to
one Input each. The layout for SV_PLC_DEBOUNCE_1 is illustrated in the following table, but all of
the System Variables for setting up Inputs are divided the same way.
Each of the 8-bit Input Setting Bytes is laid out according to the following table.
Input Setting Bit Number Function
0 Debounce Time Select 1-7 in binary
1 = Time 1
1
...
2 111 = Time 7
3 reserved
4 reserved
5 reserved
6 Invert Input
7 Force Input On
In order to figure out which Debounce System Variable to use, divide the Input number by four
and add one. PLC Input 211 is on 211 / 4 = 52.75 plus one gives 53.75 for SV_PLC_DEBOUNCE_53.
The fractional component tells which of the four input bytes in the System Variable should be
set to get the correct Input. In the example above 0.75 is ¾ which points to Byte 3 out of 4 or
bits 16-24.
Setting up the Debounce Time System Variables is more strait forward because there are only
four System Variables that can be setup for each Input type. Each of the System Variables is
split into two 16-bit values with the lowest one in each category being unused. That is why
only Debounce times from 1 to 7 are allowed to be customized. Debounce Time 0 is always
set to 0 and cannot be modified. The following table illustrates the seven available Debounce
Times by System Variable.
Debounce Time Sys. Vars. Debounce Time
SV_PLC_DEBOUNCE_61 0 – 15 always set to 0
16 – 31 Debounce Time 1
SV_PLC_DEBOUNCE_62 0 – 15 Debounce Time 2
16 – 31 Debounce Time 3
SV_PLC_DEBOUNCE_63 0 – 15 Debounce Time 4
16 – 31 Debounce Time 5
SV_PLC_DEBOUNCE_64 0 – 15 Debounce Time 6
16 – 31 Debounce Time 7
There are several ways to setup the Debounce values. One option is to calculate out the bit
values in decimal for all 32-bits and add them all up. Another option is to create each 8-bits for
the Debounce Time or Debounce Setting in a temp Word and Left Shift the value up to the
;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
;Program: debounce.src
;Purpose: Example Debounce Setup for INP6
; Set Time 5 for 13 ms., Invert Input
;Date: 20-APR-2010
;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
;--Variable Defines
Debounce_2_Bits_M IS MEM1 ;display the bits from the Word
Debounce_63_Bits_M IS MEM35 ;display the new bits for the Word
InitialStage IS STG1
MainStage IS STG2
;============
InitialStage
;============
IF 1==1 THEN Original_Deb_W = SV_PLC_DEBOUNCE_2 ;read the Settings SV
IF 1==1 THEN Orig_Deb_Time_W = SV_PLC_DEBOUNCE_63 ;read the Time SV
IF 1==1 THEN Final_Deb_W = Original_Deb_W
;============
MainStage
;============
;write out bits of final Word settings for verification
IF 1==1 THEN WTB Final_Deb_W Debounce_2_Bits_M 32
, WTB Final_Deb_Time_W Debounce_63_Bits_M 32
;/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
;Program: invert.src
;Purpose: Example invert/force Setup for INP6
;\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
;--Variable Defines
Orig_Deb_Bits_O IS OUT1 ;
Debounce_Bits_M IS MEM1 ;display the bits from the Word
Bit0_M IS MEM73 ; Deb Time Select Bit 0
Bit1_M IS MEM74 ; Deb Time Select Bit 1
Bit2_M IS MEM75 ; Deb Time Select Bit 2
Bit3_M IS MEM76 ; reserved
Bit4_M IS MEM77 ; reserved
Bit5_M IS MEM78 ; reserved
Bit6_M IS MEM79 ; Invert Input
Bit7_M IS MEM80 ; Force Input On
InitialStage IS STG1
MainStage IS STG2
;begin program
;============
InitialStage
;============
IF 1==1 THEN Original_Deb_W = SV_PLC_DEBOUNCE_2 ;read the Settings SV
IF 1==1 THEN Final_Deb_W = Original_Deb_W
Warnings
Already Defined
This message does not cause compilation to fail, but you should address this problem
because using two different variables to do two different things will cause very hard to detect
logical errors.
General Errors
These errors specify problems with the program that are more serious than an undefined
variable. They are not related to the code in the Program, but the way that the compiler was
called.
Syntax Errors
These are errors related to specific lines in the PLC program. Usually the offending line and
column number is listed along with the specific error. Sometimes the row is one farther down
the program than it should be so look around the area specified.
Compilation Failed
This message occurs when there are problems in the source file. It is displayed as the last
message after other error messages. This message will not appear if there are too many
errors.
Undefined Label
This message occurs when a valid variable name is used without it being defined in the
definition section of the PLC program.
Invalid Action
This error occurs when doing something that is not allowed. This includes trying to store a
value into a Bit data type or a Constant define and failing to put a start location for a Range.
CONST1 IS 1 ;constant value
IF 1==1 THEN CONST1 = 10 ;cannot re-assign constant values
IF 1==1 THEN MEM1 = 10 ;cannot store Word values into Bits
IF 1==1 THEN .. OUT20 ;must include starting point for Range
IF 1==1 THEN SET W1 ;SET cannot be applied to Words
Rung Expected IF
The Keyword IF was not found after a valid STG reference.
STG2
1==1 THEN (OUT1)
Bad Definition
The attempt at defining a variable is not written correctly. Brackets and negative numbers are
not allowed. Constant defines are used for messaging mostly.
Const is [10] ; brackets cannot be used in the definition section of a PLC program
Assignment Error
This error occurs when a value is getting stored to a variable and it cannot be completed. One
example is to Index to a floating-point variable.
IF INP1 THEN W[10.4] = 1
DUMP
Use the DUMP PLC command to print all of the values of the first 64 Word type variables to
disk. This can be called at any time to check status words or ATC bin position in a certain
stage. Make sure to call this infrequently because it does take quite a long time to write to
disk compared to the time to execute the PLC program once.
Use Stages
Group new features into a Stage so that it can be turned on and off to check for problems.
Use more stages for more complex features to narrow down where you need to troubleshoot.
DriveBus
These faults occur when the communication on the DriveBus is disrupted. The DriveBus goes
out on fibers 4 and 5 from the MPU11 and across the Drive Communication In/Out wire
connections on the ALLIN1DC, Optic4 and DC3IOB. If any of these connections exist and are
checked in the PLC program correctly, they will help diagnose connection problems.
PLCBus
The PLCBus also should be checked in the PLC program to make sure that communication is
in a good state. There should be checks for the Fibers 1 and 3 and miniPLCBus connections
if expansion boards are used.
; Mpu11 based systems have the ability to invert, force and/or select a custom
; debounce time on PLC inputs 1-240 using SV_PLC_DEBOUNCE_1-SV_PLC_DEBOUNCE_64.
; Jog Panel inputs are modified in the same manner using SV_JOG_LINK_DEBOUNCE_1
; -SV_JOG_LINK_DEBOUNCE_64. See system variable section for more information.
; The Mpu11 board includes connections for several types of auxiliary I/O.
; 4 digital "high speed" inputs (INP769-772) typically used for probe/TT1
; related functions, 3 auxiliary digital inputs (INP784-786), 11 Digital inputs
; used for MPG increment and axis selection and 2 auxiliary digital outputs
; (Out770-771).
; ALLIN1DC Physical I/O: While each ALLIN1DC that is installed reserves (maps)
; 16 inputs and 16 Outputs, only 16 inputs and 9 outputs are accessible through
; hardware.
; Digital Inputs: The ALLIN1DC provides 16 inputs, 10 of which are available for
; general purpose use. The first 6 inputs (1-6) are dedicated for limit switch
; use and must be either wired to a NC limit switch or defeated. All 16 inputs
; can be configured (in banks of 4) for 5, 12 or 24VDC operation in either a
; sourcing or sinking configuration.
; Analog input: The ALLIN1DC provides a single 12 bit analog input which is
; mapped to inputs 241-252. LSB = 241. This input can be configured for the
; following input:
; 1. 0 - 5VDC
; 2. 0 - 10VDC
; 3. -5 - +5VDC
; 4. -10 - +10VDC
;----------------------------------------------------------------
; CONSTANT DEFINITIONS
;----------------------------------------------------------------
AXIS_FLT_CLR IS 5378;(2+256*21)
PLC_INFLT IS 5634;(2+256*22)
PLC_OUTFLT IS 5890;(2+256*23)
PLC_FLT_CLR IS 6146;(2+256*24)
SPINDLE_FAULT_MSG IS 7681;(1+256*30)
PROBE_FAULT_MSG IS 8705;(1+256*34)
KB_JOG_MSG IS 8962;(2+256*35)
LUBE_FAULT_MSG IS 9217;(1+256*36)
LUBE_WARNING_MSG IS 9218;(2+256*36)
PROBE_JOG_FAULT_MSG IS 9473;(1+256*37)
MIN_SPEED_MSG IS 9730;(2+256*38)
SOFTWARE_EXIT_MSG IS 9985;(1+256*39)
;----------------------------------------------------------------
; INPUT DEFINITIONS
; Closed = 1 (green) Open = 0 (red)
;----------------------------------------------------------------
Ax1_MinusLimitOk IS INP1
Ax1_PlusLimitOk IS INP2
Ax2_MinusLimitOk IS INP3
Ax2_PlusLimitOk IS INP4
Ax3_MinusLimitOk IS INP5
Ax3_PlusLimitOk IS INP6
;spare IS INP7
;spare IS INP8
LubeOk IS INP9 ;Lube is "ok" when input is closed (*)
SpindleInverterOk IS INP10 ;Inverter is "ok" when input is closed (*)
EStopOk IS INP11
SpinLowRange IS INP12
;spare IS INP13
;spare IS INP14
;spare IS INP15
;spare IS INP16
;If a PLC expansion board (PLCADD1616) is used, the additional inputs will
;begin at input 17.
;----------------------------------------------------------------
; INP769 - INP784 encompass the MPU11 onboard input connections
; which are generally used for MPG and probing functions.
;----------------------------------------------------------------
MechanicalProbe IS INP769
DSPProbe IS INP770
ProbeDetect IS INP771
ProbeAux IS INP772
MPG_Inc_X_1 IS INP773
MPG_Inc_X_10 IS INP774
MPG_Inc_X_100 IS INP775
MPG_AXIS_1 IS INP776
MPG_AXIS_2 IS INP777
MPG_AXIS_3 IS INP778
MPG_AXIS_4 IS INP779
MPG_AXIS_5 IS INP780
MPG_AXIS_6 IS INP781
MPG_AXIS_7 IS INP782
MPG_AXIS_8 IS INP783
;----------------------------------------------------------------
; ALLIN1DC PLC Output Definitions
; Logic 1 = OUTPUT ON (Green), 0 = OUTPUT OFF (Red)
;----------------------------------------------------------------
; These bits control the actual analog hardware output on the ALLIN1DC.
; Output = 12bit (0-4095) 0-10VDC.
SpinAnalogOutBit0 IS OUT241
SpinAnalogOutBit1 IS OUT242
SpinAnalogOutBit2 IS OUT243
SpinAnalogOutBit3 IS OUT244
SpinAnalogOutBit4 IS OUT245
SpinAnalogOutBit5 IS OUT246
SpinAnalogOutBit6 IS OUT247
SpinAnalogOutBit7 IS OUT248
SpinAnalogOutBit8 IS OUT249
SpinAnalogOutBit9 IS OUT250
SpinAnalogOutBit10 IS OUT251
SpinAnalogOutBit11 IS OUT252
MPG_LED_OUT IS OUT769
;----------------------------------------------------------------
; Memory Bit Definitions
;----------------------------------------------------------------
PLCExecutorFault_M IS MEM1
SoftwareNotReady_M IS MEM2 ; 0 = okay, 1 = CNC11 not running/ready
MPGManOffFlag_M IS MEM3
Ax1PlusJogDisabled_M IS MEM11
Ax1MinusJogDisabled_M IS MEM12
Ax2PlusJogDisabled_M IS MEM13
Ax2MinusJogDisabled_M IS MEM14
Axis1FiberOk_M IS MEM70
Axis2FiberOk_M IS MEM71
Axis3FiberOk_M IS MEM72
Axis4FiberOk_M IS MEM73
Axis5FiberOk_M IS MEM74
Axis6FiberOk_M IS MEM75
Axis7FiberOk_M IS MEM76
Axis8FiberOk_M IS MEM77
ProbeMsgSent_M IS MEM78
true IS MEM81
SpinLowRange_M IS MEM82
SpinHighRange_M IS MEM85
SpindlePause_M IS MEM86
OnAtPowerUp_M IS MEM200
LimitTripped IS MEM208
LastProbeMode_M IS MEM210
;----------------------------------------------------------------
; Jog panel keys are referenced as JPI1 through JPI256. Alternatively,
; jog panel inputs can also be referenced as INP1057-INP1312.
;----------------------------------------------------------------
; Definitions follow JOGBOARD layout top to bottom, left to right
;----------------------------------------------------------------
; Feedrate Override Knob
;----------------------------------------------------------------
JpFeedOrKnobBit0 IS JPI193
JpFeedOrKnobBit1 IS JPI194
JpFeedOrKnobBit2 IS JPI195
JpFeedOrKnobBit3 IS JPI196
JpFeedOrKnobBit4 IS JPI197
JpFeedOrKnobBit5 IS JPI198
JpFeedOrKnobBit6 IS JPI199
;----------------------------------------------------------------
; Jog Panel Output (LED) Definitions
; Jog Panel LED's can be addressed as JPO1 - JPO256
; OR
; OUT1057 - OUT1312
;----------------------------------------------------------------
; Definitions follow JOGBOARD layout top to bottom, left to right
;
SpinOverPlusLED IS JPO1 ; Row 1 Column 1
SpinAutoModeLED IS JPO2 ; Row 1 Column 2
Aux1LED IS JPO3 ; Row 1 Column 3
Aux2LED IS JPO4 ; Row 1 Column 4
Aux3LED IS JPO5 ; Row 1 Column 5
;-------------------------------------------------------------------------------
; ---------SYSTEM VARIABLES--------
;
; For a complete list of System Variables and their functions, please see the
; MPU11 PLC manual.
;-------------------------------------------------------------------------------
; MPU11 based systems provide the PLC with the ability to read/write to a
; limited number of "System Variables". While the use of System Variables
; greatly expands PLC functionality, it comes with additional reponsibility on
; the part of the PLC programmer. Functionality that was once implemented as
; default behavior such as jogging, spindle speed, feedrate override, spindle
; gear ranges etc... is now implemented through System Variables in the PLC
; program. It is now the sole responsibilty of the PLC program to provide a
; method to jog an axis, override the spindle speed or feedrates or even map a
; jog panel keypress to a specific function. Pressing a jog key or Aux key
; won't DO anything unless the PLC assigns an action to the keypress. All jog
; panel functions MUST be explicitly implemented in the PLC program.
; ----IMPORTANT----
; Menu navigation in the CNC software requires that the escape key or Cycle
; Cancel key is used to back out of menus and screens. You must use the PLC
; program to map a jog panel key and/or a keyboard key to the Cycle Cancel
; System Variable (SV_PLC_FUNCTION_1 has been declared as "DoCycleCancel")
; in order to use the control. For example:
; The following lines map the escape key and Jog Panel Cycle Cancel key to
; produce a Cycle Cancel event:
; 2. Map MEM bit to identifier that describes what the keypress is used for.
; KbCycleCancel_M IS MEM401
; 4. Logic to cancel job if the escape key or cycle cancle key is pressed.
; IF (CycleCancelKey || KbCycleCancel_M) && SV_PROGRAM_RUNNING
; THEN (DoCycleCancel)
; Some of the information made available to the PLC through System Variables:
; 1. Encoder positions: SV_MPU11_ABS_POS_1 - SV_MPU11_ABS_POS_7
; 2. Parameter values: SV_MACHINE_PARAMETER_1 - SV_MACHINE_PARAMETER_999
; 3. Spindle Speed command from PC: SV_PC_DAC_SPINDLE_SPEED
; 4. PC Keyboard Keypress: SV_PC_FUNCTION_1 - SV_PC_FUNCTION_127
; 5. ...
;-------------------------------------------------------------------------------
; PLC Input manipulation - SV_PLC_DEBOUNCE_1 - SV_PLC_DEBOUNCE_64
; The System Variables in this section are used to modify the characteristics
; of PLC inputs 1-240. Each input can be inverted, forced or assigned a custom
; debounce time.
;-----------------------------Debounce Times------------------------------------
; SV_PLC_DEBOUNCE_61 - SV_PLC_DEBOUNCE_64 are used to define up to seven custom
; debounce times which can be selected for each input.
; SV_PLC_DEBOUNCE_61
; Unused:Bits 0-15 (Selection 0)
; 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0
; SV_PLC_DEBOUNCE_62
; As mentioned above, each 32 bit word defines the charactersitics for 4 inputs.
; SV_PLC_DEBOUNCE_1 defines the characteristics of INP1, INP2, INP3 & INP4 and
; so on through SV_PLC_DEBOUNCE_60 which handles INP237, INP238, INP239&INP240.
; The behavior of an input is set as follows:
; Declare a W32:
; Inputs_9_12_W IS W1
; use BITSET or BITRST
; if 1 == 1 THEN bitset Inputs_9_12_W 14 ;invert INP10 (bit14)
;-------------------------------------------------------------------------------
; PLC Jog Panel input manipulation - The System Variables in this section are
; used to modify the characteristics of the Jog Panel keys. The jog panel keys
; can be configured in the same manner as the PLC inputs and use debounce times
; as selected/set in SV_PLC_DEBOUNCE_61 - SV_PLC_DEBOUNCE_64.
;-----------------------------------------------------------------------------
;----------------------------------------------------------------
; System variables: Jog Panel Functions
;----------------------------------------------------------------
; Jog panel functions
;Invalid IS SV_PLC_FUNCTION_0
DoCycleCancel IS SV_PLC_FUNCTION_1
DoCycleStart IS SV_PLC_FUNCTION_2
DoToolCheck IS SV_PLC_FUNCTION_3
SelectSingleBlock IS SV_PLC_FUNCTION_4
SelectX1JogInc IS SV_PLC_FUNCTION_5
SelectX10JogInc IS SV_PLC_FUNCTION_6
SelectX100JogInc IS SV_PLC_FUNCTION_7
SelectUserJogInc IS SV_PLC_FUNCTION_8
SelectIncContJog IS SV_PLC_FUNCTION_9
SelectFastSlowJog IS SV_PLC_FUNCTION_10
SelectMpgMode IS SV_PLC_FUNCTION_11
DoAx1PlusJog IS SV_PLC_FUNCTION_12
DoAx1MinusJog IS SV_PLC_FUNCTION_13
DoAx2PlusJog IS SV_PLC_FUNCTION_14
DoAx2MinusJog IS SV_PLC_FUNCTION_15
DoAx3PlusJog IS SV_PLC_FUNCTION_16
DoAx3MinusJog IS SV_PLC_FUNCTION_17
DoAx4PlusJog IS SV_PLC_FUNCTION_18
DoAx4MinusJog IS SV_PLC_FUNCTION_19
DoAx5PlusJog IS SV_PLC_FUNCTION_20
DoAx5MinusJog IS SV_PLC_FUNCTION_21
DoAx6PlusJog IS SV_PLC_FUNCTION_22
DoAx6MinusJog IS SV_PLC_FUNCTION_23
DoAux1Key IS SV_PLC_FUNCTION_24
DoAux2Key IS SV_PLC_FUNCTION_25
DoAux3Key IS SV_PLC_FUNCTION_26
DoAux4Key IS SV_PLC_FUNCTION_27
DoAux5Key IS SV_PLC_FUNCTION_28
DoAux6Key IS SV_PLC_FUNCTION_29
DoAux7Key IS SV_PLC_FUNCTION_30
DoAux8Key IS SV_PLC_FUNCTION_31
DoAux9Key IS SV_PLC_FUNCTION_32
DoAux10Key IS SV_PLC_FUNCTION_33
SelectRapidOverride IS SV_PLC_FUNCTION_34
SelectManAutoSpindle IS SV_PLC_FUNCTION_35
DoSpindleStart IS SV_PLC_FUNCTION_37
;----------------------------------------------------------------
; System variables: Keyboard jogging functions
;----------------------------------------------------------------
;-------------------------------------------------------------------------------
; Keyboard Jogging Keys - The System Variables in this section inform the PLC
; that a PC keyboard keypress has occured. Keep in mind that some key presses
; only come down while the keyboard jogging screen is enabled (alt-j) and that
; NONE of these keys not perform ANY default actions unless programmed to do so.
; The assignments provided below are for reference only. For an example of
; mapping a keyboard key press to an MPU11 action, see the logic assigned to
; KbCycleStart_M or KbCycleCancel_M.
;
;Note:
; Keypresses are sent down as individual keys. It is the responsibility of
; the PLC programmer to insure that a keypress is only acted on at the
; appropriate times.
; The "SV_PC_VIRTUAL_JOGPANEL_ACTIVE" system variable can be used to prevent
; a keypress form being acted on unless the keyboard jog screen is being
; displayed. NOTE The above,29 character sys variable is mapped to
; KbJpActive_M (MEM80) to make it a "little" shorter......
;-------------------------------------------------------------------------------
Kb_a IS SV_PC_KEYBOARD_KEY_60
Kb_b IS SV_PC_KEYBOARD_KEY_79
Kb_c IS SV_PC_KEYBOARD_KEY_77
Kb_d IS SV_PC_KEYBOARD_KEY_62
Kb_e IS SV_PC_KEYBOARD_KEY_41
Kb_f IS SV_PC_KEYBOARD_KEY_63
Kb_g IS SV_PC_KEYBOARD_KEY_64
Kb_h IS SV_PC_KEYBOARD_KEY_65
Kb_i IS SV_PC_KEYBOARD_KEY_46
Kb_j IS SV_PC_KEYBOARD_KEY_66
Kb_k IS SV_PC_KEYBOARD_KEY_67
Kb_l IS SV_PC_KEYBOARD_KEY_68
Kb_m IS SV_PC_KEYBOARD_KEY_81
Kb_n IS SV_PC_KEYBOARD_KEY_80
Kb_o IS SV_PC_KEYBOARD_KEY_47
Kb_p IS SV_PC_KEYBOARD_KEY_48
Kb_q IS SV_PC_KEYBOARD_KEY_39
Kb_r IS SV_PC_KEYBOARD_KEY_42
;----------------------------------------------------------------
; M functions - The System Variables in this section inform the
; PLC that an M function has been requested.
;----------------------------------------------------------------
M3 IS SV_M94_M95_1 ;(Spindle CW)
M4 IS SV_M94_M95_2 ;(Spindle CCW)
M8 IS SV_M94_M95_3 ;(Flood On)
M10 IS SV_M94_M95_4 ; Clamp
M7 IS SV_M94_M95_5 ;(Mist)
; IS SV_M94_M95_6 ;
; IS SV_M94_M95_7 ;
; IS SV_M94_M95_8 ;
; IS SV_M94_M95_9 ;
; IS SV_M94_M95_10;
; IS SV_M94_M95_11;
; IS SV_M94_M95_12;
; IS SV_M94_M95_13;
; IS SV_M94_M95_14;
; IS SV_M94_M95_15;
; IS SV_M94_M95_16;
;----------------------------------------------------------------
; Word Definitions (int32)
;----------------------------------------------------------------
ErrorCode_W IS W1
TwelveBitSpeed_W IS W2
LubeAccumTime_W IS W3
KbOverride_W IS W4
FeedrateKnob_W IS W5
;----------------------------------------
; Word Definitions cont. (f32)
;----------------------------------------
SpinRangeAdjust IS FW1
RPMPerBit_FW IS FW2
CfgMinSpeed_FW IS FW3
CfgMaxSpeed_FW IS FW4
TwelveBitSpeed_FW IS FW5
SpinSpeedCommand_FW IS FW6
;------------------------------------
; One Shot Definitions
;------------------------------------
IncrContPD IS PD1
SlowFastPD IS PD2
MpgPD IS PD3
SingleBlockPD IS PD4
FeedHoldPD IS PD5
SpinAutoManPD IS PD6
SpindlePlusPD IS PD7
SpinOverMinusPD IS PD8
SpinOver100PD IS PD9
SpinStartPD IS PD10
SpinStopPD IS PD11
SpinCWPD IS PD12
SpinCCWPD IS PD13
F9PD IS PD14
x1JogPD IS PD15
x10JogPD IS PD16
x100JogPD IS PD17
Aux11KeyPD IS PD18
RapidOverPD IS PD19
CoolantAutoManualPD IS PD21
CoolantFloodPD IS PD22
CoolantMistPD IS PD23
ToolCheckPD IS PD24
JogProbeFaultPD IS PD25
RigidTapPD IS PD26
;----------------------------------------------------------------
; Timer Definitions
;----------------------------------------------------------------
; 1000 = 1 second for all timers.
;
MsgClear_T IS T1
SleepTimer IS T2
CycloneStatus_T IS T3
Initialize_T IS T4
LubeM_T IS T13
LubeS_T IS T14
;----------------------------------------------------------------
; Stage Definitions
;----------------------------------------------------------------
WatchDogStage IS STG1
InitialStage IS STG2
JogPanelStage IS STG3
MainStage IS STG4
AxesEnableStage IS STG5
SpindleStage IS STG6
MPGStage IS STG7
CheckCycloneStatusStage IS STG8
LoadParametersStage IS STG9
KeyboardEventsStage IS STG10
LubeUsePumpTimersStage IS STG13
LubeUsePLCTimersStage IS STG14
SetErrorStage IS STG50
BadErrorStage IS STG51
;#############################################################################
; Program Start
;#############################################################################
;=============================================================================
WatchDogStage
;=============================================================================
;=============================================================================
InitialStage
;=============================================================================
IF 1==1 THEN SET true,
SET OnAtPowerUp_M,
SET AxesEnableStage,
SET MainStage,
SET JogPanelStage,
SET LoadParametersStage,
SET MPGStage,
SET PLCBus_Oe_M,
RST DriveComFltIn_M,
RST DriveComFltOut_M,
RST PLCFault_M,
CycloneStatus_T = 300,
ErrorCode_W = MSG_CLEARED_MSG,
RST BadErrorStage,
SET SetErrorStage,
Initialize_T = 1000, SET Initialize_T,
RST InitialStage
;=============================================================================
LoadParametersStage
;=============================================================================
; There are two methods of control for the lube pump and they are set by CNC11
; Machine Parameter 179, where the value is between 0 - 65535 and is formatted
; as MMMSS where MMM is a time in minutes and SS is a time in seconds.
;
; METHOD 1 (SS == 0) For lube pumps with internal timers.
; METHOD 2 (SS != 0) For lube pumps with no timers (controlled soley by PLC).
;
; Load lube pump times from P179 and convert to milliseconds.
;=============================================================================
LubeUsePumpTimersStage
;=============================================================================
;=============================================================================
LubeUsePLCTimersStage
;=============================================================================
;
; METHOD 2 (SS != 0) For lube pumps that do not have internal timers.
;
; When using this method P179 should be set so the lube turns on
; every MMM minutes for SS seconds.
;
; Example 1.
; To set the lube pump power to come on for 5 seconds
; every 10 minutes, set P179 = 1005.
; MMMSS
; Example 2.
; To set the lube pump power to come on for 30 seconds
; every 2 hours, set P179 = 12030
; MMMSS
;
; This method will accumulate time while a program is running until
; it reaches MMM minutes, at which time it will apply power
; for SS seconds (unless E-stop is engaged) and then start over. It is
; possible with frequent use of E-stop that a lube cycle is cut short.
;
;=============================================================================
KeyboardEventsStage
;=============================================================================
; This stage handles functions that are required for menu navigation
; by CNC11, require multiple keypresses and/or need to be interlocked
; with SV_PC_VIRTUAL_JOGPANEL_ACTIVE and/or AllowKbInput_M. Regarding
;-------------------------Not interlocked------------------------
; The code for cycle cancel has been moved to the main stage.
; It is commented out below but remains for reference
;Cycle Cancel
;if Kb_Escape THEN (KbCycleCancel_M)
;Rapidoverride: Ctrl-r
if Kb_r && (Kb_L_Ctrl || Kb_R_Ctrl) THEN (KbTogRapidOver_M)
;KbToolCheck_M: Ctrl-t
if Kb_t && (Kb_L_Ctrl || Kb_R_Ctrl) && AllowKbInput_M then (KbToolCheck_M)
;KbTogSingleBlock_M: ctrl-b
if Kb_b && (Kb_L_Ctrl || Kb_R_Ctrl) && AllowKbInput_M then (KbTogSingleBlock_M)
;KbTogSpinAutoMan_M: ctrl-a
if Kb_a && (Kb_L_Ctrl || Kb_R_Ctrl) && AllowKbInput_M then (KbTogSpinAutoMan_M)
;KbSpinCW_M: ctrl-c
IF Kb_c && (Kb_L_Ctrl || Kb_R_Ctrl) && AllowKbInput_M THEN SET KbSpinCW_M,
RST KbSpinCCW_M
;KbSpinCCW_M: ctrl-w
IF Kb_w && (Kb_L_Ctrl || Kb_R_Ctrl) && AllowKbInput_M THEN SET KbSpinCCW_M,
RST KbSpinCW_M
;KbSpinStart_M: ctrl-s
if Kb_s && (Kb_L_Ctrl || Kb_R_Ctrl) && AllowKbInput_M then (KbSpinStart_M)
;KbSpinOver100_M: ctrl + /
IF Kb_Slash && (Kb_L_Ctrl || Kb_R_Ctrl) && AllowKbInput_M
THEN (KbSpinOver100_M)
;KbTogCoolAutoMan_M: Ctrl-m
if Kb_m && (Kb_L_Ctrl || Kb_R_Ctrl) && AllowKbInput_M then (KbTogCoolAutoMan_M)
;KbFloodOnOff_M: Ctrl-n
if Kb_n && (Kb_L_Ctrl || Kb_R_Ctrl) && AllowKbInput_M then (KbFloodOnOff_M)
;KbMistOnOff_M: Ctrl-k
if Kb_k && (Kb_L_Ctrl || Kb_R_Ctrl) && AllowKbInput_M then (KbMistOnOff_M)
;KbIncreaseJogInc_M: "insert"
if Kb_Ins && AllowKbInput_M && KbJpActive_M
then (KbIncreaseJogInc_M)
if KbIncreaseJogInc_M && x1JogLED && !X1_M && !X10_M && !X100_M
then set X10_M
if KbIncreaseJogInc_M && x10JogLED && !X1_M && !X10_M && !X100_M
then set X100_M
;KbDecreaseJogInc_M: "delete"
if Kb_Del && AllowKbInput_M && KbJpActive_M
then (KbDecreaseJogInc_M)
if KbDecreaseJogInc_M && x10JogLED && !X1_M && !X10_M && !X100_M
then set X1_M
if KbDecreaseJogInc_M && x100JogLED && !X1_M && !X10_M && !X100_M
then set X10_M
;KbJogAx2Plus_M: Up arrow
if Kb_Up && AllowKbInput_M && KbJpActive_M THEN (KbJogAx2Plus_M)
;KbJogAx3Plus_M: Page up
if Kb_PgUp && AllowKbInput_M && KbJpActive_M THEN (KbJogAx3Plus_M)
;KbAx4MinusJog: "end"
if Kb_End && AllowKbInput_M && KbJpActive_M
then (KbJogAx4Minus_M)
;=============================================================================
MPGStage
;=============================================================================
; MPG Functions
; Turn on/off Jog Panel MPG LED & on the MPG
IF MPGKey then (MpgPD)
IF MpgPD && MPGLED then set MPGManOffFlag_M
IF !SV_MPG_1_ENABLED || (MpgPD && !MPGLED) then RST MPGManOffFlag_M
;--X10
IF x10JogKey THEN (x10JogPD)
IF x10JogPD || X10_M || (MPG_Inc_X_10 && MPGLED)
THEN RST x1JogLED, SET x10JogLED, RST x100JogLED
;--X100
IF x100JogKey THEN (x100JogPD)
IF x100JogPD || X100_M || (MPG_Inc_X_100 && MPGLED)
THEN RST x1JogLED, RST x10JogLED, SET x100JogLED
;--MPG 1 Enable
IF MPG_AXIS_1 || MPG_AXIS_2 || MPG_AXIS_3 || MPG_AXIS_4 ||
MPG_AXIS_5 || MPG_AXIS_6 || MPG_AXIS_7 || MPG_AXIS_8
THEN (SV_MPG_1_ENABLED)
;=============================================================================
JogPanelStage
;=============================================================================
;--Select Incremental or Continuous Jog Mode
IF IncrContKey || KbTogIncContJog_M THEN (IncrContPD)
IF (IncrContPD && !IncrContLED) || OnAtPowerUp_M THEN SET IncrContLED
IF (IncrContPD && IncrContLED) THEN RST IncrContLED
;--Toolcheck
;-----------------------------------------------------------------------
; 2. Scale this value to a 0-200 value (0-200%)
;-----------------------------------------------------------------------
IF true THEN FeedrateKnob_W = (FeedrateKnob_W/127.5)*100
;-----------------------------------------------------------------------
; 3. Determine whether to use FeedrateKnob_W or KbOverride_W
;-----------------------------------------------------------------------
; This section determines when to use the feedrate override value sent down
; by the jogpanel (FeedrateKnob_W) or the feedrate override as determined
; by the PLC monitoring the keyboard override keys (KbOverride_W).
;-----------------------------------------------------------------------------
; At powerup, default feedrate override is jog panel (FeedrateKnob_W)
; To use both keyboard or jogpanel overrides set p170 to 0 (default)
; To use jogpanel override only set p170 to 2
; To use keyboard only set p170 to 4
;-----------------------------------------------------------------------------
IF OnAtPowerUp_M && KbOverOnly_M || KbFeedOver100_M THEN KbOverride_W = 100
;-----------------------------------------------------------------------
; 4 & 5. Limit override percentage to value set in Parameter 39
;-----------------------------------------------------------------------
;------------------Limit final override percentage to parm 39-------------------
if FinalFeedOverride_W > SV_MACHINE_PARAMETER_39
THEN FinalFeedOverride_W = SV_MACHINE_PARAMETER_39
;----------------------------------------------
; Override Controls
; It is important that the plc program only writes to SV_PLC_Feedrate_Knob once per pass
;----------------------------------------------
; Override control bit for the feedrate override
; 1 == feedrate override knob will effect feedrate
;-----------------------------------------------------------------------
; 6. Send override percentage to CNC11
;-----------------------------------------------------------------------
;----------------Send override to PC for modification if needed---------------
if true THEN SV_PLC_Feedrate_Knob = FinalFeedOverride_W
;-----------------------------------------------------------------------
; 7. Copy the feedrate override sent from the PC to the MPU11.
;-----------------------------------------------------------------------
;--------------------------------------------------------------------------
; Normally a number from 0.0-2.0, no limitations although V will not exceed
; Vmax. A negative number in here would be extremely bad.
;--------------------------------------------------------------------------
IF true THEN SV_PLC_FEEDRATE_OVERRIDE = SV_PC_FEEDRATE_PERCENTAGE/100.0
;--Coolant Functions
;--Spindle Control
;-------------------------------------------------------------
; JOGBOARD SPINDLE CONTROL
; Spindle Auto Mode / Manual mode toggles via Auto/Man jog panel key
; CW/CCW jog keys determine spindle direction in manual mode
; M3/M4 system variables determine spindle direction in Auto mode
; Spindle can be stopped and restarted in auto mode using
; spin stop/start jog keys
;-------------------------------------------------------------
;--Select Auto or Manual Spindle Operation Mode
;Triggers to Toggle Auto/Manual Spindle Mode
IF SpinAutoManKey || KbTogSpinAutoMan_M THEN (SpinAutoManPD)
;-------------------------------------------------------------------------------
; Turn spindle on/off
;-------------------------------------------------------------------------------
IF ProbeDetect && SpinStartPD THEN set ProbeFault_M
;-------------------------------------------------------
; SPINDLE OVERRIDE CONTROL
; Jogboard (-, +, and 100% keys),
; Keyboard "ctrl" + "<", "ctrl" + ">", "ctrl" + "/"
;-------------------------------------------------------
IF SpinOverPlusKey || KbIncSpinOver_M
THEN SV_PLC_SPINDLE_KNOB = SV_PLC_SPINDLE_KNOB + 1
IF SpinOverMinusKey || KbDecSpinOver_M
THEN SV_PLC_SPINDLE_KNOB = SV_PLC_SPINDLE_KNOB - 1
IF SpinOver100Key || KbSpinOver100_M || OnAtPowerUp_M
THEN SV_PLC_SPINDLE_KNOB = 100
;----------------------------------------------------------------
; Read commanded spindle speed, max & min
;
; ***NOTE*** SV_PC_COMMANDED_SPINDLE_SPEED already has override
; factored in.
;----------------------------------------------------------------
IF True THEN SpinSpeedCommand_FW = SV_PC_COMMANDED_SPINDLE_SPEED,
CfgMinSpeed_FW = SV_PC_CONFIG_MIN_SPINDLE_SPEED,
CfgMaxSpeed_FW = SV_PC_CONFIG_MAX_SPINDLE_SPEED
;----------------------------------------------------------------
; If commanded spindle speed is < Min Spin Speed * SpinRangeAdjust
; & commanded spindle speed > 0, force to commanded spindle speed
; = min spin speed value * SpinRangeAdjust.
;----------------------------------------------------------------
IF (SpinSpeedCommand_FW > 0.0) &&
(SpinSpeedCommand_FW < (CfgMinSpeed_FW * SpinRangeAdjust))
THEN SpinSpeedCommand_FW = (CfgMinSpeed_FW * SpinRangeAdjust),
ErrorCode_W = MIN_SPEED_MSG
;---------------------------------------------------------------------------
; If SpinSpeedCommand_FW > Max Spin Speed * SpinRangeAdjust, force
; SpinSpeedCommand_FW = max spin speed value * SpinRangeAdjust.
;---------------------------------------------------------------------------
IF SpinSpeedCommand_FW > (CfgMaxSpeed_FW * SpinRangeAdjust)
THEN SpinSpeedCommand_FW = (CfgMaxSpeed_FW * SpinRangeAdjust)
;----------------------------------------------------------------
; Convert Spindle "S" command to 12 bit value for output to DAC
; Output to DAC
If true then WTB TwelveBitSpeed_W SpinAnalogOutBit0 12
;=============================================================================
CheckCycloneStatusStage
;=============================================================================
; Due to amount of time it takes to retrieve data from the cyclone, this stage
; is only called few times per second to help reduce scan time of the main PLC
; program.
;=============================================================================
AxesEnableStage
;=============================================================================
; Since CNC11 v3.03r24, the MPU11 has managed axis enables
; directly. The PLC program has no further responsibility
; for SV_ENABLE_AXIS_n
;(If there is any drive or drive fiber error, then AxisFault_M will have
; been set previously, which will cause SV_STOP to be set, and SV_MASTER_ENABLE
; to be reset, later in MainStage)
;=============================================================================
MainStage
;=============================================================================
;Do gather if commanded (uncomment and recompile for debugging purposes)
;IF Aux11Key THEN (Aux11KeyPD)
;If Aux11KeyPD THEN (SV_TRIGGER_PLOT_DUMP)
; Invert input 9
IF InvLubeOk_M THEN BITSET Inputs_9_12_W 6
IF !InvLubeOk_M THEN BITRST Inputs_9_12_W 6
; Invert input 10
IF InvSpinInverterOk_M THEN BITSET Inputs_9_12_W 14
IF !InvSpinInverterOk_M THEN BITRST Inputs_9_12_W 14
;----------------------------------------------------------------
; Probe protection while jogging
;----------------------------------------------------------------
If MechanicalProbe && !JogProbeFault_M && (DoAx1PlusJog || DoAx1MinusJog ||
DoAx2PlusJog || DoAx2MinusJog || DoAx3PlusJog || DoAx3MinusJog ||
DoAx4PlusJog || DoAx4MinusJog || DoAx5PlusJog || DoAx5MinusJog)
THEN (JogProbeFaultPD)
;--Clamp
IF M10 THEN (Clamp) ; cleared by M11 or by program not running
;--Handle Faults
if !EStopOk || PLCFault_M || SV_STALL_ERROR || SpindleFault_M ||
LubeFault_M || AxisFault_M || ProbeFault_M || OtherFault_M THEN set SV_STOP
IF EStopOk &&
!(PLCFault_M || SV_STALL_ERROR || SpindleFault_M || LubeFault_M ||
AxisFault_M || OtherFault_M || SoftwareNotReady_M || PLCExecutorFault_M)
THEN RST SV_STOP
;--M-Codes
; Reset these M-codes if not in CNC Program Running mode
IF !(SV_PROGRAM_RUNNING || SV_MDI_MODE) THEN RST M3, RST M4, RST M8, RST M7, RST M10
;================================================================
SetErrorStage
;================================================================
IF !((ErrorCode_W % 256 == 1) || (ErrorCode_W % 256 == 2)) THEN JMP BadErrorStage
IF true THEN MSG ErrorCode_W
If ErrorCode_W != MSG_CLEARED_MSG Then MsgClear_T = 1000, set MsgClear_T
;=============================================================================
BadErrorStage
;=============================================================================
IF true THEN AsyncMsg_W = 2+256*100, MSG AsyncMsg_W, AsyncMsg_W = 0
IF True THEN RST BadErrorStage
Aux10-
Spindle Stop Spindle Start Aux11- Aux12-
Key JPI18/INP1074
Key JPI16/INP1072 Key JPI17/INP1073 Key JPI19/INP1075 Key JPI20/INP1076
LED JPO18/OUT1074
LED JPO16/OUT1072 LED JPO17/OUT1073 LED JPO19/OUT1075 LED JPO20/OUT1076
Blank-
Axis4+ Axis2+ Blank- Axis3+
Key JPI32/INP1088
Key JPI31/INP1087 Key JPI33/INP1089 Key JPI34/INP1090 Key JPI35/INP1091
LED JPO32/OUT1088
LED JPO31/OUT1087 LED JPO33/OUT1089 LED JPO34/OUT1090 LED JPO35/OUT1091
CYCLE CANCEL SINGLE BLOCK TOOL CHECK* FEED HOLD* CYCLE START*
Key JPI46/INP1102 Key JPI47/INP1103 Key JPI48/INP1104 Key JPI49/INP1105 Key JPI50/INP1106
LED JPO46/OUT1102 LED JPO47/OUT1103 LED JPO50/OUT1106 LED JPO48/OUT1104 LED JPO49/OUT1105
Bad Example:
IF EStop THEN SET SV_STOP
IF !EStop THEN RST SV_STOP
IF LowLube THEN SET SV_STOP
Good Example:
IF EStop THEN SET TEMP_SV_STOP
IF !EStop THEN RST TEMP_SV_STOP
IF LowLube THEN SET TEMP_SV_STOP
IF TEMP_SV_STOP THEN SET SV_STOP
IF !TEMP_SV_STOP THEN RST SV_STOP
Bad Example:
IF SV_STALL_ERROR THEN (MEM1)
IF !SV_STALL_ERROR THEN (MEM2)
Good Example:
IF TRUE THEN TEMP_SV_STALL_ERROR = SV_STALL_ERROR
IF TEMP_SV_STALL_ERROR THEN (MEM1)
IF !TEMP_SV_STALL_ERROR THEN (MEM2)
Note that all system variables are readable by either the PLC or CNC11. The following tables
indicate who, either the PLC or CNC11 software, can change the state of the Bits or Words.
In some cases there are System Variables that CNC11 and the PLC program can write to and
it is so noted.
SV_PC_MINI_PLC_ONLINE I32 Online bits for PLCADD1616 and other expansion PLC
modules.
Bit Function
0 1 = miniPLC1 is
online
... ...
15 1 = miniPLC16
online
16-31 Reserved
ALLIN1DC/DC3IOB
Bit Description
0 Current Setting Low Bit
1 Current Setting High Bit
2 High power enable - FETs
are installed to handle 15A
current setting
3 Drive master/slave – 1 =
communicating on fibers, 0
= comm. on wires
4 Aux 1 jumper state – 1 =
jumper block removed, 0 =
jumper block in place
5 Aux 2 jumper state – 1 =
jumper block removed, 0 =
jumper block in place
6 Reserved
7 Reserved
8-15 Reserved
DC1
Bit Description
0 Current Setting Low Bit
1 Current Setting High Bit
2 High power enable - FETs
are installed to handle 15A
current setting
3 Reserved
4 Reserved
5 Spare jumper state – 1 =
jumper block removed, 0 =
jumper block in place
6 Plus Limit State
7 Minus Limit State
8-15 Reserved
Optic4
Bit Description
0-10 Reserved
11 Quadrature Error: Incorrect
bit00 FatalError
Indicates a serious error. The PLC program should monitor
this bit on all AC1 drives and treat it as an emergency stop.
This bit is cleared by the AC1 drive on the rising edge of
SV_MASTER_ENABLE, but if the condition persists, the
PLC program will not see a change. Therefore, if the
FatalError bit is still on about a second after
SV_MASTER_ENABLE has been turned back on (after a
release of E-stop), then the fault should be thrown again.
Other bits in this variable can be examined to determine the
specific reason for the FatalError, but a PLC program does
not need to handle every single error with a custom
message as the state of all these bits can be viewed in the
Log Options menu of CNC11, using the <F5> HSC function
bit01 Warning
Inidicates a warning condition. Other bits in this variable can
be examined to determine the specific reason for the
warning.
bit02 ErrorUVWInvalid
bit03 ErrorUVWBadTransition
bit04 ErrorUVWBadSize
bit05 EncoderOk
bit06 QuadratureError
bit07 EncoderMismatch
bit08 LineVoltageOn
bit09 OvercurrrentHighSide
bit10 OvercurrentLowSide
bit11 OvervoltageMotor
bit12 OvervoltageLine
bit13 BrakeResistorMissing
bit14 BrakeIGBTOpen
bit15 MotorTemperatureSwitch
bit16 HeatsinkTemperatureSwitch
bit17 PlusLimit
bit18 MinusLimit
bit19 DriveShutdown
bit20 BrakeOnTooMuch
bit21 OvercurrentSensor
bit22 WarningDriveHot
bit23 ErrorDriveTooHot
bit24 WarningMotorHot
bit25 AccelTooGreat
bit26 ADCOffsetOk
bit27 ErrorMotorTooHot
bit28 MoveSyncRunning
bit29 StepRunning
bit30 TuneRunning
bit31 ErrorParameterChange
SV_SD_DRIVE_x_STATUS I32 There are five of these variables that correspond to the
status of legacy SD drives.
Indicates a serious error. The PLC program should monitor
this bit for all drives and treat it as an emergency stop
condition. Other bits in this variable can be examined to
determine the specific cause, but it is recommended that
the PLC just echo this variable to W1-W44 so it can be
viewed using line PLC diagnostics in CNC11.
SV_SPINDLE_LOW_RANGE M This must be set for Rigid Tapping and display of spindle
speed to function correctly. In combination with
SV_SPINDLE_MID_RANGE above, up to four ranges are
supported.
SV_MPG_1_ENABLED M This MPG is enabled. This bit switches between MPG mode
and Vector controlled mode for all axes in this group. When
this is enabled the MPU11 will not process motion vectors
from the PC or allow Jogging.
SV_MPG_1_WINDUP_MODE M The MPG is in windup mode. This means the MPG will
move the total distance commanded by the MPG encoder
input. This mode is typically enabled for x1 and x10 mode.
This mode should be disabled for x100 mode. When
windup mode is disabled the MPG will try to keep up, but
will go off position if the MPG encoder counts too fast.
When this happens CNC11 will display the message “MPG
moving too fast”.
SV_MPG_1_OFFSET_MODE M The MPG is in Offset Mode. The MPG movement will be
added to the current Expected Position instead of setting
the Expected Position. In this mode the MPG is
independent and is allowed to command motion while
vectors are being processed.
SV_MPG_1_PLC_MPG_MODE M The MPG is in PLC Controlled Mode. The MPG encoder
input will be read from SV_MPG_1_OFFSET instead of the
actual encoder input. The plc program can change
SV_MPG_1_OFFSET which will cause the mpg axis to
move.
SV_MPG_2_ENABLED M See SV_MPG_1_ENABLED above.
SV_MPG_2_WINDUP_MODE M See SV_MPG_1_WINDUP_MODE above.
SV_MPG_2_OFFSET_MODE M See SV_MPG_1_OFFSET_MODE above.
SV_MPG_2_PLC_MPG_MODE M See SV_MPG_1_PLC_MPG_MODE above.
SV_MPG_1_AXIS_SELECT I32 The current selected axis for the first mpg (1-8)
SV_MPG_1_MULTIPLIER I32 The mpg multiplier value normally (1, 10, 100)
SV_MPG_1_PLC_OFFSET I32 MPG Offset, for PLC controlled MPG Inputs. This allows the
PLC to control the MPG through an Analog to Digital Input
rather than an encoder. This mode is enabled when the
PLCMPGmode bit is set.
SV_MPG_2_AXIS_SELECT I32 The current selected axis for the second mpg (1-8)
SV_MPG_2_MULTIPLIER I32 The mpg multiplier value normally (1, 10, 100)
SV_MPG_2_PLC_OFFSET I32 MPG Offset, for PLC controlled MPG Inputs. This allows the
PLC to control the MPG through an Analog to Digital Input
rather than an encoder. This mode is enabled when the
PLCMPGmode bit is set.
SV_MPG_3_AXIS_SELECT I32 The current selected axis for the third mpg (1-8)
SV_MPG_3_MULTIPLIER I32 The mpg multiplier value normally (1, 10, 100)
SV_MPG_3_PLC_OFFSET I32 MPG Offset, for PLC controlled MPG Inputs. This allows the
PLC to control the MPG through an Analog to Digital Input
rather than an encoder. This mode is enabled when the
PLCMPGmode bit is set.
SV_DRIVE_CONTROL_1 to _8 I32 High Speed Drive Control word (Lower 16 Bits) see Drive
documentation
DC1 Control
Bit Description
0-14 Reserved
15* Axis Enable
OPTIC4 Control
Bit Description
0-12 Reserved
13** Tach. Direction Inversion
14 Auxiliary Output
15* Axis Enable
Notes:
*MPU11 set this bit and will overwrite any attempt by the
PLC to set it.
**Set parameters 200-207 to negative values rather than
trying to change bit 13
SV_SPINDLE_DAC I32 Used for C Axis Lathe. When this bit is set, the MPU will
send the current value of SV_SPINDLE_DAC as the PID
output to the drive for the last axis configured as a “C axis”
When this mode is active, full power without motion and
position errors are disabled for the axis.
SV_NV_W1- I32 Nonvolatile memory.
SV_NV_W10 These system variables can be used in the same manner
as other I32 variables in the PLC program. Their values are
retained even when power is off. A PLC programmer can
expect any changes to these system variables to be written
to non-volatile memory within 2ms.
SV_SYS_COMMAND I32 Setting this value to a non-zero, positive number, will cause
the CNC software to launch a process and try to execute
the Windows batch file named
plc_system_command_n.bat, where n is the number the
SV_SYS_COMMAND is set to.
SV_INVERT_INP1_16_BITS I32 The lower 16 bits of each of these system variables is used
SV_INVERT_INP17_32_BITS to invert the indicated inputs, with the least significant bit
SV_INVERT_INP33_48_BITS mapped to the lower INP bit and the most significant bit
SV_INVERT_INP49_64_BITS mapped to the higher numbered INP.
SV_INVERT_INP65_80_BITS
SV_FORCE_INP1_16_BITS I32 The lower 16 bits of each of these system variables is used
SV_FORCE_INP17_32_BITS to force the state of the indicated inputs, with the least
Input Types
The Input tables in each of the manuals for these drives contain several headings that may
need clarification as to their exact purpose. The first is Input and this directly corresponds to
the value used in the PLC Program. Next, a heading called Type corresponds to the type of
Input that can be wired in. Within this column there are several labels which need to be
explained. Configurable indicates the voltage required for the Input can be customized.
Typical Centroid 5, 12 and 24VDC SIP resistors can be used. 12VDC Optoisolated means
that it must be 12VDC powering the Input and that it has signal isolation to prevent electrical
noise getting onto the circuit board. 5VDC only means that 5V is the maximum signal voltage
that can be wired to this input. It also does not provide any electrical isolation. Sourcing
means that the input must be connected to the Input common to turn on. Lastly, ADC is an
Analog-to-Digital Conversion. The ALLIN1DC currently is the only standard PLC that has this
functionality available for use in the PLC program, though there is also an ADD4AD4DA
expansion board that has four DAC outputs and four ADC inputs.
Output Types
The Output tables in the manuals also have similar columns including Type which again refers
to the type of Output that can be wired. The first types are Relay Outputs that may or may not
be fused depending on the specific Output. There are Single Throw and Double Throw relays.
The Single Throw has two pins associated with the output and there is continuity between
them only when the Output is SET. The Double Throw has three pins which are a so-called
Output Common, Normally Open and Normally closed. There is continuity between the
Normally Closed pin and the common when the Output is RST and continuity between the
Normally Open and common when the Output is SET. The next type is a DAC Output. This is a
Digital-to-Analog Converting output. The Bit number specified defines the range of discreet
values that can be commanded. Open Collector is an output, usually limited to 5VDC that
must be wired to an external relay for anything other than low current signals. It is much safer
to use a relay and another power supply than assume the output will not draw too much
current and damage the drive.
Warning: Always review the specific board manual that came with your system before
changing any wiring.
ALLIN1DC
The ALLIN1DC has 16 inputs and 9 outputs that may be used in the PLC program. The MPG
header has 14 Inputs and 3 outputs that can be used as General I/O in a customized
program. Typically it is better to get a PLC1616ADD card rather than using the MPG header,
DC3IOB
The DC3IOB has 30 Inputs and 31 Outputs usable in the PLC program. There is one analog
Output used for Spindle control. The first six inputs are dedicated to Limit switch wiring and
cannot be used for general purpose Inputs. Moreover the first two inputs are tied to the first
axis, the 3rd and 4th inputs to the second axis and likewise for the third. The firmware on the
drive shuts down motion in the direction of the Input that is tripped, regardless of CNC11
software Limit Switch setup. For the schematic and I/O map, reference the DC3IOB manual
on the Dealer Support site or with the literature you received in your kit.
GPIO4D
The DC3IOB has 30 Inputs and 31 Outputs usable in the PLC program. There is one analog
Output used for Spindle control and four analog Outputs that are not PLC accessible that are
used for 3rd party drive control. The first six Inputs are typically dedicated to Limit switch
wiring, but can be used for general purpose Inputs. Inputs and Outputs 17-20 are dedicated to
the axis enable and fault inputs respectively. For the schematic and I/O map, reference the
DC3IOB manual on the Dealer Support site or with the literature you received in your kit.
PLC Expansion
All of the PLCs in this chapter can expand the Inputs and Outputs with miniPLC expansion
boards. There are differing numbers of available ports so be sure to check the board manual
to determine the total I/O range. There are 16 Debouncable Input and Output slots each
capable of controlling 16 individual I/O for each board type. Each new board starts at a
multiple of 16. There are 32 non-Debouncable Input and Output slots with 16 controllable bits
which may be grouped as individual I/O or combined to produce one DAC. The slot
numbering starts at 0 and goes to 47.
Once the boards are plugged into the PLC and powered as directed by the main PLC board's
manual, power on the system and look in the mpu_info.txt file in the cncm or cnct directory.
This gives a breakdown of the Inputs and Outputs and what board is associated with them.
The order that the I/O appears is directly related to which ADD port it is plugged into. ADD1 is
first and ADD4 is last. Depending on which is the master PLC the ADD boards come in on the
next available slot.
See the individual board manuals for more in-depth documentation of PLC Expansion with
examples. MiniPLC devices must be plugged in when power is off on the drive to which they
ALLIN1DC
The expansion for the ALLIN1DC starts at Slot 1 and 16 because the onboard I/O take up the
first slot of Debounced and non-Debounced I/O.
DC3IOB
The expansion for the DC3IOB starts at Slots 2 and 15 for the Inputs and Slots 4 and 15 for
the Outputs.
GPIO4D
The expansion for the GPIO4D starts at Slots 2 and 15 for the Inputs and Slots 2 and 20 for
the Outputs.
Legacy IO2 (PLCIO2, RTK3) and Legacy RTK2 (RTK2, PLC5/15, PLC3/3)
Since CNC11 v3.10, there is support for programming legacy PLCs. To program a legacy PLC
with an MPU11, the MPU11 must be fitted with the LEGACYADD daughter card, and the
Control Configuration PLC type set to “IO2” or “RTK2”.
For PLCIO2 and RTK3, INP59-INP62 have been moved to INP34-INP37 and OUT59-OUT62
have been moved to OUT49-OUT52.
Compiler/Language Differences
The following sections represent the differences between CNC10 and CNC11 PLC
Programming paradigms and keywords.
Keywords Removed
In CNC10 there were several keywords (LDT, LTS, LMT, LCP) which have been removed in
CNC11. They are all replaced by System Variables.
Timers
Timer units in CNC10 were 10 ms increments, but now in CNC11 the units are 1 ms This
means that counting to 1000 in CNC10 takes 10 seconds whereas in CNC11 it would take 1
second.
Stages
In CNC11 when a Stage is reset all the variables inside retain their value, whereas in CNC10
all the variables are reset. Keep this in mind so that when a Jump is called or the Stage is
reset manually, variables that you want off should be turned off explicitly before leaving the
Stage. Be aware especially of One-Shots because in CNC10 when Jumping from one Stage
to another all Coiled Variables are turned off whereas in CNC11 they are not. Read more on
Stages in CNC11 here.
Bit
A Binary piece of information that can be on or off. For example, Inputs are Bits.
Integer Number
A positive or negative whole number. Examples include 15, -10, 0 and 1309921.
Floating-point Number
A positive or negative number with fractional components expressed to the right of a decimal
point. Examples include 2.1453, -15.2, 0.0, and 104.999999.
Range
The span of numbers that can be represented by a variable.
Precision
A measure of the number of bits a variable can express. This directly relates to how big a
number an integer variable can represent and how precise a number a floating-point variable
can represent. A more precise (higher bit count) floating-point number is less prone to round-
off error when comparing very large numbers with very small (ex: 1454394783237.35 –
0.00000001). More bits means longer processing time, so unless extreme accuracy is needed
the 32-bit version of variables should be used.
Data Type
A classification for variables that defines what kind of information they can hold and the range
of values they can represent. Further explanation for all the available data types can be found
here.
Define/Declare
Create an easier to understand identifier for any data type. These are conveniences for the
programmer to allow easier understanding of logic in a PLC program. Data types can be set
or checked directly, but a warning is issued by the compiler because it is considered bad
practice and can cause confusion. Examples are:
Estop IS INP11 ;input 11 on DC systems is typically E-Stop
Shift_Key IS SV_PC_KEYBOARD_KEY_74 ;pushing the shift key results in this System
;Variable being set high.
Constant
Any literal number or definition of a number. Typically definitions of constants are written in all
caps to differentiate from variables. Examples include:
10
2.5
ARM_FAULT_CODE IS 2561