-
-
Notifications
You must be signed in to change notification settings - Fork 40
Blocks, Wires and Plugs

ENIAC (1946) being programmed with plugs and wires by Betty Jennings and Frances Bilas. (credit U.S. Army Research Laboratory)
The key elements in bdsim are blocks, plugs and wires. They are metaphors for physical plug-board wiring as shown below.
The top wire has a single 'conductor'. The bottom wire is a bundle with two 'conductors', it actually gets turned into two single conductor wires.
Blocks are created by factory methods of a BlockDiagram object, for example
bike = bd.BICYCLE(x0=[5, 2, 0])
represents a dynamic model of a vehicle with bicycle kinematics.
bike an instance of a Bicycle class which is a subclass of ContinuousBlock (a stateful block, in this case describing continuous-time dynamics) which is a subclass of Block. (Older code may reference TransferBlock — that's now a deprecated alias for ContinuousBlock, not a separate class in between.)
This particular block has two input ports and one output port — its output is a single 3-element array (x, y, θ), not three separate ports. Blocks have many attributes but key ones are:
-
blockclasseither'sink','source','function','continuous','sampled','subsystem'or'graphics' -
typethe block type, eg.'bicycle'or'constant' -
ninnumber of input ports, would be 0 for a source -
noutnumber of output ports, would be 0 for a sink -
nstatesnumber of states, 0 for everything except aContinuousBlockorSampledBlocksubclass -
namethe name optionally assigned by the user -
bda reference to theSimulationinstance in which this block was instantiated
There's no public x/state attribute — a stateful block's state lives in internal, underscore-prefixed
attributes (_x0 for the initial state, _x_view for the live value during a run) that aren't meant for
direct external access; see Evaluation for how state is actually threaded through during a run.
bike[1] is an instance of a Plug object which represents a block and a specific port. It is neither an input or output port, that depends on the context and is determined later. The Plug has attributes:
-
blockthe block it refers to -
portthe port on the block -
typehas the values'start','end'orNone(not yet determined),
A wire connects two plugs, or a wire has a plug on each end. Wires don't directly reference blocks, it is always via a plug.
A reference like bike is actually turned into the plug block[0] when it used in a wiring expression, and whether it is a start or end plug depends on the context.
A wire has attributes:
-
startthe plug that connects to an output, the start of the wire -
endthe plug that connects to an input, the end of the wire
The top half shows the relevant data structures after a wire connects two blocks. The wire object has references to a pair of plugs, and they each reference a block and contain the port number.
Copyright (c) Peter Corke 2020-
- Home
- API reference (Sphinx)
- Block catalog
- Control Systems Magazine article
- Adding blocks to your model
- Block path
- Connecting blocks
- Compiling
- Running
- Watching a simulation variable
- Simulation results
- Runtime options
- Environment variables
- Discrete-time blocks
- Subsystems
- Figures
- Notebook animation
- Animation and movies
- PID control
- Coding patterns
- Block methods and attributes
- Time stepping: integration, animation & events
- Blocks, wires and plugs
- Graphics blocks
- Evaluation
- Runtimes and simulator state
- Creating a new block
- Related packages
Under development on feat/realtime branch, planned for release before end of 2026.