Skip to content

Multimeter input as a third channel in the oscilloscope - #150

Closed
vvzvlad wants to merge 11 commits into
bve:mainfrom
vvzvlad:dmm-channel
Closed

vvzvlad wants to merge 11 commits into
bve:mainfrom
vvzvlad:dmm-channel

Conversation

@vvzvlad

@vvzvlad vvzvlad commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Implements #120.

  • The multimeter is a channel beside CH1 and CH2 (Channel → Channel → DMM: Enabled and Function),
    measured at the multimeter's own inputs. The chip stays powered while the scope runs (latch bit 13
    on top of the scope word); its readings draw as a line on every timebase in their own colour, with
    an "M" zero tag, units/div and position on the arrows, level cursors in its units, and
    Mean/Min/Max/P-P/RMS in the footer. With the DMM on, CH1 and CH2 can both be off.
  • Timebases continue past 20 s/div to 1 h/div (10 hours on screen): Roll with the trigger in Auto,
    each point the mean of the samples it spans; the DMM line follows the same rule.
  • A CSV.gz save gets a dmm column while the DMM channel is on. Its copy of the readings (768 × 8 bytes)
    sits in ITCM beside their ring, since zlib takes the whole Trial area. While the DMM channel is on, the multimeter's SCPI commands work in
    the scope (readings, FUNCtion, CONFigure, AUTO?/AUTO , RANGe); :DMM:FUNCtion picks the
    function. DISPlay:TEXT "<text>" shows a message over any screen until a key.
  • Memory: Glow's 12 800-byte scratch moves from its own ITCM section into the FFT work arrays (Glow
    is drawn only in the draw callback, the spectrum is computed only in Model::project), and three
    Scope choices in Preferences become bytes. The DMM readings ring takes 768 entries of ITCM and the
    dmm column copy another 768: free ITCM goes from 504 to 1016 bytes.
  • Settings: dmm_measurements and the DMM colour role take six slots and display.language one more
    (DocumentSlots 340, StringBytes 3408), and MaxBytes is 4568 for the longest file, 4564 bytes on the
    ZT706S. Preferences::valid()
    checks a timebase past 20 s/div against the plan Roll runs with, so such settings are saved.
  • With the DMM screen's HOLD on, the Scope refuses another DMM function (the channel menu, :DMM:FUNCtion,
    CONFigure), as the DMM screen does.
  • Starting the DMM trace expires the previous reading, as entering the DMM screen does: FETC? reports
    no value until the meter chip's first new packet.
  • With Swap CH1/CH2 the DMM is never swapped: it keeps its "DMM" label, colour and "M" zero tag in
    either order, and the channel selection steps in screen order (left, right, DMM).
  • Past 20 s/div the scope only rolls: a qualified trigger type is kept and applies again at 20 s/div
    or faster (docs/SCOPE_TRIGGERS.md).

Testing

  • pio run builds all four environments without new warnings
  • Tested on ZT703S
  • Tested on ZT706S
  • Not tested on hardware (explain why): no ZT706S here

On ZT703S: every multimeter function as the DMM line with CH1, switched over SCPI; the hidden-channel
cases; 60 s, 10 min and 1 h per division; Glow together with Y-T+FFT for 30 s without a reset.
From the DMM screen to the Scope with the DMM trace on, FETC? answers NAN and -230 until the first
new packet about 2 s later, then fresh values. Swap CH1/CH2: labels, colours, zero tags, the footer and
the selectors checked with a host test against main, not on screen. On 0.22.5: a CSV.gz saved with the
DMM channel on carries the dmm column, filled from the start of the DMM line; 60 s/div survives a
restart; with the DMM screen held, :DMM:FUNC and CONF:VOLT:AC in the Scope get -221 and pass once
HOLD is released.

Checklist

  • The change does not write to the factory block (0x08000000–0x0801FFFF)
  • vendor/ is unchanged, or a third-party component is updated as a whole
  • README updated if the behaviour or the installation changed

@bve

bve commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Thanks for adding the DMM trace and longer timebases. Both board builds passed. The DMM trace has a freshness issue when switching modes.

Switch from the DMM screen to Scope with the DMM trace enabled, then query FETC? during the meter chip's power-off interval. In a host test of the restart sequence, the previous 1.2345 V reading still had status Ok while the chip had 960 ms left before power-up. The trace-start path needs to invalidate the previous session reading and report no fresh value until a new packet arrives, as the standalone DMM does on entry. Trace startup

There is also overlap with the CH1/CH2 display-order work in the channel selectors, cursor labels and footer. When integrating the two changes, the DMM trace needs to retain its own label and colour in either analog channel order.

@vvzvlad

vvzvlad commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

Fixed.

  • Starting the DMM trace expires the previous reading, as entering the DMM screen does. On a ZT703S,
    from the DMM screen to the Scope with the DMM trace on, FETC? answers NAN and -230 until the first
    new packet (about 2 s), then fresh values.
  • Integrated with Swap CH1/CH2. The DMM is input 2 and is never swapped: its "DMM" label, colour and
    "M" zero tag stay in either order, and the CH1/CH2 lines match main (host test of the footer,
    selectors and labels against main). The channel selection steps in screen order.
  • Past 20 s/div the scope only rolls, so a qualified trigger type does not apply there; it is kept and
    applies again at 20 s/div or faster, as docs/SCOPE_TRIGGERS.md now says.

Merged one after the other, #148 and this PR conflict in Engine::dispatch (keep uploadCommand and
this PR's Scope/DMM order), and #153 and this PR in selectDmmFunction and poll (#153 renames
typeK to thermocouple). Rebased onto 0.21.19.

@bve

bve commented Nov 26, 2026

Copy link
Copy Markdown
Owner

Thanks for expiring the previous meter reading at trace startup and integrating the DMM label with Swap CH1/CH2. The four build targets pass against 0.21.19.

This still needs integration with the published v0.22.0 pre-release. The trial merge has 13 file conflicts, including gzip waveform export, frequency readouts and rendering. With both sets of fields retained, the ARM ReadoutSelection grows from 36 to 40 bytes and plot::Options reaches 104 bytes against the 96-byte assertion. The new dmm_measurements array is also written at its defaults, adding five JSON slots to a settings budget that already reaches its reserve limit. Plot options · Settings encoder

Please preserve the v0.22.0 export and counter behavior in the rebase and rerun the target memory and settings-size checks.

@vvzvlad

vvzvlad commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 0.22.2. The compressed export, the counter (CNT, Trace f, Timed edges), the Math label, the DMM prefixes, wake on measurement, AWG and the waveform list are kept.

  • plot::Options is 96 bytes again: averaging and zoomOut moved into the padding after the one-byte fields. ReadoutSelection is 36 again: the four DMM readouts moved to a separate MeterReadoutSelection.
  • dmm_measurements is written only when it differs from the default; the default file equals 0.22.2's, 2548 bytes.
  • Budget: the PR adds 6 slots, 5 for dmm_measurements and 1 for the dmm colour role. By your count 263 + 6 = 269, hence 337/3456. The longest file is 4502 bytes on the ZT706S: the AWG sample rate key pushed it past 4480, so MaxBytes is 4504. Strings with every colour distinct take 2581 of 3456.
  • The dmm column is now written to CSV.gz, since 0.22.2 has no plain CSV in Analyze. The copy of the DMM readings (768 × 8 bytes) sits in ITCM next to their ring instead of in Trial, which zlib takes whole. A decompressed CSV.gz equals the plain CSV of the same frame; without the DMM channel, CSV.gz and RAW.gz are byte for byte as in 0.22.2. On a ZT703S, a CSV.gz saved with the DMM channel on and downloaded with MMEM:DATA? has the # dmm: line and the dmm column in all 32768 rows.
  • I found and fixed a mistake of mine in this PR: past 20 s/div Preferences::valid() rejected the file, so settings were not saved (power-off said "Settings not saved", Restart refused). The check now uses the plan Roll runs with (Timebases::sampled). On a ZT703S, 60 s/div survived a restart.
  • Each of the 10 commits builds. Free DTCM goes from 3256 to 3152 bytes on the ZT703S and from 1656 to 1552 on the ZT706S. Free ITCM goes from 544 to 1056: Glow's 12,800-byte scratch moved into the FFT work arrays, and the readings ring and the dmm column copy take 6,144 bytes each.

Merging: with #148, uploadCommand plus the Scope/DMM order in Engine::dispatch; with #153, typeK → thermocouple in selectDmmFunction and setDmmRange; with #115, powerOnKeys.valid() next to Timebases::sampled in Preferences::valid(). The budgets add up: all six PRs together need 340/3408 and MaxBytes 4544. A test merge of all six with these numbers builds and runs on a ZT703S.

@vvzvlad

vvzvlad commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto 436d4f0. Trace index 2 is now both your MATH and the DMM, so zeroTag takes an explicit math flag and the zero-tag arrays have three entries. F1/F2 cycle L → R → MATH → DMM. MENU on MATH opens yours, otherwise the DMM channel menu. Up/Down apply your MATH gain first.

With 3be6afb, the DMM screen's HOLD now locks the function from the Scope too (the channel menu, :DMM:FUNCtion, CONFigure in the Scope). The Scope refuses with "Release HOLD in the DMM to change function" or -221.

Budget 339/3424, MaxBytes 4552 (the longest file is 4545 bytes). The longest valid theme still parses, with 826 bytes of ThemeDocument to spare (1092 on main).

@vvzvlad

vvzvlad commented Nov 29, 2026

Copy link
Copy Markdown
Contributor Author

Rebased onto f33ec27 (0.22.7). The conflicts were with the localized texts in the Scope screen, its status, footer, channel editor and AutoSetup. Our texts are catalog entries in all four languages, and DMM as a trace name stays literal, like MATH. engine.cpp tries the Scope's own commands, your upload and decoder commands included, before the DMM's.

Budget 340/3408, MaxBytes 4568, display.language included (see #115). Free ITCM goes from 504 to 1016 bytes, free DTCM drops by 104. Every commit builds, and the six CI checks pass.

@vvzvlad
vvzvlad force-pushed the dmm-channel branch 4 times, most recently from 77d0e5e to 21cc5e4 Compare November 29, 2026 22:29
Glow's 12800-byte scratch had an ITCM section of its own (.scope_glow).
It is used only inside the synchronous software draw callback and is
cleared per channel before use. The spectrum's real and imaginary
arrays (16384 bytes in DTCM) are refilled by every calculation, and a
spectrum is computed only from Model::project, never during a draw.

SpectrumStorage now holds those arrays as raw work bytes. The FFT
begins its arrays there with placement new at each calculation, and
Glow begins its scratch there at each draw, reached through the Model.
The .scope_glow section, its zeroing at reset and its term in the ITCM
check are gone; DTCM use is unchanged.
rollAuto, longerRecord and interleave hold 0..2 and took a 32-bit word
each. As bytes, Preferences shrinks from 624 to 616 bytes on both
boards: room for new Scope choices under the stack check in
preferences.hpp. Their order, defaults, file keys and accepted values
are unchanged (an interleave_mode above 255, rejected by valid()
before, is now rejected by the parse; both refuse the file).
Analyze > Display > View > DMM keeps the multimeter chip powered while
the scope runs (latch bit 13 on top of every scope word) and draws its
readings as a third trace beside CH1/CH2. DMM function picks what it
measures and is shared with the DMM mode. The trace draws in Roll
(200 ms/div and slower); every timebase shows its value. A second F1/F2
press steps CH1, CH2 and DMM among those shown; with DMM selected the
arrows set its units/div (1-2-5) and position.

The DMM UART receives through its own DMA stream beside the capture;
the link watchdog power-cycles the chip by the bit alone. While SCPI's
parallel mode serves the DMM, the trace leaves the chip to it and does
not run. The readings ring (1024 entries) lives in arena bank 3,
which Roll leaves idle; any other capture invalidates it.
The multimeter trace becomes a channel beside CH1/CH2: its own colour
role (DMM) in every scheme, a "D" zero tag in the left margin, the line
on every timebase placed by time on the record's axis (the last reading
held to the record's end), level cursors on it with the delta in its
units, and Mean/Min/Max/P-P/RMS over the visible window in the footer:
its own REL page while both channels show, a hidden channel's panel
otherwise. The readouts it shows are stored as dmm_measurements.

The readings ring moves from the Roll spare bank to its own ITCM
section (768 entries), so captures no longer invalidate it; builds with
the USB trace keep it out.

The settings budget grows with it: dmm_measurements and the DMM colour
role take six slots, and display.language from 7781a38, which main's
numbers do not count yet, one more, so 340 slots and 3408 string bytes
(8848 bytes of tree, as before), and MaxBytes rises from 4480 to 4568 for
the longest valid file, 4562 bytes on the ZT706S, 19 of them for
display.language.
Timebases continue past 20 s/div to 1 h/div (10 hours on screen). Past
20 s/div the capture runs in Roll with the trigger in Auto, sampling as
at 20 s/div, and each point shown is the mean of the samples it spans.
The DMM line follows the same rule: at slow timebases each point is the
mean of the readings within its span, and the line starts where the
record starts.

The DMM gets a channel menu like CH1/CH2 (MENU on its scale/position:
Enabled and Function), its zero tag becomes "M", and the reading overlay
over the plot is gone. With the DMM on, CH1 and CH2 can both be off: the
DMM takes the plot and the footer, the trigger shows AUTO without a
channel, and FFT, reference capture and SCPI single/normal sweeps refuse
a hidden channel. AUTO also fits the DMM's units/div to its readings;
readings off screen are marked at the plot edge.

A scope CSV.gz carries the DMM readings in a dmm column. A HOLD on the
DMM screen keeps its function in the scope too: the DMM channel menu
refuses another until it is released in the DMM.

A timebase of 1000 s/div and up takes two digits more than 20 s/div in
the settings file: the longest valid file grows to 4564 bytes on the
ZT706S, within MaxBytes (4568).
DISPlay:TEXT[:DATA] "<text>" shows a message over any screen until a
key, DISPlay:TEXT:CLEar or a new text; DISPlay:TEXT? returns it. The
message wakes a dark screen and the key that dismisses it does nothing
else, except REL/Power held, which still powers off.

The scope's DMM line starts again whenever another function is
selected, also within one quantity (DC to AC amps) and when the
function was selected while the capture was stopped.
Switching from the DMM screen to the Scope with the DMM trace on kept the
last reading Ok while the meter chip was still powered off. The trace
start now expires it, as entering the DMM screen does: the reading is
stale until a new packet arrives, and the charge counter starts a new run.
With the DMM as a third channel, the selection stepped by input number,
so with the channels swapped it went CH2, CH1, DMM on screen. It now goes
left slot, right slot, then the DMM.
The DMM channel's timebases past 20 s/div always roll in Auto; a pulse
width, runt or rise/fall trigger is kept and applies again at 20 s/div
or faster.
The DMM line, its zero, the dDMM level cursor readout, AUTO's scale fit
and the Up/Down reach of its zero counted 8 divisions, so on the square
grid a units/div did not match a square. They now take the grid's own
divisions, as the channels do: 5 on the square grid, 8 otherwise. The
plot rows per division are Painter::meterDivision() for all three
drawings; test_meter_scale checks AUTO's fit on both grids.
@bve

bve commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Thanks for the work on this. I'm deferring this change for now. I kept finding regressions in my oscilloscope tests while integrating it with the current firmware. The change touches enough of the scope that I expect further regressions without more test coverage.

I'm closing this PR for now. I may revisit it when I have more time to work through the integration and expand the regression tests.

@bve bve closed this Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants