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

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
getting_started:tutorials:hal0 [2019/03/02 16:57] grafgetting_started:tutorials:hal0 [2019/09/19 12:14] – [Accessing Output Signals Directly] graf
Line 5: Line 5:
 </code> </code>
 This examples creates a small control system with a couple of peripheral input and output blocks as shown below. 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// }}]+ [{{ :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 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 main sequence alters the values on digital and analog outputs periodically. A separate periodic task logs the digital and analog inputs.
Line 11: Line 11:
   * 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.   * 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 a signal to external hardware. Its signal value can be accessed with a get method, see line 46 in the comment in the example code in ''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 rights, because 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.txt · Last modified: 2021/03/31 15:46 by ursgraf