Getting Started with the Raspberry Pi
Introduction
Although it is common to use a desktop computer to control and collect data from our instruments, in some cases it might be advantageous to use a device with a smaller footprint. The Raspberry Pi includes an arm-based processor, uses an SD memory card for data storage, includes Wi-Fi and Ethernet connectivity (we will use a Raspberry Pi 4 Module B in this guide) and can be connected to the usual peripherals: mouse, keyboard and a display. We will now walk you through the necessary steps to use a Raspberry Pi to control Zurich Instruments lock-in amplifiers. The same approach can be applied to other Zurich Instruments products like AWGs and Impedance Analyzers.
Requirements
Hardware:
- A Raspberry Pi with a 64-bit architecture
- An SD memory card
- Peripherals: monitor, mouse, and keyboard
- A Zurich Instruments product
Software:
A 64-bit operating system running on the Raspberry Pi, for example:
Connecting to an MFLI Lock-in Amplifier
In this first part, we will demonstrate using a Raspberry Pi to control an MFLI, without installing LabOne™ on the Pi itself.
We will be using:
- A Raspberry Pi 4 Module B with 2 GB RAM
- A 128 GB micro-SD memory card
- An MFLI Lock-in Amplifier
Required hardware
We start up the Raspberry Pi and connect the MFLI using the USB cable. Then, using the ifconfig command, we check the network configuration of the Pi:
zhinst@zhinst-rpi:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 169.254.75.6 netmask 255.255.0.0 broadcast 169.254.255.255
inet6 fe80::2f92:15ef:1a1d:6052 prefixlen 64 scopeid 0x20<link>
ether e4:5f:01:13:c3:8d txqueuelen 1000 (Ethernet)
RX packets 28 bytes 1680 (1.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 113 bytes 17422 (17.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.79.53 netmask 255.255.255.252 broadcast 192.168.79.55
inet6 fe80::484b:53fe:ba60:1b40 prefixlen 64 scopeid 0x20<link>
ether 00:14:2d:63:66:34 txqueuelen 1000 (Ethernet)
RX packets 98 bytes 14068 (13.7 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 26 bytes 4830 (4.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
...
The eth0 is the normal Ethernet port of the Raspberry Pi, and eth1 is the Ethernet-over-USB connection to the MFLI. The Pi's address is 192.168.79.53, thus the MFLI's address is one above: 192.168.79.54 in this case.
One can now connect to the webserver running on the MFLI on 192.168.79.54, port 8006 from a browser running on the Raspberry Pi.
Alternatively, one can install the Zurich Instruments Python package by running the following command in a terminal:
sudo apt install zhinstThen, using any text editor, we create a test.py example program which contains:
from zhinst.toolkit import Session
session = Session("192.168.79.54")
device = session.connect_device("dev4299")
print(device.scopes[0].length())And run it with:
zhinst@zhinst-rpi:~ $ python test.py
16384This proves that we successfully connected to the instrument and read out the sample length of the MFLI's oscilloscope. If the instrument is simultaneously connected with the ethernet cable to a network, this allows us to use the Python API to read out the IP address of the MFLI:
session = Session("192.168.79.54")
device = session.connect_device("dev4299")
print(device.system.nics[0].ip4())
The MFLI connected to the Raspberry Pi by USB, which is in this case accessed over a wireless connection.
Installing LabOne and Running the Data Server Locally
We download the latest LabOne release version for arm64 from the Zurich Instruments download center, and, following the instructions found here, we install LabOne:
zhinst@zhinst-rpi:~ $ tar xzvf LabOneLinuxARM64-23.06.45428.tar.gz
zhinst@zhinst-rpi:~ $ cd LabOneLinuxARM64-23.06.45428/
zhinst@zhinst-rpi:~/LabOneLinuxARM64-23.06.45428 $ sudo ./install.sh We can then simply run the webserver:
zhinst@zhinst-rpi:~ $ sudo ziWebServerWhich then runs LabOne. It is then possible to connect to the webserver from any device within the local network, using the IP address of the Raspberry Pi on the Wi-Fi, for instance:
Naturally, one needs to substitute the host's IP address "172.20.10.8" in this example with the address of the Raspberry Pi, which can be read out by executing the "ifconfig" command. If one is running the browser on the Raspberry Pi, LabOne can be accessed by using "localhost" that is http://localhost:8006 or equivalently http://127.0.0.1:8006.
Connecting to the LabOne running on the Raspberry Pi
Controlling Multiple Instruments
Although in the case of large data throughput, the use of a dedicated computer is advised, the Raspberry Pi is capable of controlling multiple instruments. Its webserver can then be accessed by multiple mobile devices or computers. Here, for example, we control a UHFLI and an MFLI using mobile devices connected to the webserver of the Raspberry Pi.
Controlling multiple instruments with the Raspberry Pi
Data Server Accessible from External Webservers by Default
LabOne data servers are already defined as a service and run on startup. If you intend on using the Raspberry Pi as a pure data server, you can run the LabOne webserver on your computer and connect to the instrument using the data server running on the Raspberry Pi. In order to make sure you can connect from any computer, you need to set the connectivity in the "Config" tab of LabOne UI (by connecting with a browser on the webserver running on the Raspberry Pi) to “from everywhere” instead of “localhost only”.
If you require the data server to accept connections from everywhere on startup, you can edit the "labone-data-server" service file in order to start the data sever with the "--open-override=1" argument.
Conclusions
There can be many reasons to control Zurich Instruments' devices from a computer with a small footprint, and the Raspberry Pi offers a cost-effective way of doing so. This guide should help newcomers get set up and started with their Raspberry Pi and LabOne in various configurations.