PyRasp

Several controllers on one board

A board can hold more than one controller: a Pi beside a Pico, two Picos, a Pi Zero driving a Pi 5. Each controller runs its own program in its own interpreter (Python on a Pi, MicroPython on a Pico), and they talk through ordinary wires, exactly as on a bench. Every board shares one simulated clock.

Programs: one per controller

The first controller on the board keeps main.py, so every existing project opens unchanged. Every controller after it runs <its id>/main.py: a Pico with the id pico runs pico/main.py. Placing a second controller creates its program with a blink starter in its own language.

In the code dock, the Program picker beside the file name switches between them. Run starts every program that has code, all at once; a Pico is usually running before a Pi's Python has finished loading, which is also what happens on a real bench. One program ending leaves the others running.

Consoles

With several programs the console grows tabs: All interleaves every program's output with each line marked by its board ([pico] request 3 answered), and one tab per controller shows that program alone. Typing in a controller's tab goes to that program's input(); typing in All goes to the program that is waiting for input. The shell stays the first Pi's.

Wiring boards together

  • GPIO to GPIO is a net like any other: one board drives a pin, the other reads it, interrupts included. Wire a ground between the boards too, so a level means the same on both. Without one the simulation still works (every ground here is an ideal 0 V), but the warnings bar says "pi and pico share signals but no ground wire": a real build would not.
  • PWM and analog: a Pi's PWM through an RC filter into a Pico's ADC works, because the circuit solver integrates the RC.
  • UART: wire one board's TX to the other's RX (a Pi's GPIO14 to a Pico's GP1, and the Pico's GP0 back to the Pi's GPIO15). Bytes arrive at the sender's baud rate; if the receiver's UART is set to a different rate, they come out garbled, as on the bench.
  • I²C and SPI between boards are not simulated yet: neither side can act as a peripheral.
  • Power: each board runs as if it had its own USB supply. Tying a Pi's 5 V to a Pico's 3V3 still raises the "shorted supplies" warning.

Limits

A board holds at most four controllers, and at most two of them Pis: each Pi is a full Python in this browser tab, which is what a small laptop runs out of first. The daily problem and practice problems stay on one controller: a Pi, or a Pico for the Pico set.

Seeing each board

  • The Inspector's GPIO table shows the selected board's own pins.
  • The logic analyzer names channels by board: pi:GPIO17, pico:GP15.
  • The serial monitor has a Board picker: the adapter is plugged into that board's UART.

Open Pi and Pico handshake (Projects → Examples) for a ready-made board: the Pi raises a request line, the Pico answers it from a pin interrupt and flashes an LED, and each prints its side.

In the Sandbox

circuit.py may create several boards. Give each a label when there is more than one of a kind; the label is its program's folder:

from wiring import *

pi = Pi()
pico = Pico(label="pico")
pi.GPIO17 >> pico.GP16
pi.GND >> pico.GND

The editor then shows a pico/main.py tab next to main.py, and both are saved with the sandbox. Renaming a board's label keeps its program: change Pico(label="left") to Pico(label="right") and left/main.py becomes right/main.py. The console has the same tabs as Lab's: All, and one per board.

Deleting a board

In Lab, deleting a board deletes its program too; Undo brings both back. If you delete the board that runs main.py, the next board's program moves into main.py, so every remaining board keeps running its own code.