-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPIOInputChickFounction.h
386 lines (348 loc) · 10.8 KB
/
GPIOInputChickFounction.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
#ifndef GPIOInputChickFounction_H
#define GPIOInputChickFounction_H
#include "EEPROMLibrary.h"
#include "TempSensor.h"
/* ==================================================
* List of Founction used to chick on each input pin
= General ======================================
D0_SW()
D1_FlowSW()
D2_PhaseSq()
= comperasor 1 ==================================
D3_HighPressure1()
D4_LowPressure1()
D5_OverLoadComperssor1()
D6_OverLoadCFM1()
D7_MotorProtector1()
D8_OilPressure1()
= comperasor 2 ==================================
D9_HighPressure2()
D10_LowPressure2()
D11_OverLoadComperssor2()
D12_OverLoadCFM2()
D13_MotorProtector2()
D14_OilPressure2()
====================================================
*/
extern String Temp_Alarm_reason1;
extern String Temp_Alarm_reason2;
bool D0_SW_Alarm = LOW;
bool D1_FlowSW_Alarm = LOW;
bool D2_PhaseSq_Alarm = LOW;
bool D3_HighPressure1_Alarm = LOW;
bool D4_LowPressure1_Alarm = LOW;
bool D5_OverLoadComperssor1_Alarm = LOW;
bool D6_OverLoadCFM1_Alarm = LOW;
bool D7_MotorProtector1_Alarm = LOW;
bool D8_OilPressure1_Alarm = LOW;
bool D9_HighPressure2_Alarm = LOW;
bool D10_LowPressure2_Alarm = LOW;
bool D11_OverLoadComperssor2_Alarm = LOW;
bool D12_OverLoadCFM2_Alarm = LOW;
bool D13_MotorProtector2_Alarm = LOW;
bool D14_OilPressure2_Alarm = LOW;
bool temperature_difference_Alarm = LOW;
bool anyAlarm = LOW;
bool anyAlarm1 = LOW;
bool anyAlarm2 = LOW;
void GPIO_init()
{
for(int i=0; i<= 14 ; i++)
{ pinMode(i , INPUT); }
}
String D0_SW()
{
if(digitalRead(0) == HIGH)
{
D0_SW_Alarm = LOW;
return "ON ";
}
else
{
D0_SW_Alarm = HIGH;
return "OFF";
}
}
String D1_FlowSW()
{
if(digitalRead(1) == HIGH) return "OK ";
else
{
D1_FlowSW_Alarm = HIGH;
return "Alarm";
}
}
String D2_PhaseSq()
{
if(digitalRead(2) == HIGH) return "OK ";
else
{
D2_PhaseSq_Alarm = HIGH;
return "Alarm";
}
}
String D3_HighPressure1()
{
if(digitalRead(3) == HIGH) return "OK ";
else
{
D3_HighPressure1_Alarm = HIGH;
return "Alarm";
}
}
String D4_LowPressure1()
{
if(digitalRead(4) == HIGH) return "OK ";
else
{
D4_LowPressure1_Alarm = HIGH;
return "Alarm";
}
}
String D5_OverLoadComperssor1()
{
if(digitalRead(5) == HIGH) return "OK ";
else
{
D5_OverLoadComperssor1_Alarm = HIGH;
return "Alarm";
}
}
String D6_OverLoadCFM1()
{
if(digitalRead(6) == HIGH) return "OK ";
else
{
D6_OverLoadCFM1_Alarm = HIGH;
return "Alarm";
}
}
String D7_MotorProtector1()
{
if(digitalRead(7) == HIGH) return "OK ";
else
{
D7_MotorProtector1_Alarm = HIGH;
return "Alarm";
}
}
String D8_OilPressure1()
{
if(digitalRead(8) == HIGH) return "OK ";
else
{
D8_OilPressure1_Alarm = HIGH;
return "Alarm";
}
}
String D9_HighPressure2()
{
if(digitalRead(9) == HIGH) return "OK ";
else
{
D9_HighPressure2_Alarm = HIGH;
return "Alarm";
}
}
String D10_LowPressure2()
{
if(digitalRead(10) == HIGH) return "OK ";
else
{
D10_LowPressure2_Alarm = HIGH;
return "Alarm";
}
}
String D11_OverLoadComperssor2()
{
if(digitalRead(11) == HIGH) return "OK ";
else
{
D11_OverLoadComperssor2_Alarm = HIGH;
return "Alarm";
}
}
String D12_OverLoadCFM2()
{
if(digitalRead(12) == HIGH) return "OK ";
else
{
D12_OverLoadCFM2_Alarm = HIGH;
return "Alarm";
}
}
String D13_MotorProtector2()
{
if(digitalRead(13) == HIGH) return "OK ";
else
{
D13_MotorProtector2_Alarm = HIGH;
return "Alarm";
}
}
String D14_OilPressure2()
{
if(digitalRead(14) == HIGH) return "OK ";
else
{
D14_OilPressure2_Alarm = HIGH;
return "Alarm";
}
}
void Alarm_sum()
{
//this is additional Idea I'm trying ( im lettel affread that is idea might make the system slow
D0_SW();
D1_FlowSW();
D2_PhaseSq();
// = comperasor 1 ==================================
D3_HighPressure1();
D4_LowPressure1();
D5_OverLoadComperssor1();
D6_OverLoadCFM1();
D7_MotorProtector1();
D8_OilPressure1();
//= comperasor 2 ==================================
D9_HighPressure2();
D10_LowPressure2();
D11_OverLoadComperssor2();
D12_OverLoadCFM2();
D13_MotorProtector2();
D14_OilPressure2();
//the original Idea of Aleams is here
anyAlarm = D0_SW_Alarm ||
D1_FlowSW_Alarm ||
D2_PhaseSq_Alarm ||
temperature_difference_Alarm ;
anyAlarm1 = D3_HighPressure1_Alarm ||
D4_LowPressure1_Alarm ||
D5_OverLoadComperssor1_Alarm ||
D6_OverLoadCFM1_Alarm ||
D7_MotorProtector1_Alarm ||
D8_OilPressure1_Alarm ;
anyAlarm2 = D9_HighPressure2_Alarm ||
D10_LowPressure2_Alarm ||
D11_OverLoadComperssor2_Alarm ||
D12_OverLoadCFM2_Alarm ||
D13_MotorProtector2_Alarm ||
D14_OilPressure2_Alarm ;
/*
static bool Last_D1_FlowSW_Alarm = LOW;
static bool Last_D2_PhaseSq_Alarm = LOW;
static bool Last_temperature_difference_Alarm = LOW;
static bool Last_D3_HighPressure1_Alarm = LOW;
static bool Last_D4_LowPressure1_Alarm = LOW;
static bool Last_D5_OverLoadComperssor1_Alarm = LOW;
static bool Last_D6_OverLoadCFM1_Alarm = LOW;
static bool Last_D7_MotorProtector1_Alarm = LOW;
static bool Last_D8_OilPressure1_Alarm = LOW;
static bool Last_D9_HighPressure2_Alarm = LOW;
static bool Last_D10_LowPressure2_Alarm = LOW;
static bool Last_D11_OverLoadComperssor2_Alarm = LOW;
static bool Last_D12_OverLoadCFM2_Alarm = LOW;
static bool Last_D13_MotorProtector2_Alarm = LOW;
static bool Last_D14_OilPressure2_Alarm = LOW;
if(Last_D1_FlowSW_Alarm != D1_FlowSW_Alarm)
{
EEPROM.put(bool_D1_FlowSW_Alarm_ADDRESS, D1_FlowSW_Alarm);
Last_D1_FlowSW_Alarm = D1_FlowSW_Alarm;
}
if(Last_D2_PhaseSq_Alarm != D2_PhaseSq_Alarm)
{
EEPROM.put(bool_D2_PhaseSq_Alarm_ADDRESS, D2_PhaseSq_Alarm);
Last_D2_PhaseSq_Alarm = D2_PhaseSq_Alarm;
}
if(Last_temperature_difference_Alarm != temperature_difference_Alarm)
{
EEPROM.put(bool_temperature_difference_Alarm_ADDRESS, temperature_difference_Alarm);
writeStringToEEPROM(String_Temp_Alarm_reason1_ADDRESS, Temp_Alarm_reason1);
writeStringToEEPROM(String_Temp_Alarm_reason2_ADDRESS, Temp_Alarm_reason2);
Last_temperature_difference_Alarm = temperature_difference_Alarm;
}
// comp1
if(Last_D3_HighPressure1_Alarm != D3_HighPressure1_Alarm)
{
EEPROM.put(bool_D3_HighPressure1_Alarm_ADDRESS, D3_HighPressure1_Alarm);
Last_D3_HighPressure1_Alarm = D3_HighPressure1_Alarm;
}
if(Last_D4_LowPressure1_Alarm != D4_LowPressure1_Alarm)
{
EEPROM.put(bool_D4_LowPressure1_Alarm_ADDRESS, D4_LowPressure1_Alarm);
Last_D4_LowPressure1_Alarm = D4_LowPressure1_Alarm;
}
if(Last_D5_OverLoadComperssor1_Alarm != D5_OverLoadComperssor1_Alarm)
{
EEPROM.put(bool_D5_OverLoadComperssor1_Alarm_ADDRESS, D5_OverLoadComperssor1_Alarm);
Last_D5_OverLoadComperssor1_Alarm = D5_OverLoadComperssor1_Alarm;
}
if(Last_D6_OverLoadCFM1_Alarm != D6_OverLoadCFM1_Alarm)
{
EEPROM.put(bool_D6_OverLoadCFM1_Alarm_ADDRESS, D6_OverLoadCFM1_Alarm);
Last_D6_OverLoadCFM1_Alarm = D6_OverLoadCFM1_Alarm;
}
if(Last_D7_MotorProtector1_Alarm != D7_MotorProtector1_Alarm)
{
EEPROM.put(bool_D7_MotorProtector1_Alarm_ADDRESS, D7_MotorProtector1_Alarm);
Last_D7_MotorProtector1_Alarm = D7_MotorProtector1_Alarm;
}
if(Last_D8_OilPressure1_Alarm != D8_OilPressure1_Alarm)
{
EEPROM.put(bool_D8_OilPressure1_Alarm_ADDRESS, D8_OilPressure1_Alarm);
Last_D8_OilPressure1_Alarm = D8_OilPressure1_Alarm;
}
//comp2
if(Last_D9_HighPressure2_Alarm != D9_HighPressure2_Alarm)
{
EEPROM.put(bool_D9_HighPressure2_Alarm_ADDRESS, D9_HighPressure2_Alarm);
Last_D9_HighPressure2_Alarm = D9_HighPressure2_Alarm;
}
if(Last_D10_LowPressure2_Alarm != D10_LowPressure2_Alarm)
{
EEPROM.put(bool_D10_LowPressure2_Alarm_ADDRESS, D10_LowPressure2_Alarm);
Last_D10_LowPressure2_Alarm = D10_LowPressure2_Alarm;
}
if(Last_D11_OverLoadComperssor2_Alarm != D11_OverLoadComperssor2_Alarm)
{
EEPROM.put(bool_D11_OverLoadComperssor2_Alarm_ADDRESS, D11_OverLoadComperssor2_Alarm);
Last_D11_OverLoadComperssor2_Alarm = D11_OverLoadComperssor2_Alarm;
}
if(Last_D12_OverLoadCFM2_Alarm != D12_OverLoadCFM2_Alarm)
{
EEPROM.put(bool_D12_OverLoadCFM2_Alarm_ADDRESS, D12_OverLoadCFM2_Alarm);
Last_D12_OverLoadCFM2_Alarm = D12_OverLoadCFM2_Alarm;
}
if(Last_D13_MotorProtector2_Alarm != D13_MotorProtector2_Alarm)
{
EEPROM.put(bool_D13_MotorProtector2_Alarm_ADDRESS, D13_MotorProtector2_Alarm);
Last_D13_MotorProtector2_Alarm = D13_MotorProtector2_Alarm;
}
if(Last_D14_OilPressure2_Alarm != D14_OilPressure2_Alarm)
{
EEPROM.put(bool_D14_OilPressure2_Alarm_ADDRESS, D14_OilPressure2_Alarm);
Last_D14_OilPressure2_Alarm = D14_OilPressure2_Alarm;
}
*/
}
void Alarms_init()
{
/*
EEPROM.get(bool_D1_FlowSW_Alarm_ADDRESS, D1_FlowSW_Alarm);
EEPROM.get(bool_D2_PhaseSq_Alarm_ADDRESS, D2_PhaseSq_Alarm);
EEPROM.get(bool_D3_HighPressure1_Alarm_ADDRESS, D3_HighPressure1_Alarm);
EEPROM.get(bool_D4_LowPressure1_Alarm_ADDRESS, D4_LowPressure1_Alarm);
EEPROM.get(bool_D5_OverLoadComperssor1_Alarm_ADDRESS, D5_OverLoadComperssor1_Alarm);
EEPROM.get(bool_D6_OverLoadCFM1_Alarm_ADDRESS, D6_OverLoadCFM1_Alarm);
EEPROM.get(bool_D7_MotorProtector1_Alarm_ADDRESS, D7_MotorProtector1_Alarm);
EEPROM.get(bool_D8_OilPressure1_Alarm_ADDRESS, D8_OilPressure1_Alarm);
EEPROM.get(bool_D9_HighPressure2_Alarm_ADDRESS, D9_HighPressure2_Alarm);
EEPROM.get(bool_D10_LowPressure2_Alarm_ADDRESS, D10_LowPressure2_Alarm);
EEPROM.get(bool_D11_OverLoadComperssor2_Alarm_ADDRESS, D11_OverLoadComperssor2_Alarm);
EEPROM.get(bool_D12_OverLoadCFM2_Alarm_ADDRESS, D12_OverLoadCFM2_Alarm);
EEPROM.get(bool_D13_MotorProtector2_Alarm_ADDRESS, D13_MotorProtector2_Alarm);
EEPROM.get(bool_D14_OilPressure2_Alarm_ADDRESS, D14_OilPressure2_Alarm);
EEPROM.get(bool_temperature_difference_Alarm_ADDRESS, temperature_difference_Alarm);
Temp_Alarm_reason1 = readStringFromEEPROM(String_Temp_Alarm_reason1_ADDRESS);
Temp_Alarm_reason2 = readStringFromEEPROM(String_Temp_Alarm_reason2_ADDRESS);
*/
}
#endif