-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path36LB_Command.ino
195 lines (162 loc) · 4.05 KB
/
36LB_Command.ino
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
/***********************************************
This file is DEPRECATED and should no longer be used
Used as the basis of new code for RL-36
***********************************************/
//Valve Pins
// As of 10/17/2020, these were arbitrarily set to 9,10,11,12
// oxValve1 is the pin controlling the oxidizer solenoid valve
// fuelValve1Pin is the First of the two Fuel Regulation Valve
// fuelValve2Pin is the Second of the two Fuel Regulation Valve
// purgeValvePin is the pin corresponding the purge valve
// Basic Outline
// Initialize variables and whatnot
// Wait for user input
// Firing procedure
// Wait until done firing
// Purge Procedure
// End
// Pins and whatnot
//1 = COM
int oxValve1 = 9; //2
int fuelValve1Pin = 10; //3
int fuelValve2Pin = 11; //4
int purgeValvePin = 12; //5
int igniterPin = 13;
//6 = GROUND
//
//kill switch Pin
// As of 10/17/2020, this was arbitrarily set to pin 1
int killSwitch = 18;
//Pressure Transducer
//2020 Fall Prop using Honeywell MLH03KPSL01A
//Sensor Ranges from 0 to 3000 psi
//Voltage Ranges from 0.5 to 4.5 Volts
int oxPressPin = 2;
int fuelPressPin = 3;
// variables
int startdelay = 3000;
int burnTime = 7000;
String startCommand = "MosquitoStart";
String inCommand = "OOPS";
void setup() {
// Killswitch
pinMode(killSwitch,INPUT);
pinMode(oxPressPin,INPUT);
pinMode(fuelPressPin,INPUT);
pinMode(killSwitch,INPUT);
//attachInterrupt(digitalPinToInterrupt(killSwitch),shutDownValves,HIGH);
//attachInterrupt(digitalPinToInterrupt(oxPressPin),shutDownValves,HIGH);
//attachInterrupt(digitalPinToInterrupt(fuelPressPin),shutDownValves,HIGH);
Serial.begin(9600);
// Initialize Closed Valves
pinMode(oxValve1, OUTPUT);
digitalWrite(oxValve1, LOW);
pinMode(fuelValve1Pin, OUTPUT);
digitalWrite(fuelValve1Pin, LOW);
pinMode(fuelValve2Pin, OUTPUT);
digitalWrite(fuelValve2Pin, LOW);
pinMode(purgeValvePin, OUTPUT);
digitalWrite(purgeValvePin, LOW);
shutDownValves();
}
int valveStatOxV1 = 0;
int valveStatFV1 = 0;
int valveStatFV2 = 0;
int valveStatPV = 0;
void loop() {
//shutDownValves();
// Wait for user to send Mosquito Start to the controller
//while(inCommand != startCommand){
// inCommand = Serial.readString();
//}
//Open Solenoid 1 (o2 valve)
valvecontrol('1','O');
//Open Solenoids 2 and 3 (Fuel Supply)
valvecontrol('2','O');
valvecontrol('3','O');
SENDIT();
// Wait for stuff to burn - 7 seconds
delay(burnTime);
// Close Solenoids 1 2 3 (Cut off Oxygen and Fuel)
valvecontrol('1','C');
valvecontrol('2','C');
valvecontrol('3','C');
delay(3000);
// Wait 3 Seconds - Arbitrary
// Open Solenoid 4 (Purge Valve)
valvecontrol('1','C');
valvecontrol('2','C');
valvecontrol('3','C');
valvecontrol('4','O');
// Wait 3 Seconds - Arbitrary
delay(3000);
valvecontrol('4','C');
// Close Solenoid 4 (Purge Valve)
shutDownValves();
while(1==1){
valvecontrol('1','O');
valvecontrol('2','O');
valvecontrol('3','O');
valvecontrol('4','O');
}
}
void SENDIT(){
//Activate the Sparky boy
digitalWrite(igniterPin,HIGH);
delay(5);
digitalWrite(igniterPin,LOW);
}
void valvecontrol(char valve, char stat){
//Valve controller function borrowed from P18102 MainFunc()
switch(valve){
case '1':
if (stat == 'O'){
digitalWrite(oxValve1, LOW);
valveStatOxV1 = 1;
}
else{
digitalWrite(oxValve1, HIGH);
valveStatOxV1 = 0;
}
break;
case '2':
if (stat == 'O'){
digitalWrite(fuelValve1Pin, LOW);
valveStatFV1 = 1;
}
else{
digitalWrite(fuelValve1Pin, HIGH);
valveStatFV1 = 0;
}
break;
case '3':
if (stat == 'O'){
digitalWrite(fuelValve2Pin, LOW);
valveStatFV2 = 1;
}
else{
digitalWrite(fuelValve2Pin, HIGH);
valveStatFV2 = 0;
}
break;
case '4':
if (stat == 'O'){
digitalWrite(purgeValvePin, LOW);
valveStatPV = 1;
}
else{
digitalWrite(purgeValvePin, HIGH);
valveStatPV= 0;
}
break;
default:
break;
}
return;
}
void shutDownValves(){
valvecontrol('1','C');
valvecontrol('2','C');
valvecontrol('3','C');
valvecontrol('4','C');
}