Voltecx is in beta. The macOS build comes first; Windows and Linux packages are still being tested.Beta. macOS comes first; Windows and Linux are still in testing. What's new
Documentation

Zero-Order Hold (zoh)

Samples its input at fixed times and holds the value.

zoh

Component reference · 繁體中文

Group: Control · Kind: {"block":"zoh","kind":"control"}

When to use it

Use it as the ADC stage that feeds a digital controller. Use Sample and Hold when no start offset is needed.

Pins

Pin Domain Meaning
in signal Signal to sample
clk signal Optional clock; while wired the block samples at each of its rising edges instead of every ts.
out signal Held value; changes only at sample times

Common parameters

  • ts: Time between samples; with the clk input wired, every rising edge of clk instead (Default: required)
  • offset: Time of the first sample (Default: 0)

Parameters

Key Unit Default Typical range Description
ts s required Time between samples; with the clk input wired, every rising edge of clk instead
offset s 0 Time of the first sample

Parameter descriptions are in English in both languages.

Model

At each instant t = offset + k·ts (k = 0, 1, 2, ...) the output takes the value of the input at that moment and keeps it until the next instant. Before the first instant the output is 0. With clk wired the instants are the rising edges of clk (across 0.5) instead, and the block reports none of its own. The block reports its instants to the solver, so fastsolve ends a step exactly on each of them. It has direct feedthrough at the instant, so it cannot close a loop by itself.

Common mistakes

  • Keep maxStep at or below ts, and for the fixed-step solver make it divide ts evenly, or sample times are skipped. A meter has no value yet at time 0, so the first sample reads 0.
  • A loop that passes only through this block and other direct-pass blocks is refused. Add a Unit Delay to stand for the one-sample delay of the real firmware.

Problems rules: compile.error

Datasheet and sources

ts is the ADC trigger period of your MCU, which is 1/fs and matches the MCU Output Stage. offset is where the trigger falls inside the PWM period: 0 at the carrier valley, half a PWM period at the peak.

Example

Open the example with the command file.openExample and the name demo:zoh.


Generated by cargo xtask reference from the usage texts and parameter specs. Do not edit by hand.