modelRPi_Pico

Raspberry Pi Pico board: RP2040 programmable in MicroPython, real pinout and dimensions, power supply through USB, VBUS or VSYS and the on-board 3.3 V regulator

Extends from Internal.Boards.PartialUsbBoard (Common base of the boards supplied through USB (RPi_Pico, MicroBit_v2): the USB supply parameters are written here once - each board keeps its own supply chain (pins, components, wiring), whose placement and topology are board-specific).

Information

Replica of the Raspberry Pi Pico board (RP2040): real pinout (40 pins, viewed from above, USB connector at the top) and real dimensions (21 x 51 mm, 2.54 mm pitch, rows 17.78 mm apart), and its power supply. It contains the same programmable core as MCU (Internal.Boards.McuCore: Python program, machine API, sync point), wired to the power components of the board — see the internal diagram. The pins are supplied by the 3.3 V rail of the board, and the program only runs while the board is supplied.

Power supply

  • usbConnected (true by default, lightning bolt on the USB connector of the icon): the USB cable supplies 5 V on VBUS — the board runs without wiring anything, like a Pico plugged into the computer.
  • VBUS feeds VSYS through a Schottky diode (about 0.3 V). VSYS (1.8 to 5.5 V) can also be supplied directly, typically by a battery, with usbConnected = false.
  • The buck-boost regulator (Internal.Boards.Rt6150, averaged model: efficiency eta, undervoltage lockout) makes the 3.3 V rail from VSYS; 3V3_EN (pulled up to VSYS) switches it off when grounded. The rail supplies the RP2040 and the flash (ICore), the pins (high level and pull-ups: the current of an LED on a pin is drawn from it) and the 3V3(OUT) pin for external circuits.
  • ADC_VREF = 3V3 filtered through 200 Ohm: it is the reference of machine.ADC.
  • Internal sensing, as on the board: Pin(24) reads the presence of VBUS, ADC(3) (GPIO29) reads VSYS/3, ADC(4) reads the temperature sensor (dieTemperature).

Power-on and power loss: the program (boot.py/main.py or the script) starts the first time the 3.3 V rail exceeds VPowerOn with RUN high, and time.ticks_ms() counts from this instant. If the rail falls below VPowerOff or RUN is grounded afterwards, the program is stopped for good (warning in the log) and the pins are released; a restart when the supply comes back is not simulated.

Differences with MCU

  • All the pins of the board: GP0-GP22, GP26-GP28; ADC only on GP26-GP28 (ADC(0)-ADC(2)), as on the RP2040.
  • UART and I2C follow the pin multiplexing of the RP2040 (e.g. UART(0): TX on GP0, 12, 16 or 28) and the default pins of the rp2 port; UART(0) and UART(1) (and I2C(0)/I2C(1)) are both accepted, but only one at a time (single engine in the simulation). SoftI2C accepts any pins.
  • The on-board LED (Pin(25) or Pin("LED")) is drawn at its real place on the icon.

The Display0 logical link to the educational displays is kept (top of the icon), although it does not exist on the real board. See requirements.md, decision "Carte Raspberry Pi Pico et alimentation".

Parameters

TypeNameDefaultDescription
Modelica.Units.SI.TimetickPeriod (from PartialMcuSettings)0.1Period of the minimal sync point (output freshness if the script never sleeps)
Python script
StringscriptPath (from PartialMcuSettings)Modelica.Utilities.Files.loadResource("modelica://MicroPythonMCU/Resources/Scripts/MCU/demo.py")Path of the user script (.py) - with an active file system, run after boot.py instead of main.py; empty = main.py from the flash
BooleanaddScriptDirToPath (from PartialMcuSettings)trueMake the .py files next to the script importable (e.g. import my_module) - mimics the real Pico (flash root folder on sys.path)
StringlibraryPath (from PartialMcuSettings)""Optional: a .py file from a shared library folder to make importable (the folder containing this file is added to the module search path) - leave empty if unused
File system › Simulated flash
BooleanfsEnabled (from PartialMcuSettings)falseEnable the file system (simulated flash) - disabled: open() and os raise OSError
StringfsSource (from PartialMcuSettings)""Initial image of the flash (folder: data, boot.py, main.py, lib/), copied at each simulation and never modified - any file of the folder, the folder path or a modelica:// URI; empty = blank flash, only the script runs
StringfsWorkspace (from PartialMcuSettings)"."Workspace: folder where each simulation creates its copy, named <instance>_<FS name>_<date>_<time> (created if missing) - "." or relative path = from the simulation folder; full path of the copy shown in the log
BooleanfsOpenExplorer (from PartialMcuSettings)trueOpen Windows Explorer on the copy at the end of the simulation
Execution time
Modelica.Units.SI.TimegpioOpTime (from PartialMcuSettings)5e-6Execution time of a pin access (Pin.value(), on(), off()): two writes without sleep() give a pulse of this width (bit-banging) - order of magnitude of MicroPython on RP2040; 0 = instantaneous accesses
Modelica.Units.SI.TimehangWarningTime (from PartialMcuSettings)10Real (wall-clock) time after which a warning is logged if the script does not let the simulation advance (loop without sleep() nor pin access, or with gpioOpTime = 0) - the simulation keeps waiting; 0 = no warning
Debugging
BooleandebugEnabled (from PartialMcuSettings)falseDebug the program with VS Code: at the start of the simulation, the microcontroller waits until VS Code attaches (debugpy, Run and Debug > attach to localhost:debugPort); simulated time stays frozen while the program is paused - one microcontroller per model
IntegerdebugPort (from PartialMcuSettings)5678Local TCP port on which the debugger (debugpy) listens - the port of the VS Code attach configuration
Electrical › Logic levels
Modelica.Units.SI.VoltageVOL (from PartialMcuSettings)Interfaces.VOLLogic low voltage
Modelica.Units.SI.VoltageVIH (from PartialMcuSettings)Interfaces.VIHThreshold above which an input reads high
Modelica.Units.SI.VoltageVIL (from PartialMcuSettings)Interfaces.VILThreshold below which an input reads low
Electrical › Output stages
Modelica.Units.SI.ResistanceROut (from PartialMcuSettings)Interfaces.ROutOutput series resistance (drive strength)
Modelica.Units.SI.ResistanceledSeriesR330Series resistance of the on-board LED (internal, GP25)
Electrical › Input stages
Modelica.Units.SI.ResistanceRPullUp (from PartialMcuSettings)Interfaces.RPullInternal pull-up resistor to the supply, switched on by Pin(n, mode, Pin.PULL_UP) and by I2C() on SCL/SDA
Modelica.Units.SI.ResistanceRPullDown (from PartialMcuSettings)Interfaces.RPullInternal pull-down resistor to GND, switched on by Pin(n, mode, Pin.PULL_DOWN)
Modelica.Units.SI.ConductanceGOff (from PartialMcuSettings)Interfaces.GOffLeakage of a pin that does not drive its line (input, released I2C line), towards GND: 1e-9 S = 1 GOhm
Power supply › Consumption
Modelica.Units.SI.CurrentICore (from PartialBoard)0.02Current drawn from the supply rail by the core and its memory while supplied (program running, pins excluded)
Power supply › Power-on
Modelica.Units.SI.VoltageVPowerOn (from PartialBoard)1.8Supply rail voltage above which the core starts (power-on reset)
Modelica.Units.SI.VoltageVPowerOff (from PartialBoard)1.6Supply rail voltage below which a running core stops for good (brown-out)
Power supply › USB
BooleanusbConnected (from PartialUsbBoard)trueUSB cable plugged in: 5 V through the USB connector (the board runs without any wiring) - false to supply the board through its supply pin
Modelica.Units.SI.VoltageVUsb (from PartialUsbBoard)5Voltage of the USB supply
Modelica.Units.SI.ResistanceRUsb (from PartialUsbBoard)0.2Resistance of the USB cable and connector
Power supply › Regulator
Realeta (from PartialUsbBoard)0.9Efficiency of the regulator
Power supply › Temperature sensor
Modelica.Units.NonSI.Temperature_degCdieTemperature27Temperature of the RP2040, read by machine.ADC(4)

Connectors

TypeNameDefaultDescription
Modelica.Electrical.Analog.Interfaces.PositivePinGP0GPIO 0, physical pin 1 (machine.Pin(0))
Modelica.Electrical.Analog.Interfaces.PositivePinGP1GPIO 1, physical pin 2 (machine.Pin(1))
Modelica.Electrical.Analog.Interfaces.NegativePinGND_3Ground, physical pin 3 (all the GND pins and AGND are connected together)
Modelica.Electrical.Analog.Interfaces.PositivePinGP2GPIO 2, physical pin 4 (machine.Pin(2))
Modelica.Electrical.Analog.Interfaces.PositivePinGP3GPIO 3, physical pin 5 (machine.Pin(3))
Modelica.Electrical.Analog.Interfaces.PositivePinGP4GPIO 4, physical pin 6 (machine.Pin(4))
Modelica.Electrical.Analog.Interfaces.PositivePinGP5GPIO 5, physical pin 7 (machine.Pin(5))
Modelica.Electrical.Analog.Interfaces.NegativePinGND_8Ground, physical pin 8 (all the GND pins and AGND are connected together)
Modelica.Electrical.Analog.Interfaces.PositivePinGP6GPIO 6, physical pin 9 (machine.Pin(6))
Modelica.Electrical.Analog.Interfaces.PositivePinGP7GPIO 7, physical pin 10 (machine.Pin(7))
Modelica.Electrical.Analog.Interfaces.PositivePinGP8GPIO 8, physical pin 11 (machine.Pin(8))
Modelica.Electrical.Analog.Interfaces.PositivePinGP9GPIO 9, physical pin 12 (machine.Pin(9))
Modelica.Electrical.Analog.Interfaces.NegativePinGND_13Ground, physical pin 13 (all the GND pins and AGND are connected together)
Modelica.Electrical.Analog.Interfaces.PositivePinGP10GPIO 10, physical pin 14 (machine.Pin(10))
Modelica.Electrical.Analog.Interfaces.PositivePinGP11GPIO 11, physical pin 15 (machine.Pin(11))
Modelica.Electrical.Analog.Interfaces.PositivePinGP12GPIO 12, physical pin 16 (machine.Pin(12))
Modelica.Electrical.Analog.Interfaces.PositivePinGP13GPIO 13, physical pin 17 (machine.Pin(13))
Modelica.Electrical.Analog.Interfaces.NegativePinGND_18Ground, physical pin 18 (all the GND pins and AGND are connected together)
Modelica.Electrical.Analog.Interfaces.PositivePinGP14GPIO 14, physical pin 19 (machine.Pin(14))
Modelica.Electrical.Analog.Interfaces.PositivePinGP15GPIO 15, physical pin 20 (machine.Pin(15))
Modelica.Electrical.Analog.Interfaces.PositivePinVBUSMicro-USB input voltage, physical pin 40: 5 V from the USB connector when usbConnected, otherwise free (an external 5 V supply can be connected here)
Modelica.Electrical.Analog.Interfaces.PositivePinVSYSMain system input, physical pin 39: 1.8 to 5.5 V, supplied from VBUS through a Schottky diode, or directly from a battery
Modelica.Electrical.Analog.Interfaces.NegativePinGND_38Ground, physical pin 38 (all the GND pins and AGND are connected together)
Modelica.Electrical.Analog.Interfaces.PositivePinV3V3_ENEnable of the 3.3 V regulator (3V3_EN), physical pin 37: pulled up to VSYS by 100 kOhm, to ground to switch the regulator off
Modelica.Electrical.Analog.Interfaces.PositivePinV3V33.3 V output of the regulator (3V3(OUT)), physical pin 36: supplies external circuits (keep the load under 300 mA)
Modelica.Electrical.Analog.Interfaces.PositivePinADC_VREFADC reference voltage, physical pin 35: 3V3 filtered through 200 Ohm on the board; can be driven by an external reference
Modelica.Electrical.Analog.Interfaces.PositivePinGP28GPIO 28, physical pin 34 (machine.Pin(28), machine.ADC(2))
Modelica.Electrical.Analog.Interfaces.NegativePinAGNDAnalog ground of the ADC, physical pin 33 (connected to GND)
Modelica.Electrical.Analog.Interfaces.PositivePinGP27GPIO 27, physical pin 32 (machine.Pin(27), machine.ADC(1))
Modelica.Electrical.Analog.Interfaces.PositivePinGP26GPIO 26, physical pin 31 (machine.Pin(26), machine.ADC(0))
Modelica.Electrical.Analog.Interfaces.PositivePinRUNRP2040 enable, physical pin 30: internal pull-up to 3V3; to ground, the RP2040 is held in reset (the program stops for good, a restart is not simulated)
Modelica.Electrical.Analog.Interfaces.PositivePinGP22GPIO 22, physical pin 29 (machine.Pin(22))
Modelica.Electrical.Analog.Interfaces.NegativePinGND_28Ground, physical pin 28 (all the GND pins and AGND are connected together)
Modelica.Electrical.Analog.Interfaces.PositivePinGP21GPIO 21, physical pin 27 (machine.Pin(21))
Modelica.Electrical.Analog.Interfaces.PositivePinGP20GPIO 20, physical pin 26 (machine.Pin(20))
Modelica.Electrical.Analog.Interfaces.PositivePinGP19GPIO 19, physical pin 25 (machine.Pin(19))
Modelica.Electrical.Analog.Interfaces.PositivePinGP18GPIO 18, physical pin 24 (machine.Pin(18))
Modelica.Electrical.Analog.Interfaces.NegativePinGND_23Ground, physical pin 23 (all the GND pins and AGND are connected together)
Modelica.Electrical.Analog.Interfaces.PositivePinGP17GPIO 17, physical pin 22 (machine.Pin(17))
Modelica.Electrical.Analog.Interfaces.PositivePinGP16GPIO 16, physical pin 21 (machine.Pin(16))
Interfaces.DisplayLinkOutputDisplay0Logical link to an educational display peripheral (machine.Display(0).write()) - not on the real board: simplified causal link, see requirements.md decision "Périphérique d'affichage pédagogique"

Components

TypeNameDefaultDescription
Internal.Boards.PartialMcuCorecore (from PartialBoard)Programmable core, public like in the boards so that its plotted variables (powerGood, supplyOk...) stay in the simulation results - partial: every board redeclares it (McuCore); pin table (nPins, pinIds, pinCaps), board profile and on-board devices are set by the board in the modifier of its extends, pins in the order of pinIds
Internal.Boards.Rt6150regulatorBuck-boost regulator VSYS -> 3.3 V (RT6150B)
MicroPythonMCU.Peripherals.LEDbuiltinLedOn-board LED (GPIO25)
Modelica.Units.SI.VoltagevRailV3V3.v - core.gnd.vVoltage of the 3.3 V rail (3V3(OUT))
Modelica.Units.SI.VoltagevSysVSYS.v - core.gnd.vVoltage of VSYS
Modelica.Units.SI.CurrentiSysregulator.iInCurrent drawn from VSYS by the regulator