Wiregrid Kikusui Agent

The Wiregrid Kikusui Agent controls the wire-grid rotation. The KIKUSUI is a power supply and it is controlled via serial-to-ethernet converter. The converter is linked to the KIKUSUI via RS-232 (D-sub 9pin cable). The agent communicates with the converter via Ethernet.

usage: python3 agent.py [-h] [--kikusui-ip KIKUSUI_IP]
                        [--kikusui-port KIKUSUI_PORT]
                        [--encoder-agent ENCODER_AGENT] [--debug]

Agent Options

--kikusui-ip
--kikusui-port
--encoder-agent

Instance id of the wiregrid encoder agent

Default: “wgencoder”

--debug

Write a log file for debug

Default: False

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': 'WiregridKikusuiAgent',
 'instance-id': 'wgkikusui',
 'arguments': [['--kikusui-ip', '10.10.10.71'],
               ['--kikusui-port', '29'],
               ['--encoder-agent', 'wgencoder']]},
  • kikusui-ip is an IP address of the serial-to-ethernet converter.

  • kikusui-port is an asigned port for the KIKUSUI power supply. (The converter has four D-sub ports to control multiple devices connected via serial communication. Communicating device is determined by the ethernet port number of the converter.)

  • encoder-agent is an instance ID of the wiregrid encoder agent (wiregrid-encoder). This is necessary to get the position recorded by the encoder for controlling the rotation.

Docker Compose

An example docker-compose configuration:

ocs-wgkikusui-agent:
  image: simonsobs/socs:latest
  hostname: ocs-docker
  network_mode: "host"
  command:
    - INSTANCE_ID=wgkikusui
  volumes:
    - ${OCS_CONFIG_DIR}:/config:ro
    - "<local directory to record log file>:/data/wg-data/action"
  • Since the agent within the container needs to communicate with hardware on the host network you must use network_mode: "host" in your compose file.

  • To control the wire-grid rotation accurately, the agent uses the OCS output of the Wiregrid Encoder Agent.

  • For the calibration_wg() function and debug mode (assigned by --debug option), a directory path to log files should be assigned in the volumes section (/data/wg-data/action is the path in the docker).

Description

Functions

The agent has many functions, however most of them are for testing. The main function is stepwise_rotation().

Main Function (Stepwise Rotation)
  • stepwise_rotation(): Run step-wise rotation for wire-grid calibration. In each step, seveal small-rotations are occurred to rotate 22.5-deg.

Continuous Rotation Funciton Nominally, the wire-grid calibration uses the above stepwise rotation. However, if you want to rotate the wire-grid continuousely, you can use the following functions. - set_c(): Set current [A] - set_on(): Power ON the KIKUSUI power supply (start the rotation) - set_off(): Power OFF the KIKUSUI power supply (stop the rotation)

Optional Functions
  • get_vc(): Show voltage [V], current [A], and ON/OFF

  • set_v(): Set voltage [V] (NOTE: Default motor voltage is 12 V. Thus, only 12 V is acceptable.)

  • get_angle(): Show wire-grid rotation angle obtained from encoder agent

Calibration Function
  • calibrate_wg(): Run rotation-motor calibration for the wire-grid. The output of this calibration is used to control the rotation in stepwire_rotation(). This function repeats rotations several times and takes too long time (> hours).

Agent API

class socs.agents.wiregrid_kikusui.agent.WiregridKikusuiAgent(agent, kikusui_ip, kikusui_port, encoder_agent='wgencoder', debug=False)[source]

Agent to control the wire-grid rotation The KIKUSUI is a power supply and it is controlled via serial-to-ethernet converter. The converter is linked to the KIKUSUI via RS-232 (D-sub 9pin cable). The agent communicates with the converter via eternet.

Parameters:
  • kikusui_ip (str) – IP address of the serial-to-ethernet converter

  • kikusui_port (int or str) – Asigned port for the KIKUSUI power supply The converter has four D-sub ports to control multiple devices connected via serial communication. Communicating device is determined by the ethernet port number of the converter.

  • encoder_agent (str) – Instance ID of the wiregrid encoder agent

  • debug (bool) – ON/OFF of writing a log file

set_on()[source]

Task - Set output ON.

set_off()[source]

Task - Set output OFF.

set_c(current=0)[source]

Task - Set current [A]

Parameters:

current (float) – set current [A] (should be [0.0, 3.0])

set_v(session, params)[source]

set_v*volt=12.)

Task - Set voltage [V].

Parameters:

volt – set voltage [V] (Usually 12V / Should be [0.0, 12.0])

get_vc()[source]

Task - Show voltage [V], current [A], output on/off.

get_angle()[source]

Task - Show wire-grid rotaiton angle [deg].

calibrate_wg()[source]

Task - Run rotation-motor calibration for wire-grid.

stepwise_rotation(feedback_steps=8, num_laps=1, stopped_time=10, feedback_time=[0.181, 0.221, 0.251, 0.281, 0.301])[source]

Task - Run step-wise rotation for wire-grid calibration. In each step, seveal small-rotations are performed to rotate 22.5-deg.

Parameters:
  • feedback_steps (int) – Number of small rotations for each 22.5-deg step.

  • num_laps (int) – Number of laps (revolutions).

  • stopped_time (float) – Stopped time [sec] for each 22.5-deg step.

  • feedback_time (list) – Calibration constants for the 22.5-deg rotation.

IV_acq()[source]

Process - Run data acquisition.

Notes

The most recent data collected is stored in session.data in the structure:

>>> response.session['data']
{'fields':
    {
     'kikusui':
        {'volt': voltage [V],
         'curr': current [A],
         'voltset': voltage setting [V],
         'currset': current setting [A],
         'status': output power status 1(on) or 0(off)
         }
    },
 'timestamp':1601925677.6914878
}

Example Clients

Below is an example client to insert and eject the kikusui:

from ocs.ocs_client import OCSClient
wgkikusui = OCSClient('wgkikusui')

# Set Voltage
wgkikusui.set_v(volt=12.)

# Set Current
wgkikusui.set_c(current=3.)

# Get voltage/current/onoff
status, msg, session = wgkikusui.get_vc()
print(session['messages'][1][1])

# Stepwise rotation
wgkikusui.stepwise_rotation(
    feedback_steps=8,
    num_laps=1,
    stopped_time=10.,
    )

# Continuous rotation
import time
wgkikusui.set_on()
time.sleep(10) #  10 sec rotation
wgkikusui.set_off()