Difference: ControlPowerSupply (8 vs. 9)

Revision 92016-11-03 - TomErikHaugen

Line: 1 to 1
 
META TOPICPARENT name="UsingHighVoltage"

Controlling the Power Supplies Through the Computer

Line: 22 to 22
 While remote control through the GPIB connector is on, none of the buttons on either of the power supplies will be useable. Local control can be regained on either supply by pressing the "local" button

Code for Control

Changed:
<
<
There is a large collection of scripts written for serial communication with the power supplies and the Arduino. These have all been written together in the python module SerialCommands.py.txt. There is another module of root scripts for quick data analysis that is still being implemented RootCommands.py. Lastly to make the interface with these sets of scripts much easier a third script has been written, Console.py.txt. This is the program that should be run and should be able to do all of the interfacing with the power supplies and Arduino that is necessary.
>
>
There is a large collection of scripts written for serial communication with the power supplies and the Arduino. These have all been written together in the python module SerialCommands.py.txt. There is another module of root scripts for quick data analysis that is still being implemented RootCommands.py.txt. Lastly to make the interface with these sets of scripts much easier a third script has been written, Console.py.txt. This is the program that should be run and should be able to do all of the interfacing with the power supplies and Arduino that is necessary.
  SerialCommands.py
Line: 34 to 34
  Console.py
Changed:
<
<
This is the more complicated function. It establishes the serial port for communication between the computer and the power supplies. It then queries the user for an input. To get help in Console.py enter help, to get help with a certain command enter [name of command] -h. Arguments for commands are entered with flags, each flag is separated with a space then the corresponding value is after that flag with another space, for example
>
>
This is the more complicated function. It establishes the serial port for communication between the computer and the power supplies. It then queries the user for an input. It is mostly an if,else chain to interpret the input and run the necessary function. It also has protections in place (such as not letting the user drastically alter the HV without ramping it from one value to another in steps), and assigns default values to arguments.

Alternative Method

If you prefer to avoid the Console.py interface then you can do this:

  1. run python
  2. import serial
  3. import SerialCommands as ser
  4. open the serial port (s = ser.Open_Serial('/dev/ttyUSB0', 115200))
  5. run whatever command you want, for example to power on enter ser.Power_On(s,1.5,4.2). Almost all of the commands take the serial port as an argument

Using Consoly.py

To open the interface enter through the command terminal python Console.py_. This sort of mimics a command prompt, including tab completion. Any functions can be stopped by a keyboard interrupt (Ctrl + C) this will stop whatever it is doing and return you to the prompt. Every function is interruptible without causing any problems (except start_atlys it should be fine but I have not tested that)

To get help in Console.py enter help, this will list all of the possible commands. To get help with a certain command enter [name of command] -h. Arguments for commands are entered with flags, each flag is separated with a space then the corresponding value is after that flag with another space, for example

  read_arduino -f Arduino_Data.dat_ would read the Arduino data then save it to the file Arduino_Data.dat
Line: 44 to 58
  This would read the serial port for the Arduino and save the data to a default filename that is generated using the date.
Changed:
<
<
If you prefer to avoid the Console.py interface then you can do this:
  1. run python
  2. import SerialCommands as ser
  3. open the serial port (s = ser.Open_Serial('/dev/ttyUSB0', 115200))
  4. run whatever command you want, for example to power on enter ser.Power_On(s,1.5,4.2). Almost all of the commands take the serial port as an argument
>
>
Example Commands

All of the necessary communication between the power supplies, and Arduino board can be done through this script. The most important commands are listed below:

start_atlys This performs the same function as running source setup.sh from the Desktop directory (meaning it sets up the atlys board)

power_on sets the voltage to 1.5 and 4.2 volts on the +5 and +25 Volt lines respectively. It also turns on the output for the Keithley and keysight power supplies

ramp_hv -v {HV} [-s] {Voltage Step} [-t] {Delay between steips} [-I] {Compliance Current} This ramps the voltage from whatever it currently is to the value HV. It does not accept positive values and will assign default values to any non-included arguments (only the -v flag is required)

iv_scan same as ramp_hv but saves the current and voltage at each step to a file ([-f] {filename} will save it to that filename) if no filename is given it saves it to a generated .dat file, then turns that into a root TTree in a TFile

read_arduino [-f] {filename} reads the arduino serial port and saves the readings to the filename given

monitor [-f] {filename} reads the arduino and power supplies and saves to the filename given. It waits for the Arduino output (which is periodic with a time period hard coded into arduino) then queries the power supplies.

power_off Lowers the voltage to 0 and turns all outputs off. If the Keithley HV supply is high (higher than 10V) then it will call the Ramp_HV function to lower it in steps.

There are other functions that it can run as well but those are listed under the help command and are relatively simple/less commonly used

Changing Console.py

It should be relatively easy to add new functionality to the python script. Below is an example that should include most of the necessary information:

Let's say that you have a new function named New_Func( voltage, filename ) in a module NewCommands.py where voltage is a necessary input and filename can be given a default value.

To add this to the interface you would need to edit Console.py this way:

  1. at the beginning of the script add import NewCommands
  2. in the array commands add a new string that is the name new_func
  3. in the array help_messages add a string describing how to use New_Func (this string needs to start with " new_func\n" as that is how the script matches up the command and the help message
  4. In the function process_command(ser, line)
    1. add to the if else chain elif entry[0] == "new_func":
    2. voltage = get_key_value(entry, 'v') This will find whenever the flag -v was given in the command and take the substring after it. This is using the -v flag because it is a voltage (the flag needs to be a single char and choose one that is easy to remember for the context)
    3. filename = get_key_value(entry, 'f') This assigns filename the name of whatever followed the -f flage. Since the filename is not a required input there needs to be a way to assign this variable a default value.
    4. the function get_key_value returns the string "NONE" if it was unable to find the string, so if the command new_func -v -20 was given then the script will give the filename as "NONE". Add an if statement to catch this value, if filename == "NONE":
    5. then write code to assign a default value to filename
    6. then run NewCommands.New_Func(voltage, filename)
    7. return
Note that if the new functions involves communicating through a serial port, the port either needs to be passed as an argument (sort of cumbersome), or be reinitialized in that function (incredibly repetitive/inefficient).
 -- Tom-Erik Haugen - 2016-10-21

Comments

Line: 61 to 110
 
META FILEATTACHMENT attachment="SerialCom.cpp" attr="" comment="" date="1477090488" name="SerialCom.cpp" path="SerialCom.cpp" size="1871" user="TomErikHaugen" version="1"
META FILEATTACHMENT attachment="SerialCom.h" attr="" comment="" date="1477090488" name="SerialCom.h" path="SerialCom.h" size="703" user="TomErikHaugen" version="1"
META FILEATTACHMENT attachment="start_mon.cxx" attr="" comment="" date="1477090488" name="start_mon.cxx" path="start_mon.cxx" size="3780" user="TomErikHaugen" version="1"
Changed:
<
<
META FILEATTACHMENT attachment="Console.py.txt" attr="" comment="" date="1477695264" name="Console.py.txt" path="Console.py.txt" size="9244" user="TomErikHaugen" version="2"
META FILEATTACHMENT attachment="SerialCommands.py.txt" attr="" comment="" date="1477695282" name="SerialCommands.py.txt" path="SerialCommands.py.txt" size="8637" user="TomErikHaugen" version="2"
>
>
META FILEATTACHMENT attachment="Console.py.txt" attr="" comment="" date="1478198479" name="Console.py.txt" path="Console.py.txt" size="10634" user="TomErikHaugen" version="3"
META FILEATTACHMENT attachment="SerialCommands.py.txt" attr="" comment="" date="1478198508" name="SerialCommands.py.txt" path="SerialCommands.py.txt" size="8854" user="TomErikHaugen" version="3"
META FILEATTACHMENT attachment="RootCommands.py.txt" attr="" comment="" date="1478198528" name="RootCommands.py.txt" path="RootCommands.py.txt" size="2994" user="TomErikHaugen" version="1"
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback