
modelLED
LED whose icon lights up according to the current flowing through it (inspired by Arduino.Components.LED, Modelica-Arduino library)
Extends from Modelica.Electrical.Analog.Interfaces.TwoPin (Component with two electrical pins).
Information
Two-pin LED (p/n), modelled as a Modelica.Electrical.Analog.Semiconductors.Diode (smooth exponential characteristic, not Ideal.IdealDiode — its switching through a discrete event turned out to block the sync mechanism on very long simulations with a periodic tick, see requirements.md), calibrated for a voltage drop close to Vknee once conducting — like a real LED, it needs an external series resistor to limit the current. The current flowing through the LED is measured then smoothed (first-order filter Modelica.Blocks.Continuous.FirstOrder, 20 ms time constant, no discrete event) to drive the brightness of the icon through DynamicSelect: outside the replay of a simulation result (for instance while building a schematic), the icon shows colorOn (bright red by default) to stay clearly visible; during the animated replay of a result, it interpolates between colorOff (zero current) and colorOn (current ≥ IMax). Inspired by Arduino.Components.LED in the Modelica-Arduino library (CATIA-Systems).
Parameters
| Type | Name | Default | Description |
| Modelica.Units.SI.Voltage | Vknee | 1.8 | Threshold (knee) voltage of the diode, approximation of a red LED |
| Modelica.Units.SI.Current | IMax | 0.0035 | Current giving the maximum brightness of the icon (display scale, not an enforced physical limit) - set to the current typically reached in this project (~3.5 mA with a 330 Ω series resistance, VOH=3.3V, ROut=100 Ω), so that the icon really reaches colorOn in steady state rather than stopping halfway |
| Integer[3] | colorOn | {255, 0, 0} | Colour of the icon at full brightness (RGB) |
| Integer[3] | colorOff | {90, 25, 25} | Colour of the icon when off (RGB) |
Components
| Type | Name | Default | Description |
| SI.Voltage | v (from TwoPin) | | Voltage drop of the two pins (= p.v - n.v) |
| Modelica.Electrical.Analog.Semiconductors.Diode | diode | | Diode with a smooth characteristic (not Ideal.IdealDiode: its switching through a discrete event breaks the sync mechanism on very long simulations with a periodic tick, see requirements.md). Ids calibrated for ~5 mA at Vknee; Vt=0.1 (softer than a real physical Vt) for numerical stability, knee voltage close to Vknee to first order. |
| Modelica.Electrical.Analog.Sensors.CurrentSensor | currentSensor | | |
| Modelica.Blocks.Continuous.FirstOrder | mean | | Smooths the measured current, for a steady icon animation (no electrical role). A continuous first-order filter rather than Blocks.Math.Mean: Mean relies on a sample() that generates an event at each window (50 per simulated second with f=50), a cost that dominates long simulations - see requirements.md. T = 20 ms: short enough compared with the fastest blinking of the project (chaser at 150 ms/pin) not to blur the transitions. Name "mean" kept: the icons (DynamicSelect) read mean.y |