LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot run Simulink dll at the same time as running real-time target VI

Solved!
Go to solution

If I understand correctly, you have a VI that you created yourself to talk to your DAQ boards to do measurements and generate signals.  On the other hand you have an SIT VI that runs a model (in Windows) and that receives data through changes to controls in the LabVIEW front panel. You would like to merge those two VIs, so that you can pass the data from the DAQ board to the model and from the model to the DAQ board.  Is that correct?

 

If so, what you need to do is first make sure that you have inports and outports in your Simulink model for every signal that you would like to modify/write through/to a DAQ channel.  Only top level model inports and outports can be accessed by hardware through SIT.  Remember that parameter blocks can only be accessed by LabVIEW Front Panel controls.  Inports and Outports are used to connect to hardware through SIT and CAN'T be accessed through LabVIEW front panel controls.

 

Then, you have two options: 

1) By default you can use the SIT connection manager to connect your model to Hardware. If you are using DAQmx then you shouldn't need to program anything.  In other words, you don't need your DAQmx VI that you wrote; SIT will create everything for you.

 

2) The other option if you want to use your VI, is to not use the connection manager and then just insert your code in the Init, Read and Write VIs inside the Base Rate VI. At this point, you can insert and index the data array based on the ports readme file that should have information by now (after adding inports and outports to the model and recompiling).

 

Ricardo

National Instruments

Systems Engineer

Message 11 of 18
(1,089 Views)

Thank you for the answer. Yes I have two separate projects. One that I created for measuring and writing sometime ago, and the new one with which I pretend to do the HIL test.

 

-the inports and outports  you are mentioning are the SIT inport/outpot in SIMULINK or the regular simulink input/output?

 

I am going to try option 1, hopefully successfully.

 

Regarding sampling time, the test will be using the step-size I specified on my SIMULINK model all the time? Can I change this samplling time from the VI?

 

Additionally, I notice that the simulation is not completely running in real-time, there seems to be some lags at times and sometimes the simulation just seems to be going a little faster than run-time. What can I do about it?

 

Thank you again. Best regards!!

Javier Ruiz - Partner at JKI
jki.net
vipm.io
0 Kudos
Message 12 of 18
(1,085 Views)

1) The inports and outports I'm talking about are the Simulink  inports/outports.  I don't recall seeing the SIT ones (maybe those are new to the new version of SIT) but they should work the same way.

 

2)Your sampling time should be the model rate.  You can overwrite it by changing the settings in the Driver VI front panel (second tab).

 

3) Your system can't run in real-time or deterministically unless is running in an RT system.  Anything running in Windows will be dependant to the OS timer and the OS interrupts.

 

Ricardo

0 Kudos
Message 13 of 18
(1,082 Views)

Great. Thanks.

Is there anything I can do in order to give TOP priority to my program and make it run as close to Real-Time as possible?

 

How hard is it to make a PC run a real-time operating system, and how would I run my VI's from there?

 

Thanks again!

Javier Ruiz - Partner at JKI
jki.net
vipm.io
0 Kudos
Message 14 of 18
(1,080 Views)

Hello,

 

To change the priority of your VI to a time critical (top priority) you can go to VI properties >>Execution and change the priority there.  As a matter of fact I believe the base rate VI is already set for time critical.  Unfortunately, in a Windows OS that doesn't help much because Windows OS will give a higher priority to OS service tasks.  For example, if you move your mouse while your VI is running, Windows will service that mouse move even if your VI was set to a high priority.  That is the reason why when you want to run your models or control systems, you need to run them in a real-time OS that can provide determinism.

 

To answer your second question, here is a quick reference to a document that talks about the requirements to convert your PC into a real-time target. 

Converting a Desktop PC to a LabVIEW Real-Time Target

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA03q000000x4PhCAI&l=en-US

 

Ricardo

 

0 Kudos
Message 15 of 18
(1,066 Views)

Thank you. I really appreciate your help.

 

I am simulating my application and created a virtual NI-cDAQ 9172 chassis using Measurement and Automation Studio. I configured the modules and everything, but I am not able to access this virtual instrument from the SIT Connection Manager. I would like to be able to test the communication with the device and my driver VI and map my model input/outputs with the ones from the device.

 

Thanks again,

 

 

 

Javier Ruiz - Partner at JKI
jki.net
vipm.io
0 Kudos
Message 16 of 18
(1,051 Views)

Unfortunately SIT won't let you map hardware to your model when running your computer in Windows, only in RT Systems.  That been said, you can do it yourself by modifying the base rate loop (Read,Write and Init VIs) to talk to the DAQ driver.  You can use the Ports Readme file to know the index of the inputs and outputs of your model.

 

Ricardo

0 Kudos
Message 17 of 18
(1,033 Views)

That is a shame. Although it seems to me that SIT let's me do the mapping (see fig), the problem is that I cannot automatically find my hardware on the list, but I have to create it by right-clicking, add device, DAQ, etc. When I add a random device (as the one shown in the figure), I am able to map my inputs and outputs from the model and the base rate loop file gets created fine (with IO VIs). The problem again is that the input/output channels from the 9172 are not automatically detected for me to map.

Am I mistaken?

 

Thanks again.

Javier Ruiz - Partner at JKI
jki.net
vipm.io
0 Kudos
Message 18 of 18
(1,026 Views)