User Tools

Site Tools


eeros_architecture:hal:feature_functions

Feature Functions

All inputs and outputs of the HAL have a common set of properties and functions for reading or writing them. Some hardware channels have specific properties not common to other channels, e.g. a pulse width modulated output needs to be assigned its base frequency. Another example would be a digital to analog converter which has a calibration function which needs to be called upon request.
Feature functions are functions which are specific to a HAL object. They can be called by a user with

  void callOutputFeature(OutputInterface *obj, std::string featureName, ArgTypesOut... args);
  void callInputFeature(InputInterface *obj, std::string featureName, ArgTypesIn... args);

The parameter are as follows:

  1. OutputInterface / InputInterface: the HAL object
  2. featureName: name of the function as defined in the appropriate hardware wrapper library, see Hardware Libraries.
  3. args: arguments to this function

The following example shows how to set the frequency of a pulse width modulated output. This is usually done just once. After this you can release the object.

  HAL& hal = HAL::instance();
  eeros::hal::Output<double>* pwm = hal.getScalableOutput("pwm1");
  hal.callOutputFeature(pwm, "setPwmFrequency", 100.0);
  hal.releaseOutput("pwm1");

Accessing Feature Functions from the Control System

The control system defines a peripheral output objects which is connected to our HAL object. The control system will usually periodically write to this output and set the duty cycle. However, if you wish to change the frequency of the signal you must again use the feature function as follows:

  PeripheralOutput<double> motorSpeed("pwm1");
  motorSpeed.callOutputFeature("setPwmFrequency", 200.0);

List of Feature Function for Hardware Wrapper Libraries

librarytypefunctionParameterDescription
bbblue-eerosAnalogOutfreeSpinchannelPuts a motor into a zero-throttle state allowing it to spin freely. Motor channel (1-4) or 0 for all channels. Make sure, that the peripheral output driving the motor does not run, else the set function will reenable the H-bridge.
brakechannelConnects the motor terminal pairs together which makes the motor fight against its own back EMF turning it into a brake resisting rotation. Motor channel (1-4) or 0 for all channels. Make sure, that the peripheral output driving the motor does not run, else the set function will reenable the H-bridge.
FqdresetFqd Sets the encoder position to zero. This can be useful for homing.
setFqdPospositionSets the encoder position to a given value. This can be useful for homing.
flink-eerosFqdresetFqd Sets the encoder position to zero. This can be useful for homing.
PwmsetPwmFrequencyfrequencySets the pwm frequency (Hz).
setPwmDutyCycleduty cycleSets the pwm duty cycle (0.0 .. 1.0).
WatchdogresetWatchdog Resets the watchdog.
setWatchdogTimeouttimeoutSets the watchdog timeout (s).
eeros_architecture/hal/feature_functions.txt · Last modified: 2021/05/16 09:33 by ursgraf