Metadata-Version: 2.4
Name: stitchlockin
Version: 0.1.0
Summary: Python API for STITCH, the FPGA lock-in amplifier for the attocube IDS3010
Home-page: https://gitlab.phys.ethz.ch/code/experiment/stitchlockin
Author: Sebastian Huber
Author-email: huberse@phys.ethz.ch
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: numpy>=1.18.0
Requires-Dist: pyserial>=3.5
Dynamic: author
Dynamic: author-email
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# stitchlockin

Python client for **STITCH**, an FPGA lock-in amplifier that drives an excitation signal
(up to 500 kHz, up to 1023 programmed frequencies per shot, adiabatic ramps between them),
receives the attocube IDS3010 distance stream over LVDS-HSSL and accumulates the cos/sin
components of every frequency in real time. The gateware and this API are versioned together:
the package version is the git tag of the `stitchlockin` repository, in which the VHDL lives
under `stitch_project/stitch`.

The FPGA talks over a serial port (115200 baud, 8N1).

```python
from stitchlockin import Stitch, frequencyHzToDphi, rampHzSqToDdphi, \
    numPeriodsToNringup, numPeriodsToNmeas, DeltaDphiAndDdphiToNsweep, dataToAmpsPhase

st = Stitch("/dev/ttyUSB0")            # alwaysOpen=True keeps the port open between commands

freqs = [100e3, 110e3, 120e3]
dphis = [frequencyHzToDphi(f) for f in freqs]
st.setNumFrequencies(len(freqs))
st.setFrequencies(dphis)
st.setRingupDurations([numPeriodsToNringup(200, f) for f in freqs])
st.setMeasureDurations([numPeriodsToNmeas(1000, f) for f in freqs])
ddphi = rampHzSqToDdphi(1e9)
st.setSweepFrequencyDeltas([ddphi] * len(freqs))
st.setSweepDurations([DeltaDphiAndDdphiToNsweep(abs(dphis[i + 1] - dphis[i]), ddphi)
                      for i in range(len(freqs) - 1)] + [1])

st.startExperiment()
n, cos, sin = st.getData()             # raw 64-bit accumulators + sample counts per frequency
amps_nm, (phase, phase_unwrapped), cos_nm, sin_nm, nsamp = dataToAmpsPhase((n, cos, sin))
```

`Stitch` exposes the register-level primitives too (`setAddress`, `setRegister`, `dphiWrite`, ...)
for anything the convenience methods don't cover; the command and destination byte constants
(`CMD_*`, `DEST_*`) are importable from the package.

Install with `pip install stitchlockin`; it is also pulled in by `cmtqoutilities`, which
re-exports it as `from utilities import stitchlockin`.
