modelHandshake
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
| Type | Name | Default | Description |
|---|---|---|---|
| MCU | mcuA | Board A: Resources/Scripts/MCU/handshake_a.py (REQ on GP0, ACK read on GP1) | |
| MCU | mcuB | Board B: Resources/Scripts/MCU/handshake_b.py (REQ read on GP0, ACK on GP1) | |
| Modelica.Electrical.Analog.Basic.Ground | ground | ||
| Modelica.Electrical.Analog.Basic.Resistor | pullReq | pull-down of the REQ line, so that it does not float while neither board drives it | |
| Modelica.Electrical.Analog.Basic.Resistor | pullAck | pull-down of the ACK line | |
| Modelica.Electrical.Analog.Basic.Resistor | r2 | limits the current of ledDone | |
| MicroPythonMCU.Peripherals.LED | ledDone | mcuA GP2: lit once every round has been acknowledged |