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

Sample and Hold (sampleHold)

Samples its input once per period and holds the value.

sampleHold

Component reference · 繁體中文

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

When to use it

Use it to model a digital controller that reads a measurement once per period. Use ADC for rounding and Sample Delay for extra delay.

Pins

Pin Domain Meaning
in signal Signal to sample
clk signal Optional clock; while wired the block samples at each of its rising edges (across 0.5) instead of every period.
out signal Value held from the last sample

Common parameters

  • period: Sample period; unused while the clk input is wired (then every rising edge of clk samples) (Default: required)

Parameters

Key Unit Default Typical range Description
period s required Sample period; unused while the clk input is wired (then every rising edge of clk samples)

Parameter descriptions are in English in both languages.

Model

At every multiple of period (starting at t = 0) the block copies its input to the output, then holds it constant until the next instant. The solver lands a step exactly on each sample instant. With clk wired the block samples at each rising edge of clk instead (not at a pass with no time step, so a clock high at t = 0 does not fire) and reports no instants of its own. The block has no direct feedthrough, so it breaks algebraic loops.

Common mistakes

  • The period is in seconds, so write 100u for 10 kHz. A value written without its prefix is probably wrong.
  • Without direct feedthrough, the solver may read the signal that drives it one step late. Keep the maximum step well below period, and sample signals that change slowly compared with the step.

Problems rules: param.out_of_range

Datasheet and sources

No datasheet applies. The value of period is the sample period of the controller you model: the inverse of the interrupt or ADC trigger rate, often equal to the PWM period or half of it.

Example

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


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