modelBoot
Extends from Modelica.Icons.Example (Icon for runnable examples).
Information
Verification scenario 25 (see requirements.md, decision "Système de fichiers"): the file system is enabled (fsEnabled) and scriptPath is empty, so the microcontroller starts like a real board — boot.py then main.py, read at the root of the flash.
At each simulation, the image Resources/FileSystems/datalogger (fsSource) is copied into a new folder of the workspace (fsWorkspace = "." by default: the simulation folder), named mcu_datalogger_<date>_<time> — its exact path is announced in the simulation log, at the start and at the end, and Windows Explorer opens on it at the end of the simulation (fsOpenExplorer). The original image is never modified: each simulation starts again from the same state and produces the same files.
boot.pycreates the/datafolder;main.pyreads its settings from/config.txt, imports theDataLogmodule from/lib, then logs every 100 ms the voltage read by the ADC onGP0(ramp from 0 to 3.3 V) to/data/measurements.csv;- it finally checks itself (file read-back,
os.listdir,os.stat, attempt to escape the flash through../..) and lightsled1(GP1) if everything is as expected.
To run it on your own files: point fsSource to a folder containing boot.py/main.py, and possibly fsWorkspace to the folder where the copies should go. Variant with a script instead of main.py: Examples.FileSystem.Script.
Components
| Type | Name | Default | Description |
|---|---|---|---|
| MCU | mcu | empty scriptPath: boot.py then main.py of the image Resources/FileSystems/datalogger; copy created in the simulation folder (fsWorkspace = "." by default), opened in Explorer at the end of the simulation | |
| Modelica.Electrical.Analog.Basic.Ground | ground | ||
| Modelica.Electrical.Analog.Sources.RampVoltage | ramp | voltage measured by the ADC (GP0): ramp from 0 to 3.3 V in 1 s | |
| Modelica.Electrical.Analog.Basic.Resistor | r1 | limits the current of led1 (GP1) | |
| MicroPythonMCU.Peripherals.LED | led1 | GP1: self-check of main.py passed |