-
Notifications
You must be signed in to change notification settings - Fork 3
/
Uno_Rpi_Lockin Procedure.ipf
617 lines (575 loc) · 22.8 KB
/
Uno_Rpi_Lockin Procedure.ipf
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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
#pragma TextEncoding = "MacRoman"
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
// Created by Ro-ee Tal on 14/07/2017
// Requires the easyHttp xop placed in the igor extension folder.
// The xop can be found at: http://www.igorexchange.com/project/easyHttp
///////////////////////////////////// User Guide ////////////////////////////////////////////////
// When requesting data repeatedly, a short sleep is required
// so as not to overload the raspberry pi and cause the lock-in to unlock.
// To initialize the lock-in after start-up, use the write_multiple() function.
// To choose a specific lock-in, change 'qdot-pi' in the url: "http://qdot-pi.qdot-lab.net:5000/"
// to the name the raspberry pi was given by the server admin.
// Each function performs an http request. It is faster to perform a multiple read or write
// as aposed to performing a single read or write when dealing with more than one value at once.
// There is an example function at the bottom of the procedure which server as an example of how to use this procedure.
///////////// Multiple read/write functions ///////////////
// read_multiple(): Function to read from the lock-in.
// User must send in at least one command. User can send in multiple commands
// separated by a space to perform a multi-data read.
// User must also send in the number of commands sent in.
// Example of commands:
// - RI: real (x) and Imaginary (y)
// - MP: magnitude (R) and phase (theta)
// - FR: frequency (the frequncy the lock-in is functioning at when on an internal reference)
// - TC: time constant, in miliseconds
// - NS: number of samples
// - RE: reference (internal or external)
// - ST: status (running, overloaded, unlocked)
// Still in development:
// - PS: phase, in degrees
// - G1: gain 1
// - G2: gain 2
// - G3: gain 3
// - AF: auxiliary frequency (the frequency of the signals generated by the lock-in)
// - AM: amplitude (amplitude of the signal generated by the lockin)
// Function Example: read("MP RI S R TC F")
// returns a string, with the requested values in order of the parameter sent in, separated by commas
// write_multiple(): Function to write to the lock-in.
// User must send in at least one command. User can send in multiple commands
// separated by a space to perform a multi-data read.
// Each command must be followed by an '=' and then the value, without spaces.
// Example of commands:
// - FR: frequency (the frequncy the lock-in is functioning at when on an internal reference)
// - TC: time constant, in miliseconds
// - RE: reference (internal-J or external-I)
// Still in development:
// - PS: phase, in degrees
// - NS: number of samples
// - G1: gain 1
// - G2: gain 2
// - G3: gain 3
// - AF: auxiliary frequency (the frequency of the signals generated by the lock-in)
// - AM: amplitude (amplitude of the signal generated by the lockin)
// Function Example: write("TC=100 F=79")
// returns a string, with success or error messages (in order of commands sent in) separated by commas
/////////////// Get functions /////////////////////////////////
// get_reference() and get_status() return strings (Either an error message or the information requested).
// get_x_y() and get_r_theta() reutrn strings with the values separated by commas in the order of the functions' name
// All other get functions read a single numeric data value.
// Can be used to read frequency, time constant, real, imaginary, magnitude, phase ...
// A value of -999111 is returned if the request failed (network error) or -111999 if another error is encountered
//////////////// Set Functions /////////////////////////////////
//set_ref_internal() and set_ref_external() require no parameters.
//All other set functions require parameters.
//Time constant must be in ms, phase must be in degrees
//All set functions return a success or error message
//////////////////////////////////////// Functions /////////////////////////////////////////////////
///////////////// Multiple read/write ////////////////
function/S read_multiple(cmd, num_cmds)
//Preform the url POST request to send a command to the RPI and receive data from the lockin
string cmd
variable num_cmds
//easyHttp /POST is declared by the POST string and then by the url to which you wish to POST
easyHttp/POST = "command="+cmd "http://qdot-pi.qdot-lab.net:5000/read"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data
string output="", temp="", command=""
variable i, j
string data = request_wave[StrSearch(request_wave,"data",0)+8, StrSearch(request_wave, "errors",0)-5]
for(i=0; i<num_cmds; i++)
command = Stringfromlist(i, cmd, " ")
strswitch(command)
case "RI":
for(j=0; j<num_cmds+2; j++)
temp = Stringfromlist(j, data, ", ")
if(StrSearch(temp, "Real",0)!=-1)
output = output+temp[strlen("Real\": \"")+1,strlen(temp)-2]+","
break
endif
endfor
for(j=0; j<num_cmds+2; j++)
temp = Stringfromlist(j, data, ", ")
if(StrSearch(temp, "Imaginary",0)!=-1)
output = output+temp[strlen("Imaginary\": \"")+1,strlen(temp)-2]+","
break
endif
endfor
break
case "MP":
for(j=0; j<num_cmds+2; j++)
temp = Stringfromlist(j, data, ", ")
if(StrSearch(temp, "Magnitude",0)!=-1)
output = output+temp[strlen("Magnitude\": \"")+1,strlen(temp)-2]+","
break
endif
endfor
for(j=0; j<num_cmds+2; j++)
temp = Stringfromlist(j, data, ", ")
if(StrSearch(temp, "Theta",0)!=-1)
output = output+temp[strlen("Theta\": \"")+1,strlen(temp)-2]+","
break
endif
endfor
break
case "FR":
for(j=0; j<num_cmds+2; j++)
temp = Stringfromlist(j, data, ", ")
if(StrSearch(temp, "Frequency",0)!=-1)
output = output+temp[strlen("Frequency\": ")+1,strlen(temp)-1]+","
break
endif
endfor
break
case "PS":
//what happens if there are the "phase" from the cmd:"MP PS"
for(j=0; j<num_cmds+2; j++)
temp = Stringfromlist(j, data, ", ")
if(StrSearch(temp, "Phase",0)!=-1)
output = output+temp[strlen("Phase\": ")+1,strlen(temp)-1]+","
break
endif
endfor
break
case "RE":
for(j=0; j<num_cmds+2; j++)
temp = Stringfromlist(j, data, ", ")
if(StrSearch(temp, "Reference",0)!=-1)
output = output+temp[strlen("Reference\": \"")+1,strlen(temp)-2]+","
break
endif
endfor
break
case "ST":
for(j=0; j<num_cmds+2; j++)
temp = Stringfromlist(j, data, ", ")
if(StrSearch(temp, "Status",0)!=-1)
output = output+temp[strlen("Status\": \"")+1,strlen(temp)-2]+","
break
endif
endfor
break
case "TC":
for(j=0; j<num_cmds+2; j++)
temp = Stringfromlist(j, data, ", ")
if(StrSearch(temp, "Time Constant",0)!=-1)
output = output+temp[strlen("Time Constant\": ")+1,strlen(temp)-1]+","
break
endif
endfor
break
case "NS":
for(j=0; j<num_cmds+2; j++)
temp = Stringfromlist(j, data, ", ")
if(StrSearch(temp, "Number of Samples",0)!=-1)
output = output+temp[strlen("Number of Samples\": ")+1,strlen(temp)-1]+","
break
endif
endfor
break
endswitch
endfor
return output[0, strlen(output)-2]
endif
else
return "EasyHttp Request failed!"
endif
end
function/S write_multiple(cmd, num_cmds)
//Preform the url POST request to send a command to the RPI and receive data from the lockin
string cmd
variable num_cmds
//easyHttp /POST is declared by the POST string and then by the url to which you wish to POST
easyHttp/POST = "command="+cmd "http://qdot-pi.qdot-lab.net:5000/write"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data
String command="", output = "", temp=""
variable i
string data = request_wave[StrSearch(request_wave,"data",0)+8, StrSearch(request_wave, "errors",0)-5]
for(i=0; i<num_cmds; i++)
command = Stringfromlist(i, cmd, " ")
temp = Stringfromlist(i, data, "\\n")
output += temp[strlen(command)+2, strlen(temp)]+","
endfor
return output[0, strlen(output)-2]
endif
else
return "EasyHttp Request failed!"
endif
end
////////////////// Get Functions ////////////////////////////
function/S get_x_y()
easyHttp/POST = "command=RI" "http://qdot-pi.qdot-lab.net:5000/read"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data
string data = request_wave[StrSearch(request_wave,"data",0)+8, StrSearch(request_wave, "errors",0)-5]
String v1 = Stringfromlist(0, data, ", ")
String v2 = Stringfromlist(1, data, ", ")
if(StrSearch(v1, "Real",0)!=-1)
return v1[strlen("Real\": \"")+1,strlen(v1)-2]+","+v2[strlen("Imaginary\": \"")+1,strlen(v2)-2]
else
return v2[strlen("Real\": \"")+1,strlen(v2)-2]+","+v1[strlen("Imaginary\": \"")+1,strlen(v1)-2]
endif
endif
else
return "EasyHttp Request failed!"
endif
end
function/S get_r_theta()
easyHttp/POST = "command=MP" "http://qdot-pi.qdot-lab.net:5000/read"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data
string data = request_wave[StrSearch(request_wave,"data",0)+8, StrSearch(request_wave, "errors",0)-5]
String v1 = Stringfromlist(0, data, ", ")
String v2 = Stringfromlist(1, data, ", ")
if(StrSearch(v1, "Magnitude",0)!=-1)
return v1[strlen("Magnitude\": \"")+1,strlen(v1)-2]+","+v2[strlen("Theta\": \"")+1,strlen(v2)-2]
else
return v2[strlen("Magnitude\": \"")+1,strlen(v2)-2]+","+v1[strlen("Theta\": \"")+1,strlen(v1)-2]
endif
endif
else
return "EasyHttp Request failed!"
endif
end
function get_frequency()
//Preform the url POST request to send a command to the RPI and receive data from the lockin
//easyHttp /POST is declared by the POST string and then by the url to which you wish to POST
easyHttp/POST = "command=FR" "http://qdot-pi.qdot-lab.net:5000/read"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return -111999
else
//return data
return str2num(request_wave[StrSearch(request_wave,"Frequency",0)+strlen("Frequency\": "), StrSearch(request_wave, "},",0)-1])
endif
else
return -999111
endif
end
function get_time_constant()
//Preform the url POST request to send a command to the RPI and receive data from the lockin
//easyHttp /POST is declared by the POST string and then by the url to which you wish to POST
easyHttp/POST = "command=TC" "http://qdot-pi.qdot-lab.net:5000/read"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return -111999
else
//return data
return str2num(request_wave[StrSearch(request_wave,"Time Constant",0)+strlen("Time Constant\": "), StrSearch(request_wave, "},",0)-1])
endif
else
return -999111
endif
end
function get_phase()
//Preform the url POST request to send a command to the RPI and receive data from the lockin
//easyHttp /POST is declared by the POST string and then by the url to which you wish to POST
easyHttp/POST = "command=PS" "http://qdot-pi.qdot-lab.net:5000/read"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return -111999
else
//return data
return str2num(request_wave[StrSearch(request_wave,"Phase",0)+strlen("Phase\": "), StrSearch(request_wave, "},",0)-1])
endif
else
return -999111
endif
end
function get_num_samples()
//Preform the url POST request to send a command to the RPI and receive data from the lockin
//easyHttp /POST is declared by the POST string and then by the url to which you wish to POST
easyHttp/POST = "command=NS" "http://qdot-pi.qdot-lab.net:5000/read"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return -111999
else
//return data
return str2num(request_wave[StrSearch(request_wave,"Number of Samples",0)+strlen("Number of Samples\": "), StrSearch(request_wave, "},",0)-1])
endif
else
return -999111
endif
end
function/S get_reference()
//Preform the url POST request to send a command to the RPI and receive data from the lockin
//easyHttp /POST is declared by the POST string and then by the url to which you wish to POST
easyHttp/POST = "command=RE" "http://qdot-pi.qdot-lab.net:5000/read"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data
return request_wave[StrSearch(request_wave,"Reference",0)+strlen("Reference\": \""), StrSearch(request_wave, "errors",0)-6]
endif
else
return "EasyHttp Request failed!"
endif
end
function/S get_status()
//Preform the url POST request to send a command to the RPI and receive data from the lockin
//easyHttp /POST is declared by the POST string and then by the url to which you wish to POST
easyHttp/POST = "command=ST" "http://qdot-pi.qdot-lab.net:5000/read"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data
return request_wave[StrSearch(request_wave,"Status",0)+strlen("Status\": \""), StrSearch(request_wave, "errors",0)-6]
endif
else
return "EasyHttp Request failed!"
endif
end
///////////////// Set Functions ////////////////////
function/S set_frequency(f)
variable f
easyHttp/POST = "command=FR="+num2str(f) "http://qdot-pi.qdot-lab.net:5000/write"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data (success command for set/write functions)
return request_wave[StrSearch(request_wave,"data",0)+10+strlen("FR="+num2str(f)), StrSearch(request_wave, "errors",0)-7]
endif
else
return "EasyHttp Request failed!"
endif
end
function/S set_aux_frequency(f)
variable f
easyHttp/POST = "command=AF="+num2str(f) "http://qdot-pi.qdot-lab.net:5000/write"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data (success command for set/write functions)
return request_wave[StrSearch(request_wave,"data",0)+10+strlen("AF="+num2str(f)), StrSearch(request_wave, "errors",0)-7]
endif
else
return "EasyHttp Request failed!"
endif
end
function/S set_phase(p)
variable p
easyHttp/POST = "command=PS="+num2str(p) "http://qdot-pi.qdot-lab.net:5000/write"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data (success command for set/write functions)
return request_wave[StrSearch(request_wave,"data",0)+strlen("PS="+num2str(p))+10, StrSearch(request_wave, "errors",0)-7]
endif
else
return "EasyHttp Request failed!"
endif
end
function/S set_time_constant(tc)
variable tc
easyHttp/POST = "command=TC="+num2str(tc) "http://qdot-pi.qdot-lab.net:5000/write"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data (success command for set/write functions)
return request_wave[StrSearch(request_wave,"data",0)+strlen("TC="+num2str(tc))+10, StrSearch(request_wave, "errors",0)-7]
endif
else
return "EasyHttp Request failed!"
endif
end
function/S set_ref_external()
easyHttp/POST = "command=RE=I" "http://qdot-pi.qdot-lab.net:5000/write"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data (success command for set/write functions)
return request_wave[StrSearch(request_wave,"data",0)+strlen("RE=I")+10, StrSearch(request_wave, "errors",0)-7]
endif
else
return "EasyHttp Request failed!"
endif
end
function/S set_ref_internal()
easyHttp/POST = "command=RE=J" "http://qdot-pi.qdot-lab.net:5000/write"
// Now we need to do some error checking
// V_flag indicates the easyHttp request encountered an error
if(V_flag==0)
//Check if the RPI returned an error or useful data, and return the appropriate info
string request_wave = S_gethttp
string error
error = request_wave[StrSearch(request_wave, "errors",0)+9, StrLen(request_wave)-2]
if(strlen(error) > 2)
return error
else
//return data (success command for set/write functions)
return request_wave[StrSearch(request_wave,"data",0)+strlen("RE=J")+10, StrSearch(request_wave, "errors",0)-7]
endif
else
return "EasyHttp Request failed!"
endif
end
////////////////// Example Data Aquisition ////////////////////
function example()
//Initialize Lock-in and check that initialization was successful
if(cmpstr(write_multiple("RE=I, TC=50",2),"success,success")==0)
//Allow the lock-in to adjust if needed
Sleep/S 1
variable count=0, err=0, greatest_errs=0, timerRefNum, microSeconds
//Specify how many loops to run. Alternatively you can run indefinitely or use a timer.
variable loops=1000
//Start a timer
timerRefNum = StartMSTimer
//Check that timer started successfully
if (timerRefNum == -1)
Abort "All timers are in use"
else
//Read data from the lock-in continuously
//Do a bit of error checking and testing
variable i=0
do
i += 1
//Read the x and y components and the status, print the x and y
string data = read_multiple("RI ST", 2)
print str2num(Stringfromlist(0, data, ",")), str2num(Stringfromlist(1, data, ","))
string status = Stringfromlist(2, data, ",")
//If the lock-in is not running, give it time to "recover"
if(cmpstr(status, "Running")!=0)
err+=1
Sleep/S 0.1
endif
//If lock-in is running but was not earlier, record how long it was not running for
if(cmpstr(status, "Running")==0 && err>0)
if(err>greatest_errs)
greatest_errs = err
endif
err = 0
endif
//if the lockin was not running for a set amount of requests (i.e. 7), abort!
if(err>6)
print "An Error Occured"
microSeconds = StopMSTimer(timerRefNum)
print "Loops: "+num2str(loops)
print "Seconds: "+num2str(microSeconds/1000000.0)
print "Error limit of 7 failed."
break
endif
//if lock-in ran as intented, exit function appropriately
if(i==loops)
print "Success"
microSeconds = StopMSTimer(timerRefNum)
print "Seconds: "+num2str(microSeconds/1000000.0)
print "Error limit: 7. Number of greatest consecutive errord: "+num2str(greatest_errs)
break
endif
//sleep delay between requests. Too little of a sleep and the lock-in could crash.
Sleep/s 0.03
while(i<loops)
endif
else
print "could not initialize."
endif
end