Skip to content
This repository was archived by the owner on May 17, 2023. It is now read-only.

Commit 453d1b6

Browse files
scripts/tests/rtm_lamp_test.py: fix current offset calc
1 parent acbcc5c commit 453d1b6

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

scripts/tests/rtm_lamp_test.py

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# #
33
# Description: Script to test RTM-LAMP boards #
44
# #
5-
# Authors: Melissa Aguiar #
5+
# Author: Melissa Aguiar #
66
# #
77
# Created: Feb. 25, 2022 #
88
# #
@@ -25,7 +25,7 @@
2525

2626
try:
2727
json_file_in = int(sys.argv[1]) # if argv = 1: read the input data from the old json file
28-
except: # else: the user need to input the new values
28+
except: # if argv = None: the user need to input the new values
2929
json_file_in = None
3030

3131
# constants
@@ -57,6 +57,7 @@
5757
# PVs per channel
5858
pv_current_ArrayData = []
5959
pv_voltage_ArrayData = []
60+
pv_current_ArrayDataRAW = []
6061
pv_current_gain = []
6162
pv_voltage_gain = []
6263
pv_current_offset = []
@@ -75,6 +76,7 @@
7576
for i in range(0, channels):
7677
pv_current_ArrayData.append( str(pv_prefix) + str("GENConvArrayDataCH") + str(i))
7778
pv_voltage_ArrayData.append( str(pv_prefix) + str("GENConvArrayDataCH") + str(i+channels))
79+
pv_current_ArrayDataRAW.append( str(pv_prefix) + str("GEN_CH") + str(i) + str("ArrayData"))
7880
pv_current_gain.append( str(pv_prefix) + str("PSGainWavCH") + str(i) + str("-SP.VAL"))
7981
pv_voltage_gain.append( str(pv_prefix) + str("PSGainWavCH") + str(i+channels) + str("-SP.VAL"))
8082
pv_current_offset.append( str(pv_prefix) + str("PSOffsetWavCH") + str(i) + str("-SP.VAL"))
@@ -89,6 +91,15 @@
8991
pv_pi_kp.append( str(pv_prefix) + str("PSPIKpCH") + str(i) + str("-SP.VAL"))
9092
pv_pi_ti.append( str(pv_prefix) + str("PSPITiCH") + str(i) + str("-SP.VAL"))
9193

94+
print(' # # # # # # # # # # # # # # # # # # # # # # # # # #')
95+
print(' # #')
96+
print(' # Description: Script to test RTM-LAMP boards #')
97+
print(' # #')
98+
print(' # #')
99+
print(' # Created: Feb. 25, 2022 #')
100+
print(' # #')
101+
print(' # # # # # # # # # # # # # # # # # # # # # # # # # #\n')
102+
92103
print('\n--------------------------------------------------------------------------')
93104
print('------------------------------ STARTING TEST -----------------------------')
94105
print('--------------------------------------------------------------------------\n')
@@ -166,7 +177,7 @@
166177

167178
new_offset = np.zeros(channels)
168179
for i in range(0, channels):
169-
new_offset[i] = np.mean(PV(pv_current_ArrayData[i]).get())
180+
new_offset[i] = np.mean(PV(pv_current_ArrayDataRAW[i]).get())
170181

171182
print('New current offset values: \n', new_offset)
172183

@@ -362,8 +373,8 @@
362373
for i in range(0, channels):
363374
PV(pv_current_setpoint[i]).put(0, wait=True)
364375
PV(pv_current_setpoint_inf).put(0, wait=True)
365-
PV(pv_pi_enable[i]).put(0, wait=True)
366-
PV(pv_amp_enable[i]).put(0, wait=True)
376+
PV(pv_pi_enable[i]).put(0, wait=True)
377+
PV(pv_amp_enable[i]).put(0, wait=True)
367378

368379
print('>>> Set the current setpoint limits in zero for all channels... Done!')
369380

@@ -386,9 +397,9 @@
386397
time.sleep(0.2)
387398
PV(pv_square_wave_enable[i]).put(1, wait=True)
388399
time.sleep(0.2)
389-
PV(pv_pi_enable[i]).put(1, wait=True)
400+
PV(pv_pi_enable[i]).put(1, wait=True)
390401
time.sleep(0.2)
391-
PV(pv_amp_enable[i]).put(1, wait=True)
402+
PV(pv_amp_enable[i]).put(1, wait=True)
392403
time.sleep(0.5)
393404

394405
print('>>> Enable the square wave for channel %02d... Done!'%(i))
@@ -420,8 +431,8 @@
420431

421432
PV(pv_square_wave_enable[i]).put(0, wait=True)
422433
PV(pv_current_setpoint[i]).put(0, wait=True)
423-
PV(pv_pi_enable[i]).put(0, wait=True)
424-
PV(pv_amp_enable[i]).put(0, wait=True)
434+
PV(pv_pi_enable[i]).put(0, wait=True)
435+
PV(pv_amp_enable[i]).put(0, wait=True)
425436
time.sleep(0.5)
426437

427438
print('>>> Disable the square wave and set SP = 0 for channel %02d... Done!\n'%(i))
@@ -476,8 +487,8 @@
476487

477488
for i in range(0, channels):
478489
PV(pv_current_setpoint[i]).put(sp, wait=True)
479-
PV(pv_pi_enable[i]).put(1, wait=True)
480-
PV(pv_amp_enable[i]).put(1, wait=True)
490+
PV(pv_pi_enable[i]).put(1, wait=True)
491+
PV(pv_amp_enable[i]).put(1, wait=True)
481492

482493
print('\n----------------- Calculate the PSD for SP = %fA ------------------\n'%(sp))
483494

@@ -528,8 +539,8 @@
528539
for i in range(0, channels):
529540
PV(pv_current_setpoint[i]).put(0, wait=True)
530541
PV(pv_current_setpoint_inf).put(0, wait=True)
531-
PV(pv_pi_enable[i]).put(0, wait=True)
532-
PV(pv_amp_enable[i]).put(0, wait=True)
542+
PV(pv_pi_enable[i]).put(0, wait=True)
543+
PV(pv_amp_enable[i]).put(0, wait=True)
533544

534545
print('>>> Set the current setpoint limits in zero for all channels... Done!')
535546

@@ -550,9 +561,9 @@
550561
time.sleep(0.2)
551562
PV(pv_square_wave_enable[i]).put(1, wait=True)
552563
time.sleep(0.2)
553-
PV(pv_pi_enable[i]).put(1, wait=True)
564+
PV(pv_pi_enable[i]).put(1, wait=True)
554565
time.sleep(0.2)
555-
PV(pv_amp_enable[i]).put(1, wait=True)
566+
PV(pv_amp_enable[i]).put(1, wait=True)
556567
time.sleep(0.5)
557568

558569
print('>>> Enable the square wave for channel %02d... Done!'%(i))
@@ -583,8 +594,8 @@
583594

584595
PV(pv_square_wave_enable[i]).put(0, wait=True)
585596
PV(pv_current_setpoint[i]).put(0, wait=True)
586-
PV(pv_pi_enable[i]).put(0, wait=True)
587-
PV(pv_amp_enable[i]).put(0, wait=True)
597+
PV(pv_pi_enable[i]).put(0, wait=True)
598+
PV(pv_amp_enable[i]).put(0, wait=True)
588599
time.sleep(0.5)
589600

590601
print('>>> Disable the square wave and set SP = 0 for channel %02d... Done!\n'%(i))
@@ -639,8 +650,8 @@
639650

640651
for i in range(0, channels):
641652
PV(pv_current_setpoint[i]).put(sp, wait=True)
642-
PV(pv_pi_enable[i]).put(1, wait=True)
643-
PV(pv_amp_enable[i]).put(1, wait=True)
653+
PV(pv_pi_enable[i]).put(1, wait=True)
654+
PV(pv_amp_enable[i]).put(1, wait=True)
644655

645656
print('\n----------------- Calculate the PSD for SP = %fA ------------------\n'%(sp))
646657

@@ -691,8 +702,8 @@
691702
for i in range(0, channels):
692703
PV(pv_current_setpoint[i]).put(0, wait=True)
693704
PV(pv_current_setpoint_inf).put(0, wait=True)
694-
PV(pv_pi_enable[i]).put(0, wait=True)
695-
PV(pv_amp_enable[i]).put(0, wait=True)
705+
PV(pv_pi_enable[i]).put(0, wait=True)
706+
PV(pv_amp_enable[i]).put(0, wait=True)
696707

697708
print('>>> Set the current setpoint limits in zero for all channels... Done!')
698709

@@ -713,9 +724,9 @@
713724
time.sleep(0.2)
714725
PV(pv_square_wave_enable[i]).put(1, wait=True)
715726
time.sleep(0.2)
716-
PV(pv_pi_enable[i]).put(1, wait=True)
727+
PV(pv_pi_enable[i]).put(1, wait=True)
717728
time.sleep(0.2)
718-
PV(pv_amp_enable[i]).put(1, wait=True)
729+
PV(pv_amp_enable[i]).put(1, wait=True)
719730
time.sleep(0.5)
720731

721732
print('>>> Enable the square wave for channel %02d... Done!'%(i))
@@ -746,8 +757,8 @@
746757

747758
PV(pv_square_wave_enable[i]).put(0, wait=True)
748759
PV(pv_current_setpoint[i]).put(0, wait=True)
749-
PV(pv_pi_enable[i]).put(0, wait=True)
750-
PV(pv_amp_enable[i]).put(0, wait=True)
760+
PV(pv_pi_enable[i]).put(0, wait=True)
761+
PV(pv_amp_enable[i]).put(0, wait=True)
751762
time.sleep(0.5)
752763

753764
print('>>> Disable the square wave and set SP = 0 for channel %02d... Done!\n'%(i))

0 commit comments

Comments
 (0)