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

Commit

Permalink
scripts/tests/rtm_lamp_test.py: fix current offset calc
Browse files Browse the repository at this point in the history
  • Loading branch information
melissa-aguiar committed Mar 10, 2022
1 parent acbcc5c commit 453d1b6
Showing 1 changed file with 36 additions and 25 deletions.
61 changes: 36 additions & 25 deletions scripts/tests/rtm_lamp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# #
# Description: Script to test RTM-LAMP boards #
# #
# Authors: Melissa Aguiar #
# Author: Melissa Aguiar #
# #
# Created: Feb. 25, 2022 #
# #
Expand All @@ -25,7 +25,7 @@

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

# constants
Expand Down Expand Up @@ -57,6 +57,7 @@
# PVs per channel
pv_current_ArrayData = []
pv_voltage_ArrayData = []
pv_current_ArrayDataRAW = []
pv_current_gain = []
pv_voltage_gain = []
pv_current_offset = []
Expand All @@ -75,6 +76,7 @@
for i in range(0, channels):
pv_current_ArrayData.append( str(pv_prefix) + str("GENConvArrayDataCH") + str(i))
pv_voltage_ArrayData.append( str(pv_prefix) + str("GENConvArrayDataCH") + str(i+channels))
pv_current_ArrayDataRAW.append( str(pv_prefix) + str("GEN_CH") + str(i) + str("ArrayData"))
pv_current_gain.append( str(pv_prefix) + str("PSGainWavCH") + str(i) + str("-SP.VAL"))
pv_voltage_gain.append( str(pv_prefix) + str("PSGainWavCH") + str(i+channels) + str("-SP.VAL"))
pv_current_offset.append( str(pv_prefix) + str("PSOffsetWavCH") + str(i) + str("-SP.VAL"))
Expand All @@ -89,6 +91,15 @@
pv_pi_kp.append( str(pv_prefix) + str("PSPIKpCH") + str(i) + str("-SP.VAL"))
pv_pi_ti.append( str(pv_prefix) + str("PSPITiCH") + str(i) + str("-SP.VAL"))

print(' # # # # # # # # # # # # # # # # # # # # # # # # # #')
print(' # #')
print(' # Description: Script to test RTM-LAMP boards #')
print(' # #')
print(' # #')
print(' # Created: Feb. 25, 2022 #')
print(' # #')
print(' # # # # # # # # # # # # # # # # # # # # # # # # # #\n')

print('\n--------------------------------------------------------------------------')
print('------------------------------ STARTING TEST -----------------------------')
print('--------------------------------------------------------------------------\n')
Expand Down Expand Up @@ -166,7 +177,7 @@

new_offset = np.zeros(channels)
for i in range(0, channels):
new_offset[i] = np.mean(PV(pv_current_ArrayData[i]).get())
new_offset[i] = np.mean(PV(pv_current_ArrayDataRAW[i]).get())

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

Expand Down Expand Up @@ -362,8 +373,8 @@
for i in range(0, channels):
PV(pv_current_setpoint[i]).put(0, wait=True)
PV(pv_current_setpoint_inf).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)

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

Expand All @@ -386,9 +397,9 @@
time.sleep(0.2)
PV(pv_square_wave_enable[i]).put(1, wait=True)
time.sleep(0.2)
PV(pv_pi_enable[i]).put(1, wait=True)
PV(pv_pi_enable[i]).put(1, wait=True)
time.sleep(0.2)
PV(pv_amp_enable[i]).put(1, wait=True)
PV(pv_amp_enable[i]).put(1, wait=True)
time.sleep(0.5)

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

PV(pv_square_wave_enable[i]).put(0, wait=True)
PV(pv_current_setpoint[i]).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)
time.sleep(0.5)

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

for i in range(0, channels):
PV(pv_current_setpoint[i]).put(sp, wait=True)
PV(pv_pi_enable[i]).put(1, wait=True)
PV(pv_amp_enable[i]).put(1, wait=True)
PV(pv_pi_enable[i]).put(1, wait=True)
PV(pv_amp_enable[i]).put(1, wait=True)

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

Expand Down Expand Up @@ -528,8 +539,8 @@
for i in range(0, channels):
PV(pv_current_setpoint[i]).put(0, wait=True)
PV(pv_current_setpoint_inf).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)

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

Expand All @@ -550,9 +561,9 @@
time.sleep(0.2)
PV(pv_square_wave_enable[i]).put(1, wait=True)
time.sleep(0.2)
PV(pv_pi_enable[i]).put(1, wait=True)
PV(pv_pi_enable[i]).put(1, wait=True)
time.sleep(0.2)
PV(pv_amp_enable[i]).put(1, wait=True)
PV(pv_amp_enable[i]).put(1, wait=True)
time.sleep(0.5)

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

PV(pv_square_wave_enable[i]).put(0, wait=True)
PV(pv_current_setpoint[i]).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)
time.sleep(0.5)

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

for i in range(0, channels):
PV(pv_current_setpoint[i]).put(sp, wait=True)
PV(pv_pi_enable[i]).put(1, wait=True)
PV(pv_amp_enable[i]).put(1, wait=True)
PV(pv_pi_enable[i]).put(1, wait=True)
PV(pv_amp_enable[i]).put(1, wait=True)

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

Expand Down Expand Up @@ -691,8 +702,8 @@
for i in range(0, channels):
PV(pv_current_setpoint[i]).put(0, wait=True)
PV(pv_current_setpoint_inf).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)

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

Expand All @@ -713,9 +724,9 @@
time.sleep(0.2)
PV(pv_square_wave_enable[i]).put(1, wait=True)
time.sleep(0.2)
PV(pv_pi_enable[i]).put(1, wait=True)
PV(pv_pi_enable[i]).put(1, wait=True)
time.sleep(0.2)
PV(pv_amp_enable[i]).put(1, wait=True)
PV(pv_amp_enable[i]).put(1, wait=True)
time.sleep(0.5)

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

PV(pv_square_wave_enable[i]).put(0, wait=True)
PV(pv_current_setpoint[i]).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)
PV(pv_pi_enable[i]).put(0, wait=True)
PV(pv_amp_enable[i]).put(0, wait=True)
time.sleep(0.5)

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

0 comments on commit 453d1b6

Please sign in to comment.