LIBRARY
Examples.AccumulatorDemo ​
Test harness that samples a sine wave and accumulates it using both accumulator types.
This model demonstrates:
Generating a continuous sine wave
Sampling it at a fixed rate (10 Hz)
Accumulating the discrete samples using both syntactic and graphical approaches
Usage ​
DiscreteComponents.Examples.AccumulatorDemo()
Parameters: ​
| Name | Description | Units | Default value |
|---|---|---|---|
dt | – | 0.1 |
Behavior ​
Source ​
dyad
"""
Test harness that samples a sine wave and accumulates it using both accumulator types.
This model demonstrates:
- Generating a continuous sine wave
- Sampling it at a fixed rate (10 Hz)
- Accumulating the discrete samples using both syntactic and graphical approaches
"""
example component AccumulatorDemo
"Continuous sine wave source at 1 Hz"
sine = BlockComponents.Sources.Sine(frequency = 1.0, amplitude = 1.0)
"Samples the sine wave at each clock tick"
sampler = DiscreteComponents.Sampler()
"Periodic clock controlling the sampling rate"
clock = DiscreteComponents.PeriodicClock(dt = 0.1)
"Accumulator using clock syntax"
acc_syntactic = AccumulatorSyntactic()
"Accumulator using block diagram"
acc_graphical = AccumulatorGraphical()
structural parameter dt::Real = 0.1
relations
connect(sine.y, sampler.u)
connect(sampler.y, acc_syntactic.u, acc_graphical.u, clock.y)
endFlattened Source
dyad
"""
Test harness that samples a sine wave and accumulates it using both accumulator types.
This model demonstrates:
- Generating a continuous sine wave
- Sampling it at a fixed rate (10 Hz)
- Accumulating the discrete samples using both syntactic and graphical approaches
"""
example component AccumulatorDemo
"Continuous sine wave source at 1 Hz"
sine = BlockComponents.Sources.Sine(frequency = 1.0, amplitude = 1.0)
"Samples the sine wave at each clock tick"
sampler = DiscreteComponents.Sampler()
"Periodic clock controlling the sampling rate"
clock = DiscreteComponents.PeriodicClock(dt = 0.1)
"Accumulator using clock syntax"
acc_syntactic = AccumulatorSyntactic()
"Accumulator using block diagram"
acc_graphical = AccumulatorGraphical()
structural parameter dt::Real = 0.1
relations
connect(sine.y, sampler.u)
connect(sampler.y, acc_syntactic.u, acc_graphical.u, clock.y)
metadata {}
endTest Cases ​
No test cases defined.
Related ​
Examples
Experiments
Analyses