User Tools

Site Tools


getting_started:tutorials:hal0

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
getting_started:tutorials:hal0 [2017/04/27 15:16] – created grafgetting_started:tutorials:hal0 [2021/03/31 15:46] (current) ursgraf
Line 1: Line 1:
 ====== Using the HAL with the Simulator ====== ====== Using the HAL with the Simulator ======
-In the EEROS library you will find a directory with examples. Open a shell in the build directory of your EEROS library and run ''examples/controlsystem/PeriodicExample1''. +The [[eeros_architecture:hal:start|]] provides an interface between the robot control system and the hardware of the robotAs we do not have any real output we will use a simulator, see [[getting_started:install_wrapper#simulator|Simulator]]. The system in this example uses inputs and outputs
-This examples does: +
-  * Creates a main task //ss// with an execution period of five milliseconds. The task itself is defined of type ''Lambda'' with a run method given by an empty lambda function.  +
-  * Creates a time domain //t1// with a period of five milliseconds+
  
-Both harmonic tasks have periodic counter which measure its periods and run timesOnce every 1000th run the results are logged. The results are printed in units of seconds.  +In the EEROS library you will find directory with examples. For this example see [[https://github.com/eeros-project/eeros-framework/blob/master/examples/hal/HalTest1.cpp|HalTest1.cpp]].  
-Additionally both harmonics have default monitor function addedThis monitor function logs warning if the measured period differs more than 5%Depending on your hardware platform and realtime support of your operating system you might get no warningsseveral or many warnings.+ 
 +Open a shell in the build directory of your EEROS library and run  
 +<code> 
 +./halTest1 -c HalTest1Config.json 
 +</code> 
 +This examples creates a small control system with a couple of peripheral input and output blocks as shown below. 
 + [{{ :getting_started:tutorials:haltest1.png?300 | //Control system of the test program// }}] 
 +The dashed lines denote the feedback of the signals by the simulator\\  
 +The main sequence alters the values on digital and analog outputs periodically. A separate periodic task logs the digital and analog inputs. 
 +  * The state on the digital output 0 is reflected by the simultor to the digital input 0. The control system connects this input to the digital output 1, which in turn is reflected by the simulator to digital input 1. However, the second reflection is ''inverted'' and we get the logical inversion of digital output 0. The value of digital input 0 changes every 5 seconds. 
 +  * A constant value is output to analog output 0 and 2. These values change every 10 seconds. Both are reflected onto analog inputs 0 and 2, respectively. 
 + 
 +===== Accessing Output Signals Directly ===== 
 +A peripheral output block delivers signal to external hardwareIts signal value can be accessed with get method, see line 46 in the comment in the example code in [[https://github.com/eeros-project/eeros-framework/blob/master/examples/hal/HalTest1.cpp|HalTest1.cpp]]. 
 + 
 +Alternatively the signal in the HAL could be accessed by getting an reference to the corresponding output block with 
 +<code cpp> 
 +auto digOut = hal.getLogicOutput("dOut0", false);  // line 42 
 +</code> 
 +The signal value can then be logged with 
 +block with 
 +<code cpp> 
 +log.info() << digOut->get(); // line 47 
 +</code> 
 +You have to make sure to access the output with non-exclusive rightsbecause the control system already has a handle to it, see line 28 in ''halTest1.hpp''. Likewise, the control system must access the same output in the same fashion.
getting_started/tutorials/hal0.1493298980.txt.gz · Last modified: 2017/04/27 15:16 by graf