Skip to main content

Spectroscopy lock application using RedPitaya

Project description

Spectroscopy locking of lasers using RedPitaya (STEMlab 125-14) that just works. Linien aims to follow the UNIX philosophy of doing one thing very well. It is built with Python and Migen and is based on RED PID.

Features

  • All included: Modulation (up to 50 MHz), demodulation, filtering and servo implemented on the FPGA.

  • Client-server architecture: Autonomous operation on RedPitaya. One or multiple GUI clients can connect to the server.

  • Autolock: Click and drag over a line, and linien will automatically approach it and lock to it.

  • Lock detection: linien is capable of detecting loss of lock.

  • Automatic relocking: in that case, it can relock automatically using the autolock.

  • Automatic Optimization: linien uses machine learning to optimize spectroscopy parameters

  • Remote-controllable: The client libraries can be used to control or monitor the spectroscopy lock with python.

  • Combined FMS+MTS: Supports dual-channel spectroscopy that can be used to implement combined FMS+MTS

  • Logging: Use linien-influxdb to log the lock status to influxdb.

  • TTL status: Outputs the lock status via TTL

screencast.gif

Getting started

Linien runs on Windows and Linux. For most users the standalone binaries containing the graphical user interface are recommended. If you want to control linien using the python interface you should install it using pip.

Standalone binary

You can download standalone binaries for windows and linux on the releases page. On linux you have to mark it as executable before executing:

chmod +x linien-client-linux*

Installation with pip

Linien is written for python 3 and can be installed using python’s package manager pip:

pip3 install linien

Run the application by calling

linien

If this doesn’t work, your local bin directory (e.g. ~/.local/bin) is probably missing in your PATH. Alternatively you can open linien using python:

from linien.client.client import run_application
run_application()

Then, you can enter your RedPitaya’s credentials and connect. If you agree, linien’s server component is automatically installed.

Physical setup

The default setup looks like this:

setup.png

You can also configure linien for different setups, e.g. if you want to have the modulation frequency and the control on the same output.

explain-pins.png

Scriptable interface

In addition to the GUI, Linien can also be controlled using python scripts. For that purpose, installation via pip is required (see above).

from linien.client.connection import BaseClient, MHz, Vpp
c = BaseClient(host, 18862, False)

# read out the modulation frequency
print(c.parameters.modulation_frequency.value / MHz)

# set modulation amplitude
c.parameters.modulation_amplitude.value = 1 * Vpp
# in the line above, we set a parameter. This is not written directly to the
# FPGA, though. In order to do this, we have to call write_data():
c.connection.root.write_data()

# plot control and error signal
import pickle
from matplotlib import pyplot as plt
plot_data = pickle.loads(c.parameters.to_plot.value)

# depending on the status (locked / unlocked), different signals are available
print(plot_data.keys())

# if unlocked, signal1 and signal2 contain the error signal of channel 1 and 2
# if the laser is locked, they contain error signal and control signal.
if c.parameters.locked.value:
    plt.plot(plot_data['control_signal'], label='control')
    plt.plot(plot_data['error_signal'], label='error')
else:
    plt.plot(plot_data['error_signal_1'], label='error 1')
    plt.plot(plot_data['error_signal_2'], label='error 2')

plt.legend()
plt.show()

For a full list of parameters that can be controlled or accessed have a look at parameters.py.

Development

As linien uses a git submodule, you should check it out like this:

git clone https://github.com/hermitdemschoenenleben/linien.git --recursive

Then edit the VERSION file and replace it’s content with

dev

When starting a development version of the client, the latest server code is automatically uploaded to the RedPitaya which should simplify development of the server component. For that, check that no server is running on the RedPitaya (execute linien_stop_server on the RedPitaya) before launching the client. Your development code is then uploaded to the /linien directory of the RedPitaya and the linien server is started from there.

Fake server

For testing the GUI, there is also a fake server that you can run locally on your machine:

python3 server/server.py --fake

Then you can connect to “localhost” using the client.

Run server locally

For debugging it may also be helpful to execute the server component on your machine (e.g. if you want to work on the autolock). In order to provide access to the FPGA registers, you have to start server/acquisition_process.py on the RedPitaya. Then you can run the server locally and connect to the FPGA registers:

python3 server/server.py –remote-rp=root:password@rp-f0xxxx.local

Building the FPGA image

In order to build the FPGA image, use scripts/build_gateware.sh.

Releasing a new version

First, update the version number in the VERSION file. Then you can build and upload the package to pypi using scripts/upload_pypi.sh. Finally, build the standalone client using build_standalone_client.sh (you have to do this on the platform you want to build the standalone client for). The standalone client should be uploaded to a github release.

Troubleshooting

Connection problems

If the client fails to connect to a RedPitaya, first check whether you can ping it by executing

ping rp-f0xxxx.local

in a command line. If this works, check whether you can connect via SSH. On Windows, you have to install a SSH client, on linux you can execute

ssh rp-f0xxxx.local

on the command line.

See Also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

linien-0.1.2.tar.gz (404.2 kB view details)

Uploaded Source

Built Distribution

linien-0.1.2-py3-none-any.whl (65.0 kB view details)

Uploaded Python 3

File details

Details for the file linien-0.1.2.tar.gz.

File metadata

  • Download URL: linien-0.1.2.tar.gz
  • Upload date:
  • Size: 404.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4

File hashes

Hashes for linien-0.1.2.tar.gz
Algorithm Hash digest
SHA256 b7927bc9078bb3266283fdcc794b1e31bccd5fcbd7c3581629a49025dd1f47f6
MD5 e0060c3a34f019c2434f269b6f77619c
BLAKE2b-256 553868648fb507e6382587454af003de581f5b5249e2f80f320ff27141d89062

See more details on using hashes here.

File details

Details for the file linien-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: linien-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 65.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.4

File hashes

Hashes for linien-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 271ffce659fb4ac2dbcbc765b2b4fb9f6f81ff718ae9c18db99f08107335d556
MD5 b6e4deb5e01d7540740c986bd4146c43
BLAKE2b-256 8bb352a4c8377b08bca9b9c8d972509e1c50c18de63f59485899eade50eb3068

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page