Support : Knowledge base

Knowledge Base

Welcome to OPAL-RT’s Knowledge Base

OPAL-RT offers a repository of support information for optimal use of its technology.

Loading…

Please note that OPAL-RT knowledge base is not fully optimized for mobile platforms.

For optimal experience, use a desktop computer.

Reference Number: AA-02045// Views: AA-02045// Created: 2021-10-20 15:45:21// Last Updated: 2021-10-20 15:56:22
HYPERSIM
[HYPERSIM] Manually Force Quality Time Byte for C37.118 Slave Packets / C37.118 Stream with Spectracom Card

[HYPERSIM] Manually Force Quality Time Byte for C37.118 Slave Packets / C37.118 Stream with Spectracom Card


Problem


In a C37.118 Stream, there is always a timestamp. Typically, an Oregano card can be used to synchronize the packets with a Grand Master Clock. When an external synchronization is not available, the Time Quality Byte will automatically be set to 'Clock failure, time not reliable (0xf)'.

Here is an example of a decoded Wireshark packets without Synchronization:



However, those packets can be refused by the external device if the time is considered not reliable.

Note: This applies only to the C37.118 slave stream because the C37.118 master only reads, it does not publish any packets.


Solution 1:

The first solution is to purchase an Oregano card and a Grand Master Clock.


Solution 2:

The second solution is to force the Time Quality Byte. This procedure can also be used if a Spectracom card is present in the system to synchronize the stream with an external clock.


Step 1: In the IO interface of the C37.118, select the option 'Use External Clock' (but do not check 'Auto-connect', that is for the Oregano card).



Step 2: Press Apply and close the IO interface. Open any sensor form and notice that there are now three more options for the C37.118 Data point.



Those are the data points for the clock from the driver. With the 'Auto-connect' option checked, it would map it to the Oregano driver. Without the Oregano driver, we need to map them manually.


Step 3: First Data point: 'Clock/Synchronized'. This is the for the time quality byte.

If it is equal to 0, time quality byte = '0x0f' Clock Failure, time not reliable. There is no synchronization.

If it is equal to 1, time quality byte = '0x00' Normal operation, clock locked (0x0). There is a synchronization.


Therefore, simply add a constant to the model and map the 'y' output to that sensor.





Step 4: Second Data point: 'Clock/Nanoseconds'.

This is a saw tooth signal from 0 to 1E9 that is periodic of duration of one second.



 For Spectracom: Map this C37.118 Datapoint to the Spectracom 'Timestamp/time_ref_ns' Datapoint.

Without an Oregano nor a Spectracom card, we need to fake this signal in HYPERSIM. One possible solution is to use the triangular wave block with the following settings:

Frequency = 1Hz

Amplitude = 1E9

Phase = 0.0

Duty = 0.9999






Map the output of the triangular wave generator to the Data point 'Clock / Nanoseconds'.






Step 5: Third Data point. 'Clock / Epoch'


The Epoch time starts on the 1st of January 1970, at midnight.



 For Spectracom: Map this C37.118 Datapoint to the Spectracom 'Timestamp/time_ref_utc' Data point.


Note: If the date itself in the stream is not important (e.g. first of January 1970), then map the Data point directly on the Time Output of the Point-On-Wave.

If the date itself is important, one possible way to fake this signal in HYPERSIM is to:

5a. Add an observable on the Point-On-Wave to get the time from the beginning of the simulation (check 'Time'):







5b. Insert an "Add" and a "constant" block and map the output of the "Add" block to the last Datapoint:




The constant makes the offset from 1970 to nowadays. The current Epoch time is available on internet. For example, here: https://www.epochconverter.com/




The constant could then be tuned when the simulation is running. It could be done manually or through a Python script.


Conclusion:

Using solution 2 forces the Time Quality Byte of the C37.118 Slaves to 'Normal Operation. Clock locked'. Unfortunately, the Epoch time requires a bit of tuning to have a precise date and time.