@@ -11,17 +11,26 @@ bool ready_to_fire = false;
11
11
bool low_power_mode = false ;
12
12
bool high_power_mode = false ;
13
13
14
+ #define DEFAULT_BURST_COUNT 31
15
+ #define DEFAULT_PULSE_MODE 0
16
+ #define DEFAULT_DIODE_TRIGGER 0
17
+ #define DEFAULT_PULSE_WIDTH 0.00014000
18
+ #define DEFAULT_PULSE_PERIOD 0.20000000
19
+ #define DEFAULT_REP_RATE 5.0 ;
20
+
14
21
unsigned int shot_count = 0 ;
15
- unsigned int burst_count = 31 ;
16
- unsigned short pulse_mode = 0 ;
17
- unsigned short diode_trigger = 0 ;
22
+ unsigned int burst_count = DEFAULT_BURST_COUNT ;
23
+ unsigned short pulse_mode = DEFAULT_PULSE_MODE ;
24
+ unsigned short diode_trigger = DEFAULT_DIODE_TRIGGER ;
18
25
19
26
const float diode_current = 110.00 ; // Latest models of QC ujlasers have this fixed
20
- float pulse_width = 0.00014000 ;
21
- float pulse_period = 0.20000000 ;
22
- float rep_rate = 5.00 ;
27
+ float pulse_width = DEFAULT_PULSE_WIDTH ;
28
+ float pulse_period = DEFAULT_PULSE_PERIOD ;
29
+ float rep_rate = DEFAULT_REP_RATE ;
23
30
float resonator_temp = -0.401 ; // NOTE: This value was taken while the diode was not connected.
24
31
float fet_temp = 34.082 ;
32
+ float bank_voltage = 0 ;
33
+
25
34
26
35
#define ID_STRING " QC,MicroJewel,08130,1.0.9"
27
36
@@ -127,6 +136,13 @@ void loop() {
127
136
laser_enabled = false ;
128
137
}
129
138
139
+ if (bank_voltage > 0 ) {
140
+ bank_voltage -= bank_voltage / 3 ; // This is a VERY rough approximation of the bank voltage discharging
141
+ if (bank_voltage < 0 ) {
142
+ bank_voltage = 0 ;
143
+ }
144
+ }
145
+
130
146
c = 0 ;
131
147
while (Serial.available () > 0 ) {
132
148
c = Serial.read ();
@@ -201,6 +217,55 @@ void loop() {
201
217
Serial.print (" ?6\r\n " );
202
218
}
203
219
}
220
+ else if (strcmp (cmd, " PE" ) == 0 ) {
221
+ Serial.readBytes (k, 1 );
222
+ if (*k == ' ?' ) {
223
+ Serial.print (pulse_period, 3 );
224
+ Serial.print (" \r\n " );
225
+ }
226
+ else if (*k == ' ' ) {
227
+ float f = -1000 ;
228
+ f = Serial.parseFloat ();
229
+ if (f == -1000 ) {
230
+ Serial.print (" ?4\r\n " );
231
+ continue ;
232
+ }
233
+ if (f < MIN_PE || f > MAX_PE) {
234
+ Serial.print (" ?5\r\n " );
235
+ continue ;
236
+ }
237
+ pulse_period = f;
238
+ rep_rate = 1.0 /f;
239
+ ok ();
240
+ }
241
+ else if (*k == ' :' ) {
242
+ char keyword[4 ];
243
+ memset (keyword, 0 , 4 );
244
+ if (Serial.readBytesUntil (' ?' , keyword, 3 ) != 3 ){
245
+ Serial.print (" ?5\r\n " );
246
+ Serial.flush ();
247
+ delay (200 ); // Idk why this must be here, but it makes it pass the test bench....... And yes, it must be 200ms, i tested it... idc
248
+ continue ;
249
+ }
250
+ if (strcmp (keyword, " MIN" )==0 ) {
251
+ Serial.print (MIN_PE);
252
+ Serial.print (" \r\n " );
253
+ continue ;
254
+ }
255
+ else if (strcmp (keyword, " MAX" )==0 ) {
256
+ Serial.print (MAX_PE);
257
+ Serial.print (" \r\n " );
258
+ continue ;
259
+ }
260
+ else {
261
+ Serial.print (" ?3\r\n " );
262
+ continue ;
263
+ }
264
+ }
265
+ else {
266
+ Serial.print (" ?5\r\n " );
267
+ }
268
+ }
204
269
else if (strcmp (cmd, " RR" ) == 0 ) {
205
270
Serial.readBytes (k, 1 );
206
271
if (*k == ' ?' ) {
@@ -219,8 +284,32 @@ void loop() {
219
284
continue ;
220
285
}
221
286
rep_rate = f;
287
+ pulse_period = 1 /f;
222
288
ok ();
223
289
}
290
+ else if (*k == ' :' ) {
291
+ char keyword[4 ];
292
+ memset (keyword, 0 , 4 );
293
+ if (Serial.readBytesUntil (' ?' , keyword, 3 ) != 3 ){
294
+ Serial.print (" ?5\r\n " );
295
+ Serial.flush ();
296
+ continue ;
297
+ }
298
+ if (strcmp (keyword, " MIN" )==0 ) {
299
+ Serial.print (MIN_RR);
300
+ Serial.print (" \r\n " );
301
+ continue ;
302
+ }
303
+ else if (strcmp (keyword, " MAX" )==0 ) {
304
+ Serial.print (MAX_RR);
305
+ Serial.print (" \r\n " );
306
+ continue ;
307
+ }
308
+ else {
309
+ Serial.print (" ?3\r\n " );
310
+ continue ;
311
+ }
312
+ }
224
313
else {
225
314
Serial.print (" ?5\r\n " );
226
315
}
@@ -381,7 +470,27 @@ void loop() {
381
470
else if (strcmp (cmd, " BV" ) == 0 ) {
382
471
Serial.readBytes (k,1 );
383
472
if (*k == ' ?' ) {
384
- Serial.print (0.000 , 5 );
473
+ Serial.print (bank_voltage, 3 );
474
+ Serial.print (" \r\n " );
475
+ }
476
+ else {
477
+ Serial.print (" ?6\r\n " );
478
+ }
479
+ }
480
+ else if (strcmp (cmd, " RS" ) == 0 ) {
481
+ Serial.end ();
482
+ pulse_mode = DEFAULT_PULSE_MODE;
483
+ diode_trigger = DEFAULT_DIODE_TRIGGER;
484
+ pulse_width = DEFAULT_PULSE_WIDTH;
485
+ pulse_period = DEFAULT_PULSE_PERIOD;
486
+ rep_rate = DEFAULT_REP_RATE;
487
+ burst_count = DEFAULT_BURST_COUNT;
488
+ Serial.begin (115200 );
489
+ }
490
+ else if (strcmp (cmd, " TR" ) == 0 ) {
491
+ Serial.readBytes (k,1 );
492
+ if (*k == ' ?' ) {
493
+ Serial.print (resonator_temp, 3 );
385
494
Serial.print (" \r\n " );
386
495
}
387
496
else {
0 commit comments