HWP Rotation Agent
usage: python3 rotation_agent.py [-h] [--kikusui-ip KIKUSUI_IP]
[--kikusui-port KIKUSUI_PORT]
[--pid-ip PID_IP] [--pid-port PID_PORT]
[--verbose] [--mode {idle,init,iv_acq}]
Agent Options
- --kikusui-ip
- --kikusui-port
- --pid-ip
- --pid-port
- --verbose, -v
PID Controller verbosity level.
Default: 0
- --mode
Possible choices: idle, init, iv_acq
Starting operation for the Agent.
Default: “iv_acq”
Configuration File Examples
Below are configuration examples for the ocs config file and for running the Agent in a docker container.
OCS Site Config
An example site-config-file block:
{'agent-class': 'RotationAgent',
'instance-id': 'rotator',
'arguments': [['--kikusui-ip', '10.10.10.100'],
['--kikusui-port', '2000'],
['--pid-ip', '10.10.10.101'],
['--pid-port', '2001'],
['--mode', 'iv_acq']]},
Docker Compose
An example docker-compose configuration:
ocs-hwp-rotation:
image: simonsobs/ocs-hwp-rotation-agent:latest
hostname: ocs-docker
network_mode: "host"
volumes:
- ${OCS_CONFIG_DIR}:/config:ro
command:
- "--instance-id=hwp-rotation"
- "--site-hub=ws://127.0.0.1:8001/ws"
- "--site-http=http://127.0.0.1:8001/call"
Note
Since the Agent container needs network_mode: "host"
, it must be
configured to connect to the crossbar server as if it was on the host
system. In this example the crossbar server is running on localhost,
127.0.0.1
, but on your network this may be different.
Description
Agent API
- class agents.hwp_rotation.rotation_agent.RotationAgent(agent, kikusui_ip, kikusui_port, pid_ip, pid_port, pid_verbosity)[source]
Agent to control the rotation speed of the CHWP
- Parameters
kikusui_ip (str) – IP address for the Kikusui power supply
kikusui_port (str) – Port for the Kikusui power supply
pid_ip (str) – IP address for the PID controller
pid_port (str) – Port for the PID controller
pid_verbosity (str) – Verbosity of PID controller output
- init_connection(auto_acquire=False, force=False)[source]
Task - Initialize connection to Kikusui Power Supply and PID Controller.
- Parameters
auto_acquire (bool, optional) – Default is False. Starts data acquisition after initialization if True.
force (bool, optional) – Force initialization, even if already initialized. Defaults to False.
- tune_stop()[source]
Task - Reverse the drive direction of the PID controller and optimize the PID parameters for deceleration.
- tune_freq()[source]
Task - Tune the PID controller setpoint to the rotation frequency and optimize the PID parameters for rotation.
- declare_freq(freq=0)[source]
Task - Store the entered frequency as the PID setpoint when
tune_freq()
is next called.- Parameters
freq (float) – Desired HWP rotation frequency
- set_pid(p=0.2, i=63, d=0.0)[source]
Task - Set the PID parameters. Note these changes are for the current session only and will change whenever the agent container is reloaded.
- Parameters
p (float) – Proportional PID value
i (int) – Integral PID value
d (float) – Derivative PID value
- get_direction()[source]
Task - Return the current HWP tune direction as seen by the PID controller.
- set_direction(direction='0')[source]
Task - Set the HWP rotation direction.
- Parameters
direction (str) – ‘0’ for forward and ‘1’ for reverse.
- set_scale(slope=1, offset=0.1)[source]
Task - Set the PID’s internal conversion from input voltage to rotation frequency.
- Parameters
slope (float) – Slope of the “rotation frequency vs input voltage” relationship
offset (float) – y-intercept of the “rotation frequency vs input voltage” relationship
- set_v(volt=0)[source]
Task - Set the Kikusui drive voltage.
- Parameters
volt (float) – Kikusui set voltage
- set_v_lim(volt=32)[source]
Task - Set the Kikusui drive voltage limit.
- Parameters
volt (float) – Kikusui limit voltage
- use_ext()[source]
Task - Set the Kikusui to use an external voltage control. Doing so enables PID control.
- ign_ext()[source]
Task - Set the Kiksui to ignore external voltage control. Doing so disables the PID and switches to direct control.
- iv_acq(test_mode=False)[source]
Process - Start Kikusui data acquisition.
- Parameters
test_mode (bool, optional) – Run the Process loop only once. This is meant only for testing. Default is False.
Notes
The most recent data collected is stored in the session data in the structure:
>>> response.session['data'] {'kikusui_volt': 0, 'kikusui_curr': 0, 'last_updated': 1649085992.719602}
Supporting APIs
- class socs.agent.pmx.PMX(rtu_port=None, tcp_ip=None, tcp_port=None, timeout=None)[source]
The PMX object is for communicating with the Kikusui PMX power supplies.
- Parameters
rtu_port (str) – Serial RTU port
tcp_ip (str) – TCP IP address
tcp_port (int) – TCP port
timeout (int) – Connection timeout
- check_connect()[source]
Check the connection.
- check_voltage()[source]
Check the voltage.
- check_current()[source]
Check the current.
- check_voltage_current()[source]
Check both the voltage and current.
- check_voltage_setting()[source]
Check the voltage setting
- check_current_setting()[source]
Check the current setting
- check_voltage_current_setting()[source]
Check both the voltage and current setting
- check_output()[source]
Return the output status.
- set_voltage(val, silent=False)[source]
Set the PMX voltage.
- set_current(val, silent=False)[source]
Set the PMX on.
- use_external_voltage()[source]
Set PMX to use external voltage.
- ign_external_voltage()[source]
Set PMX to ignore external voltage.
- set_voltage_limit(val, silent=False)[source]
Set the PMX voltage limit.
- set_current_limit(val, silent=False)[source]
Set the PMX current limit.
- turn_on()[source]
Turn the PMX on.
- turn_off()[source]
Turn the PMX off.
- wait()[source]
Sleep.
- clean_serial()[source]
Flush the serial buffer.