IDA Tunnel HIL Tutorial
Training Material for HIL extension in IDA Tunnel
Introduction
This document provides a general overview and introduction to the tunnel simulator and its HIL extension. First a brief description will be presented and then a detailed starting guide for a simple model will be provided.
Background on the simulation models
The IDA Tunnel reflects all relevant physical processes in the tunnel: air movements, air and wall temperatures, traffic flows and fractions transported by air. The most common use of the program is in the design stage for designing ventilation systems and control systems. At this stage, parts of the control system are being built up to test different tunnel ventilation principles. However, at this stage, the control system is not usually complete in the sense that it can respond to all sorts of situations in the tunnel. With HIL, the user knows what to test and the control system is generally tailored for each situation.
The HIL feature can be enabled in IDA Tunnel by installing the “EXCHANGE” extension. After installation, a new library named HIL will be available in the IDA Tunnel sidebar (Fig.1).

Figure 1: Component palette of IDA Tunnel with the HIL library
The Import/Export objects are the main components used for communication between IDA Tunnel and a PLC. The Import models (Fig. 2) receive control signals from the OPC UA server, while the Export models transmit metrics to the OPC UA server.

Figure 2. The import object from and parameters
In each Import object and Export object, you then need to change the parameters that follow (see Table 1):
Table 1. Input parameter for import and export objects
| data_1dim | shall be the number of signals you import into or export from the model. |
| Channel | must be a unique name for each Import/Export model. |
| Server | Should be the address to OPC UA server. |
| nameSpace | If the OPC UA server has a namespace for the signals, it should be stated here. |
| extrapolationLimit | Time (in seconds) for the maximum allowed extrapolation of data. Note that the maximum time step cannot exceed extrapolationLimit / 2. |
| order | Variable interpolation order 0=discrete, 1=continuous |
| vars | Here, the path to the parameters shall be specified, separated with the / sign. E.g.: "Siemens_4/Fans/_20601583FI001PV" . (. |
| deadBand | Deadband for OPC server |
You can see in following an example of the filled Import parameters in outline

Figure 3- An example of the filled form for parameters in the import object.
The settings for the Export object are similar.
Running the models together with hardware via OPC UA
Simulation data-dialogues
Another essential requirement for HIL operation is synchronizing the time step of the IDA Tunnel solver with the time on the OPC UA server. This can be configured in the Simulation Data dialog in IDA Tunnel, under the Options tab.
A command similar to the following should be entered:
SAMPLING "opcua:opc.tcp://192.168.20.156:4980/Softing dataFEED OPC Suite Configuration1" -1 -1
where the long string inside "" characters is the path of an OPC UA server that sends/receives signals from the tunnel simulation, but with opcua: in front.
User interface
The model can be run either using the default Run button in IDA Tunnel, or by creating a custom simulation run button. This new button can be added in the General tab.
When using the default Run button, the time range must be defined in the Calculation tab of the Simulation Data dialog. The specified time range must include the current time. When using the custom “Start Simulation” button, the simulation starts automatically from the current time. The procedure for creating this button will be explained later in the Getting Started Guide. A similar procedure is used for running a 3D animation.
Start simulation
Click Start simulation (Fig. 4) in general tab to start the simulation. The simulation starts from the current time and runs at the speed determined by the OPC UA server if you run the models together with hardware. If you run the models off-line, the simulation runs as fast as possible in the IDA Tunnel (much faster than real time).
Solver time-lag (Fig. 4) shows how the simulation is related to real-time. Since the simulator cannot immediately calculate the consequence of a steering signal, the simulator is always a little behind the PLC on time. In real-time simulation, therefore, a negative value that is the number of seconds the simulation is behind appears. In addition, a bar appears in the box to the right of time.
The console and running the models off-line
An additional option is to use the models for training tunnel operators. The possibility is to experiment with the examples of rules systems and running the models off-line. This requires an introduction to the IDA Tunnel. The Console object (Figure 1) can be used to link desired input parameters to GUI input types (Fig. 4). Examples of input parameters that can be linked to the Console object include entry traffic or vehicle speed. These linked parameters can then be used for GUI-based offline running of the models.

Figure 4. Sample of user-defined buttons and input parameter assignments in the General tab.
Starting guide for using HIL extension.
The user is expected to have a basic familiarity with IDA Tunnel. Begin by opening IDA Tunnel and constructing a simple road tunnel model (Fig. 5).

Figure 5. A schematic of the tunnel model
Construct a simple model using the default settings. Set the entry traffic from the left portal to 1000 passenger cars (Fig. 6a). Change the traffic model in Vehicles tab to the standing traffic (Fig. 6)b.

(a)

(b)
Figure 6. Input forms for the left entry portal and the vehicles tab
Place a jet fan at the midpoint of the tunnel and a NO₂ sensor 950 m from the tunnel inlet. Set the number of lanes to 2 for the left-to-right direction and 0 for the right-to-left direction (Fig. 7).

Figure 7. Settings for tunnel section in edit segment form
Add a PI controller and place it at the top of the tunnel section. Connect the tunnel sensor to the input signal of the controller and connect the output signal of the PI controller to the jet fan control link (Fig. 8)). Adda constant and use it as the setpoint of the PI controller. Set the value to 500. Open the PI controller and change the MODE parameter in the list to 1.

Figure 8. Schematic of the model with PI controller and its input parameters.
Perform a simulation by clicking the Run button. Check the maximum NO₂ concentration in the tunnel section; it should be around 254 µg/m³, which is below the setpoint of the controller. You can log the OUT signal of the controller to an output file to see when the fan turns on.
To determine the maximum NO₂ concentration without a jet fan in the tunnel, you can either increase the setpoint to a very high value (keeping the fan always off) or disconnect the controller from the fan and manually set the fan off. Under congested traffic conditions without a fan, the maximum NO₂ concentration would be approximately 982 µg/m³ after one hour of simulation.
Duplicate the tunnel section with two portals and position it below the existing model. This section will be used for the PLC connection (Fig. 9).
Save the IDA Tunnel model under a preferred name.

Figure 9. The schematic form of the model at this step
Get the IP address of the PLC (SPS in German) from the OPC server:
Install the dataFEED software (OPC client) and enter the address to connect to your PLC, if you already have one.
In this guide, we will create a virtual OPC server. Install the dataFEED OPC Suite and open the dataFEED OPC Suite Configurator.
Create a new configuration by clicking the “New” tab. In the left sidebar, select Data Destination and activate the OPC UA Server Endpoint (Fig. 10). You can modify the server endpoint name if desired; in this guide, we will continue with the default name.

Figure 10. Screenshot of dataFEED OPC Suite Configurator for Data Destination
In the left sidebar, click Data Source, then scroll down and select Local Items. This section allows you to create and manage local items within the namespace of the local application (Figure 11).

Figure 11. Screenshot of dataFEED OPC Suite Configurator for Data Source/Local Items
To add an item class, click the + button on the right. Enter a name for the node and confirm by clicking OK (Fig. 12).

Figure 12. Screenshot of Item Class form for local items in data source of dataFEED OPC Suite Configurator
To add your desired data signals, right-click the Simulation node and choose Add, or click the + button with the Simulation node selected. The form in Fig. 13 will appear.
Select Tag as the item class, then specify the name, data type, access rights, and default quality (Figure 13).

Figure 13. Filled form for one of the input signals in dataFEED OPC Suite Configurator
You may add multiple data signals as required. Add the remaining signals named NO₂ Sensor and Traffic_PC (Fig. 14). Set the default value of Traffic_PC to 1000, which corresponds to the entry traffic of passenger cars at the tunnel portal.

Figure 14. The signal data added to the data source of dataFEED OPC Suite Configurator
Go the Data Destination and check the server endpoint name;
opc.tcp://EQ-LT-52:4983/Softing_dataFEED_OPC_Suite_Configuration1
OPC UA endpoint hostname is the middle part of the address named: EQ-LT-52 and the port number for OPC UA is 4983. OPC UA endpoint suffix is: Softing_dataFEED_OPC_Suite_Configuration1. “opc.tcp” is the prefix needed for connection to the OPC UA server.
You can modify the names for each part. Press the start button in above ribbon. The configuration will be started.
Launch dataFEED OPC UA Client. Double-click to add a session (1 in Figure 15). Copy the server endpoint address from the dataFEED OPC Suite Configurator and paste it into the Endpoint URL field (2). Click Validate Connection (3), then confirm by clicking OK.

Figure 15. Screenshot of dataFEED OPC UA Client upon launch.
When the address is correctly configured, the folder structure of local items becomes accessible. You can retrieve a variable name by browsing the subfolders, for example: Objects → Local Items → Simulations, and selecting the variable, e.g., Fan_Signal.
Always use the Browse Name displayed on the right-hand side, which includes the prefix (e.g., “3:”) followed by the variable name, such as “3:Fan_Signal”.

Figure 16: OPC UA client - dataFeed to find the variables of the master (sensor data)
Complete the setup of IDA Tunnel
Go back to your IDA Tunnel model. Click on the Hil button on the Side bar to make the Hil components available (Figure 1). Drag an Import and an export component into your system model (Figure 17).

Figure 17. Schematic form of the model at this step
In “Import” component, in Outline tab, set parameters (cf. Figure 18):
- Data: number of variables to read, e.g. 2
- Channel: give a unique name to this import channel, e.g. “Fan&Traffic”, to avoid errors using multiple import components (from variables being overwritten)
- Server: set the server and IP address, here: opcua: opc.tcp://EQ-LT-52:4983/Softing_dataFEED_OPC_Suite_Configuration1
N.B.: We are using the keyword ‘opcua’ in front of the address to get access to the right protocol.
- NameSpace: leave blank, not relevant in our case. Could help in some cases to access the right folder where the variables are stored
- extrapolationLimit: Time (in seconds) for the maximum allowed extrapolation of data.
If the input signal needs to remain constant before a new update is received from the server, a large value should be assigned. If the signal value varies significantly, a smaller value should be used (e.g., 60 s) (default: 10) - deadBand: Deadband for OPC server (default: 10)
- vars: type here the address and name of the variable(s):
-
- In dataFEED software (cf. Fig.16):
-
- the structure of the variables can be found: in our case, measured and control variables are in the following folder: Local items/Simulations/
- The address should be copied step by step by copying the “BrowseName” field (in the top right area) of each folder and sub-folders.
- In the end, the variable “BrowseName” has to be copied.
-
- For example, for the “Fan_Signal” and Traffic_PC, these are:
-
- 3:Local Items/3:Simulation/3:Fan_Signal
- 3:Local Items/3:Simulation/3:Traffic_PC
-
- In dataFEED software (cf. Fig.16):
The complete form of the parameters should look like Fig. 18.

Figure 18. Import component and its parameters
NB: Exporting control variables requires a setup similar to the one described previously, using the Export component (Figure 19). Here, the NO₂ concentration sensor variable is configured to be transmitted to the OPC server through the Export component.

Figure 19. Export component and its parameters.
Connecting Import and Export component and testing
Once the Import and Export components are configured, define the links to the respective input and output variables (cf. Fig. 20). Link the Import object to the fan control connection (1, Fig. 20). A form will appear, enabling you to select the appropriate data signal (e.g., Fan_Signal, Fig. 21). Connect the NO₂ sensor to the Export object (2, Fig. 20).
The Export component can be tested by assigning a sine function to an additional data variable and monitoring it in the dataFEED tool.

Figure 20: Import and Export component with its connection to other models for testing

Figure 21
Some data cannot be linked automatically via the Import and Export objects and must be bound manually.
For instance, the tunnel traffic entry must be manually linked to the appropriate input signal:
Select the left portal of the lower tunnel model (Fig. 22).
Click the icon
adjacent to the passenger car traffic flow (1, Fig. 22).
Choose the <SYSTEM>: “NAME OF IDA MODEL” and locate the Import1 object (2, Fig. 22).
Select the corresponding data_var and click Connect.

Figure 22. Steps to bind the entry traffic to one of the Import data variables
Click on “Simulation data” button to open its window (cf. Fig, 23) to use the configuration of the OPC UA server (PLC). Three tabs are available in this form:
- Calculation:
Ensure that the simulation time range includes the current date and time (from the start to the end of the live simulation). If not, an error may occur, causing the simulation to stop or fail to start. If the starting time is set earlier than the current time, the simulation will run until it reaches the current time and then continue synchronizing with the OPC server.
There is also an option to start the simulation automatically from the current time, which will be explained later.
- Advanced:
Set Max time step to e.g. 0.008 h (about 30 s)
This parameter sets the time step for saving data in the output files. If you leave the default value (0), data will be saved at every simulation time step. This can result in very large files for long time simulations, as IDA Tunnel automatically adjusts the time step, which can sometimes be as small as 0.001 seconds.
- In Tab “Options”, write:
SAMPLING
“opcua: opc.tcp://EQ-LT-52:4983/Softing_dataFEED_OPC_Suite_Configuration1”
-1 -1

Figure 23: Simulation data options and its setup for HIL connection
Setting a user defined Start simulation button
To start the simulation automatically from the current time, you can create a custom “Run Simulation” button. This button can be placed either in the schematic view or in the General tab. The General tab is reserved for a user-defined form, customized for a specific case. Detailed instructions for building a custom form are provided in the IDA Tunnel manual, Selected topics on IDA usage - XWiki.
For this example, the button is added to the General form. Open the General tab, right-click on the form, and select New Button. Then right-click the button and select Properties to open the Properties window (Fig. 24.a). Under Default, choose All Languages, and enter the desired name for the button in the input box. In this case, it is named Run Simulation.
Click the + sign on the left side of the box under Events. Add CLICK to the predefined name so that the event name becomes :ON-CLICK. In the right-hand box, enter (RUN-REAL-TIME [@] 10000). Click OK and close the form. You now have a Run Simulation button (Figure 24.b) that starts the simulation from the current time and runs for 10,000 seconds. You can modify the script above to set a different simulation duration if needed. You can also enlarge the button if the full name text is not displayed completely.

- (b)
Figure 24. (a) Form for the user-defined run simulation button (b) Designed button
As mentioned earlier, because the simulator cannot immediately calculate the consequences of a steering signal, it is always slightly behind the PLC in time. To illustrate this difference, a solver time-lag can be added, which shows how the simulation relates to real time. In a real-time simulation, a negative value appears, indicating the number of seconds by which the simulation is behind.
First, go to the schematic form. From the All palette in the sidebar, search for the TIMEDEVELOP object and drag it onto the schematic form. Next, switch to the General form, right-click on the form, and select New Field. In the object window under “Other Models”, locate the “TIMEDEVELOP” object and select the DIFF variable. In the Show As field, choose Value (Fig. 25a). Click OK and close the form. Finally, add two text labels: “Solver time-lag” to the left and “s” to the right of the newly added field (Figure 25.b).

Figure 25. (a) Form for user-defined Solver time-lag representation (b) Designed output
Running the simulation
The model can now be run in two ways: either using the default Run button in IDA Tunnel or by clicking the user-defined Run Simulation button in the General form. To connect to the OPC UA server, the server must be active.
You can verify the connection and synchronization by observing data changes both in IDA Tunnel and in the dataFEED client. While the simulation is running, monitor the data variations in the Import and Export objects (Fig. 26).

Figure 26. Data and simulation time variations in the Import and Export objects while a simulation runs
You can also check and modify input control signals directly from the server. In the dataFEED client, click on Fan_Signal (1 in Fig. 27) and change its value from 0 to 1 (2 in Fig. 27). Then click the pen symbol (3 in Fig. 27) to apply the change. This signal serves as the input for the jet fan in IDA Tunnel, and the fan control signal should update simultaneously in IDA Tunnel (Fig. 28).

Figure 27. Steps to change and monitor the data sent and received from IDA Tunnel in dataFEED client
Similarly, change the Traffic_PC data value in the dataFEED client using the same method, increasing the traffic density from 1000 to 2000. The imported data in IDA Tunnel will update accordingly (Fig. 28). With these new input parameters, the exported data from the model—namely the NO₂ concentration from the sensor—will change and can be observed both in IDA Tunnel and in the dataFEED client. In the client, click the book symbol (4 in Fig. 27) for the NO₂ sensor data to view the updated value.

Figure 28. Data in import and export components of IDA Tunnel communicated with and updated via the OPC UA server
Animation
The results can also be visualized in 3D. To do this, the user must create a tunnel system in the 3D view of IDA Tunnel and map the corresponding tunnel sections. The 3D view in IDA Tunnel is used to translate the 1D simulation model from the schematic view into a 3D representation of the actual tunnel system geometry. A starting guide for a simple 3D road tunnel exercise is available in 3D Simple exercise-Road tunnel - XWiki.
Similar to the user-defined Run Simulation button, another button can be created to start an animation. First, stop the simulation in IDA Tunnel. Then click on the General tab, right-click on the form, and select New Button. Next, right-click on the button and select Properties; the Field Properties window will open (Fig. 29.a). Click on Default and select All Languages, then enter the desired name for the button in the lower box. In this example, the button is named Animation.
Under Events, click the + sign on the left side of the box and add CLICK to the predefined name so that the event becomes :ON-CLICK. In the right-hand box, enter (RT-SHOW-PIPERES (:CALL VIEW-PANE [@] THREE-D)). Click OK and close the form. You will now have an Animation button (Fig. 29.b).

Figure 29. (a) Form for the user-defined run simulation button (b) Designed animation button
Change the traffic model to “Moving traffic” in the Vehicles tab in IDA Tunnel in the schematic view. Start the simulation again by clicking the Run Simulation button in the General form. Then click Animation to open the 3D tab, which displays a 3D model of the tunnel. In the dialog that appears, select the variable you want to visualize (Fig. 30). Enter the minimum and maximum values for the variable, and optionally enable the animation of traffic and fans.

Figure 30. Form for selecting the variables, traffic and fans to display in 3D animation
The Animation feature can be used both during the simulation and after the simulation to review the results (Fig. 31).

Figure 31. Animation of traffic flow and NO2 concentration in real time
Changes in input signals from the OPC server can also be observed directly in the 3D view. For example, change the input Traffic_PC signal to 20000, and you will see the corresponding changes in traffic flow and NO₂ concentration in real time in the 3D animation of IDA Tunnel (Fig. 32a). You can also turn off the jet fan by changing the control signal to 0 on the server and observe the fan symbol stopping its rotation in the 3D animation (Figure 32.b)


Figure 32. Animation of traffic flow and NO2 concentration in real time controlled by OPC server with (a) increase in traffic flow (b)turning off the fan
Some samples from previous projects
** The following remarks are not part of this simple starting guide and require further elaboration. They are briefly mentioned here to demonstrate the capabilities of the HIL extension.
A fire event can also be simulated, and smoke propagation in the tunnel can be observed in real time. Fig. 33 shows an example of smoke propagation from a fire in a more complex tunnel model.

Figure 33. Animation of smoke from fire, traffic and fans from an old Projects
Other checks on the General tab
The other controls can be used when you want to experiment with different traffic flows, fire positions and fire types as well as queuing.

Figure 34. A designed general tab for a more complex road tunnel project.
Traffic flow
At each tunnel entrance, the flow of passenger cars, light trucks, and heavy trucks can be controlled. At each exit, the proportion of traffic leaving the tunnel can also be specified. These parameters can be adjusted during the simulation.
Fire
The user can select a fire type from several predefined options. By clicking Add Fire, the view switches to the 3D tab, where clicking on a location in the 3D model specifies the position of the fire. This action cannot be performed during the simulation because the model must be rebuilt after a fire is added.

Figure 35. A sample screenshot in fire section.
Queuing
Congestion can be added to get to 3d tabs and clicking on the 3d model specifies where the obstacle should be located. Pulling the slider sets the speed past the obstacle. (Nor can this be done during simulation)
One remark for transformation of signals between simulator and PLC
In the physical PLC, a large number of signals will occur that are missing from the simulator or that have a slightly different meaning in the simulator. A clear example is the regulation of exhaust stations, which in the simulator are only modeled as a given disconnect that responds to a single signal. In practice, a very large number of signals are exchanged between the actual tunnel and the PLC for each exhaust station. A signal transformation must therefore in many cases take place between the simulator and the PLC.
The signal conversion is assumed to take place outside the simulator itself. If an excessive number of "unnecessary" signals are transmitted between the simulator and the PLC, this risks weighing down the simulator unnecessarily with a possible consequence that the simulator does not have time in real time.
The regulatory components used in the IDA models mainly work in continuous time. They are not co-planned as in a digital rules system. This means that the code of rules cannot be directly reused in a PLC. Instead, the focus is on principled function and to some extent the setting of regulator parameters.
IDA Tunnel comes with general software documentation linked to a WIKI webpage. EQUA can also provide a general introduction to the programme and models at a meeting in connection with the start-up.
23