Programmable controller ((extra) large)

Symbol and connections

These blocks can be programmed to your liking. On the top side connections all inputs can be connected, on the bottom sides, all the outputs can be connected. The coding languange that is compatible with the programable controlers is Javascript. However, Hysopt evaluates the writen code in these programmable controllers every simulation step. This results that not all off the functionalities of Javascript are possible to be implemented. For instance:

  • While and with statements.

  • String inputs or outputs

  • ….

There are 3 options:

  1. Controller with 8 in/outputs

  2. Controller with 16 in/outputs

  3. Controller with 32 in/outputs

Writing code

Controller syntax

In these controllers, code can be written to translate certain controls.

this can include things like:

Initialisation

When using a variable that has not been defined before, the controller will equal the new variable to 0. This functionality can be used for initialisation purposes with the following topology:

 

image-20240320-152616.png
Implemenation of an initialisation step

Built-in simulation variables

The following built-in variables can be used in the code withour prior assignment in the programmeable controller:

  • time : the time variable of the simulation

  • timestep: the timestep of the simulation

Example code

here is an example with code : example.txt

Note that the inspiration library is filled with written code like this, so be sure to look here for inspiration.