40m QIL Cryo_Lab CTN SUS_Lab TCS_Lab OMC_Lab CRIME_Lab FEA ENG_Labs OptContFac Mariner WBEEShop
  PSL  Not logged in ELOG logo
Entry  Fri Aug 25 00:23:24 2017, awade, DailyProgress, Computers, Configuring upstart services to boot python scripts 
    Reply  Sun Sep 3 15:55:47 2017, awade, DailyProgress, Computers, Updates to python PID locker and new autolocker scripts 
Message ID: 1894     Entry time: Sun Sep 3 15:55:47 2017     In reply to: 1878
Author: awade 
Type: DailyProgress 
Category: Computers 
Subject: Updates to python PID locker and new autolocker scripts 

I've been doing a bit of maintenance on our current locker scripts in the PSL lab.


Yinzi translated our perl PID locker code (originally from the 40m) into python and I had added a argument and config file parser to make the script more general purpose.  The idea was that you just drop parameters and channel names into an external .ini file to configure the script to any PID application with EPICS slow channels.  None of these hard coding of channels into each script, which is a nightmare to manage, in terms of version management, the long term. However, the way I implemented this in the code was awkward and made it hard to expand/modify.  I've rearranged the PIDlocker.py script to be more modular, calling config and cmdline argument parsers from functions/classes and moving some of the general purpose code into functions. 

I've also added a feature which allows you to list an arbitrary number of 'requiredstates' channels for the loop to engage (or no channels if you want it to be always on).  Simple drop binary channel names under requiredstates in the .ini config file, one per line, with at least one space or tab at the start of each line (no blank lines in between).  All of these channels must be state 1 for the PID loop to engage.  The reason for this is to allow for a locking hierarchy. Dedicated PID north and south channel buttons can activate the loop as well as the requirement that the FSS engage channel must be up as well. This saves a lot of pain from having scripts to manage the scripts.  Each PIDlocker.py instance looks after itself.

The input arguments have changed a little, you no longer need a '-i' flag to specify the name and location of the .ini config file.

Also, Gautam had an issue at the 40m, they didn't have soft channels for some of the less essential channels, like blinkly channel and set point.  Now, if you leave these lines blank in the .ini file or remove them, it defaults to no blinky indicator and set point zero. You can also omit the timestep channel to default to 1 second.

All of these is committed to the CTNLab/current/computing/scripts/ path of the 40m svn.  



The last auto locker used in the PSL lab was also perl.  I've written a python autolocker.py that ramps an actuator voltage up and down until either a threshold value on a monitor channel is met or the requiredstates list of channels are no longer all state 1. It then sits there polling the state of the theshold or required channels until action is needed (at the moment every 5 seconds).  Similar to the PIDLocker.py there is an .ini config file to specify channels in each running instance of the script and it supports the same style of hierarchical engage based all the prerequisite binary channels all being engaged. Below is a typical .ini file for the south path autolocker. Variables are self explanatory: you specify a channel to monitor for threshold reached, and actuator, a binary engage channel to enable target loop and a list of required states for autolocker to know its ok to start searching. stepRate sets the time between steps along with stepSize to set the size of each step.  You need to also set a range with sweepRangeUpper/Lower. The settleTime is time to wait for slow systems to catch up to big changes.

loopStateEnable: C3:PSL-SCAV_TTFSS_RAMP_EN

thresholdVal: 0.65
stepRate: 0.1
stepSize: 0.00005
sweepRangeUpper: -6.9
sweepRangeLower: -6.80
settleTime: 5.0
loopsToFullRange: 1
numAttempts: 0

pollRate: 5.0

I've put lots of comments in the script and its commited to the 40m svn under path CTNLab/current/computing/scripts/

Changes to services on acromag1 in the PSL lab

For reference here is a list of upstart services running on acromag1:

  • PSL-SLC-north
  • PSL-SLC-south
  • PSL-AUTOLOCK-north
  • PSL-AUTOLOCK-south

As noted in the previous post PSL:1878, these can be stopped with

sudo service <service-name> stop

and started with

sudo service <service-name> start

you can also try 'restart' to reboot if .ini files is updated.  

All services will automatically boot with restart of the machine, if you're feeling lazy.

ELOG V3.1.3-