|
22 | 22 | # constants |
23 | 23 |
|
24 | 24 | fs = 1/940e-9 # frequency for PSD calc |
25 | | -samples = 2000 # number of samples for acquisition |
| 25 | +samples = 1500 # number of samples for acquisition |
26 | 26 | channels = 8 # number of channels (max 12, 8 actually in use) |
27 | 27 | pi_kp = 5000000 # PI Kp parameter |
28 | 28 | pi_ti = 300 # PI Ti parameter |
|
35 | 35 | dac_cnt_max = 50000 # 0.5ms |
36 | 36 | dac_data = 2689 # 0.3V |
37 | 37 | sp_data = 22382 # 2.5V |
38 | | -debug = 1 # 1 = activate debug mode |
| 38 | +debug = 0 # 1 = activate debug mode |
39 | 39 |
|
40 | 40 | # PV prefixes |
41 | 41 |
|
|
320 | 320 | input() |
321 | 321 |
|
322 | 322 | sp_data_conv = sp_data*voltage_gain |
| 323 | +PV(pv_current_setpoint_inf).put(-sp_data, wait=True) |
323 | 324 |
|
324 | | -err = 1 |
325 | | -while err >= 1: |
| 325 | +print('>>> Configure open loop square wave for +-%.2fV...' %(sp_data_conv)) |
326 | 326 |
|
327 | | - print('>>> Configure open loop square wave for +-%.2fV...' %(sp_data_conv)) |
| 327 | +if debug == 1: |
| 328 | + print('\033[1;32m \nPress ENTER to continue... \033[0m') |
| 329 | + input() |
328 | 330 |
|
329 | | - for i in range(0, channels): |
330 | | - PV(pv_amp_enable[i]).put(0, wait=True) |
331 | | - PV(pv_pi_enable[i]).put(0, wait=True) |
332 | | - PV(pv_square_wave_openloop[i]).put(0, wait=True) |
333 | | - |
334 | | - time.sleep(0.1) |
335 | | - PV(pv_current_setpoint_inf).put(-sp_data, wait=True) |
336 | | - |
337 | | - for i in range(0, channels): |
338 | | - PV(pv_current_setpoint[i]).put(sp_data, wait=True) |
339 | | - PV(pv_square_wave_openloop[i]).put(1, wait=True) |
340 | | - PV(pv_amp_enable[i]).put( 1, wait=True) |
| 331 | +for i in range(0, channels): |
| 332 | + PV(pv_current_setpoint[i]).put(sp_data, wait=True) |
| 333 | + PV(pv_square_wave_openloop[i]).put(1, wait=True) |
| 334 | + PV(pv_amp_enable[i]).put( 1, wait=True) |
| 335 | + |
| 336 | +time.sleep(1) |
341 | 337 |
|
342 | | - print('>>> Configure open loop square wave for +-%.2fV... Done!' %(sp_data_conv)) |
| 338 | +print('>>> Configure open loop square wave for +-%.2fV... Done!' %(sp_data_conv)) |
| 339 | + |
| 340 | +err = 1 |
| 341 | +while err >= 1: |
343 | 342 |
|
344 | 343 | min_values_1 = np.zeros(channels) |
345 | 344 | max_values_1 = np.zeros(channels) |
|
370 | 369 | time.sleep(1) # just to see the waveform change in graphical interface |
371 | 370 | PV(pv_acq_trigger_event).put(1, wait=True) |
372 | 371 |
|
373 | | - PV(pv_current_setpoint_inf).put(0, wait=True) |
374 | | - |
375 | 372 | print('>>> New acquisition... Done!') |
376 | 373 |
|
377 | 374 | print('\n>>> Find the two max and min values for each channel...') |
|
445 | 442 | print('\033[1;32m \nPress ENTER to continue... \033[0m') |
446 | 443 | input() |
447 | 444 |
|
| 445 | +for i in range(0, channels): |
| 446 | + PV(pv_amp_enable[i]).put(0, wait=True) |
| 447 | + PV(pv_pi_enable[i]).put(0, wait=True) |
| 448 | + PV(pv_square_wave_openloop[i]).put(0, wait=True) |
| 449 | + |
448 | 450 | print('\n>>> Calculate the inductance for each channel...') |
449 | 451 |
|
450 | 452 | inductance = np.zeros(channels) |
|
486 | 488 |
|
487 | 489 | results.close() |
488 | 490 |
|
| 491 | +PV(pv_current_setpoint_inf).put(0, wait=True) |
489 | 492 | for i in range(0, channels): |
490 | 493 | PV(pv_amp_enable[i]).put(0, wait=True) |
491 | 494 | PV(pv_square_wave_openloop[i]).put(0, wait=True) |
| 495 | + PV(pv_current_setpoint[i]).put(0, wait=True) |
492 | 496 |
|
493 | 497 | print('\n--------------------------------------------------------------------------') |
494 | 498 | print('----------------------------------- END ----------------------------------') |
|
0 commit comments