// WORLD CELL:  AWIV-6200SL/6200HD
// PART #:      
//
// DATE: 7/30/14
// SW VERSION: DX200 DN1.80 & Above for saftey logic expansion and allow removal of safety PLC
// CREATED BY: Jason Young (PSG)
// 
// Base CIO File
//
// REV.0 Initial Release
// REV.1 (Nov. 2014) Removed Safety PLC OK Alarm (does not function as expected per AG and PILZ),Removed IF-Panel test for "Cycle Start" button
// REV.2 (Feb. 2015) Adding logic to ensure all cell required FSU function are enabled.
// REV.3 (July 2015) Removing PILZ PLC and replacing with Safety Logic Circuit included in DN1.80 software and later.
// REV.4 (Feb 2016) Adding logic for JoyStick Home Latching	
//
//-------Ext/Universal Input Usages:---------------------------------------
//Ext In #20030   //Ext Input-to-Universal Input#1 - Cycle Start PB
//Ext In #20040   //Ext Input-to-Universal Input#9 - Joystick Reverse
//Ext In #20041		//Ext Input-to-Universal Input#10 - Joystick Home
//Ext In #20042   //Ext Input-to-Universal Input#11 - Joystick Forward
//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
//
//-------Aux Relay Usages:---------------------------------------
//Aux #78000 			//Emergency Stop OK
//Aux #78050    	//Cycle Start Pulse
//Aux #78054      //Joystick Active
//Aux #78057    	//Cycle Start Anti-Tie Down/Pulse
//
//-------Ext/Universal Output Usages:---------------------------------------
//Ext Out #30030  //Ext Out 1 - Sta1 Cycle Latched
//
//-------Control Inputs Usages:---------------------------------------
//Ctrl #81320 		//Light Curtain Clear 										--> Mapped to Universal In#4001 (05010)
//Ctrl #81321    	//S1 (Trunnion) A-Side at Robot(s) 				--> Mapped to Universal In#4002 (05011)
//Ctrl #81322    	//S1 (Trunnion) B-Side at Robot(s) 				--> Mapped to Universal In#4003 (05012)
//Ctrl #81323 		//S1 (Trunnion) At Side A OR B						--> Mapped to Universal In#4004 (05013)
//Ctrl #81324    	//S1 (Trunnion) At Side A OR B OR LC Clear--> Mapped to Universal In#4005 (05014)
//Ctrl #81325    	//S1 (Trunnion) Sweeping (Not At A OR B)	--> Mapped to Universal In#4006 (05015)
//Ctrl #81326    	//S1 Standstill														--> Mapped to Universal In#4007 (05016)
//Ctrl #81327    	//S2 Standstill														--> Mapped to Universal In#4008 (05017)
//Ctrl #81330    	//S3 Standstill														--> Mapped to Universal In#4009 (05020)
//Ctrl #81331    	//S2 Speed Limit (30%)										--> Mapped to Universal In#4010 (05021)
//Ctrl #81332    	//S3 Speed Limit (30%)										--> Mapped to Universal In#4011 (05022)
//Ctrl #81333    	//S2 (Tooling A) Power On									--> Mapped to Universal In#4012 (05023)
//Ctrl #81334    	//S3 (Tooling B) Power On									--> Mapped to Universal In#4013 (05024)
//
// ========================================================
// USER ALARM TRIGGERS:
// ========================================================
//
// Make sure the robot(s) stay home when sweeping.
STR #81325				//S1 (Trunnion) Sweeping (Not At A or B)
STR-NOT #50153    //Robot #1 Wall Cube - Cube 60
OR-NOT #50152			//Robot #2 Wall Cube - Cube 59
AND-STR
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
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 M351,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 (system section)
STR #79775				//User Alarm: FSU Speed Limit Function(s) not valid when expected
STR #79871				// Latching bit
AND #50013				// Latch while alarm above still active
OR-STR
OUT #79871				//User Message: FSU Speed Limit Function(s) File #1,2,or 3 is not enabled
//
// ========================================================
// 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
//
// Cycle Start Pulse
STR #20030        //Ext In 1 - Cycle Start PB
AND-NOT #78057    //Cycle Start Anti-Tie Down/Pulse
OUT #78050        //Cycle Start Pulse
//
STR #20030        //Ext In 1 - Sta1 Cycle Start PB
TMR M350,5        //Sta1 Timer (0.5)
OUT #78057        //Sta1 Cycle Start Anti-Tie Down/Pulse
//
// Cycle Start Latch
STR #78050        //Cycle Start Pulse
OR #00010         //Univ In 1 - 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 #00010        //Univ In 1 - Cycle Start
//
//Cycle Start Latched Light
STR #00010        //Univ In 1 - Sta1 Cycle Start Latched
AND #50070        //Operating
STR #10010        //Univ Out 1
AND #50053        //Teach Mode
OR-STR
OUT #30030        //Ext Out 1 - Sta1 Cycle Latched
//
// ========================================================
// MAPPING OF CONTROL & OUTPUTS TO UNIVERSAL INPUTS:
// ========================================================
// Map Light Curtain Clear to External Input#4001
STR #81320				//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				//S1 (Trunnion) A-Side at Robot(s)
OUT #05011				//A-Side at Robot(s) Universal In#4002
//
// Map "S1 (Trunnion) B-Side at Robot(s)" to External Input#4003
STR #81322				//S1 (Trunnion) B-Side at Robot(s)
OUT #05012				//B-Side at Robot(s) Universal In#4003
//
// Map "S1 (Trunnion) At Side A OR B" to External Input#4004
STR #81323				//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				//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				//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				//S1 StandStill
OUT #05016				//S1 StandStill Universal In#4007
//
// Map "S2 StandStill" to External Input#4008
STR #81327				//S2 StandStill
OUT #05017				//S2 StandStill Universal In#4008
//
// Map "S3 StandStill" to External Input#4009
STR #81330				//S3 StandStill
OUT #05020				//S3 StandStill Universal In#4009
//
// Map "S2 Speed Limit (30%)" to External Input#4010
STR #81331				//S2 Speed Limit (30%)
OUT #05021				//S2 Speed Limit (30%) Universal In#4010
//
// Map "S3 Speed Limit (30%)" to External Input#4011
STR #81332				//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				//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				//S3 (Tooling B) Power On
OUT #05024				//S3 (Tooling B) Power On Universal In#4013
//
// ========================================================
// JOYSTICK CONTROLS:
// ========================================================
// Joystick controls - only allow usage if light curtains clear
STR #20040        //Ext In 9 - Joystick Reverse
AND #81320 				//Light Curtain Clear
OUT #00020        //Univ In 9 - Joystick Reverse
//                
STR #20041        //Ext In 10 - Joystick Home
OR #00021					//Ext In 11 - Joystick Home
AND #81320 				//Light Curtain Clear
AND-NOT #12272		//Output 1811 Joystick Home Complete (from Joystick JBI)
OUT #00021        //Ext In 11 - Joystick Home
//
STR #20042        //Ext In 11 - Joystick Forward
AND #81320 				//Light Curtain Clear
OUT #00022        //Ext In 11 - Joystick Forward
//
// Jog Active
STR #20040        //Ext In 9 - Joystick - Reverse
OR #20041         //Ext In 10 - Joystick - Home
OR #20042         //Ext In 11 - Joystick - Forward
OUT #78054        //Joystick Active
//
$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 ROBOTS 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
000
001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021
022
023
024
025
026
027
028
029
030
031
032
033
034
035
036
037
038
039
040
041
042
043
044
045
046
047
048
049
050
051
052
053
054
055
056
057
058
059
060
061
062
063
064
065
066
067
068
069
070
071
072
073
074
075
076
077
078
079
080
081
082
083
084
085
086
087
088
089
090
091
092
093
094
095
096
097
098
099
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 AxSpdMon#1-5/AxisRange#1,2 Dbled
121
122
123
124
125
126
127
$MESSAGE2
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
