Skip to content

Changes

Peter Corke edited this page Jun 7, 2021 · 4 revisions

Changes

2021-06-06

  • arithmetic operators autogenerate blocks
  • * operator replaced by >> operator, thanks to Cal Hays for both suggestions
  • simple event handling allow more accurate results for discontinuous inputs, eg. STEP block
  • new RAMP and NULL block, the latter useful for testing
  • new DICT block, like a mux but with names, works with ITEM block
  • PRINT block now has better formatting
  • SCOPEXY block has named input ports now: x and y
  • unit tests working again
  • len(blockdiagram) is the number of blocks
  • fix bug with BDSim() being instantiated multiple times
  • new way to schedule execution of blocks, now a data flow graph
  • updates to wiki documentation, some documentation polish

Coming soon, a GUI-based editor.

2021-03-28 commit 2296858

Major syntax change.

The old syntax

import bdsim

bd = bdsim.BlockDiagram()  # create an empty block diagram

 .
 .
 .
out = bd(5)  # simulate the model

is now

import bdsim

sim = bdsim.BDSim(animation=True)  # create simulator
bd = sim.blockdiagram()  # create an empty block diagram

 .
 .
 .
out = sim.run(bd, 5)  # simulate the model

Trying to separate out all the operating specific stuff (matplotlib, argparse, SciPy) from the blocks and wires. Longer term aim is to make the blocks stateless, but not there yet.

Clocked blocks

clock = bd.clock(2, 'Hz')  # create a 2Hz clock
zoh = bd.ZOH(clock)  # create a ZOH block that samples on this clock

A clock can drive multiple clocked blocks. The discrete state associated with a particular clock is kept within the Clock block.# Getting started