modelIndependent
Extends from Modelica.Icons.Example (Icon for runnable examples).
Information
Two MCU blocks run the same program, multi_counter.py, which imports the module multi_counter_lib.py (placed next to it) and increments its module-level counter every 100 ms, five times. Each microcontroller runs in its own Python sub-interpreter: its program globals, its imported modules (here the counter), machine, time, sys.path and its file system are its own. Both boards therefore count exactly 5 ticks and light their GP1 LED at the end; with a shared state, the counter would reach 10 and the second board would also see the globals of the first.
With two microcontrollers or more, every line printed by a program is prefixed with the instance name in the simulation log ([mcu1] ...), as the scripted peripherals already do.
Components
| Type | Name | Default | Description |
|---|---|---|---|
| MCU | mcu1 | First board: Resources/Scripts/MCU/multi_counter.py | |
| MCU | mcu2 | Second board: the same program | |
| Modelica.Electrical.Analog.Basic.Ground | ground | ||
| Modelica.Electrical.Analog.Basic.Resistor | r10 | limits the current of led10 | |
| MicroPythonMCU.Peripherals.LED | led10 | mcu1 GP0: blinks with the ticks of mcu1 | |
| Modelica.Electrical.Analog.Basic.Resistor | r11 | limits the current of led11 | |
| MicroPythonMCU.Peripherals.LED | led11 | mcu1 GP1: lit at the end if mcu1 counted only its own 5 ticks | |
| Modelica.Electrical.Analog.Basic.Resistor | r20 | limits the current of led20 | |
| MicroPythonMCU.Peripherals.LED | led20 | mcu2 GP0: blinks with the ticks of mcu2 | |
| Modelica.Electrical.Analog.Basic.Resistor | r21 | limits the current of led21 | |
| MicroPythonMCU.Peripherals.LED | led21 | mcu2 GP1: lit at the end if mcu2 counted only its own 5 ticks |