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

TypeNameDefaultDescription
MCUmcuscriptPath = Resources/Scripts/MCU/adc_read.py
Modelica.Electrical.Analog.Basic.Groundground
Modelica.Electrical.Analog.Basic.Resistorr0limits the current of led0 (GP0)
MicroPythonMCU.Peripherals.LEDled0GP0: copy of (v > half of the ADC scale)?
Modelica.Electrical.Analog.Sources.ConstantVoltagesupplysupply of the voltage divider (independent of MCU)
Modelica.Electrical.Analog.Basic.ResistorrToptop of the voltage divider
Modelica.Electrical.Analog.Basic.ResistorrBotbottom of the voltage divider: GP1 reads ~3.3*2/3 = 2.2 V