modelLed
GP0 drives an LED in PWM (machine.PWM), 200 Hz / ~30% duty cycle, set once then generated continuously on the Modelica side
Extends from Modelica.Icons.Example (Icon for runnable examples).
Information
Verification scenario 9 (see requirements.md): GP0 is configured as a PWM output (machine.PWM) rather than as a plain digital pin — the script pwm_led.py calls PWM(Pin(0)), freq(200) and duty_u16(19661) (~30%) only once then ends: the square wave is then generated continuously on the Modelica side (expression mod(time, period) in MCU.mo), without any further round trip with the Python thread — true to the real PWM hardware peripheral of the RP2040, which runs independently of the CPU once configured. led0 makes the duty cycle visually observable (reduced brightness compared with a digital GPIO permanently on). Pins GP1-GP7, unused by this scenario, are left unconnected.
Components
| Type | Name | Default | Description |
|---|---|---|---|
| MCU | mcu | scriptPath = Resources/Scripts/MCU/pwm_led.py | |
| Modelica.Electrical.Analog.Basic.Ground | ground | ||
| Modelica.Electrical.Analog.Basic.Resistor | r0 | limits the current of led0 (GP0) | |
| MicroPythonMCU.Peripherals.LED | led0 | GP0: PWM square wave (200 Hz, ~30%) |