Modelica_DeviceDrivers.ClockedBlocks.OperatingSystem

Information

Extends from Modelica.Icons.Package (Icon for standard packages).

Package Content

NameDescription
Modelica_DeviceDrivers.ClockedBlocks.OperatingSystem.SynchronizeRealtime SynchronizeRealtime A pseudo realtime synchronization
Modelica_DeviceDrivers.ClockedBlocks.OperatingSystem.Types Types  
Modelica_DeviceDrivers.ClockedBlocks.OperatingSystem.RandomRealSource RandomRealSource  

Modelica_DeviceDrivers.ClockedBlocks.OperatingSystem.SynchronizeRealtime Modelica_DeviceDrivers.ClockedBlocks.OperatingSystem.SynchronizeRealtime

A pseudo realtime synchronization

Information


Synchronizes the simulation time of the simulation process with the operating system real-time clock. Different priority levels are supported:

Note that the provided level of real-time synchronization is "soft", meaning that there are no guarantees that dead lines are met or that latencies are restricted to a predictable (low) maximum. This is often enough to satisfy requirements for interactive simulations and can be compared to the real-time experience provided by computer games. However, applications requiring "hard" real-time synchronization (e.g. HIL simulations) are not satisfied!

Using the "High Priority" and "Real-Time" priorities in Linux will usually require "root" privileges for the simulation process. Using the "Real-Time" priority in Linux with a low-latency kernel as provided by the PREEMPT_RT patch will even provide limited (however, implementation specific limitations given below still apply) "hard" real-time capabilities (see e.g., https://www.osadl.org/Realtime-Linux.projects-realtime-linux.0.html).

IMPORTANT: This real-time synchronization is a hack. Don't rely on it in any (safety) relevant applications there precise timing is mandatory!

Implementation Notes

The block introduces an equation with a call to an external C-function that takes the current simulation time as an argument. Within the C-function the simulation time is compared to the operating system real-time clock and execution of the thread is halted until simulation time == real-time. This equation will be added to the other model equations and sorted according to the (tool dependent) sorting algorithm. Therefore, no prediction can be made when, within the simulation cycle, the real-time synchronization function is called (e.g., it might be before, or after (external) inputs are read from a device or (external) outputs are written to a device).

Final Remark

If your Modelica tool provides a better mechanism to real-time synchronization, consider to use that mechanism instead of that block. E.g., Dymola provides a "Synchronize with real-time" option within the solver settings. If that option is ticked the "SynchronizeRealtime" block is not needed! However, Dymola only supports that option for Windows (at least Dymola 2013 and below). Also, experiences of the authors indicate that compile and run-time performance seems sometimes better using the "hackish" block, than using the "official" real-time synchronization of Dymola. Please test for yourself, which option works best for you.

Extends from Modelica_DeviceDrivers.Utilities.Icons.BaseIcon (Base icon for blocks providing access to external devices).

Parameters

NameDescription
resolutionresolution of the timer
priorityPriority of the simulation process

Modelica_DeviceDrivers.ClockedBlocks.OperatingSystem.RandomRealSource Modelica_DeviceDrivers.ClockedBlocks.OperatingSystem.RandomRealSource

Information


Uses the rand()function from the C standard library for creating pseudo-random numbers. The computers real-time clock is used to obtain seed values for the sequence of pseudo-random numbers.

Extends from Modelica_DeviceDrivers.Utilities.Icons.BaseIcon (Base icon for blocks providing access to external devices), Modelica_DeviceDrivers.Utilities.Icons.PartialClockedDeviceDriverIcon.

Parameters

NameDescription
nDimension of output vector
minValue[n]maximum Value of random output
maxValue[n]maximum Value of random output

Connectors

NameDescription
y[n] 

Automatically generated Tue Oct 1 14:26:58 2013.