// WORLD CELL:  AW6x00-755 Series / AW6x00-1255RH (lubeless) Series
//
// DATE: 6/8/18
// SW VERSION: YRC1000
// CREATED BY: Mike Katchmar
//
// This cell uses a RM2 positioner (no I/O).  The operator station now has an
// EtherNet/IP interface for non-safe signals.  This file will work with 1-3
// robot solutions.
//
//
// Base CIO File
//
// REV.0 Initial Release for DX200 - before first build
// REV.1 Changed hold logic, updated comments for I/O and address usage.
// REV.2 FSU User Message fixes.  Hold PB operation changed.
// REV.3 Hold changed to STR-NOT
// REV.4 Changed Start and ServoOn PBs to #7xxxx's for use in Simple Connect ladder.
// REV.4a Removed a comment in the header of this file to avoid confusion. No logic was changed.
// REV.6 Added AND Play to Robot Range alarm triggers.  This allows a
//       user to escape / disable FSU settings without alarm occur.
// REV.7 Removed OUT #78051, #78052, #40014, #70027 rungs from this file - already in Simple Connect.
// REV.8 Changed home complete output in #02701 Joystick Home rung.
// REV.9 Added OR #02701 to OUT #78054 rung, to capture when Joystick latch is occuring.
//       Added AND Operating/#50070 to OUT #02701 latch so that joystick does not latch accidently.
//

//-------Ext/Universal Input Usages:---------------------------------------

//Ext In #22710     //Ext Input-to-Universal Input#2145 - Servo On PB
//Ext In #22711     //Ext Input-to-Universal Input#2146 - Start PB
//Ext In #22712     //Ext Input-to-Universal Input#2147 - Alarm/Reset PB
//Ext In #22713     //Ext Input-to-Universal Input#2148 - Hold PB
//Ext In #22714     //Ext Input-to-Universal Input#2149 - Auto/Manual Select
//Ext In #22715     //Ext Input-to-Universal Input#2150 - Cycle Start PB
//Ext In #22716     //Ext Input-to-Universal Input#2151 - Light Curtain Reset PB
//Ext In #22720     //Ext Input-to-Universal Input#2153 - Joystick Forward
//Ext In #22721     //Ext Input-to-Universal Input#2154 - Joystick Home
//Ext In #22722     //Ext Input-to-Universal Input#2155 - Joystick Reverse
//Ext In #22726     //Ext Input-to-Universal Input#2159 - E-Stop Pressed
//
//Univ In #4001     //Light Curtain Clear
//Univ In #4002     //S1 (Trunnion) A-Side at Robot(s)
//Univ In #4003     //S1 (Trunnion) B-Side at Robot(s)
//Univ In #4004     //S1 (Trunnion) At Side A OR B
//Univ In #4005     //S1 (Trunnion) At Side A OR B OR LC Clear
//Univ In #4006     //S1 (Trunnion) Sweeping (Not At A OR B)
//Univ In #4007     //S1 Standstill
//Univ In #4008     //S2 Standstill
//Univ In #4009     //S3 Standstill
//Univ In #4010     //S2 Speed Limit (30%)
//Univ In #4011     //S3 Speed Limit (30%)
//Univ In #4012     //S2 (Tooling A) Power On
//Univ In #4013     //S3 (Tooling B) Power On
//
//-------SPIN:---------------------------------------
//Specified Input #0617 ~ Address #40780    // SLC SPIN01
//
//-------Aux Relay Usages:---------------------------------------
//Aux #78000        //Emergency Stop OK
//Aux #78050        //Cycle Start Pulse
//Aux #78051        //Op Station 1 – External Servo On
//Aux #78052        //Op Station 1 – External Start
//Aux #78054        //Joystick Active
//Aux #78057        //Cycle Start Anti-Tie Down/Pulse
//Aux #78055        //S1 Leaving A-Side PLS
//Aux #78056        //S1 Leaving B-Side PLS
//Aux #78056        //S1 Traveling/At to B-Side
//
//-------Ext/Universal Output Usages:---------------------------------------
//Ext Out #32717    //Ext Out 2156 - Op Station LC Reset Required Lamp
//Ext Out #32723    //Ext Out 2156 - Op Station Servo On Lamp
//Ext Out #32724    //Ext Out 2157 - Op Station Alarm Lamp
//Ext Out #32725    //Ext Out 2158 - Op Station Cycle Latched Lamp
//
//Univ Out #4011    //Joystick Home Complete  (15022)
//
//-------Control Inputs Usages:---------------------------------------
//Ctrl #81320       //MS-OUT01 - Light Curtain Clear                       --> Mapped to Universal In#4001 (05010)
//Ctrl #81321       //MS-OUT02 - S1 (Trunnion) A-Side at Robot(s)          --> Mapped to Universal In#4002 (05011)
//Ctrl #81322       //MS-OUT03 - S1 (Trunnion) B-Side at Robot(s)          --> Mapped to Universal In#4003 (05012)
//Ctrl #81323       //MS-OUT04 - S1 (Trunnion) At Side A OR B              --> Mapped to Universal In#4004 (05013)
//Ctrl #81324       //MS-OUT05 - S1 (Trunnion) At Side A OR B OR LC Clear  --> Mapped to Universal In#4005 (05014)
//Ctrl #81325       //MS-OUT06 - S1 (Trunnion) Sweeping (Not At A OR B)    --> Mapped to Universal In#4006 (05015)
//Ctrl #81326       //MS-OUT07 - S1 Standstill                             --> Mapped to Universal In#4007 (05016)
//Ctrl #81327       //MS-OUT08 - S2 Standstill                             --> Mapped to Universal In#4008 (05017)
//Ctrl #81330       //MS-OUT09 - S3 Standstill                             --> Mapped to Universal In#4009 (05020)
//Ctrl #81331       //MS-OUT10 - S2 Speed Limit (30%)                      --> Mapped to Universal In#4010 (05021)
//Ctrl #81332       //MS-OUT11 - S3 Speed Limit (30%)                      --> Mapped to Universal In#4011 (05022)
//Ctrl #81333       //MS-OUT12 - S2 (Tooling A) Power On                   --> Mapped to Universal In#4012 (05023)
//Ctrl #81334       //MS-OUT13 - S3 (Tooling B) Power On                   --> Mapped to Universal In#4013 (05024)
//Ctrl #81335       //MS-OUT14 - Light Curtain Reset Required              --> Mapped to Universal In#4014 (05025)
//
//
//-------Special Bits from MotoPlus software:---------------------------------------
//Univ In #1769     //R1 Configured     --> Address #02220
//Univ In #1770     //R2 Configured     --> Address #02221
//Univ In #1771     //R3 Configured     --> Address #02222
//Univ In #1772     //R4 Configured     --> Address #02223
//
//
// ========================================================
// CELL OPERATION LOGIC:
// ========================================================
// System Ready
//STR #80025          //External Emergency Stop
//AND #80026          //Programming Pendant E-Stop
//AND #80027          //Playback Box E-Stop
//OUT #78000          //Emergency Stop OK
//
//STR-NOT #78002      // Blinker OFF bit
//TMR M103,5          // 0.5 sec timer
//OUT #78001          // Blinker ON bit
//
// Cycle Start Pulse
STR #22715          //Ext In 2150 - Cycle Start PB
AND-NOT #78057      //Cycle Start Anti-Tie Down/Pulse
OUT #78050          //Cycle Start Pulse
//
STR #22715          //Ext In 2150 - Sta1 Cycle Start PB
TMR M099,5          //Sta1 Timer (0.5)
OUT #78057          //Sta1 Cycle Start Anti-Tie Down/Pulse
//
// Cycle Start Latch
STR #78050          //Cycle Start Pulse
OR #02695           //Univ In 2150 - Cycle Start
AND-NOT #50053      //Teach
AND #50070          //Operating
AND #81320          //Light Curtain Clear
AND #78000          //E-Stops Clear
STR #81321          //S1 (Trunnion) A-Side at Robot(s)
STR #81322          //S1 (Trunnion) B-Side at Robot(s)
OR-STR
AND-STR
AND-NOT #78054      //Joystick Active
OUT #02695          //Univ In 2150 - Cycle Start
//
//Cycle Start Latched Light
STR #02695          //Univ In 2150 - Sta1 Cycle Start Latched
AND #50070          //Operating
STR #12705          //Univ Out 2158
AND #50053          //Teach Mode
OR-STR
OUT #32725          //Ext Out 2158 - Sta1 Cycle Latched
//
// ========================================================
// MAPPING OF CONTROL & OUTPUTS TO UNIVERSAL INPUTS:
// ========================================================
// Map Light Curtain Clear to External Input#4001
STR #81320          //MS-OUT01 - Light Curtain Clear
OUT #05010          //Light Curtain Clear Universal In#4001
//
// Map "S1 (Trunnion) A-Side at Robot(s)" to External Input#4002
STR #81321          //MS-OUT02 - S1 (Trunnion) A-Side at Robot(s)
OUT #05011          //A-Side at Robot(s) Universal In#4002
//
STR #81321          //MS-OUT02 - S1 (Trunnion) A-Side at Robot(s)
PLF #78055          //S1 Leaving A-Side PLS
//
// Map "S1 (Trunnion) B-Side at Robot(s)" to External Input#4003
STR #81322          //MS-OUT03 - S1 (Trunnion) B-Side at Robot(s)
OUT #05012          //B-Side at Robot(s) Universal In#4003
//
STR #81322          //MS-OUT03 - S1 (Trunnion) B-Side at Robot(s)
PLF #78056          //S1 Leaving B-Side PLS
//
STR #78055          //S1 Leaving A-Side PLS
OR #81322           //MS-OUT03 - S1 (Trunnion) B-Side at Robot(s)
STR #32707          //UNIVERSAL OUTPUT #2144 -"OP1-SIDE-B-TWS"
AND-NOT #78056      //S1 Leaving B-Side PLS
OR-STR
OUT #32707          //UNIVERSAL OUTPUT #2144 -"OP1-SIDE-B-TWS"
//
// Map "S1 (Trunnion) At Side A OR B" to External Input#4004
STR #81323          //MS-OUT04 - S1 (Trunnion) At Side A OR B
OUT #05013          //S1 (Trunnion) At Side A OR B Universal In#4004
//
// Map "S1 (Trunnion) At Side A OR B OR LC Clear" to External Input#4005
STR #81324          //MS-OUT05 - S1 (Trunnion) At Side A OR B OR LC Clear
OUT #05014          //S1 (Trunnion) At Side A OR B OR LC Clear Universal In#4005
//
// Map "S1 (Trunnion) Sweeping (Not At A OR B)" to External Input#4006
STR #81325          //MS-OUT06 - S1 (Trunnion) Sweeping (Not At A OR B)
OUT #05015          //S1 (Trunnion) Sweeping (Not At A OR B) Universal In#4006
//
// Map "S1 StandStill" to External Input#4007
STR #81326          //MS-OUT07 - S1 StandStill
OUT #05016          //S1 StandStill Universal In#4007
//
// Map "S2 StandStill" to External Input#4008
STR #81327          //MS-OUT08 - S2 StandStill
OUT #05017          //S2 StandStill Universal In#4008
//
// Map "S3 StandStill" to External Input#4009
STR #81330          //MS-OUT09 - S3 StandStill
OUT #05020          //S3 StandStill Universal In#4009
//
// Map "S2 Speed Limit (30%)" to External Input#4010
STR #81331          //MS-OUT10 - S2 Speed Limit (30%)
OUT #05021          //S2 Speed Limit (30%) Universal In#4010
//
// Map "S3 Speed Limit (30%)" to External Input#4011
STR #81332          //MS-OUT11 - S3 Speed Limit (30%)
OUT #05022          //S3 Speed Limit (30%) Universal In#4011
//
// Map "S2 (Tooling A) Power On" to External Input#4012
STR #81333          //MS-OUT12 - S2 (Tooling A) Power On
OUT #05023          //S2 (Tooling A) Power On Universal In#4012
//
// Map "S3 (Tooling B) Power On" to External Input#4013
STR #81334          //MS-OUT13 - S3 (Tooling B) Power On
OUT #05024          //S3 (Tooling B) Power On Universal In#4013
//
// Map "Light Curtain Reset Required" to External Input#4014
STR #81335          //MS-OUT14 - Light Curtain Reset Required
OUT #05025          //Light Curtain Reset Required Universal In#4014
//
// ========================================================
// OP STATION STANDARD CONTROLS:
// ========================================================
//
// Light Curtain Reset (PB)
STR #22716          //Cycle Start / Light Curtain Reset Button Press - Input #2151
//STR #22715          //Ext In 2150 - Cycle Start PB
AND-NOT #81320      //Light Curtain#1 Latched
PLS #40780          //Send LC Reset request to Safety Logic on SPIN#1
//
// Servo On (Indication)
STR #50073          // Servo On
OUT #32723          // Op Station - Output #2156
//
// Alarm Present (Indication)
STR #70020          // Any Alarm or Warning occur
OUT #32724          // Op Station - Output #2157
//
// Light Curtain Reset Request (Indication)
STR #81335          // MS-OUT14 - Light Curtain Reset Required
//AND #78001          // Blinker ON bit
OUT #32717          // Op Station - Output #2152
//
// ========================================================
// JOYSTICK CONTROLS:
// ========================================================
// Joystick controls - only allow usage if light curtains clear
STR #22720          //Ext In 2153 - Joystick Reverse
AND #81320          //MS-OUT01 - Light Curtain Clear
OUT #02700          //Univ In 2153 - Joystick Reverse
//
STR #22721          //Ext In 2154 - Joystick Home
OR #02701           //Ext In 2154 - Joystick Home
AND #81320          //MS-OUT01 - Light Curtain Clear
AND #50070          //Operating
AND-NOT #15022      //Output 4011 Joystick Home Complete (from Joystick JBI)
OUT #02701          //Univ In 2154 - Joystick Home
//
STR #22722          //Ext In 2155 - Joystick Forward
AND #81320          //MS-OUT01 - Light Curtain Clear
OUT #02702          //Univ In 2155 - Joystick Forward
//
// Jog Active
STR #22720          //Ext In 2153 - Joystick - Reverse
OR #22721           //Ext In 2154 - Joystick - Home
OR #22722           //Ext In 2155 - Joystick - Forward
OR #02701           //Univ In 2154 - Joystick Home
OUT #78054          //Joystick Active
//
//
// ========================================================
// USER ALARM TRIGGERS:
// ========================================================
//
// Make sure the robot(s) stay home when sweeping.
//   ** same rung R1-R4 **
STR #02220          //R1 Configured (Moto+)
AND-NOT #50153      //Robot #1 Wall Cube - Cube 60
STR #02221          //R2 Configured (Moto+)
AND-NOT #50152      //Robot #2 Wall Cube - Cube 59
STR #02222          //R3 Configured (Moto+)
AND-NOT #50151      //Robot #3 Wall Cube - Cube 58
STR #02223          //R4 Configured (Moto+)
AND-NOT #50150      //Robot #4 Wall Cube - Cube 57
OR-STR
OR-STR
OR-STR
AND #81325          //S1 (Trunnion) Sweeping (Not At A or B)
AND #50070          //Operating
OUT #79772          //User Alarm 58 - Robot(s) Must Be Clear For Sweep
//
//
//System Message Indentifying which FSU files are expected to be enabled:
//
// ** Break down each FSU function group into rungs of when 
//    the function is expected.  Trigger bits for when each
//    particular function or group.  This allows grouping of 
//    the user alarm, and break-up of the user messages.
//
STR #50054
STR-NOT #81320      //Light Curtain Clear
STR #81321          //S1 (Trunnion) A-Side at Robot(s)
OR #81322           //S1 (Trunnion) B-Side at Robot(s)
AND-NOT #52130      //FSU#1 Axis Speed Monitor File #1 (S1 Trunnion) "Valid"
STR #81322          //S1 (Trunnion) B-Side at Robot(s)
AND-NOT #52131      //FSU#1 Axis Speed Monitor File #2 (S2 Side A Tooling) "Valid"
OR-STR
STR #81321          //S1 (Trunnion) A-Side at Robot(s)
AND-NOT #52132      //FSU#1 Axis Speed Monitor File #3 (S3 Side B Tooling) "Valid"
OR-STR
AND-STR
STR #81322          //S1 (Trunnion) B-Side at Robot(s)
AND-NOT #52133      //FSU#1 Axis Speed Monitor File #4 (S2 Side A Tooling 30% Spped Limit) "Valid"
OR-STR
STR #81321          //S1 (Trunnion) A-Side at Robot(s)
AND-NOT #52134      //FSU#1 Axis Speed Monitor File #5 (S3 Side B Tooling 30% Spped Limit) "Valid"
OR-STR
STR #50141          //A-Side At Robot(s) Cube #50
AND-NOT #52010
OR-STR
STR #50142          //B-Side At Robot(s) Cube#51
AND-NOT #52011
OR-STR
AND-STR
TMR M101,1
OUT #78070          //User Alarm: FSU Speed Limit Function(s) not valid when expected
//
STR-NOT #52010      //Axis Range Limit File #1 Enabled (S1 - Side A @ Robots)
OR-NOT #52011       //Axis Range Limit File #2 Enabled (S1 - Side B @ Robots)
OUT #78071          //User Alarm: FSU Axis Range Limit Function(s) not valid when expected
//
STR #02220          //R1 Configured (Moto+)
AND-NOT #52090      //Robot Range Limit File #1 (R1 - Full Cell allowed) "Valid"
STR #02221          //R2 Configured (Moto+)
AND-NOT #52091      //Robot Range Limit File #2 (R2 - Full Cell allowed) "Valid"
STR #02222          //R3 Configured (Moto+)
AND-NOT #52092      //Robot Range Limit File #3 (R3 - Full Cell allowed) "Valid"
STR #02223          //R4 Configured (Moto+)
AND-NOT #52093      //Robot Range Limit File #4 (R4 - Full Cell allowed) "Valid"
OR-STR
OR-STR
OR-STR
AND #50054          //Play Mode Set
OUT #78072          //User Alarm: FSU Range Limit Function(s) not valid when expected
//
STR #78070          //User Alarm: FSU Axis Speed Monitor Function(s) not valid when expected
OR #78071           //User Alarm: FSU Axis Range Limit Function(s) not valid when expected
OR #78072           //User Alarm: FSU Range Limit Function(s) not valid when expected
TMR M106,1
OUT #79775          //User Alarm: FSU Speed Limit Function(s) not valid when expected
//
// ========================================================
// USER MESSAGE TRIGGERS:
// ========================================================
//
//User Message Indentifying which FSU files are expected to be enabled - User Msg 57
STR #78072          //User Alarm: FSU Any Robot Range Limit not valid when expected
STR #79880          //Latching bit
AND #50013          //Latch while alarm above still active
OR-STR
OUT #79880          //User Message: Any Robot Range Limit Disabled
//
//User Message Indentifying which FSU files are expected to be enabled - User Msg 58
STR #78071          //User Alarm: FSU Axis Range Limit Function(s) not valid when expected
STR #79881          //Latching bit
AND #50013          //Latch while alarm above still active
OR-STR
OUT #79881          //User Message: Axis Range Limit 1 or 2 Disabled
//
//User Message Indentifying which FSU files are expected to be enabled - User Msg 59
STR #78070          //User Alarm: FSU Any Speed Monitor Function(s) not valid when expected
STR #79882          //Latching bit
AND #50013          //Latch while alarm above still active
OR-STR
OUT #79882          //User Message: Any Speed Monitor File Disabled
//
//
$ALARM1
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
9018
9019
9020
9021
9022
9023
9024
9025
9026
9027
9028
9029
9030
9031
9032
9033
9034
9035
9036
9037
9038
9039
9040
9041
9042
9043
9044
9045
9046
9047
9048
9049
9050
9051
9052
9053
9054
9055
9056
9057
9058
9059
9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122 ROBOT(S) MUST BE CLEAR FOR SWEEP
9123
9124
9125 SYS CRITICAL FSU FUNCT DISABLED
9126
9127
$ALARM2
9128
9129
9130
9131
9132
9133
9134
9135
9136
9137
9138
9139
9140
9141
9142
9143
9144
9145
9146
9147
9148
9149
9150
9151
9152
9153
9154
9155
9156
9157
9158
9159
9160
9161
9162
9163
9164
9165
9166
9167
9168
9169
9170
9171
9172
9173
9174
9175
9176
9177
9178
9179
9180
9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
9224
9225
9226
9227
9228
9229
9230
9231
9232
9233
9234
9235
9236
9237
9238
9239
9240
9241
9242
9243
9244
9245
9246
9247
9248
9249
9250
9251
9252
9253
9254
9255
$MESSAGE1
0001 
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 
0012 
0013 
0014 
0015 
0016 
0017 
0018 
0019 
0020 
0021 
0022 
0023 
0024 
0025 
0026 
0027 
0028 
0029 
0030 
0031 
0032 
0033 
0034 
0035 
0036 
0037 
0038 
0039 
0040 
0041 
0042 
0043 
0044 
0045 
0046 
0047 
0048 
0049 
0050 
0051 
0052 
0053 
0054 
0055 
0056 
0057 
0058 
0059 
0060 
0061 
0062 
0063 
0064 
0065 
0066 
0067 
0068 
0069 
0070 
0071 
0072 
0073 
0074 
0075 
0076 
0077 
0078 
0079 
0080 
0081 
0082 
0083 
0084 
0085 
0086 
0087 
0088 
0089 
0090 
0091 
0092 
0093 
0094 
0095 
0096 
0097 
0098 
0099 
0100 
0101 
0102 
0103 
0104 
0105 
0106 
0107 
0108 
0109 
0110 
0111 
0112 
0113 
0114 
0115 
0116 
0117 
0118 
0119 
0120 
0121 Any Robot Range Limit Disabled
0122 Axis Range Limit 1 or 2 Disabled
0123 Any Speed Limit File Disabled
0124 
0125 
0126 
0127 
0128 
$MESSAGE2
0129 
0130 
0131 
0132 
0133 
0134 
0135 
0136 
0137 
0138 
0139 
0140 
0141 
0142 
0143 
0144 
0145 
0146 
0147 
0148 
0149 
0150 
0151 
0152 
0153 
0154 
0155 
0156 
0157 
0158 
0159 
0160 
0161 
0162 
0163 
0164 
0165 
0166 
0167 
0168 
0169 
0170 
0171 
0172 
0173 
0174 
0175 
0176 
0177 
0178 
0179 
0180 
0181 
0182 
0183 
0184 
0185 
0186 
0187 
0188 
0189 
0190 
0191 
0192 
0193 
0194 
0195 
0196 
0197 
0198 
0199 
0200 
0201 
0202 
0203 
0204 
0205 
0206 
0207 
0208 
0209 
0210 
0211 
0212 
0213 
0214 
0215 
0216 
0217 
0218 
0219 
0220 
0221 
0222 
0223 
0224 
0225 
0226 
0227 
0228 
0229 
0230 
0231 
0232 
0233 
0234 
0235 
0236 
0237 
0238 
0239 
0240 
0241 
0242 
0243 
0244 
0245 
0246 
0247 
0248 
0249 
0250 
0251 
0252 
0253 
0254 
0255 
0256 
