- C++ 63.8%
- C 25%
- Python 8.3%
- Linker Script 2.9%
Boundaries measured with `knobs on` at 1|2, 6|7 and 11|12 on each knob, the rest spread evenly over each half. The old placeholder table was about one position off at the ends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| 3d | ||
| docs | ||
| firmware | ||
| hardware | ||
| .gitignore | ||
| LICENSE.md | ||
| README.md | ||
IQ Thing
A pocket I/Q signal generator. Feed a carrier into one SMA, turn two knobs, and get one of 144 modulated test signals out of the other: tones, AM/FM, PSK, QAM/APSK, FSK/GMSK, OFDM, LoRa-style chirps, multitone and noise tests, and deliberately impaired signals.
An STM32G473 makes the two baseband waveforms (I and Q) with its dual 12-bit DAC at 1 MSPS. An ADL5390 vector multiplier puts them on the external carrier.
┌── DAC buffer + 268 kHz LPF ──► ADL5390 ("I" pins)
STM32G473 DAC1 CH2 ───┘
STM32G473 DAC1 CH1 ────── DAC buffer + 268 kHz LPF ──► ADL5390 ("Q" pins)
J7 LO IN ──► QCN-3+ 90° splitter ──► ADL5390 ──► balun ──► J6 RF OUT
- Baseband bandwidth is about ±250 kHz around the carrier.
- The carrier frequency comes from whatever you plug into J7. The board doesn't need to know it; the QCN-3+ splitter's passband sets the usable range.
- The board is powered and controlled over USB-C. The USB port also carries a serial console.
Repository
| Path | |
|---|---|
firmware/ |
PlatformIO / Arduino (stm32duino) firmware |
hardware/ |
KiCad project, plus schematic PDF and BOM |
docs/HARDWARE_SPEC.md |
the board as firmware sees it: pins, clocks, analog chain, I/Q swap, transfer function |
The presets
The left knob (MODE) picks the row and the right knob (PARAM) picks the column. The table is printed on the back of the board.
| MODE | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 TONE | -200k | -100k | -50k | -25k | -10k | 0 | +10k | +25k | +50k | +100k | +150k | +200k |
| 2 AM | 10% | 25% | 50% | 75% | 90% | 100% | 120% | 150% | DSBSC | USB | LSB | ISB |
| 3 FM | 0.25 | 0.5 | 1 | 1.5 | 2 | 2.405* | 3 | 3.832* | 5 | 5.520* | 8 | 10 |
| 4 PSK | OOK | 4ASK | BPSK | π2BPSK | DBPSK | QPSK | DQPSK | OQPSK | π4DQ | 8PSK | D8PSK | 16PSK |
| 5 QAM | 8QAM | 16QAM | 32QAM | 64QAM | 128QAM | 256QAM | 512QAM | 1kQAM | 8APSK | 16APSK | 32APSK | 64APSK |
| 6 RATE | 1k | 2.5k | 5k | 10k | 25k | 50k | 62.5k | 100k | 125k | 167k | 200k | 250k |
| 7 FILTER | RECT | RC1 | RC.5 | RC.35 | RRC1 | RRC.8 | RRC.5 | RRC.35 | RRC.25 | RRC.22 | RRC.2 | RRC.1 |
| 8 FSK | MSK | FSKh1 | FSKh2 | FSKh4 | 4FSK | 8FSK | 16FSK | GMSK.5 | GMSK.3 | GMSK.2 | 2GFSK | 4GFSK |
| 9 OFDM | 1SC | 2SC | 4SC | 8SC | 16SC | 32SC | 48SC | 48x16Q | 48x64Q | PILOT | NOTCH | NOCP |
| 10 CHIRP | SF7 | SF8 | SF9 | SF10 | SF11 | SF12 | UP1m | UP10m | UP100m | DN10m | TRI10m | HOP8 |
| 11 TEST | 2T5k | 2T25k | 2T100k | 8T-0 | 8T-N | 32T-0 | 32T-N | N25k | N100k | N200k | NPR | OFF |
| 12 IMPAIR | CLEAN | G1dB | G3dB | Q3deg | Q10deg | DC-30 | DC-20 | F+500 | PNOISE | SNR30 | SNR20 | SNR12 |
From the silkscreen legend:
- Unless a row says otherwise, signals run at 125 ksym/s with RRC α = 0.35 and PRBS9 data.
- TONE: offset from the carrier, in Hz.
- FM: β with a 10 kHz tone. * marks a Bessel null.
- RATE: QPSK at that symbol rate.
- FILTER: 16QAM with that pulse shape.
- FSK: 10 ksym/s.
- TEST: 2T is two tones at that spacing; 8T/32T are multitone, with zero phase (-0) or Newman phase (-N); Nxx is noise of that bandwidth; NPR is notched noise.
- IMPAIR: I/Q gain imbalance, quadrature error, carrier leak (dBc), carrier offset, phase noise, and AWGN, all applied to QPSK.
The board leaves some details open. The firmware's choices are below; all of
them live in
firmware/lib/IqDsp/src/signal_config.h.
| Row | Choice |
|---|---|
| AM | 10 kHz tone. Above 100 % the envelope clips at zero, like a real over-modulated transmitter. ISB has 10 kHz on the upper sideband and 20 kHz on the lower. |
| FSK | 4/8/16FSK use orthogonal tones spaced 10 kHz apart (h = 1). GMSK uses h = 0.5. 2GFSK uses h = 0.32, BT 0.5. 4GFSK uses h = 0.33 per level step, BT 0.5. |
| OFDM | 128-point IFFT at 1 MSPS gives 7.8125 kHz subcarriers; CP = 1/4. QPSK on 1…48 subcarriers around DC. PILOT has 52 subcarriers with BPSK pilots at ±7 and ±21. NOTCH leaves subcarriers +8…+13 empty. NOCP drops the cyclic prefix. |
| CHIRP | SF7…SF12 are LoRa-style: BW 125 kHz, 8 up-chirps, 2 down-chirps, then 32 data symbols. UP/DN sweep ±200 kHz. TRI10m has a 10 ms period. HOP8 hops a CW tone over 8 channels 50 kHz apart with a 1 ms dwell. |
| TEST | 8T tones are spaced 20 kHz apart; 32T tones are spaced 5 kHz apart. Noise is an 8192-sample frequency-domain loop with an exactly flat band. NPR is 200 kHz of noise with a notch from +20 to +30 kHz. OFF is zero baseband. |
| IMPAIR | Phase noise is 3° RMS with a 2 kHz corner. SNR is Es/N0, with the noise in 125 kHz. |
The RF output can't be switched off: the ADL5390's disable pin is tied low. "OFF" means zero baseband, and LO leakage still comes through.
Firmware
Build and flash
The firmware uses PlatformIO and the Arduino
framework (stm32duino core 2.12). There's no stock board definition for a bare
STM32G473RB, so the repo carries its own board and variant
(firmware/boards/IQ_THING.json, firmware/variants/IQ_THING/). The variant
sets up a 12 MHz crystal at 170 MHz, USB clocked from HSI48 + CRS, and a RAM
layout that keeps the DMA buffer in SRAM1.
cd firmware
pio run # build
pio run -t upload # flash over SWD (ST-Link by default)
pio device monitor # USB console
pio test -e native # host unit tests for the DSP and knob code
Before flashing:
- Power the board from USB-C while flashing. The PROG header (J1: GND, SWCLK, SWDIO) doesn't supply power, because AVDD and DVDD are separate.
- NRST isn't on the header, so connect-under-reset isn't available. The firmware never touches PA13/PA14 and never sleeps, so SWD stays reachable.
- With firmware already running,
dfuin the console reboots into ST's ROM USB DFU bootloader. Thenupload_protocol = dfuworks without a probe.
Console
The console is USB CDC (pio device monitor). Type help for the full list.
| Command | |
|---|---|
status |
current preset, DAC interrupt load, underruns, clipped samples, knob readings, clock, VREFBUF, trims |
knobs on / knobs off |
stream the raw ADC value and decoded position of both knobs |
set <mode> <param> |
take over from the knobs, e.g. set 5 2 or set qam 16qam |
knob |
hand control back to the knobs |
list [mode] |
print the preset table |
trim … |
adjust DC offset, gain, phase, I/Q swap or Q sign live. Prints #defines to paste into config.h. |
dfu, reset |
reboot into the ROM bootloader, or plain reboot |
LEDs
| LED | Where | Meaning |
|---|---|---|
| D1 | left of MODE | heartbeat; solid while a preset is being built |
| D2 | right of MODE | USB console open |
| D3 | left of PARAM | console override active; fast blinking means a fault (see status) |
| D4 | right of PARAM | the output clipped in the last 200 ms |
Bring-up and calibration
Everything to tune is in
firmware/include/config.h.
- Check the basics. Run
status. You should seevrefbuf 2.5 V ok, a 170 MHz clock from the crystal, and a DAC at 1000000 S/s with 0 underruns. VREFBUF is the reference for the DAC, the ADC, both knobs and the 0.5 V common mode, so nothing analog works without it. - Knob thresholds. Run
knobs onand turn each knob through its printed positions. Note the raw value at each boundary, then editKNOB_MODE_THRESHOLDS/KNOB_PARAM_THRESHOLDS: 11 ascending boundaries per knob.KNOB_*_REVERSEDsets which end is position 1, andKNOB_HYSTERESISsets how sticky each boundary is. - Sideband orientation. Select TONE +10k (
set tone +10k). On a spectrum analyser the tone must sit 10 kHz above the LO. If it's below, runtrim invq 1and then setIQ_INVERT_Q 1. The board's I/Q swap (IQ_SWAP_CHANNELS) is already applied. - Carrier leakage. Select TEST OFF (
set test off). Adjusttrim dc <I> <Q>in DAC counts until the LO feedthrough is at its minimum. You can also measure TP7−TP5 (I) and TP8−TP6 (Q) with a voltmeter. - Image rejection. With TONE +10k selected, tune
trim gain <I> <Q>andtrim phase <deg>until the image at −10 kHz is at its minimum. - Run
trimto print the final values, and paste them intoconfig.h.
How the signal path works
All generation lives in firmware/lib/IqDsp, which is plain C++ without
Arduino and is unit-tested on the PC. The tests run all 144 presets and check
level, range, loop seamlessness, sideband and DC level.
- Loops. Most presets are periodic: PRBS9 repeats every 511 symbols at any number of bits per symbol. For these, a preset change builds one period (≤16384 samples) into a table, and the DMA interrupt then only replays it. Symbol presets are pulse-shaped by circular convolution, so the loop has no seam.
- Live generation. Slow symbol rates (RATE 1k…25k), π/4-DQPSK, the FSK row and the CHIRP row are generated in real time in the DMA interrupt, one 256-sample block at a time.
- Output stage. This stage applies to every sample: optional carrier offset / phase-noise rotation, then a 2×2 matrix that combines level, I/Q impairments, trims and Q sign, then DC and AWGN. The result is clamped to DAC codes 164…3932 and packed with I on DAC CH1 / PA4 and Q on CH2 / PA5, which is the board's I/Q swap.
- Level and switching. Every signal is normalised so its peak |I| / |Q| reaches 90 % of the designed ±0.5 V swing (less when impairments or noise need room). A preset change fades to zero over 2 ms, builds the new preset, and fades back in.
- Timing. DAC1 updates both channels on the same TIM6 trigger at exactly
1 MSPS from the crystal, through one 32-bit DMA write to
DHR12RD.
Status
The firmware builds and passes its host tests, but it has not been run on a board yet. Things to watch at first power-up:
statusreports the DAC interrupt's CPU load and any underruns. The live symbol paths are the heaviest.- Check the knob direction.
- Check the sideband orientation.
- Check that the
dfujump to ST's bootloader works.
Licence
- Firmware: MIT. The files in
firmware/variants/IQ_THING/derived from stm32duino keep ST's BSD-3-Clause licence. - Hardware: CERN-OHL-P-2.0.
See LICENSE.md for details.

