# E-502 Wiring For `gate_capture.exe`

## Purpose

This program captures two differential analog signals on `E-502` while:

- `DI_SYN1` provides the external ADC clock
- `START_IN` provides the repeating gate
- data goes to the PC over the built-in `USB 2.0`

The program does not use any digital output.

## Analog Inputs

- `Signal 1 +` -> `X3`
- `Signal 1 -` -> `Y3`
- `Signal 2 +` -> `X4`
- `Signal 2 -` -> `Y4`

These pairs correspond to:

- `ch1:2` -> `X3-Y3`
- `ch2:3` -> `X4-Y4`

## Sync Inputs

- `2 MHz clock` from generator -> `DI_SYN1`
- `20 kHz gate` from generator -> `START_IN`

Behavior in software:

- every clock edge on `DI_SYN1` advances ADC sampling
- rising edge of `START_IN` starts a capture window
- falling edge of `START_IN` closes the current window

The stream itself starts immediately after `X502_StreamsStart()`. Windowing is done in software from the sampled state of `START_IN`.

## Ground

- generator common / reference ground -> `GND` of `E-502`

Even with differential analog channels, the sync inputs still need a valid common reference with the generator.

## USB

- `E-502 USB 2.0` -> PC

## ASCII Diagram

```text
Signal source #1 (+) --------------------------> E-502 X3
Signal source #1 (-) --------------------------> E-502 Y3

Signal source #2 (+) --------------------------> E-502 X4
Signal source #2 (-) --------------------------> E-502 Y4

2 MHz generator output ------------------------> E-502 DI_SYN1
20 kHz gate output ----------------------------> E-502 START_IN
Generator common / GND ------------------------> E-502 GND

E-502 USB 2.0 ---------------------------------> PC
```

## Recommended Run Command

```powershell
.\gate_capture.exe clock:di_syn1_rise clock_hz:2000000 gate_hz:20000 windows:1000 csv:gate_capture.csv svg:gate_capture.svg
```
