VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

test simulink model

Solved!
Go to solution

Hi !

 

I'm trying to test a simulink model in veristand. I Import the model in veristand and deploy the code to the target. The model seems to works properly.  But i want to measure the time used for the model, therefore, i wonder if it's possible to have a trace with tracetoolkit.

 

Does anyone have any idea ??

 

Thanks .... 

0 Kudos
Message 1 of 11
(10,826 Views)
Solution
Accepted by topic author KaBooOoom

Check out this Execution Trace Tool Custom Device provided on the VeriStand Add-ons page. Adding this Custom Device to your System Definition File allows you to programmatically configure, start and stop execution traces that get sent back to the host.

 

You can examine these traces to see approximately how long your model takes to complete by searching for the thread named after your model. For instance, if your model is named sinewave, then you should see a thread named sinewave_MODEL LOOP. Use this to track your model execution, keeping in mind that there's a small amount of added overhead in the model loop before we schedule your model.

Jarrod S.
National Instruments
Message 2 of 11
(10,824 Views)

Hi Jarrod, thanks for your answer....

 

So, i followed your instructions, but something is a little bit weird...

 

When i mesaure the time with the tracetoolkit i get approximatively 100 µs for the model execution. The problem is it takes approximatively 50 % CPU on both cores. The model and the custom device for the tracetoolkit are the only thing that execute on the target (i have no alarm, no card, no procedure....).

 

The other question is:  the model has a lot of parameter ( more than 10 000 ) are all these parameter send periodically to the host ? that's may be the reason why it takes so much CPU ... IF yes, is there a way to disabled the parameters ... ???

 

O ne last question is there a parameter to know if i'm loosing cycle ? Cause i have a lot of flag in the trace and not a lot of free time ... 

0 Kudos
Message 3 of 11
(10,810 Views)

I am not sure if transmitting the parameters is causing the CPU burden.

 

We will only transmit the parameters that have been imported in System Explorer as channels. You can double check which parameters have been imported by going to System Explorer and looking in the Parameters section under your model. Any imported parameters will be listed there.

 

These channel values, along with all other channels, are sent back to the host at a 5Hz interval. We haven't noticed this being a huge CPU burden, but it would have to scale with size.

 

If you want to test out the effect yourself, simply remove all imported parameters from your model, or just reimport the model without importing any of the parameters. Then redeploy your system and see if it makes a difference. Your parameters will still exist, but you won't be able to set them or read their values. This will at least give you an idea of what's going on. If it does help, let me know, but at that point you can start being selective about which parameters to import.

 

You can check some System Channel values to know if you are missing iterations at various places. Check out the following channels:

  • Model Count: Increments every time a model fails to complete on time and misses an iteration.
  • HP Count: Increments every time the Primary Control Loop reports being late.

If you run your system in Parallel mode (configurable on the main Controller page in System Explorer), we don't wait for models to complete if they're late. We just note that they were late in the Model Count variable. This means the models shouldn't cause lateness in the Primary Control Loop. If you run your system in Low Latency mode, we do wait for the models to complete, because they are called inline. This means the models won't report being late, but they can cause the Primary Control Loop to be late.
Jarrod S.
National Instruments
0 Kudos
Message 4 of 11
(10,798 Views)

Hi Jarrod!

 

Well, i tested the model, with and without the parameters... When i import all parameters and signals (more than 10 000) i have more than 50% on both CPU (as i said ...) .Moreover both the model count and the HP count are increasing ( I loose cycles...).

 

When i test the same model without any parameters i have approximatively 4% on the first CPU and 12 % on the second... So It seems that the number of parameters used change the CPU consomption... but i think that's quite normal.

 

But do you have any graph that shows the CPU consumption and the number of variables used ? So that we can know how many variables are supported, and how many parameters are supported by VeriStand....

 

And a last question is it possible to import parameters values from a file ? 

 

0 Kudos
Message 5 of 11
(10,760 Views)

We don't have numbers that specifically reference the CPU burden of extra channels in a system. It would be helpful to profile that. Are you on a Gigabit Ethernet network? Is it 10/100? Is it a private network? These would likely be important factors in the overall performance of the variable transmission.

 

It is possible to import and export parameter values from a file. In the Model Parameter Manager, you can add one or more text files written in a simplified m-file syntax. So if you have model Workspace Variables named A, B and C, you can import a file like the following:

 

A = 10;

B = 20;

C= A + B;

 

You can see that this file format can either set Workspace Variable values directly or configure their values as calculations of other variable values in the system. After importing this file, the variables would have the following values:

10, 20, 30.

 

If you then manually changed A to 15, C would automatically become 35, due to its dependence on A and B.

 

You can even create variable values in the text file that don't correspond to any imported model variable. For instance, I could create a variable called D in my text file and use it in calculations of other real model variables, even if D doesn't exist in any model. For instance, I could have the following file:

 

D = 10;

A = D;

B= D;

C = D;

 

This allows me to be able to set one variable value and have it propagate simultaneously to multiple other variable values.

 

You can also set regular model parameters (non-Workspace Variables) using values imported from a file, but you will need to reference the full model parameter path. For instance:

MyModel/Pulse Generator/Amplitude = 1.000000;

 

However, because of the inherent slashes in the parameter name, you can't use these values directly in calculations like Workspace Variables, because it would look like division.

 

The easiest way to create one of these files is to click the Save Values button in the Model Parameter Manager tool. Then open the generated text file and edit the values to be what you want.

Jarrod S.
National Instruments
0 Kudos
Message 6 of 11
(10,755 Views)

Hi Jarrod!

 

I'm sorry i'va another question, when you wrote "In the Model Parameter Manager, you can add one or more text files written in a simplified m-file syntax" what do you really think ? Because in veristand i can't find any funtion to add text files. I searched in the model,  (it is possible to add a descritpion, set the decimation, the processor where the model will be executed) ... in the parameters (Add a parameter, serach a parameters ..) But i really can't find any import function ...

 

 

Ps: the refresh of the Treeview is really really slow ( and takes 100% CPU during 10 s ) .... 

0 Kudos
Message 7 of 11
(10,743 Views)

Sorry if I wasn't clear. The Model Parameter Manager is a tool in the Workspace, not in System Explorer. The initial parameter values are set as those that were compiled into the model. You can only change those parameters by recompiling the model or by changing them at run-time with the Model Parameter Manager dialog tool.

 

Jarrod S.
National Instruments
0 Kudos
Message 8 of 11
(10,737 Views)

OK...

 

Thanks a lot for your help, I don't know why, for me it was logical to set the parameters is the system explorer...

 

 

0 Kudos
Message 9 of 11
(10,730 Views)

dear jarrod_S,

 

Can you provide the link for downloading that Execution Trace Tool Custom Device. i am also facing same issue with my model in calculating execution time.

 

Regards,

Vikas

0 Kudos
Message 10 of 11
(4,414 Views)