Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ Captured on a ZT703S running OpenOSC. The Bode screens replay a recorded twin-T

**Oscilloscope**

- Two channels, 20 mV/div to 10 V/div, timebase from 10 ns/div to 20 s/div
- Two channels, 20 mV/div to 10 V/div, timebase from 10 ns/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: each point
shown is the mean of the samples it spans
- Trigger modes Auto, Normal and Single, with adjustable pre/post-trigger position and Center trigger.
Tap **F3** to select Trigger and use Left/Right to adjust pretrigger. Tap **F3** again to cycle modes.
The Trigger menu supports Edge, Pulse width, Runt, Rise/fall time and Video (PAL/SECAM and NTSC sync). [Trigger setup](docs/SCOPE_TRIGGERS.md)
Hold **F3** to set the trigger level to the signal midpoint and pretrigger to 50%. Pan with **F2**
- Continuous Roll mode for slow timebases (200 ms/div and slower)
- Continuous Roll mode for slow timebases (200 ms/div and slower, always past 20 s/div)
- Enable addition or subtraction under **Analyze → Display → View → MATH**. With both inputs enabled,
tap **F1** or **F2** to cycle through CH1, CH2 and MATH. On F1, Up/Down steps through the same V/div
presets as the input channels, with extra steps for digital zoom. The scale uses the probe ratio of the
Expand All @@ -179,6 +181,15 @@ Captured on a ZT703S running OpenOSC. The Bode screens replay a recorded twin-T
of that budget, for example as DMA headroom at the fastest sample rates. The prefix depends on the
plan only, so it stays steady while the settings stay the same. **Analyze → Acquisition → Captured**
shows the exact number of points per channel in the displayed record.
- The multimeter as a third channel beside CH1 and CH2 (**Channel → Channel → DMM**: **Enabled** and
**Function**), measured at the multimeter's own inputs: its line at every timebase in its own color
(**Analyze → Colors**), with its zero tag, from where the record starts. At slow timebases each point
of the line is the mean of every reading it spans. **F1**/**F2** select it after the channels;
Up/Down then set its units/div and its position, and **MENU** opens its channel menu. **AUTO** also
sets its units/div to fit the readings on screen; with the DMM alone, only that. Its readouts
(mean, min, max, peak to peak, RMS) have a footer page of their own, or the panel of a channel that
is off, and level cursors can measure it in its units. With the DMM on, CH1 and CH2 can both be off:
the DMM takes the plot and the whole footer, on the time axis of the last channel, kept hidden
- In the default **Quick** profile, tap **AUTO** to start Auto Setup or cancel it in progress.
Hold **AUTO** for 2 s in Y-T to open **Zoom & Pan**. Up/Down zoom the view, Left/Right pan, and
**F4** returns to the previous card. The **Classic** profile uses a tap to reset pan and a hold to
Expand Down Expand Up @@ -253,8 +264,9 @@ Captured on a ZT703S running OpenOSC. The Bode screens replay a recorded twin-T
and profile. The ZT703S defaults to Off and the ZT706S to Auto (the stock rule)
- Save waveforms to `/openosc/CAPTURES` from **Analyze** with **Save waveform CSV.gz** or
**Save waveform RAW.gz**. Both use streaming gzip compression. Decompress the file on a
computer to recover the CSV or RAW data. OpenOSC checks free space as it writes compressed
bytes and removes the temporary file if the save runs out of space.
computer to recover the CSV or RAW data. With the DMM channel on, the CSV.gz also has its
readings in a `dmm` column. OpenOSC checks free space as it writes compressed bytes and removes
the temporary file if the save runs out of space.
- **Settings → Files & USB → Waveforms** lists the saved waveforms with their sizes. F3 deletes
the selected file after a confirmation. **Clear waveforms** deletes every waveform after a
confirmation, and F4 stops it part way. Both cover files in `/openosc/CAPTURES` ending in
Expand Down Expand Up @@ -340,6 +352,10 @@ Captured on a ZT703S running OpenOSC. The Bode screens replay a recorded twin-T
press. `AUTO` on the multimeter screen acts from 52 ms held. As on the panel, `REL` held longer than
**Settings → Device → Power → Power-off hold**, counted from the start of the press, powers the device
off, and `MODE` switching the instrument mode reconnects USB, so the reply is lost
- `DISPlay:TEXT "<text>"` shows a message in a box over any screen until a key is pressed (that
press does nothing else), `DISPlay:TEXT:CLEar` or the next message; `DISPlay:TEXT?` returns the
text on show, or `""`. The text is printable ASCII. On a dark screen the first key only wakes it;
REL/Power held still powers off, the message staying
- USB Remote mode: the PC controls the device while the screen keeps showing live data
- USB data works only in the 200/100 performance profile. Connect directly to a PC port:
disconnects are known, especially through USB hubs.
Expand Down
5 changes: 3 additions & 2 deletions docs/SCOPE_TRIGGERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ record. Lines in the vertical interval before the broad pulses count from the pr

Normal and Single re-arm after a rejected candidate. Single holds the first qualified record or an
explicitly forced capture. Auto can still display an untriggered record after its wait budget, which
follows the record duration with a 20 ms minimum and a 1 s maximum. At slow timebases, the qualified
types use finite records. Roll is available with Edge.
follows the record duration with a 20 ms minimum and a 1 s maximum. At slow timebases up to 20 s/div,
the qualified types use finite records, and Roll is available with Edge. Past 20 s/div the capture
only rolls: a qualified type is kept and applies again at 20 s/div or faster.

OpenOSC qualifies these events in the ADC samples around a comparator crossing or in a timed video window. The entire pulse or
transition and the samples needed for noise rejection must fit in the buffered record. A longer
Expand Down
21 changes: 21 additions & 0 deletions include/openosc/acquisition/readouts.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ struct ReadoutSelection {
}
};
static_assert(sizeof(ReadoutSelection)==36, "ReadoutSelection keeps its size (GitHub #171's flag in its padding)");
// The Scope's DMM trace's readouts (plot::MeterReadouts): of its readings over the visible window,
// whatever the basis; only Kinds. Beside ReadoutSelection, not in it: the scheduler never computes
// them, and ReadoutSelection has no byte to spare.
struct MeterReadoutSelection {
static constexpr Measurement Kinds[]={Measurement::Off,Measurement::Mean,Measurement::Minimum,Measurement::Maximum,
Measurement::PeakToPeak,Measurement::Rms};
static constexpr bool kind(unsigned value) {
for (auto k : Kinds) if (value==unsigned(k)) return true;
return false;
}
uint8_t values[ReadoutSelection::PerChannel]={uint8_t(Measurement::Mean),uint8_t(Measurement::PeakToPeak),
uint8_t(Measurement::Minimum),uint8_t(Measurement::Maximum)};
bool valid() const {
for (auto value : values) if (!kind(value)) return false;
return true;
}
bool same(const MeterReadoutSelection &b) const {
for (unsigned i=0;i<ReadoutSelection::PerChannel;++i) if (values[i]!=b.values[i]) return false;
return true;
}
};
// Computed readouts with where they come from: the record (sequence), the record points they
// cover, the basis and when they were finished, so a result is never taken for another frame's.
struct ReadoutResult {
Expand Down
17 changes: 15 additions & 2 deletions include/openosc/acquisition/request.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "openosc/acquisition/analysis.hpp"
#include "openosc/acquisition/frontend.hpp"
#include "openosc/acquisition/record_depths.hpp"
#include "openosc/acquisition/timebases.hpp"

namespace openosc {
struct ScopeRequest {
Expand All @@ -13,8 +14,20 @@ struct ScopeRequest {
uint32_t probeNumerator[2] = {1, 1}, probeDenominator[2] = {1, 1};
bool rollAuto=true;
bool longerRecord = true;
// A qualified trigger needs a bounded record with the history around its candidate.
bool rolling() const { return rollAuto && timebaseNs>=200000000 && trigger.mode==scope::TriggerMode::Auto && !trigger.qualified(); }
// Roll: Auto from 200 ms/div with rollAuto, and always past Timebases::SampledMaximum (averaged Roll).
// Up to it, a qualified trigger needs a bounded record with the history around its candidate.
bool rolling() const {
return trigger.mode==scope::TriggerMode::Auto && (timebaseNs>scope::Timebases::SampledMaximum ||
(rollAuto && timebaseNs>=200000000 && !trigger.qualified()));
}
// Past Timebases::SampledMaximum the scope only rolls: a trigger mode asked for there is Auto (every
// caller through ApplicationController::applyScope, the saved settings as they load; DataAccess
// refuses any other). True when it changed the mode.
bool followTimebase() {
if (timebaseNs<=scope::Timebases::SampledMaximum || trigger.mode==scope::TriggerMode::Auto) return false;
trigger.mode=scope::TriggerMode::Auto;
return true;
}
unsigned channels() const { return scope::RecordBudget::channels(frontend.enabled[0], frontend.enabled[1]); }
uint32_t depth() const { return scope::RecordBudget::perChannel(recordPoints, channels()); } // Points per channel.
// At a fixed timebase, depth beyond the default budget can extend the captured time.
Expand Down
13 changes: 10 additions & 3 deletions include/openosc/acquisition/rolling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
#include "openosc/acquisition/frame.hpp"

namespace openosc::scope {
// Roll's history: the frames' points in order, CH1 in the low byte of a word and CH2 in the high one.
// Averaged (Timebases::averaging past its SampledMaximum), a stored point is the mean of `averaging`
// consecutive points of the frames, its codes rounded half away from zero; the sums run on across
// frames, and the snapshot's points are at that rate, each at the middle of the points it averages.
class RollingBuffer {
public:
explicit RollingBuffer(uint16_t *storage, size_t capacity) : storage_(storage), capacity_(capacity), limit_(capacity) {}
Expand All @@ -10,15 +14,16 @@ class RollingBuffer {
FrameView snapshot() const;
size_t size() const { return size_; }
size_t capacity() const { return capacity_; }
bool reset(size_t capacity) {
if (!capacity || capacity>65536 || capacity>limit_) return false;
capacity_=capacity; reset(); return true;
bool reset(size_t capacity, uint32_t averaging = 1) {
if (!capacity || capacity>65536 || capacity>limit_ || !averaging) return false;
capacity_=capacity; averaging_=averaging; reset(); return true;
}
uint64_t dropped() const { return dropped_; }
void reset() {
cursor_ = size_ = 0;
dropped_ = 0;
continuous_ = false;
pending_ = 0; sums_[0] = sums_[1] = 0;
}

private:
Expand All @@ -27,6 +32,8 @@ class RollingBuffer {
uint64_t dropped_ = 0;
FrameMetadata metadata_;
uint64_t nextTimestampUs_ = 0;
uint32_t averaging_ = 1, pending_ = 0; // Points per stored point; points in sums_ not yet stored.
int32_t sums_[2] = {};
bool continuous_ = false;
};
} // namespace openosc::scope
3 changes: 2 additions & 1 deletion include/openosc/acquisition/sample_plan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "openosc/acquisition/analysis.hpp"
#include "openosc/acquisition/record_depths.hpp"
#include "openosc/acquisition/arena.hpp"
#include "openosc/acquisition/timebases.hpp"
#include <algorithm>
#include <numeric>

Expand Down Expand Up @@ -37,7 +38,7 @@ struct SamplePlan {
uint32_t headroom = FullSpeedHeadroom, uint32_t pointsPerTransfer = 1, uint32_t windowPoints = 0,
uint32_t videoSearchMs = 0, uint32_t videoMinimumDepth = 0) {
const uint32_t granule = 4 * pointsPerTransfer;
if (timebaseNs < 10 || timebaseNs > 20000000000ULL || !RecordDepth::valid(depth) || ringPoints < depth ||
if (timebaseNs < 10 || timebaseNs > Timebases::SampledMaximum || !RecordDepth::valid(depth) || ringPoints < depth ||
!maximumRate || maximumRate > MaximumSampleRate || (pointsPerTransfer != 1 && pointsPerTransfer != 2) ||
depth % granule) return false;
const uint64_t pointRate = uint64_t(maximumRate) * pointsPerTransfer;
Expand Down
10 changes: 8 additions & 2 deletions include/openosc/acquisition/spectrum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,13 @@ struct SpectrumStorage {
// Exactly 2048 points: the one CMSIS-DSP real FFT length whose tables are linked.
static constexpr unsigned Capacity=2048, MinimumCount=Capacity;
// real: the windowed input (the FFT works in place on it); imaginary: the packed FFT output.
float real[Capacity],imaginary[Capacity],weights[Capacity],amplitude[Capacity/2+1];
struct Work { float real[Capacity],imaginary[Capacity]; };
// Work's raw bytes. They hold nothing between calculations, so the scope's software Glow
// draws in them too: a spectrum is never computed during a draw (calculate() runs from
// Model::project, outside the LVGL draw callbacks). Each use begins its own object here
// with placement new and never reads what the other left.
alignas(Work) unsigned char work[sizeof(Work)];
float weights[Capacity],amplitude[Capacity/2+1];
SpectrumResult result;
unsigned windowCount=0;
SpectrumWindow cachedWindow=SpectrumWindow::Rectangular;
Expand All @@ -40,6 +46,6 @@ class Spectrum {
static bool calculate(SpectrumStorage &,const FrameView &,const SpectrumOptions &);
private:
static void window(SpectrumStorage &,unsigned,SpectrumWindow);
static bool transform(SpectrumStorage &,unsigned);
static bool transform(SpectrumStorage::Work &,unsigned);
};
} // namespace openosc::scope
19 changes: 17 additions & 2 deletions include/openosc/acquisition/timebases.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@

namespace openosc::scope {
struct Timebases {
// Nanoseconds/division; 64 bits are required for 5/10/20 s/div.
// The slowest timebase the ADC is clocked for. Slower ones (to Maximum) Roll only: the ADC keeps
// this one's sample plan and Roll stores the mean of averaging() consecutive points as one.
static constexpr uint64_t SampledMaximum = 20000000000ULL, Maximum = 3600000000000ULL;
// Nanoseconds/division; 64 bits are required for 5 s/div and slower. Past SampledMaximum each value
// is a whole multiple of it, so its averaged points are exactly a tenth of a division apart in time.
static constexpr uint64_t Values[] = {10, 25, 50, 100, 250, 500,
1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000,
1000000, 2000000, 5000000, 10000000, 20000000, 50000000, 100000000,
200000000, 500000000, 1000000000, 2000000000, 5000000000ULL,
10000000000ULL, 20000000000ULL};
10000000000ULL, 20000000000ULL, 60000000000ULL, 120000000000ULL, 300000000000ULL,
600000000000ULL, 1200000000000ULL, 1800000000000ULL, 3600000000000ULL};
// ADC points per stored Roll point (1 up to SampledMaximum), and the timebase the ADC is planned for.
static constexpr uint32_t averaging(uint64_t ns) {
return ns > SampledMaximum ? uint32_t((ns + SampledMaximum - 1) / SampledMaximum) : 1U;
}
static constexpr uint64_t sampled(uint64_t ns) { return ns / averaging(ns); }
static uint64_t step(uint64_t current, int direction) {
if (direction > 0) { for (auto value : Values) if (value > current) return value; }
else if (direction < 0) {
Expand All @@ -23,5 +33,10 @@ struct Timebases {
if (ns * ns >= double(Values[i - 1]) * double(Values[i])) best = Values[i];
return best;
}
static constexpr bool exact() {
for (auto value : Values) if (value > SampledMaximum && value % SampledMaximum) return false;
return Values[sizeof Values / sizeof *Values - 1] == Maximum;
}
};
static_assert(Timebases::exact(), "Averaged timebases are whole multiples of the sampled maximum, the last one Maximum");
} // namespace openosc::scope
Loading