modelRead
GP1 used as an analog input (machine.ADC), driven by an external voltage divider; the script copies a threshold to GP0 (LED) to make the reading observable
Extends from Modelica.Icons.Example (Icon for runnable examples).
Information
Verification scenario 8 (see requirements.md): GP1 is used as an analog input (machine.ADC(1)) rather than as a digital pin — an external voltage divider (supply/rTop/rBot, independent of MCU) sets it to ~2.2 V (3.3 V × 2000/3000). The script adc_read.py reads ADC(1).read_u16() and drives Pin(0, Pin.OUT) according to a threshold (half of the 16-bit scale) — led0 makes this threshold observable, acting as a probe that validates the whole pipeline (voltage division → ADC → threshold → output) without relying on reading a float directly. Pins GP2-GP7, unused by this scenario, are left unconnected.
Components
| Type | Name | Default | Description |
|---|---|---|---|
| MCU | mcu | scriptPath = Resources/Scripts/MCU/adc_read.py | |
| Modelica.Electrical.Analog.Basic.Ground | ground | ||
| Modelica.Electrical.Analog.Basic.Resistor | r0 | limits the current of led0 (GP0) | |
| MicroPythonMCU.Peripherals.LED | led0 | GP0: copy of (v > half of the ADC scale)? | |
| Modelica.Electrical.Analog.Sources.ConstantVoltage | supply | supply of the voltage divider (independent of MCU) | |
| Modelica.Electrical.Analog.Basic.Resistor | rTop | top of the voltage divider | |
| Modelica.Electrical.Analog.Basic.Resistor | rBot | bottom of the voltage divider: GP1 reads ~3.3*2/3 = 2.2 V |