@@ -25,12 +25,12 @@ float launchTime = -1; //Time for keeping the launch sequence on for set t
25
25
int cycleState = 0 ; // Cycles through the different
26
26
#define cycleTime 5 // # of seconds to stay on each cycle state
27
27
float lastCycleUpdate = 0 ; // # of seconds since last cycle change
28
- #define launchDuration 300 // # of seconds to stay in the launched mode
28
+ #define launchDuration 450 // # of seconds to stay in the launched mode
29
29
int ranCnt = 0 ;
30
30
31
31
// Code frequency in Hz
32
32
#define PRE_LAUNCH_FREQUENCY 10
33
- #define LAUNCH_FREQUENCY 50
33
+ #define LAUNCH_FREQUENCY 100
34
34
35
35
36
36
// Other pins
@@ -53,29 +53,104 @@ bool coilVoltageDetected = false;
53
53
54
54
// Cycle Sequences
55
55
56
- int preLaunchCycleSize = 80 ;
57
- bool preLaunchCycle[80 ][6 ] = {
56
+ int preLaunchCycleSize = 149 ;
57
+ bool preLaunchCycle[149 ][6 ] = {
58
58
{0 , 0 , 0 , 0 , 0 , 0 },
59
+ {1 , 1 , 1 , 1 , 1 , 1 },
60
+ {0 , 0 , 0 , 0 , 0 , 0 },
61
+ {1 , 1 , 0 , 0 , 0 , 1 },
62
+ {0 , 0 , 0 , 0 , 0 , 0 },
63
+ {1 , 0 , 1 , 1 , 1 , 0 },
64
+ {0 , 0 , 0 , 0 , 0 , 0 },
65
+ {1 , 0 , 1 , 1 , 0 , 0 },
66
+ {0 , 0 , 0 , 0 , 0 , 0 },
67
+ {1 , 0 , 1 , 0 , 0 , 1 },
68
+ {0 , 0 , 0 , 0 , 0 , 0 },
69
+ {1 , 0 , 0 , 1 , 1 , 1 },
70
+ {0 , 0 , 0 , 0 , 0 , 0 },
71
+ {1 , 0 , 0 , 1 , 0 , 1 },
72
+ {0 , 0 , 0 , 0 , 0 , 0 },
73
+ {1 , 0 , 0 , 0 , 0 , 1 },
74
+
75
+ {0 , 0 , 0 , 0 , 0 , 0 },
76
+ {0 , 0 , 0 , 0 , 0 , 0 },
77
+ {0 , 0 , 0 , 0 , 0 , 0 },
78
+ {0 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{0 , 0 , 0 , 0 , 0 , 0 },
62
117
{0 , 0 , 0 , 0 , 0 , 0 },
63
118
{0 , 0 , 0 , 0 , 0 , 0 },
64
- {1 , 1 , 1 , 1 , 1 , 1 },
65
119
{0 , 0 , 0 , 0 , 0 , 0 },
66
- {1 , 1 , 0 , 0 , 0 , 0 },
67
120
{0 , 0 , 0 , 0 , 0 , 0 },
68
- {1 , 0 , 1 , 1 , 1 , 1 },
69
121
{0 , 0 , 0 , 0 , 0 , 0 },
70
- {1 , 0 , 1 , 1 , 0 , 0 },
122
+ {0 , 0 , 0 , 0 , 0 , 0 },
123
+ {0 , 0 , 0 , 0 , 0 , 0 },
124
+ {0 , 0 , 0 , 0 , 0 , 0 },
125
+ {0 , 0 , 0 , 0 , 0 , 0 },
126
+
127
+ {0 , 0 , 0 , 0 , 0 , 0 },
128
+ {0 , 0 , 0 , 0 , 0 , 0 },
129
+ {0 , 0 , 0 , 0 , 0 , 0 },
130
+ {0 , 0 , 0 , 0 , 0 , 0 },
131
+ {0 , 0 , 0 , 0 , 0 , 0 },
132
+ {0 , 0 , 0 , 0 , 0 , 0 },
133
+ {0 , 0 , 0 , 0 , 0 , 0 },
134
+ {0 , 0 , 0 , 0 , 0 , 0 },
135
+ {0 , 0 , 0 , 0 , 0 , 0 },
136
+ {0 , 0 , 0 , 0 , 0 , 0 },
137
+ {0 , 0 , 0 , 0 , 0 , 0 },
138
+ {0 , 0 , 0 , 0 , 0 , 0 },
139
+
140
+ {1 , 0 , 0 , 0 , 1 , 0 },
141
+ {0 , 0 , 0 , 0 , 0 , 0 },
142
+ {1 , 0 , 0 , 1 , 1 , 0 },
71
143
{0 , 0 , 0 , 0 , 0 , 0 },
72
144
{1 , 0 , 1 , 0 , 0 , 0 },
73
145
{0 , 0 , 0 , 0 , 0 , 0 },
74
- {1 , 0 , 0 , 1 , 0 , 0 },
146
+ {1 , 0 , 1 , 0 , 1 , 0 },
75
147
{0 , 0 , 0 , 0 , 0 , 0 },
76
- {1 , 0 , 0 , 0 , 0 , 0 },
148
+ {1 , 0 , 1 , 1 , 0 , 1 },
77
149
{0 , 0 , 0 , 0 , 0 , 0 },
150
+ {1 , 0 , 1 , 1 , 1 , 1 },
78
151
{0 , 0 , 0 , 0 , 0 , 0 },
152
+ {1 , 1 , 0 , 1 , 1 , 1 },
153
+
79
154
{0 , 0 , 0 , 0 , 0 , 0 },
80
155
{0 , 0 , 0 , 0 , 0 , 0 },
81
156
{0 , 0 , 0 , 0 , 0 , 0 },
@@ -87,6 +162,8 @@ bool preLaunchCycle[80][6] = {
87
162
{0 , 0 , 0 , 0 , 0 , 0 },
88
163
{0 , 0 , 0 , 0 , 0 , 0 },
89
164
{0 , 0 , 0 , 0 , 0 , 0 },
165
+ {0 , 0 , 0 , 0 , 0 , 0 },
166
+
90
167
{0 , 0 , 0 , 0 , 0 , 0 },
91
168
{0 , 0 , 0 , 0 , 0 , 0 },
92
169
{0 , 0 , 0 , 0 , 0 , 0 },
@@ -99,6 +176,7 @@ bool preLaunchCycle[80][6] = {
99
176
{0 , 0 , 0 , 0 , 0 , 0 },
100
177
{0 , 0 , 0 , 0 , 0 , 0 },
101
178
{0 , 0 , 0 , 0 , 0 , 0 },
179
+
102
180
{0 , 0 , 0 , 0 , 0 , 0 },
103
181
{0 , 0 , 0 , 0 , 0 , 0 },
104
182
{0 , 0 , 0 , 0 , 0 , 0 },
@@ -111,6 +189,7 @@ bool preLaunchCycle[80][6] = {
111
189
{0 , 0 , 0 , 0 , 0 , 0 },
112
190
{0 , 0 , 0 , 0 , 0 , 0 },
113
191
{0 , 0 , 0 , 0 , 0 , 0 },
192
+
114
193
{0 , 0 , 0 , 0 , 0 , 0 },
115
194
{0 , 0 , 0 , 0 , 0 , 0 },
116
195
{0 , 0 , 0 , 0 , 0 , 0 },
@@ -123,6 +202,7 @@ bool preLaunchCycle[80][6] = {
123
202
{0 , 0 , 0 , 0 , 0 , 0 },
124
203
{0 , 0 , 0 , 0 , 0 , 0 },
125
204
{0 , 0 , 0 , 0 , 0 , 0 },
205
+
126
206
{0 , 0 , 0 , 0 , 0 , 0 },
127
207
{0 , 0 , 0 , 0 , 0 , 0 },
128
208
{0 , 0 , 0 , 0 , 0 , 0 },
@@ -137,32 +217,45 @@ bool preLaunchCycle[80][6] = {
137
217
{0 , 0 , 0 , 0 , 0 , 0 }
138
218
};
139
219
140
- // {1, 0, 0, 0, 0, 0}, -> 3.04A
141
- // {1, 1, 0, 0, 0, 0}, -> 1.08A
142
- // {1, 0, 1, 0, 0, 0}, -> 1.92A, 6.82V
143
- // {1, 0, 0, 1, 0, 0}, -> 2.93A, 11.95V
144
- // {1, 0, 0, 0, 1, 0}, -> 2.9A
145
- // {1, 0, 1, 1, 0, 0}, -> 1.47A, 5.06V
146
- // {1, 0, 1, 1, 1, 1}, -> 1.2A, 4.08V
147
- // {1, 1, 1, 1, 1, 1}, -> 0.77A, 2.55V
148
-
149
220
150
- int launchCycleSize = 14 ;
151
- bool launchCycle[14 ][6 ] = {
152
- {0 , 0 , 0 , 0 , 0 , 0 },
221
+ int launchCycleSize = 34 ;
222
+ bool launchCycle[34 ][6 ] = {
153
223
{0 , 0 , 0 , 0 , 0 , 0 },
154
224
{1 , 1 , 1 , 1 , 1 , 1 },
155
- {1 , 0 , 1 , 1 , 1 , 1 },
156
225
{0 , 0 , 0 , 0 , 0 , 0 },
226
+ {1 , 1 , 0 , 0 , 0 , 1 },
227
+ {0 , 0 , 0 , 0 , 0 , 0 },
228
+ {1 , 0 , 1 , 1 , 1 , 0 },
229
+ {0 , 0 , 0 , 0 , 0 , 0 },
230
+ {1 , 0 , 1 , 1 , 0 , 0 },
231
+ {0 , 0 , 0 , 0 , 0 , 0 },
232
+ {1 , 0 , 1 , 0 , 0 , 1 },
157
233
{0 , 0 , 0 , 0 , 0 , 0 },
158
234
{1 , 0 , 0 , 1 , 1 , 1 },
159
- {1 , 0 , 0 , 0 , 1 , 1 },
160
235
{0 , 0 , 0 , 0 , 0 , 0 },
236
+ {1 , 0 , 0 , 1 , 0 , 1 },
161
237
{0 , 0 , 0 , 0 , 0 , 0 },
162
238
{1 , 0 , 0 , 0 , 0 , 1 },
239
+
240
+ {0 , 0 , 0 , 0 , 0 , 0 },
241
+ {0 , 0 , 0 , 0 , 0 , 0 },
242
+
243
+ {1 , 0 , 0 , 0 , 1 , 0 },
244
+ {0 , 0 , 0 , 0 , 0 , 0 },
245
+ {1 , 0 , 0 , 1 , 1 , 0 },
246
+ {0 , 0 , 0 , 0 , 0 , 0 },
247
+ {1 , 0 , 1 , 0 , 0 , 0 },
163
248
{0 , 0 , 0 , 0 , 0 , 0 },
164
- {0 , 0 , 0 , 0 , 0 , 0 },
165
- {1 , 0 , 0 , 0 , 0 , 0 }
249
+ {1 , 0 , 1 , 0 , 1 , 0 },
250
+ {0 , 0 , 0 , 0 , 0 , 0 },
251
+ {1 , 0 , 1 , 1 , 0 , 1 },
252
+ {0 , 0 , 0 , 0 , 0 , 0 },
253
+ {1 , 0 , 1 , 1 , 1 , 1 },
254
+ {0 , 0 , 0 , 0 , 0 , 0 },
255
+ {1 , 1 , 0 , 1 , 1 , 1 },
256
+
257
+ {0 , 0 , 0 , 0 , 0 , 0 },
258
+ {0 , 0 , 0 , 0 , 0 , 0 }
166
259
};
167
260
168
261
int cyclePins[6 ] = {2 , 3 , 4 , 5 , 6 , 7 };
@@ -178,6 +271,10 @@ void setup() {
178
271
if (SD.begin (SD1CSPIN)){
179
272
Serial.println (" SD 1 Good" );
180
273
sd1Active = true ;
274
+
275
+ File myFile = SD.open (filename1, FILE_WRITE);
276
+ myFile.write (" Time,State,MagX,MagY,MagZ,AccX,AccY,AccZ,LaunchTime,PD,Launched,RanCount,Temp,SD1,SD2,MainBat,CoilBat,Coil,," );
277
+
181
278
} else {
182
279
Serial.println (" SD 1 Bad" );
183
280
sd1Active = false ;
@@ -186,6 +283,10 @@ void setup() {
186
283
if (SD.begin (SD2CSPIN)){
187
284
Serial.println (" SD 2 Good" );
188
285
sd2Active = true ;
286
+
287
+ File myFile = SD.open (filename2, FILE_WRITE);
288
+ myFile.write (" Time,State,MagX,MagY,MagZ,AccX,AccY,AccZ,LaunchTime,PD,Launched,RanCount,Temp,SD1,SD2,MainBat,CoilBat,Coil,," );
289
+
189
290
} else {
190
291
Serial.println (" SD 2 Bad" );
191
292
sd2Active = false ;
@@ -211,9 +312,6 @@ void setup() {
211
312
pinMode (imuLED, OUTPUT);
212
313
pinMode (ranLED, OUTPUT);
213
314
214
- // Write headers to SD card
215
- // TODO
216
-
217
315
}
218
316
219
317
void loop () {
@@ -279,15 +377,15 @@ void loop() {
279
377
digitalWrite (sdLED, (sd1Active && sd2Active) ? HIGH : LOW);
280
378
digitalWrite (coilLED, coilVoltageDetected ? HIGH : LOW);
281
379
digitalWrite (photoDiodeLED, (newPhotoDiodeValue > 150 && newPhotoDiodeValue < 400 ) ? HIGH : LOW);
282
- digitalWrite (imuLED, (acc.x () != 0.0 || acc.y () != 0.0 || acc.z () != 0.0 ) ? HIGH : LOW);
380
+ digitalWrite (imuLED, (( abs ( acc.x ()) > 0.5 ) || ( abs ( acc.y ()) > 0.5 ) || ( abs ( acc.z ()) > 0.5 ) ) ? HIGH : LOW);
283
381
digitalWrite (ranLED, ranCnt > 0 );
284
382
285
383
// Setting this to true if we see some voltage over coil
286
384
if (coilVoltage > 0.25 ){
287
385
coilVoltageDetected = true ;
288
386
}
289
387
290
- Serial.println (newPhotoDiodeValue );
388
+ // Serial.println(acc.z() );
291
389
// Serial.print(",");
292
390
// Serial.println(coilVoltage);
293
391
// Serial.println(acc.z());
@@ -310,7 +408,7 @@ void loop() {
310
408
dataOut[14 ] = sd2Active ? 1 : 0 ;
311
409
dataOut[15 ] = mainBatVoltage;
312
410
dataOut[16 ] = coilBatVoltage;
313
- dataOut[17 ] = coilVoltage;
411
+ dataOut[17 ] = currentCombo[ 0 ] ? coilVoltage : 0 ;
314
412
315
413
316
414
// Writing to SD
0 commit comments