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.


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

For optimal experience, use a desktop computer.

Reference Number: AA-02170// Views: AA-02170// Created: 2023-05-03 22:07:25// Last Updated: 2023-05-03 23:00:48
Problem & Solution
Problem and Solution: Debugging UCM (User-Coded Model) For Incorrect Sampling Rate in HYPERSIM

This article will describe a problem that users may face and how to avoid it altogether. It is assumed that the user is familiar with the UCM process and comfortable with the steps needed to create a UCM. 
Note: This articles considers the standard TimeStep of 50us for simulation purposes.


There may be a certain situation when the user will face a UCM that behaves in an unexpected manner with reference to the sampling rate. A screenshot (Figure 1) is attached with overlapping waveforms is attached to illustrate the behavior.

Figure 1: UCM output for a given UCM with sample rate of 200ms or 0.2s - overlap between HYPERSIM and MATLAB

Upon diving deeper into the .def file to see about the code, the user will see the following, Figure 2. 

Figure 2: UCM .def file - approximately 65% of the way down into the code


Simply put, the user has to make sure that the TimeStep is defined properly in the Model Settings section of MATLAB. This step is the last step where the parameters are set before generating the C Code for HYPERSIM. See Figure 3 below, where Ts = 50us. The error could also occur when the user is creating multiple UCMs in one go and the parameters were not double-checked due to Save As... or other copying mistakes. 

Figure 3: Model Settings; parameter tuning and TimeStep selection. 

Overlapped waveforms before and after the fix. 

Figure 4: before the UCM fix with incorrect sampling rate due to incorrect TimeStep

Figure 5: after the UCM fix with the correct sampling rate due to correct TimeStep