Ejemplo n.º 1
0
            break

    #Calculate the new write values from the step being taken 
    WF6H_Write_Value = WF6H_Start + (Delta_6/read_steps)*i
    WF7H_Write_Value = WF7H_Start - (Delta_7/read_steps)*i
    
    #Append the new write value to the Window Frame lists
    WF6H_list.append(WF6H_Write_Value)
    WF7H_list.append(WF7H_Write_Value)

    #Update a temporary value to be used when walking the loop back
    WF6H_max = WF6H_Write_Value
    WF7H_max = WF7H_Write_Value

    #Write to the PLC
    M.Write(Client, WF6H_Tag, WF6H_Write_Value)
    M.Write(Client, WF7H_Tag, WF7H_Write_Value)

    #Taking the value of the current collected and averaging, the list is temporary because it is updated each run
    collection = (M.Read(Client, Target_Tag, Average = True, count = 20,sleep_time = .010) + M.Read(Client, Target_Tag_2, Average = True, count = 20,sleep_time = .010))

    collected_list_H.append(collection) #Storing the values in the collection list

    i_max = i #storing the maximum i value to be used to walk the loop back

    #This is to start the walk backward from the max horizontal value reached
    #    where we are checking to see that we
    #        1: haven't fallen below our threshold colletion and
    #        2: Haven't reached our maximum walking value
    #    When either of these conditions are satisfied, we start our walk in the other direction
    if abs(collection) < abs(Start_Current) * Threshold_Percent/100 or i == read_steps:
Ejemplo n.º 2
0
for index in range(Num_sawtooths_1):  #First loop with V0_1 and V0_2

    #Taking the plateau data
    runtime = time.time()
    if index:
        while time.time() - runtime < sleep_time:
            Full_Data_Set.append(M.Gather(Client, Tag_List))

    #Start setting the sleep time if on the first pass in this loop
    if not index:
        start_time = time.time()

    #Ramp one way in V0 while collecting data
    for value in V0_List_1:
        M.Write(Client, Tags.V0_SP, value)
        Full_Data_Set.append(M.Gather(Client, Tag_List))

    #Finish setting the sleep time to what it took to ramp one way
    if not index:
        sleep_time = (time.time() - start_time) / 3
        print(sleep_time * 3)
    #Taking the trough data
    runtime = time.time()
    while time.time() - runtime < sleep_time:
        Full_Data_Set.append(M.Gather(Client, Tag_List))

    #Reverse! Reverse!
    for value in V0_List_1[::-1]:
        M.Write(Client, Tags.V0_SP, value)
        Full_Data_Set.append(M.Gather(Client, Tag_List))
Ejemplo n.º 3
0
        #Comparing the current value to the last write value, if it is different, this updates the break loop for both Horizontal and Vertical
        if abs(temp_check_12 - WF12H_Write_Value) >= 0.001: #WF12H Check
            H_Broken = True #Update the value of our loop breaker if there was human intervention so that further loops and this one don't run
            V_Broken = True
            print("Loop Broken")
            break
        if abs(temp_check_13 - WF13H_Write_Value) >= 0.001: #WF13H Check
            H_Broken = True
            V_Broken = True
            print("Loop Broken")
            break
            
    WF12H_Write_Value = WF12H_Start + (Delta_12/Read_Steps)*Right_Steps #Calculate the written value for each window frame
    WF13H_Write_Value = WF13H_Start - (Delta_13/Read_Steps)*Right_Steps
    
    M.Write(Client, WF12H_Tag, WF12H_Write_Value) #Write the calculated value to each window frame
    M.Write(Client, WF13H_Tag, WF13H_Write_Value)
    
    RFBM_Collection = M.Read(Client, Target_Tag, Average = True, count = count, sleep_time = sleep) #Read the Target tag count times and average
    
    Full_Data_Set.append([M.Read(Client, WF12H_Tag), M.Read(Client, WF13H_Tag), M.Read(Client, WF12V_Tag), M.Read(Client, WF13V_Tag), RFBM_Collection]) #Append all data to the current list
    
    if dBm_to_Watts(RFBM_Collection)/dBm_to_Watts(Start_Power) < Threshold_Percent*0.01: #Check to see that we are above our Threshold
        break

#############################
### Back to Center
#############################

#This function will walk us back to the start positions without taking data
M.Ramp_Two(Client, WF12H_Tag, WF13H_Tag, Magnet_1_Stop = WF12H_Start, Magnet_2_Stop = WF13H_Start, Resolution = Right_Steps)
Ejemplo n.º 4
0
IP = '192.168.1.2'

Client = M.Make_Client(IP)

WFH_Start = M.Read(Client, WFH_Tag)
WFV_Start = M.Read(Client, WFV_Tag)

######
#Walking us to our starting point
######

for i in range(1, Grid_Resolution + 1):
    WFH_Write_Value = WFH_Start - i/2 * (Horizontal_Delta/Grid_Resolution)
    WFV_Write_Value = WFV_Start + i/2 * (Vertical_Delta/Grid_Resolution)
    
    M.Write(Client, WFH_Tag, WFH_Write_Value)
    M.Write(Client, WFV_Tag, WFV_Write_Value)
    
WFH_Corner = M.Read(Client, WFH_Tag)
WFV_Corner = M.Read(Client, WFV_Tag)

#Total_Data = M.Rapid_T_Scan(Client, WFH_Tag, WFV_Tag, Read_Tag, Horizontal_Delta, Vertical_Delta, Resolution)

for i in range(Grid_Resolution_Vertical):
    
    WFV_Write_Value = WFV_Corner - i * (Vertical_Delta/Grid_Resolution_Vertical)
    
    M.write(Client,WFV_Tag,WFV_Write_Value)
    
    if i == 0:
        
Step_size = 30 #(Hz) Change in frequency with each regulation step
Pulse_Step_Size = 20 #(Hz) Change in frequency with each regulation step when pulsing
Max_Threshold = 100000000 #(Hz) Total amount of frequency change before automatically tripping off program ## 1e8 is effectively deactivating this interlock
Walk_Threshold = 0.5 #(mV) Deviation from 0 the error signal needs to be before CW regulation kicks in
Pulse_Walk_Threshold = 0.5 #(mV) Deviation from 0 the error signal needs before pulsing regulation kicks in
Wait_after_step = 0.0400 #Seconds, the time waited after a step is taken, necessary to allow oscope measurements to change
Wait_between_reads = 0.0100 #Seconds, currently not used, supplemented by GUI time between reads
Interlock_Threshold_mv = 40 #mv, this is the amount of deviation before regulation trips off

Loops_Debounce = 1
Trip_Debounce = 6
Long = False #The form that our measurement is output from the o-scope, depending on the way it is set up this can be in either a short or long form
## additional tweak in testing 200417

Error_signal_offset = 0 # (mV) want to pulse off zero
M.Write(Client, Regulation_Entry_Tag, Error_signal_offset)
reset_on_start = False #This tag is in case we want to reset the entire oscilloscope on startup

GPIB.measurement_setup(OS,IF_Channel, measurement = Measurement) #Setting up the required measurement for regulation

# These reset the oscilloscope on startup, only the one above is needed.
#GPIB.channel_settings_check(OS, IF_Channel) #Setting up the vertical and horizontal settings for the error signal
#GPIB.trigger_settings_set(OS, Trigger_Channel, Trigger_Level) #Sets up the vertical settings for trigger channel and trigger parameters
#GPIB.vertical_marker_pulsing(OS, IF_Channel) #Sets up vertical cursor bars to read edge of pulse

Ups = 0 #number of steps taken up before taking one down
Downs = 0 #visa versa
i = 0 #total number of iterative loops gone through, only present to show differences in command line readouts
ups_debounce_counter = 0
downs_debounce_counter = 0
Ejemplo n.º 6
0
        #Comparing the current value to the last write value, if it is different, this updates the break loop for both Horizontal and Vertical
        if abs(temp_check_6 - WF6H_Write_Value) >= 0.001: #WF6H Check
            H_Broken = True
            V_Broken = True
            print("Loop Broken")
            break
        if abs(temp_check_7 - WF7H_Write_Value) >= 0.001: #WF7H Check
            H_Broken = True
            V_Broken = True
            print("Loop Broken")
            break
            
    WF6H_Write_Value = WF6H_Start + (Delta_6/Read_Steps)*Right_Steps #Calculated value to walk 6 to the right
    WF7H_Write_Value = WF7H_Start - (Delta_7/Read_Steps)*Right_Steps #Calculated value to walk 7 to the left
    
    M.Write(Client, WF6H_Tag, WF6H_Write_Value) #Writing to 6h
    M.Write(Client, WF7H_Tag, WF7H_Write_Value) #Writing to 7h
    
    Target_1_Collection = M.Read(Client, Target_Tag, Average = True, count = count, sleep_time = sleep) #Averaging the collection at these points for each dump
    Target_2_Collection = M.Read(Client, Target_Tag_2, Average = True, count = count, sleep_time = sleep) 
    
    Full_Data_Set.append([M.Read(Client, WF6H_Tag), M.Read(Client, WF7H_Tag), M.Read(Client, WF6V_Tag), M.Read(Client, WF7V_Tag), Target_1_Collection, Target_2_Collection, M.Read(Client, EC_Tag)]) #Adding all the data from this point to the array
    
    if abs(Target_1_Collection + Target_2_Collection) < abs(Threshold_Percent*Start_Current*.01): #Checking our threshold
        break

#############################
### Back to Center
#############################

print("Moving to center")
import Master as M
import time
import Tag_Database as Tags
import matplotlib.pyplot as plt

Client = M.Make_Client('10.50.0.10')

times = list()

for _ in range(1000):

    start_time = time.time()

    Tag1 = M.Read(Client, Tags.WF1H)

    M.Write(Client, Tags.WF1H, 0)

    times.append(1000 * (time.time() - start_time))

plt.hist(times)
plt.xlabel('time (ms)')
plt.ylabel('counts')

plt.show()
Ejemplo n.º 8
0
def Toggle(Client, Tag_Number):

    M.Write(Client, Tag_Number, (M.Read(Client, Tag_Number) == False))

    return
Ejemplo n.º 9
0
def Writes(Client, Tags, Values):
    for Tag, Value in Tags, Values:
        M.Write(Client, Tag, Value)
Ejemplo n.º 10
0
        append_to_file(filename,
                       "{:.1f} ms".format(1000 * (time.time() - start_time)))
    except:
        print("Write to Excel failed")
        filename = '{}/Amp_data_{}.csv'.format(
            datadir,
            datetime.today().strftime('%y%m%d_%H%M'))

#         M.Write_Multiple(Client, Tag_List[0], Values) #Writing all of the values to the PLC
#         Writes(Client, [],[])

    try:
        for Value_Index, Mod in zip(LOI, Modbus):
            print(Mod, Values[Value_Index - 1])
            M.Write(Client, Mod, Values[Value_Index - 1])
        pass
    except:

        print("Write to PLC failed...")
        print("Waiting...")
        time.sleep(Sleep_Check_Time / 10)

        try:  #Try again with fresh connection
            #M.Make_Client(PLC_IP)
            #M.Write_Multiple(Client, Tag_List[0], Values)
            pass
        except:
            print("Write to PLC failed after {:.2f} second wait".format(
                Sleep_Check_Time / 10))
Ejemplo n.º 11
0
    #Taking the plateau data
    runtime = time.time()
    if index:
        while time.time() - runtime < sleep_time:
            Full_Data_Set.append(M.Gather(Client, Tag_List, \
                      initial_values = [\
                          time.time(), \
                          value]))

    #Start setting the sleep time if on the first pass in this loop
    start_time = time.time()

    #Ramp one way in V0 while collecting data
    for value in V0_List_1:
        M.Write(Client, Tags.V0_SP, value)
        Full_Data_Set.append(M.Gather(Client, Tag_List, \
                      initial_values = [\
                          time.time(), \
                          value]))

    #Finish setting the sleep time to what it took to ramp one way
    print(time.time() - start_time)

    #Taking the trough data
    runtime = time.time()
    while time.time() - runtime < sleep_time:
        Full_Data_Set.append(M.Gather(Client, Tag_List, \
                      initial_values = [\
                          time.time(), \
                          value]))