Using HAL Objects

Hal objects are all the input and output channels given in the configuration. You can use these objects either from the safety system, the control system or the sequencer.

Inputs and Outputs of the Safety System

The safety system can check for each of its safety levels whether the level of certain channels meet given criterias. Such channels are called critical inputs and outputs and have to be defined as such, see Critical Inputs and Outputs. If the criterias are not met you can choose what action has to be taken, see Input / Output Actions.
The safety system will get a handle to tha HAL object with:

  eeros::hal::Input<bool>* emergency = hal.getLogicInput("emergency");

Here, you get a reference to an digital input representing the emergency button. Please make sure that the id (“emergency”) is the same as given in the configuration file.

Inputs and Outputs of the Control System

The control system can read from or write to the hardware solely through its Peripheral Input or Peripheral Output block. When you declare one of these blocks you have to give an id as parameter to its constructor.

  eeros::control::PeripheralInput<double> enc("q0");
  eeros::control::PeripheralOutput<double> controlVoltage("dac0");

Please make sure that the ids (“q0”, “dac0”) are the same as given in the configuration file.

Accessing Inputs and Outputs from the Sequencer

The sequencer usually does not access hardware channels directly but reads from or writes to the control system. However, it is well possible to get a direct handle to a HAL object.

Exclusive Access

Whenever you request an input or output from the HAL manager you will get exclusive access to this channel. This could be the safety system or the control system but not both. There might be a case where an input is a critical input to the safety system and at the same time serves as an input to to control system. In this case you can request the input with

  eeros::control::PeripheralInput<double> enc("q0", false);

Please keep in mind that whenever the safety system or the control system read from this input, the actual hardware is read for any access, which might take some time. It is possible to change the access privilege by releasing a channel and requesting it again, e.g.

  eeros::control::PeripheralInput<double> enc("q0", false);
  HAL& hal = HAL::instance();
  hal.releaseInput("q0");
  eeros::control::PeripheralInput<double> enc("q0");

The latter example is a very uncommon case and might be useful for testing purposes.