Tags:
create new tag
view all tags

Controlling the Power Supplies Through the Computer

Both the Keithley (High Voltage source) and the Keysight (LV and LVDS power supply) can be controlled through the computer. They are connected to each other and the computer through a GPIB connector bus, then controlled from python scripts (temporarily in ~/Desktop/Haugen/New_Scripts). These are based heavily on the scripts from timon and allow for powering on, powering off, ramping high voltage, performing an IV scan, and recording the data. There is documentation for the connector here.

The communication happens through a serial port name /dev/ttyUSB0

Each device on the bus has to have a unique ID number between 0-30. I have set the Keysight supply to be ID 05, and the Keithley supply to be ID 10.

To change the ID:

  • Keysight:
    • press the I/O config button
    • Select HPIB / 488 (if the screen shows this press I/O Config again, if not scroll the adjust wheel till it does)
    • set the address
  • Keysight:
    • Press MENU
    • select COMMUNICATION
    • select GPIB
    • set the address
    • select GPIB protocol (SCPI)
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

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

This is the raw code that is a combination of the scripts for the power supplies and the scripts for the Arduino. All of the communication is done through serial ports, and most of the functions defined in this module take the serial port as an argument (this is so that it does not need to be reopened with every function).

RootCommands.py

This is a small set of Root macros (written in python). Currently it only features functions that read the raw data files and converts the .dat files into .root files (with a TTree). Most of these take 2 arguments, an input file, and an output file.

The new more complicated function takes an input arduino file, and output .root file, and a directory of data files from the DAQ system. It matches files from the directory to data from the arduino using the timestamp then fills a standard ttree with the arduino and daqload data. This process has one major flaw, the process loops over the data of the daq files but can only read the last modification data. If any 3PG files are changed later then the date they were modified will replace the data when the data was taken. It also currently requires the DAQ files to all be their own directory as the file matching only runs on hour and minute not on day or month of data taking.

Console.py

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

Some flags/arguments are optional. These are all listed under the specific help for that command (the flag will be listed in brackets). for example the previous command could also be given as:

read_arduino

This would read the serial port for the Arduino and save the data to a default filename that is generated using the date.

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


Topic attachments
I Attachment History ActionSorted ascending Size Date Who Comment
Texttxt Console.py.txt r5 r4 r3 r2 r1 manage 11.4 K 2016-11-15 - 00:54 TomErikHaugen  
Unknown file formatEXT Makefile r1 manage 0.8 K 2016-10-21 - 22:54 TomErikHaugen  
Texttxt RootCommands.py.txt r3 r2 r1 manage 15.1 K 2016-11-15 - 00:55 TomErikHaugen  
C source code filecpp SerialCom.cpp r1 manage 1.8 K 2016-10-21 - 22:54 TomErikHaugen  
Header fileh SerialCom.h r1 manage 0.7 K 2016-10-21 - 22:54 TomErikHaugen  
Texttxt SerialCommands.py.txt r4 r3 r2 r1 manage 9.2 K 2016-11-15 - 00:55 TomErikHaugen  
Unknown file formatcxx power_off.cxx r1 manage 2.3 K 2016-10-21 - 22:54 TomErikHaugen  
Unknown file formatcxx power_on.cxx r1 manage 4.2 K 2016-10-21 - 22:54 TomErikHaugen  
Unknown file formatcxx start_mon.cxx r1 manage 3.7 K 2016-10-21 - 22:54 TomErikHaugen  
Edit | Attach | Watch | Print version | History: r11 < r10 < r9 < r8 < r7 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r11 - 2016-11-15 - TomErikHaugen
 
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