Wiregrid Encoder Agent
The Wiregrid Encoder Agent records the wire-grid encoder outputs related to the rotational angle of the wire-grid. The encoder reader data is read by a BeagleBoneBlack on the grid-loader electronics plate. The BeagleBoneBlack sends the measured data to this agent via ethernet UDP connection. This agent parses the received data to a readable data and records it.
usage: python3 agent.py [-h] [--port PORT]
Agent Options
- --port
Port of the beaglebone running wiregrid encoder DAQ
Default: 50007
Dependencies
This agent recieves the data from BeagleBoneBlack. Therefore, a script reading the encoder data should be running in the BeagleBoneBlack: https://github.com/simonsobs/wire_grid_loader/tree/master/Encoder/Beaglebone.
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': 'WiregridEncoderAgent',
'instance-id': 'wgencoder',
'arguments': [['--port', 50007]]},
The port is used to receive the data from the BeagleBoneBlack. The port number is determined in the script running in the BeagleBoneBlack.
Docker Compose
An example docker-compose configuration:
ocs-wgencoder-agent:
image: simonsobs/socs:latest
restart: always
hostname: ocs-docker
environment:
- INSTANCE_ID=wgencoder
volumes:
- ${OCS_CONFIG_DIR}:/config:ro
- "/data/wg-data:/data/wg-data"
ports:
- "50007:50007/udp"
/data/wg-data
is a directory to store the information of the current angle of the wire-grid rotation, which is used inWiregrid Kikusui Agent
for feedback control of the rotation.ports
is defined to receive the data from BeagleBoneBlack via UDP connection.
Description
Hardware Configurations
The hardware-related variables are defined in wiregrid_encoder.py
:
COUNTER_INFO_LENGTH = 100
COUNTS_ON_BELT = 52000
These should be consistent with the script running in the BeagleBoneBlack, and these numbers will rarely be changed because they depend on the hardware.
There are variables related to the data format in signal_parser.py
.
The variables should be consistent with the BeagleBoneBlack script as well.
They also will rarely be changed.
Agent API
- class socs.agents.wiregrid_encoder.agent.WiregridEncoderAgent(agent_obj, bbport=50007)[source]
Agent to record the wiregrid rotary-encoder data. The encoder signal and IRIG timing signal is read by a BeagleBoneBlack (BBB). The BBB sends the data to this PC via Ethernet.
- Parameters:
bbport (int) – Port number of the PC determined in the script running in the BBB.
- acq()[source]
Process - Run data acquisition.
Notes
The most recent data collected is stored in session.data in the structure:
>>> response.session['data'] {'fields': { 'irig_data': { 'last_updated': timestamp, 'irig_time': computer unix time in receiving the IRIG packet, 'rising_edge_count': PRU clock (BBB clock) count, 'edge_diff': Difference of PRU clock from the previous IRIG data, 'irig_sec': IRIG second, 'irig_min': IRIG minuite, 'irig_hour': IRIG hour, 'irig_day': IRIG Day, 'irig_year': IRIG Year }, 'encoder_data': { 'last_updated': timestamp, 'quadrature' (list): quadrature encoder signals, 'pru_clock' (list): PRU clock (Beaglebone clock) , 'reference_degree' (list): Encoder rotation position [deg.], 'error' (list): Encoder error flags }, }, 'timestamp': timestamp when it updates the irig or encoder data }