# SN9000 (PLANAR SNVNA / Иридиум) Setup

This project controls the PLANAR SN9000 multi-port VNA through the SNVNA
companion application running on an external PC. The production path is:

```text
SN9000 --USB 2.0--> SNVNA host PC --HiSLIP/VISA--> radar_system
```

For complete run-mode instructions see
[`docs/operation_modes.md`](operation_modes.md). For `run_config.json` field
reference see [`docs/run_config.md`](run_config.md).

The SN9000 hardware has no built-in SCPI server; the SNVNA application on the
companion PC exposes the SCPI HiSLIP server (default port `4880`). This
project uses HiSLIP only, with the same `pyvisa` + IVI VISA stack already
required by K209 — there is no additional dependency.

For maximum throughput the driver:

- Uses HiSLIP, not raw TCP Socket.
- Keeps one persistent VISA session.
- Sends `FORM:DATA REAL32` and `FORM:BORD SWAP` (little-endian) once.
- Pre-configures 10 traces covering all S-parameters of the 2×4 matrix so
  one trigger drives both stimulus ports.
- Sends the entire acquisition as one synchronized SCPI message:
  `TRIG:SING;*OPC?;:SENS:DATA:CORR? S11;:SENS:DATA:CORR? S31;…;:SENS:DATA:CORR? S62`.
  The K209 setup notes the same constraint: splitting `TRIG:SING` from the
  data queries can return `-211,"Trigger system is not in the trigger wait state"`.

Topology (manual p. 1457):

| Trace | Output position | Stimulus port | Input position | Receiver port |
|-------|-----------------|---------------|----------------|----------------|
| S11   | 0               | 1             | (reflection)   | 1              |
| S31   | 0               | 1             | 0              | 3              |
| S41   | 0               | 1             | 1              | 4              |
| S51   | 0               | 1             | 2              | 5              |
| S61   | 0               | 1             | 3              | 6              |
| S22   | 1               | 2             | (reflection)   | 2              |
| S32   | 1               | 2             | 0              | 3              |
| S42   | 1               | 2             | 1              | 4              |
| S52   | 1               | 2             | 2              | 5              |
| S62   | 1               | 2             | 3              | 6              |

## Required Components

Install these on the machine that runs the SN9000 smoke test or acquisition
process:

1. SNVNA companion application from Planar.
   - The SN9000 hardware is connected to this host over USB 2.0.

2. IVI VISA runtime and development files.
   - Must support TCPIP HiSLIP resources.
   - Suitable implementations include NI-VISA or Keysight IO Libraries Suite.
   - If K209 already works on this host, no additional install is needed.

3. Project Python environment.
   - Use the repository virtual environment, not system Python.
   - Install `requirements.txt` into `.venv`.

## SNVNA HiSLIP Server

Start SNVNA with the SN9000 connected over USB 2.0. Enable HiSLIP server on
port `4880`. From the SNVNA UI:

```text
System -> Settings -> Remote control network settings -> HiSLIP server -> On
System -> Settings -> Remote control network settings -> HiSLIP port -> 4880
```

Verify that the server is listening:

```bash
ss -ltnp | grep 4880
```

If SNVNA runs on a different machine from `radar_system`, set
`radar.remote_host` to that machine's IP address.

The VISA resource string the driver assembles is:

```text
TCPIP0::<radar.remote_host>::hislip0,<radar.remote_port>::INSTR
```

## `run_config.json`

```json
"radar": {
  "model": "sn9000",
  "remote_host": "127.0.0.1",
  "remote_port": 4880,
  "driver_mode": "native"
}
```

The 2×4 virtual switch matrix is enforced automatically; do not edit
`switches.port1` / `switches.port2` or `run.combos` for SN9000 mode — the
config codec rewrites them on load.

## Python Smoke Test

Use the project virtual environment:

```bash
.venv/Scripts/python.exe -m python_app.scripts.sn9000_smoke_test ^
  --host 127.0.0.1 --port 4880 ^
  --start-hz 1000000 --stop-hz 3000000000 ^
  --points 201 --ifbw-hz 10000 --power-dbm -10 ^
  --no-preset
```

Expected result:

```text
SN9000 IDN: Planar, SN9000-N, ...
SN9000 collection OK: traces=8, points=201, first_hz=..., last_hz=..., mean_abs_s21=...
```

Use `--no-preset` for the first smoke test to avoid resetting the current
SNVNA session. Remove it when testing the full driver setup path.

## SN9000 Limits

The SNVNA SCPI surface exposes service capability queries identical to K209:

```text
SERV:SWE:FREQ:MAX?    Upper frequency bound in Hz.
SERV:SWE:FREQ:MIN?    Lower frequency bound in Hz.
SERV:SWE:POIN?        Maximum sweep point count.
SERV:SWE:POW:MAX?     Upper power bound in dBm.
SERV:SWE:POW:MIN?     Lower power bound in dBm.
```

The base SN9000 model covers `0.3 MHz .. 9 GHz`; power range is
`-45 .. +10 dBm` up to 6 GHz, and `-45 .. +2 dBm` from 6 GHz to 9 GHz
(manual p. 58). IF bandwidth selectable in the 1, 1.5, 2, 3, 5, 7 sequence
across decades from `1 Hz` to `300 kHz` (manual p. 58, 1261).
