Zurick lockin amplifier(HF2Server)#
A TCP-based gateway for Zurich Instruments HF2 series lock-in amplifiers. This server allows remote clients to control hardware nodes and acquire averaged data via a simple Tab-Separated Protocol.
📡 Network Protocol#
The server uses a Tab-Separated Protocol over TCP.
Request Format:
command + \t + arg1 + \t + arg2 … + \n
Response Format:
1\t[Data]\n: Success.0\t[Error Message]\n: Failure.
HF2Server Reference#
A TCP-based gateway for Zurich Instruments HF2 series lock-in amplifiers. This server allows remote clients to control hardware nodes and acquire averaged data via a simple Tab-Separated Protocol.
📡 Network Protocol#
Request Format: command + \t + arg1 + \t + arg2 … + \n
Response Format: 1\t[Data]\n (Success) or 0\t[Error Message]\n (Failure)
📖 Complete Command Reference#
Command |
Arguments |
Description |
|---|---|---|
Data Acquisition |
||
|
|
Returns: |
|
|
Configures Scope for single shot (Time, Length, Input Select). |
Oscillator & Output |
||
|
|
Sets Lockin reference Frequency (Hz). |
|
|
Sets reference voltage Amplitude (Vpk). |
|
|
Sets Signal voltage Offset (V). |
|
|
Enables (1) or Disables (0) Signal Output 0. |
Demodulator Settings |
||
|
|
Sets Lockin (low pass) Time Constant (s). |
|
|
Sets Demodulator 0 Sample Rate (Hz). |
|
|
Sets Demodulator Harmonic. |
Input & Autorange |
||
|
|
Sets Current Input Range (Powers of 10). |
|
None |
Triggers Autorange for Current Input 0. |
|
None |
Triggers Autorange for Signal Input 0. |
System |
||
|
None |
Returns |
|
None |
Re-establishes connection to ZI Data Server. |
|
None |
Safely disconnects from hardware. |
|
None |
Stops the server and disconnects hardware. |
💻 Example Usage#
1. Start the Server#
from sm_bluesky.common.servers import HF2Server
server = HF2Server(
host="0.0.0.0", port=7891, device_id="dev4206", hf2_ip="172.23.110.84"
)
server.start()
2. Client#
import socket
def query_hf2(command):
with socket.create_connection(("localhost", 7891)) as sock:
sock.sendall(f"{command}\n".encode())
return sock.recv(1024).decode()
# Example: Get 0.5s of averaged data
print(query_hf2("get_data\t0.5"))