Ejemplo n.º 1
0
    bias harmonic field both on and off to help compensate for change in
    position of the cathode. This data is used to determine the strength 
    of our accelerating fields and to help determine running parameters.
    
Example of how to use it:
    - Run it
'''

import Master as M
import Tag_Database as Tags
import numpy as np
import matplotlib.pyplot as plt
import time

time_1 = time.time()
Client = M.Make_Client("10.50.0.10")
M.Read(Client, Tags.WF1H
       )  #Arbitrary read to establish trust (I think this part is weird to me)

################################################################
### Initialize #################################################
################################################################

V0_resolution = 50  #Resolution of steps taken in both cutoff measurements
Num_sawtooths_1 = 1  #number of points taken in the first cutoff
Num_sawtooths_2 = 1  #second cutoff

################################################################
### Grab the operator input of V0 ranges #######################
################################################################
Ejemplo n.º 2
0
import sys
# insert at 1, 0 is the script path (or '' in REPL)
sys.path.insert(1, '..\\')

import Master as M
import Tag_Database_West as Tags

plot_type = 'png'

Tunnel, PLC_IP, os_address, Runs, Step_Size, count, Oscope = M.config_reader(
    'dp1_scan_config.txt', "Dipole Scan")

# print(Tunnel, PLC_IP, os_address, Runs, Step_Size, count, Oscope)
# print(type(Tunnel), type(PLC_IP), type(os_address), type(Runs), type(Step_Size), type(count), type(Oscope))

Client = M.Make_Client(PLC_IP)

End_Value = float(
    input(
        "What is the ending amperage that you want to ramp the magnet to? (Amps)   "
    ))

now = datetime.today().strftime(
    '%y%m%d_%H%M%S'
)  #Taking the current time in YYMMDD_HHmm format to save the plot and the txt file

#Grabbing all of our data for the system snapshot
#################################################
Pulsing_Status = bool(M.Read(Client, Tags.Pulsing_Output, Bool=True))

Emission_Setpoint = M.Read(Client, Tags.Emission_Set)
Ejemplo n.º 3
0

#Adjust T scan Parameters
Horizontal_Delta = .1
Vertical_Delta = .1
Resolution = 40


#Adjust Grid Parameters
Grid_Resolution_Horizontal = 4
Grid_Resolution_Vertical = 5

#For the client
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)
    
Ejemplo n.º 4
0
    - Read the Starting current of the Dump
    - At the beginning of each run, check to insure no human intervention has occurred with the write, if it has, kill the loop, continue to produce graphs and txt file
    - Add the appropriate step to each magnet
    - Read the current many times and then take the average of that current and store it alongside the written values for the magnets
    - Every step of the way check if the current has dropped below a specified threshold, if it has, then walk the magnets backs where they came from by the steps taken,
         plus the same amount of read steps going the other way.
    - Repeat the same safety checks, always check each step that the current hasn't reached a lowpoint beyond the threshold
    - When it has, or it reaches the end, turn the magnets back around to walk back to where they started.
    - Repeat for the other set of magnets (Vertical)
    - Plot and produce txt file with Magnet settings in the left column and current readbacks in the right

'''

#Establish a connection to the PLC

Client = M.Make_Client('10.50.0.10')

#Dog Leg

Target_Tag = Tags.Recirculator_Halfway #Importing the tag value from our Tag Database
Target_Tag_2 = Tags.Recirculator_Bypass
Threshold_Percent = 0 #Float. The percentage of beam that we want to collect in order to turn the Dog Leg around

Zoom_In_Factor = 1 #This is how much we want to zoomn in if we are interested in an artifact at the center of the dog leg or want higher precision in the center

#Starting the loop to read the current collected

#Take the starting value of the Target Tag, use for the threshold

read_steps = 40 #Integer. Number of steps to be taken in the Dog Leg. Must be an integer
count = 10 #Integer. How many points will be recorded at each step and averaged over.
Ejemplo n.º 5
0
import GPIB_FUNCS as GPIB #Importing our GPIB communication functions for easier comprehension and use
import pyvisa #import GPIB communication module
import time #imports time to sleep program temporarily
import Master as M
import Tag_Database as Tags

Client = M.Make_Client('10.50.0.10') #Connecting to PLC


print(M.Read(Client, Tags.Oscope_Reset, Bool = True))
print(M.Read(Client, Tags.Regulation_Setpoint_Reset, Bool = True))
print(M.Read(Client, Tags.Error_Signal_Regulation, Bool = True))
print(M.Read(Client, Tags.Pulsing_Output, Bool = True))
#for i in range(100):
#    M.Write(Client,55555, i)
#    print(i)
#    time.sleep(0.1)


#Pulsing_Tag = Tags.Pulsing_Output #Assign Modbus address here
Running_Tag = Tags.Error_Signal_Regulation #Assign Modbus address here
#Reset_Tag = Tags.Error_Signal_Reset #Assign Modbus address here
#Regulation_Setpoint_Tag = Tags.Regulation_Setpoint_Reset #Assign Modbus address here

RM = pyvisa.ResourceManager() #pyVISA device manager
Resources = RM.list_resources() #Printing out all detected device IDs
print(Resources)
SG = RM.open_resource("GPIB0::10::INSTR")
OS = RM.open_resource("GPIB0::16::INSTR")
time.sleep(2)
Ejemplo n.º 6
0
    - Repeat for the other set of magnets (Vertical)
    - Plot and produce txt file with Magnet settings in the left column and current readbacks in the right

'''

import Master as M
import time
import matplotlib.pyplot as plt
import numpy as np
from datetime import datetime
import Tag_Database as Tags


#Establish a connection to the PLC

Client = M.Make_Client('192.168.1.6')

start_time = time.time()
#Dog Leg

Target_Tag = Tags.RF_Beam_Mon #Int or Str. Which Tag we are reading, we are interested in the RF Beam monitor currently
Threshold_Percent = 0 #Float. The percentage of beam that we want to collect in order to turn the Dog Leg around

Zoom_In_Factor = 1 #This is how much we want to zoom in if we are interested in an artifact at the center of the dog leg or want higher precision in the center

Scale_Factor = 1 #This is how much we want to scale off of the excel documents used prior to Dog Legs
mm_factor = 1
#Starting the loop to read the current collected

#Take the starting value of the Target Tag, use for the threshold
Ejemplo n.º 7
0
import time  #imports time to sleep program temporarily
import Master as M
import numpy as np
import Tag_Database as Tags
from datetime import datetime
import os


def flasher(times):
    for _ in range(times):
        os.system('color DF')
        time.sleep(0.2)
        os.system('color 0F')


Client = M.Make_Client('10.60.0.11')

Pulsing_Tag = Tags.Pulsing_Output  #Assign Modbus address here
Running_Tag = Tags.Error_Signal_Regulation  #Assign Modbus address here
Reset_Tag = Tags.Oscope_Reset  #Assign Modbus address here
Regulation_Setpoint_Tag = Tags.Regulation_Setpoint_Reset  #Assign Modbus address here
Regulation_Entry_Tag = Tags.Regulation_Float  #The input tag for this guy

RM = pyvisa.ResourceManager()  #pyVISA device manager
Resources = RM.list_resources()  #Printing out all detected device IDs
print(Resources)
try:
    SG = RM.open_resource(
        Resources[0])  #Opening the Signal generator as an object
    OS = RM.open_resource(Resources[1])  #Opening the oscilloscope as an object
Ejemplo n.º 8
0
        )  #Modbus tag numbering convention for all of these, these are the starts and steps between likewise magnets
    if i < WFVnum:
        Vnums.append(20201 + 4 * i)
    if i < DPnum:
        Dpnums.append(22201 + 2 * i)
    if i < Solnum:
        Solnums.append(21201 + 2 * i)

#Reading in the excel file as a dataframe for easier access (abbreviated as df)

excel_as_df = pd.read_excel(
    '..\Magnet Saves\{}.xlsx'.format(Notebook)
)  #Using windows command line controls to direct python to the directory

Client = M.Make_Client(
    '192.168.1.2'
)  #Establishing a connection with the PLC, see Master.Make_Client

for i in range(
        len(Hnums)):  #Iterate through the list of Horizontal window frames
    print("Window Frame {} H".format(i + 1), Hnums[i],
          excel_as_df['WF H'].iloc[i])  #Print which magnet it is ramping
    M.Ramp_One_Way(Client,
                   Hnums[i],
                   excel_as_df['WF H'].iloc[i],
                   Max_Step=0.010)  #Ramp that magnet, see Master.Ramp_One_Way
#Repeat for all types of magnets
for i in range(len(Vnums)):
    print("Window Frame {} V".format(i + 1), Vnums[i],
          excel_as_df['WF V'].iloc[i])
    M.Ramp_One_Way(Client,
Ejemplo n.º 9
0
    - Run it

******* Changes to Master File -- Gather() added inital_values for speed
******* Changes to Tag Database -- Added BH Pf slider bar params (bottom)

'''

import Master as M
import Tag_Database as Tags
import numpy as np
import matplotlib.pyplot as plt
import time
from datetime import datetime

time_1 = time.time()
Client = M.Make_Client("10.60.0.11")
M.Read(Client, Tags.WF1H
       )  #Arbitrary read to establish trust (I think this part is weird to me)

################################################################
### Initialize #################################################
################################################################

number_of_points = 50  #Resolution of steps taken in both cutoff measurements
Num_sawtooths_1 = 6  #number of points taken in the first cutoff
Num_sawtooths_2 = 6  #second cutoff
Ratio_From_Start = 0.8  #The amount to move the slider bar back up after running

################################################################
### Grab the operator input of V0 ranges #######################
################################################################
Ejemplo n.º 10
0
import time
import os
import numpy as np
import Master as M  #importing the PLC communications library

#############################
## Connect to PLC, define Modbus addresses
#############################

PLC_IP = "10.1.2.100"
Amp_IP = '10.1.2.125'
Sleep_Check_Time = 10  #Seconds

try:
    Client = M.Make_Client(PLC_IP)  #Connecting to PLC
except:
    print("Connection to PLC Failed")
    print("Waiting...")
    time.sleep(Sleep_Check_Time)
    try:
        Client = M.Make_Client(PLC_IP)
    except:
        print("Connection after {} seconds failed. Ending script...".format(
            Sleep_Check_Time))
        time.sleep(10)
        exit()

#Convert amp forward power from percent to Watts
Conversion_Rate = 50
Ejemplo n.º 11
0
Points = 3000

Dipole_Amplitude = 5  #(Amps) The value we want Dipoles to reach in the peak
#This can also be set to the start value if need be

Frequency = 5  #Increase this value for more oscillations

WF_Amplitude = 3  #(Amps)

Sol_Amplitude = 4  #(Amps)

######################################
#PLC Parameters
######################################

Client = M.Make_Client("192.168.1.2")

Dipole_Start_Tag = Tags.DP1  #First Dipole we are controlling

Window_Frame_Start_Tag = Tags.WF1V  #First Window Frame we are controlling

Solenoid_Start_Tag = Tags.Sol1  #First Solenoid we are controlling

Dipole_Count = 2  #Number of Dipoles

Window_Frame_Count = 7  #Number of Window Frames

Solenoid_Count = 3  #Number of Solenoids (Not used currently)

Start_Time = time.time()
Ejemplo n.º 12
0
    - Read the Starting current of the Dump
    - At the beginning of each write, check to insure no human intervention has occurred with the write, if it has, kill the loop, continue to produce graphs and txt file
    - Add the appropriate step to each magnet
    - Read the current many times and then take the average of that current and store it alongside the written values for the magnets
    - Every step of the way check if the current has dropped below a specified threshold, if it has, then walk the magnets backs where they came from by the steps taken,
         plus the same amount of read steps going the other way.
    - Repeat the same safety checks, always check each step that the current hasn't reached a lowpoint beyond the threshold
    - When it has, or it reaches the end, turn the magnets back around to walk back to where they started.
    - Repeat for the other set of magnets (Vertical)
    - Plot and produce txt file with Magnet settings in the left column and current readbacks in the right

'''

#Establish a connection to the PLC

Client = M.Make_Client('')

start_time = time.time()
#Dog Leg

Target_Tag = Tags.Recirculator_Halfway  #Int or Str. Which Tag we are reading, 11109 is Loop bypass dump as of 01/01/2020
Target_Tag_2 = Tags.Recirculator_Bypass
Threshold_Percent = 20  #Float. The percentage of beam that we want to collect in order to turn the Dog Leg around

Zoom_In_Factor = 1  #This is how much we want to zoomn in if we are interested in an artifact at the center of the dog leg or want higher precision in the center

Scale_Factor = 0.91  #This is how much we want to scale off of the excel documents used prior to Dog Legs
#Starting the loop to read the current collected

#Take the starting value of the Target Tag, use for the threshold
Ejemplo n.º 13
0
import GPIB_FUNCS as GPIB  #Importing our GPIB communication functions for easier comprehension and use
import pyvisa  #import GPIB communication module
import time  #imports time to sleep program temporarily
import Master as M
import Tag_Database as Tags

Client = M.Make_Client('10.60.0.11')  #Connecting to PLC

print(M.Read(Client, Tags.Oscope_Reset, Bool=True))
print(M.Read(Client, Tags.Regulation_Setpoint_Reset, Bool=True))
print(M.Read(Client, Tags.Error_Signal_Regulation, Bool=True))
print(M.Read(Client, Tags.Pulsing_Output, Bool=True))
#for i in range(100):
#    M.Write(Client,55555, i)
#    print(i)
#    time.sleep(0.1)

#Pulsing_Tag = Tags.Pulsing_Output #Assign Modbus address here
Running_Tag = Tags.Error_Signal_Regulation  #Assign Modbus address here
#Reset_Tag = Tags.Error_Signal_Reset #Assign Modbus address here
#Regulation_Setpoint_Tag = Tags.Regulation_Setpoint_Reset #Assign Modbus address here

RM = pyvisa.ResourceManager()  #pyVISA device manager
Resources = RM.list_resources()  #Printing out all detected device IDs
print(Resources)
SG = RM.open_resource(Resources[0])
time.sleep(2)

print("SG \n", SG.query("*IDN?"))
print("OS \n", OS.query("*IDN?"))