Metadata-Version: 2.4
Name: dt5810
Version: 2.1.0
Summary: Python binding of the DT5810 SDK: control of the CAEN DT5810 / DT5810B Digital Detector Emulator
Author-email: Nuclear Instruments <support@nuclearinstruments.eu>
License: MIT
Project-URL: Homepage, https://gitlab.nuclearinstruments.eu/public-repo/dt5810/dt5810-sdk
Project-URL: Documentation, https://public-repo.pages.nuclearinstruments.eu/dt5810/dt5810-sdk/
Project-URL: Source, https://gitlab.nuclearinstruments.eu/public-repo/dt5810/dt5810-sdk
Project-URL: Issues, https://gitlab.nuclearinstruments.eu/public-repo/dt5810/dt5810-sdk/-/issues
Keywords: DT5810,DT5810B,CAEN,Nuclear Instruments,detector emulator,pulser,nuclear physics
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Topic :: System :: Hardware :: Hardware Drivers
Classifier: Typing :: Typed
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: numpy
Requires-Dist: numpy; extra == "numpy"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Dynamic: license-file

# dt5810 — Python binding of the DT5810 SDK

Control the **CAEN DT5810 / DT5810B Digital Detector Emulator** (Nuclear Instruments) from
Python: energy (fixed or spectrum), pulse shape, time base, noise, baseline drift,
correlation, digital I/O, run control, monitoring, AWG / sequences and the analog input
MCA. The package calls the native DT5810 library (`dt5810.dll` / `libdt5810.so`) through
`ctypes`; a built-in simulator (`sim://`) lets you develop and test without hardware.

## Installation

```
pip install dt5810
```

The wheels for Windows x64 and Linux x86_64 (glibc 2.34+) include the native library.
Python 3.8 or later; no mandatory dependency (`pip install dt5810[numpy]` to get numpy
arrays from the read functions with `as_numpy=True`).

With the source distribution, or to use another build of the library, point
`DT5810_LIBRARY` at it (full path of `dt5810.dll` / `libdt5810.so`); otherwise the library
is looked up in the package, then by the system loader.

## Quick start

```python
import dt5810

print(dt5810.version())
for d in dt5810.enumerate(dt5810.Bus.USB):
    print(d.serial, d.address)

with dt5810.open("sim://") as dev:          # or "usb://", "usb://NI050123"
    print(dev.info.model_name, dev.info.serial)
    ch = dev.channel(0)
    ch.set_fixed_energy(20000)              # LSB, 0..32767
    ch.set_drc(rise_ns=20, decay_ns=50000)
    ch.set_timebase(dt5810.TimebaseMode.POISSON, rate_hz=10000)
    ch.enable()
    print(ch.stats())
```

Errors raise `dt5810.Dt5810Error` subclasses (`OutOfRangeError`, `InvalidParameterError`,
`NoDataError`, `NotFoundError`, `DeviceTimeoutError`, ...) carrying `.status` and
`.message`. The `examples/` folder has runnable scripts for every feature
(`python examples/01_info.py usb://`).

## Instruments on USB and firmware

```python
for d in dt5810.usb_list():                 # every instrument, in any state
    print(d.usb_serial, d.state.name, d.serial, "USB 3" if d.super_speed == 1 else "USB 2")
dt5810.fx3_load_all()                       # load the USB firmware where it is missing
dt5810.fpga_update("", "DT5810B.NIU",       # FPGA update, instrument in FPGA boot loader
                   progress=lambda stage, f: print(stage, f"{f:.0%}"))
```

At power-up the USB controller of the instrument waits for its firmware: the firmware
service of the SDK installer / Linux packages loads it automatically, `fx3_load_all()` does
it from Python (the firmware is inside the library).

## GUI example

`examples/gui/dt5810_gui.py` is a PyQt6 control panel with live plots (signal, emitted
spectrum, count rate) and the firmware functions; it runs on the simulator too:

```
pip install -r examples/requirements.txt
python examples/gui/dt5810_gui.py sim://
```

## Documentation

User guide and API reference: <https://public-repo.pages.nuclearinstruments.eu/dt5810/dt5810-sdk/>

Source: <https://gitlab.nuclearinstruments.eu/public-repo/dt5810/dt5810-sdk> — MIT License.
