VeriStand HP Loop Count Increasing on Linux or Windows Target

Updated May 1, 2023

Reported In

Software

  • VeriStand

Operating System

  • Windows
  • Linux

Issue Details

I am deploying a VeriStand project and I am monitoring the HP Count System Channel, which shows the number of times the Primary Controlled Loop (PCL) of the VeriStand Engine reported being late.
I noticed that the HP Count for my project is increasing - what can I do to address this?

Solution

This behavior can occur on both real-time operating systems like Linux and non-real-time, like Windows.

In order to address this issue, we need to determine what portion of your system is causing the HP loop to increment and if this behavior is expected.
 
1. Disable any simulation models or hardware I/O in your project and see if the HP count incrementation stops or slows. If the problem does improve, try to isolate the project components which are causing the greatest impact on loop performance and optimize/remove them. Also, consider lowering your PCL rate, as this will give your project's elements more time to successfully execute.

2. Try to simplify the UI for your VeriStand project by reducing controls, indicators, and other elements if you're deploying your project to your local machine. Unlike with RT target VeriStand applications, the UI for your code and the code itself is executing on the same machine, so more complex UIs will slow down your code's execution. Non-real-time OSs like Windows tend to prioritize UI elements over background processes in their scheduler, so priority is likely being given to UI elements in VeriStand and the OS when not in the scheduled time for VeriStand.

3. Try to change the Simulation model processor from Automatic to Manual in the model settings:
Automatic—(Default) The RT scheduler determines the optimal processor on which to execute the model at each iteration.
Manual—Executes the model on the processor you specify in the Processor field.
It is not recommended to use the CPU's processor 0 for model execution.
image.png

4. Try to change the PCL execution mode from Parallel to Low-Latency. You can select the PCL execution mode on the Controller configuration page in the System Explorer window.
image.png

5. The HP count increments when the CPU is overloaded and therefore the VeriStand engine fails to complete its execution during the PCL time period (1/PCL rate).
If the HP count still increases after performing the above-mentioned optimization steps, then it is most likely that your CPU's capacity is not meeting your project's resource requirements.
Logging and monitoring the CPU and RAM usage using the Telemetry Custom Device will provide you with a TDMS file of clear representation of every CPU processor's usage, during every PCL iteration. If the CPU's processor usage is reaching 100% during the execution of the project, then you are facing a hardware limitation.

On Windows target:
 
1. Disable background processes like Windows Update or high-load programs like Google Chrome that aren't necessary for your code's execution to free up system resources.
 
2. Check Task Manager during the execution of your VeriStand project to monitor the system CPU and memory usage - if the CPU or memory usage is high, determine the programs which are causing this load and determine if they can be closed or disabled during your code's execution.

If the behavior is still appearing after attempting these steps, it is important to note that this behavior is, to a certain extent, expected on non-real-time targets. If this behavior is not negatively impacting your project's performance, it is likely just a consequence of not deploying to a real-time target. Monitoring the HP count is still a good idea, but increases shouldn't be a cause for worry unless code execution becomes impacted.

Additional Information

On a non-real time OS, you don't have control over the OS scheduler like you do on a real-time target. The priority that you dictate in your VeriStand project will only affect the system during the allotted scheduler slot for your project's execution. As such, your high-priority loop will only have execution priority during that scheduler slot. Note that this is only true on a non-real time OS like Windows.