---
url: /dyad/stable/stdlib/BlockComponents/tests/Sources.Tests.Pulse.md
description: >-
  Dyad Sources.Tests.Pulse docs.  Generates a pulse signal with configurable
  parameters and integrates it.
---

# `Sources.Tests.Pulse` {#Sources.Tests.Pulse}

Generates a pulse signal with configurable parameters and integrates it.

This test component demonstrates the connection of a Pulse signal generator to an Integrator block, showing how the integrated value of a periodic pulse signal evolves over time. The pulse signal alternates between two levels (offset and offset+amplitude) based on the duty cycle and period parameters. The resulting waveform is then integrated over time.

## Usage {#Usage}

`BlockComponents.Sources.Tests.Pulse()`

## Behavior {#Behavior}

$$ \begin{align}
0 &= \mathrm{connect}\left( signal\_{+}y, integrator\_{+}u \right) \\
\frac{\mathrm{d}\mathtt{integrator.x}\left( t \right)}{\mathrm{d}t} &= \mathtt{integrator.k} ~ \mathtt{integrator.u}\left( t \right) \\
\mathtt{integrator.y}\left( t \right) &= \mathtt{integrator.x}\left( t \right) \\
\mathtt{signal.y}\left( t \right) &= ifelse\left( \mathtt{signal.start_time} < t, ifelse\left( t \leq \mathtt{signal.start_time} + \mathtt{signal.duty_cycle} ~ \mathtt{signal.period}, \mathtt{signal.amplitude}, \mathtt{signal.offset} \right), \mathtt{signal.offset} \right)
\end{align}
$$

## Source {#Source}

```dyad
"""
Generates a pulse signal with configurable parameters and integrates it.

This test component demonstrates the connection of a Pulse signal generator to an
Integrator block, showing how the integrated value of a periodic pulse signal evolves
over time. The pulse signal alternates between two levels (offset and offset+amplitude)
based on the duty cycle and period parameters. The resulting waveform is then integrated
over time.
"""
test component Pulse
  "Integrator that accumulates the pulse signal value over time"
  integrator = BlockComponents.Continuous.Integrator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 155, "y1": 20, "x2": 255, "y2": 120, "rot": 0}
      }
    }
  }
  "Pulse signal generator with configurable amplitude, duty cycle, offset, period and start time"
  signal = BlockComponents.Sources.Pulse(amplitude = 1.5, duty_cycle = 0.5, offset = 0.75, period = 0.75, start_time = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
      }
    }
  }
relations
  "Connects the pulse signal output to the integrator input"
  connect(signal.y, integrator.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {"case1": {"stop": 3, "expect": {"signals": ["signal.y", "integrator.x"]}}}
  }
}
end
```

```dyad
"""
Generates a pulse signal with configurable parameters and integrates it.

This test component demonstrates the connection of a Pulse signal generator to an
Integrator block, showing how the integrated value of a periodic pulse signal evolves
over time. The pulse signal alternates between two levels (offset and offset+amplitude)
based on the duty cycle and period parameters. The resulting waveform is then integrated
over time.
"""
test component Pulse
  "Integrator that accumulates the pulse signal value over time"
  integrator = BlockComponents.Continuous.Integrator() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 155, "y1": 20, "x2": 255, "y2": 120, "rot": 0}
      }
    }
  }
  "Pulse signal generator with configurable amplitude, duty cycle, offset, period and start time"
  signal = BlockComponents.Sources.Pulse(amplitude = 1.5, duty_cycle = 0.5, offset = 0.75, period = 0.75, start_time = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 20, "y1": 20, "x2": 120, "y2": 120, "rot": 0}
      }
    }
  }
relations
  "Connects the pulse signal output to the integrator input"
  connect(signal.y, integrator.u) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
metadata {
  "Dyad": {
    "icons": {"default": "dyad://BlockComponents/Example.svg"},
    "tests": {"case1": {"stop": 3, "expect": {"signals": ["signal.y", "integrator.x"]}}}
  }
}
end
```

## Test Cases {#Test-Cases}

### Test Case `case1` {#Test-Case-case1}

```julia
plt
```

![](stismqp.svg)

```julia
plt
```

![](eitedpw.svg)

## Related {#Related}

* Examples

* Experiments

* Analyses

* Tests
  * [`Integrator`](Sources.Tests.Pulse.md)

  * [`Pulse`](Sources.Tests.Pulse.md)

  * [`Pulse`](Sources.Tests.Pulse.md)
