modelMicroBit_v2

BBC micro:bit v2 board: nRF52833 programmable in MicroPython, real pinout and dimensions, multiplexed 5x5 LED matrix, buttons A/B, integrated sensors and USB power supply

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

Light level 0-255 read by display.read_light_level()

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)
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
Modelica.Units.SI.VoltageVTgt3.0Voltage of the 3V rail (output of the on-board regulator, high level and ADC reference of the pins)
Pins › Supply
BooleanuseGroundPintrueShow the GND pin - unchecked: the board is referenced to the simulation ground (0 V), nothing to wire
Sensors › Accelerometer
InputSourceaccelXSourceInputSource.ConstantHow accelX is driven: constant parameter, time table, or connector wired from the diagram
RealaccelX0X axis of the accelerometer, constant value (m/s2)
Real[:,2]accelXTable{{0, 0}, {0.5, 0}, {1, 5}, {1.5, 0}, {5, 0}}Time table of accelX (column 1 = time in s, column 2 = value in m/s2)
InputSourceaccelYSourceInputSource.ConstantHow accelY is driven: constant parameter, time table, or connector wired from the diagram
RealaccelY0Y axis of the accelerometer, constant value (m/s2)
Real[:,2]accelYTable{{0, 0}}Time table of accelY (column 1 = time in s, column 2 = value in m/s2)
InputSourceaccelZSourceInputSource.ConstantHow accelZ is driven: constant parameter, time table, or connector wired from the diagram
RealaccelZ-9.81Z axis of the accelerometer (default: gravity, board lying display up), constant value (m/s2)
Real[:,2]accelZTable{{0, -9.81}}Time table of accelZ (column 1 = time in s, column 2 = value in m/s2)
Sensors › Magnetometer/compass
InputSourcemagXSourceInputSource.ConstantHow magX is driven: constant parameter, time table, or connector wired from the diagram
RealmagX0X axis of the magnetometer/compass, constant value (uT)
Real[:,2]magXTable{{0, 0}}Time table of magX (column 1 = time in s, column 2 = value in uT)
InputSourcemagYSourceInputSource.ConstantHow magY is driven: constant parameter, time table, or connector wired from the diagram
RealmagY50Y axis of the magnetometer/compass (default: field pointing along +Y), constant value (uT)
Real[:,2]magYTable{{0, 50}}Time table of magY (column 1 = time in s, column 2 = value in uT)
InputSourcemagZSourceInputSource.ConstantHow magZ is driven: constant parameter, time table, or connector wired from the diagram
RealmagZ0Z axis of the magnetometer/compass, constant value (uT)
Real[:,2]magZTable{{0, 0}}Time table of magZ (column 1 = time in s, column 2 = value in uT)
Sensors › Temperature
InputSourcetempSourceInputSource.ConstantHow temp is driven: constant parameter, time table, or connector wired from the diagram
Realtemp27Temperature read by microbit.temperature(), constant value (degC)
Real[:,2]tempTable{{0, 27}, {10, 35}}Time table of temp (column 1 = time in s, column 2 = value in degC)
Sensors › Light
InputSourcelightSourceInputSource.ConstantHow light is driven: constant parameter, time table, or connector wired from the diagram
Reallight100Light level 0-255 read by display.read_light_level(), constant value (1)
Real[:,2]lightTable{{0, 200}, {5, 50}}Time table of light (column 1 = time in s, column 2 = value in 1)
Buttons › Button A
InputSourcebuttonASourceInputSource.ConnectorHow button A is driven: connector wired from the diagram, time table, or constant state
BooleanbuttonAPressedfalseState of button A in constant mode (true = pressed)
Real[:,2]buttonATable{{0, 0}, {1, 0}, {2, 1}, {3, 0}, {4, 0}, {5, 1}, {6, 0}}Time table of button A (column 1 = time in s, column 2 = 0 released / 1 pressed)
Buttons › Button B
InputSourcebuttonBSourceInputSource.ConnectorHow button B is driven: connector wired from the diagram, time table, or constant state
BooleanbuttonBPressedfalseState of button B in constant mode (true = pressed)
Real[:,2]buttonBTable{{0, 0}, {2.5, 0}, {3, 1}, {4, 0}}Time table of button B (column 1 = time in s, column 2 = 0 released / 1 pressed)

Connectors

TypeNameDefaultDescription
Modelica.Electrical.Analog.Interfaces.PositivePinP0GPIO 0, edge connector (microbit.pin0, analog input (pin0.read_analog()))
Modelica.Electrical.Analog.Interfaces.PositivePinP1GPIO 1, edge connector (microbit.pin1, analog input (pin1.read_analog()))
Modelica.Electrical.Analog.Interfaces.PositivePinP2GPIO 2, edge connector (microbit.pin2, analog input (pin2.read_analog()))
Modelica.Electrical.Analog.Interfaces.PositivePinP3GPIO 3, edge connector (microbit.pin3, analog input (pin3.read_analog()))
Modelica.Electrical.Analog.Interfaces.PositivePinP4GPIO 4, edge connector (microbit.pin4, analog input (pin4.read_analog()))
Modelica.Electrical.Analog.Interfaces.PositivePinP5GPIO 5, edge connector (microbit.pin5)
Modelica.Electrical.Analog.Interfaces.PositivePinP6GPIO 6, edge connector (microbit.pin6)
Modelica.Electrical.Analog.Interfaces.PositivePinP7GPIO 7, edge connector (microbit.pin7)
Modelica.Electrical.Analog.Interfaces.PositivePinP8GPIO 8, edge connector (microbit.pin8)
Modelica.Electrical.Analog.Interfaces.PositivePinP9GPIO 9, edge connector (microbit.pin9)
Modelica.Electrical.Analog.Interfaces.PositivePinP10GPIO 10, edge connector (microbit.pin10, analog input (pin10.read_analog()))
Modelica.Electrical.Analog.Interfaces.PositivePinP11GPIO 11, edge connector (microbit.pin11)
Modelica.Electrical.Analog.Interfaces.PositivePinP12GPIO 12, edge connector (microbit.pin12)
Modelica.Electrical.Analog.Interfaces.PositivePinP13GPIO 13, edge connector (microbit.pin13)
Modelica.Electrical.Analog.Interfaces.PositivePinP14GPIO 14, edge connector (microbit.pin14)
Modelica.Electrical.Analog.Interfaces.PositivePinP15GPIO 15, edge connector (microbit.pin15)
Modelica.Electrical.Analog.Interfaces.PositivePinP16GPIO 16, edge connector (microbit.pin16)
Modelica.Electrical.Analog.Interfaces.PositivePinP19GPIO 19, edge connector (microbit.pin19)
Modelica.Electrical.Analog.Interfaces.PositivePinP20GPIO 20, edge connector (microbit.pin20)
Modelica.Electrical.Analog.Interfaces.PositivePinP_3V3V supply of the edge connector: output of the on-board regulator (3.0 V rail)
Modelica.Electrical.Analog.Interfaces.NegativePinGNDCommon reference (ground) - shown when useGroundPin is checked, otherwise the board is referenced to the simulation ground (0 V)
Modelica.Blocks.Interfaces.BooleanInputbuttonAButton A (P5): true while pressed - wire a boolean signal or source; pressed = pin to GND, 10 kOhm pull-up otherwise
Modelica.Blocks.Interfaces.BooleanInputbuttonBButton B (P11): true while pressed - same as buttonA
Interfaces.AntennaAntennaAntenna of the on-board 2.4 GHz radio (microbit.radio): wire it with ONE wire to the antenna of the other boards (or Peripherals.Radio.RadioModem) that share the same air
Modelica.Blocks.Interfaces.RealInputaccelXInX axis of the accelerometer from the diagram
Modelica.Blocks.Interfaces.RealInputaccelYInY axis of the accelerometer from the diagram
Modelica.Blocks.Interfaces.RealInputaccelZInZ axis of the accelerometer (default: gravity, board lying display up) from the diagram
Modelica.Blocks.Interfaces.RealInputmagXInX axis of the magnetometer/compass from the diagram
Modelica.Blocks.Interfaces.RealInputmagYInY axis of the magnetometer/compass (default: field pointing along +Y) from the diagram
Modelica.Blocks.Interfaces.RealInputmagZInZ axis of the magnetometer/compass from the diagram
Modelica.Blocks.Interfaces.RealInputtempInTemperature read by microbit.temperature() from the diagram
Modelica.Blocks.Interfaces.RealInputlightInLight level 0-255 read by display.read_light_level() from the diagram

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 USB -> 3V rail (RT6150)
Modelica.Electrical.Analog.Sources.ConstantVoltageusbSupplyUSB supply (5 V)
Modelica.Electrical.Analog.Basic.ResistorusbCableResistance of the USB cable
Modelica.Units.SI.VoltagevRailP_3V.v - core.gnd.vVoltage of the 3V rail
MicroPythonMCU.Peripherals.LEDled_0_0Matrix LED, column 0, row 0 (anode on row 1, cathode on column 1)
MicroPythonMCU.Peripherals.LEDled_0_1Matrix LED, column 0, row 1 (anode on row 2, cathode on column 1)
MicroPythonMCU.Peripherals.LEDled_0_2Matrix LED, column 0, row 2 (anode on row 3, cathode on column 1)
MicroPythonMCU.Peripherals.LEDled_0_3Matrix LED, column 0, row 3 (anode on row 4, cathode on column 1)
MicroPythonMCU.Peripherals.LEDled_0_4Matrix LED, column 0, row 4 (anode on row 5, cathode on column 1)
MicroPythonMCU.Peripherals.LEDled_1_0Matrix LED, column 1, row 0 (anode on row 1, cathode on column 2)
MicroPythonMCU.Peripherals.LEDled_1_1Matrix LED, column 1, row 1 (anode on row 2, cathode on column 2)
MicroPythonMCU.Peripherals.LEDled_1_2Matrix LED, column 1, row 2 (anode on row 3, cathode on column 2)
MicroPythonMCU.Peripherals.LEDled_1_3Matrix LED, column 1, row 3 (anode on row 4, cathode on column 2)
MicroPythonMCU.Peripherals.LEDled_1_4Matrix LED, column 1, row 4 (anode on row 5, cathode on column 2)
MicroPythonMCU.Peripherals.LEDled_2_0Matrix LED, column 2, row 0 (anode on row 1, cathode on column 3)
MicroPythonMCU.Peripherals.LEDled_2_1Matrix LED, column 2, row 1 (anode on row 2, cathode on column 3)
MicroPythonMCU.Peripherals.LEDled_2_2Matrix LED, column 2, row 2 (anode on row 3, cathode on column 3)
MicroPythonMCU.Peripherals.LEDled_2_3Matrix LED, column 2, row 3 (anode on row 4, cathode on column 3)
MicroPythonMCU.Peripherals.LEDled_2_4Matrix LED, column 2, row 4 (anode on row 5, cathode on column 3)
MicroPythonMCU.Peripherals.LEDled_3_0Matrix LED, column 3, row 0 (anode on row 1, cathode on column 4)
MicroPythonMCU.Peripherals.LEDled_3_1Matrix LED, column 3, row 1 (anode on row 2, cathode on column 4)
MicroPythonMCU.Peripherals.LEDled_3_2Matrix LED, column 3, row 2 (anode on row 3, cathode on column 4)
MicroPythonMCU.Peripherals.LEDled_3_3Matrix LED, column 3, row 3 (anode on row 4, cathode on column 4)
MicroPythonMCU.Peripherals.LEDled_3_4Matrix LED, column 3, row 4 (anode on row 5, cathode on column 4)
MicroPythonMCU.Peripherals.LEDled_4_0Matrix LED, column 4, row 0 (anode on row 1, cathode on column 5)
MicroPythonMCU.Peripherals.LEDled_4_1Matrix LED, column 4, row 1 (anode on row 2, cathode on column 5)
MicroPythonMCU.Peripherals.LEDled_4_2Matrix LED, column 4, row 2 (anode on row 3, cathode on column 5)
MicroPythonMCU.Peripherals.LEDled_4_3Matrix LED, column 4, row 3 (anode on row 4, cathode on column 5)
MicroPythonMCU.Peripherals.LEDled_4_4Matrix LED, column 4, row 4 (anode on row 5, cathode on column 5)

Contents

NameDescription
InputSourceSource of each button and integrated sensor value (alias of the shared type, so that existing models keep writing MicroBit_v2.InputSource.Connector)