modelHandshake

Two microcontrollers wired together: A raises a request, B acknowledges it from a Pin.irq handler

Extends from Modelica.Icons.Example (Icon for runnable examples).

Information

Two-wire request/acknowledge handshake between two MCU blocks. Board A (handshake_a.py) raises REQ on GP0; board B (handshake_b.py) sleeps in its main loop, and a Pin.irq handler on its GP0 copies the level onto ACK (GP1), which A reads on its own GP1. A prints how long B took to answer (a few microseconds: the execution time of the pin accesses, gpioOpTime), releases REQ, waits for ACK to fall, three times, then lights ledDone. The 100 kΩ resistors keep each line at 0 V while no board drives it.

Each board runs in its own Python sub-interpreter and thread: the electrical edge produced by one wakes the other at the next event iteration of Modelica, exactly as with a peripheral component.

Components

TypeNameDefaultDescription
MCUmcuABoard A: Resources/Scripts/MCU/handshake_a.py (REQ on GP0, ACK read on GP1)
MCUmcuBBoard B: Resources/Scripts/MCU/handshake_b.py (REQ read on GP0, ACK on GP1)
Modelica.Electrical.Analog.Basic.Groundground
Modelica.Electrical.Analog.Basic.ResistorpullReqpull-down of the REQ line, so that it does not float while neither board drives it
Modelica.Electrical.Analog.Basic.ResistorpullAckpull-down of the ACK line
Modelica.Electrical.Analog.Basic.Resistorr2limits the current of ledDone
MicroPythonMCU.Peripherals.LEDledDonemcuA GP2: lit once every round has been acknowledged