Documentation / Concepts / Blocks

Blocks

Introduction

This is a bit of a dry theoretical explanation, but to get the most out of BrainBuilder, it is helpful to get a general idea of the concepts used. The examples are extremely basic, and not meant to illustrate the entire set of possibilities (they’re endless!). We hope you’ll browse through this page.

Blocks

A block is an abstract entity. A block performs a function.

Block

There are several types of blocks:

  • Hardware blocks that read from and write to hardware.
  • Logic blocks process inputs, rules, and write to outputs.
  • Specialized blocks, which have complex functionalities built-in (for handling LCD screens or keyboards)

All blocks can have inputs (also called sources) and outputs.

Variables

In- and outputs communicate via variables. Outputs set variables, inputs read variables.

Blocks communicating via variable

A block can own variables. When a block is added, a variable, usually with the same name as the block, is automatically created.

For instance, a blinker block named ‘myblink1’, automatically creates an output variable ‘myblink1’ that goes high and low on the frequency specified in the ‘myblink1’ block, and can be used for making a LED blink.

Blinker block
To make 'led1' blink; specify 'myblink1' as the source in 'led1'
Blinker and LED blocks
A switch named 'sw1' automatically create a variable named 'sw1' that represents 
the state of the hardware switch. You can use variable 'sw1' to control the state
of another variable directly, or use it in a rule.
Switch block

A block can own input variables.

A LED block called 'led1' automatically creates a variable named 'led1'. 
By changing the value of variable 'led1', the hardware LED can be turned on or off.
LED block

A rule block

to connect a switch 'sw1' to a led 'led1', you write a rule like: "led1 = sw1; " 
Rule block
 This links the output of 'sw1' to the input 'led1' via the rule
Rule block

Derived variables (or expressions) are a special kind of variable to make things easy. A block can follow an expression. In that case it does not have its own input variable(s).

Performance considerations

The beauty of our design is that the system only performs work when things change. For example when a variable changes or timer events occur.

The are multiple subsystems, for displays, for keyboard, for settings and for telemetry.