Skip to content
MultiSensor.md

MultiSensor

Provides combined voltage and current measurements from an electrical circuit.

This component extends a PowerSensor to offer voltage, current and power readings as real-valued outputs. The output v represents the measured voltage, the output i represents the measured current and the output power represents power. v and i outputs are directly sourced from internal voltage_sensor and current_sensor subcomponents, which are part of the inherited PowerSensor. The defining equations from the relations block are:

v = \text{voltage_sensor.v} i = \text{current_sensor.i} power = \text{voltage_sensor.v*current_sensor.i} This component extends from [`PowerSensor`](#) ## Usage `MultiSensor()` ## Connectors * `pc` - ([`Pin`](@ref)) * `nc` - ([`Pin`](@ref)) * `pv` - ([`Pin`](@ref)) * `nv` - ([`Pin`](@ref)) * `power` - This connector represents a real signal as an output from a component ([`RealOutput`](@ref)) * `i` - This connector represents a real signal as an output from a component ([`RealOutput`](@ref)) * `v` - This connector represents a real signal as an output from a component ([`RealOutput`](@ref)) ## Behavior

@example behavior using ElectricalComponents #hide using ModelingToolkit #hide @named sys = MultiSensor() #hide full_equations(sys) #hide


## Source

dyad

Provides combined voltage and current measurements from an electrical circuit.

{#}

This component extends a PowerSensor to offer voltage, current and power

readings as real-valued outputs. The output v represents the measured

voltage, the output i represents the measured current and the output power

represents power. v and i outputs are directly sourced from internal

voltage_sensor and current_sensor subcomponents, which are part of the

inherited PowerSensor. The defining equations from the relations block are:

```math

v = \text{voltage_sensor.v} {#v-\text{voltage_sensor.v}}

```

```math

i = \text{current_sensor.i} {#i-\text{current_sensor.i}}

```

```math

power = \text{voltage_sensor.v*current_sensor.i} {#power-\text{voltagesensor.vcurrentsensor.i}}

component MultiSensor extends PowerSensor

Output signal representing the measured current

i = RealOutput() [{ "Dyad": { "placement": {"icon": {"x1": 650, "y1": 950, "x2": 750, "y2": 1050, "rot": 90}} } }]

Output signal representing the measured voltage

v = RealOutput() [{ "Dyad": { "placement": {"icon": {"x1": 850, "y1": 950, "x2": 950, "y2": 1050, "rot": 90}} } }] relations i = current_sensor.i v = voltage_sensor.v metadata { "Dyad": { "labels": [ {"label": "instance", "x": 500, "y": 1100, "rot": 0}, {"label": "M", "x": 500, "y": 713, "rot": 0} ], "icons": {"default": "dyad://ElectricalComponents/FourPinSensor.svg"} } } end

@raw html

<details> <summary>Flattened Source</summary>

dyad

Provides combined voltage and current measurements from an electrical circuit.

This component extends a PowerSensor to offer voltage, current and power

readings as real-valued outputs. The output v represents the measured

voltage, the output i represents the measured current and the output power

represents power. v and i outputs are directly sourced from internal

voltage_sensor and current_sensor subcomponents, which are part of the

inherited PowerSensor. The defining equations from the relations block are:

```math

v = \text{voltage_sensor.v} {#v-\text{voltage_sensor.v}-2}

```

```math

i = \text{current_sensor.i} {#i-\text{current_sensor.i}-2}

```

```math

power = \text{voltage_sensor.v*current_sensor.i} {#power-\text{voltagesensor.vcurrentsensor.i}-2}

component MultiSensor

Positive pin for current measurement path

pc = Pin() [{ "Dyad": { "placement": {"icon": {"iconName": "pos", "x1": -50, "y1": 450, "x2": 50, "y2": 550}} } }]

Negative pin for current measurement path

nc = Pin() [{ "Dyad": { "placement": {"icon": {"iconName": "neg", "x1": 950, "y1": 450, "x2": 1050, "y2": 550}} } }]

Positive pin for voltage measurement

pv = Pin() [{ "Dyad": { "placement": {"icon": {"iconName": "pos", "x1": 450, "y1": -50, "x2": 550, "y2": 50}} } }]

Negative pin for voltage measurement

nv = Pin() [{ "Dyad": { "placement": {"icon": {"iconName": "neg", "x1": 450, "y1": 950, "x2": 550, "y2": 1050}} } }]

Internal subcomponent to measure voltage

voltage_sensor = VoltageSensor()

Internal subcomponent to measure current

current_sensor = CurrentSensor()

Output signal representing the calculated instantaneous power

power = RealOutput() [{ "Dyad": { "placement": {"icon": {"x1": 150, "y1": 950, "x2": 250, "y2": 1050, "rot": 90}} } }]

Output signal representing the measured current

i = RealOutput() [{ "Dyad": { "placement": {"icon": {"x1": 650, "y1": 950, "x2": 750, "y2": 1050, "rot": 90}} } }]

Output signal representing the measured voltage

v = RealOutput() [{ "Dyad": { "placement": {"icon": {"x1": 850, "y1": 950, "x2": 950, "y2": 1050, "rot": 90}} } }] relations connect(pv, voltage_sensor.p) connect(voltage_sensor.n, nv) connect(pc, current_sensor.p) connect(current_sensor.n, nc) power = voltage_sensor.v*current_sensor.i i = current_sensor.i v = voltage_sensor.v metadata { "Dyad": { "labels": [ {"label": "instance", "x": 500, "y": 1100, "rot": 0}, {"label": "M", "x": 500, "y": 713, "rot": 0} ], "icons": {"default": "dyad://ElectricalComponents/FourPinSensor.svg"} } } end

@raw html </details>

@raw html

<br></br>


## Test Cases
This is setup code, that must be run before each test case.

@example tests using ElectricalComponents using ModelingToolkit, OrdinaryDiffEqDefault using Plots using CSV, DataFrames

snapshotsdir = joinpath(dirname(dirname(pathof(ElectricalComponents))), "test", "snapshots") ```