Skip to content
PulseTest.md

PulseTest ​

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 ​

BlockComponents.PulseTest()

Behavior ​

[connect(signal+y(t),integrator+u(t))dintegrator.x(t)dt=integrator.kintegrator.u(t)integrator.y(t)=integrator.x(t)signal.y(t)=ifelse(t>signal.start_time,ifelse(t≤signal.start_time+signal.duty_cyclesignal.period,signal.amplitude,signal.offset),signal.offset)]

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 PulseTest
  "Integrator that accumulates the pulse signal value over time"
  integrator = 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 = 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": {
          "initial": {"signal.y": 0.75},
          "signals": ["signal.y", "integrator.x"],
          "final": {"signal.y": 0.75, "integrator.x": 2.24999999}
        }
      }
    }
  }
}
end
Flattened 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 PulseTest
  "Integrator that accumulates the pulse signal value over time"
  integrator = 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 = 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": {
          "initial": {"signal.y": 0.75},
          "signals": ["signal.y", "integrator.x"],
          "final": {"signal.y": 0.75, "integrator.x": 2.24999999}
        }
      }
    }
  }
}
end


Test Cases ​

Test Case case1 ​

julia
plt

julia
plt