From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Signal Generators

cancel
Showing results for 
Search instead for 
Did you mean: 

simulation interface toolit

Solved!
Go to solution

Hello,

 

I want to connect the signal generator from Labview to the Generated DLL model from the simulink.

My simulink model has 2 input ports 1. Sine and 2. Cosine.

How can I connect these input ports to the signal generator of labiew.

Is this possible? because I am not able to see any Input Ports during the mapping in SIT connection manager.

I am not able to connect directly to the dll model also..

 

Which kind of Input ports should i use in the Simulink model, so that the Signals from Labview can be connected to the simulink model.?

 

 

Thank you,

 

Mandar Malji.

0 Kudos
Message 1 of 7
(7,059 Views)

Hey,

 

The following Link will give you some general Information in building a model for SIT (Out of the SIT Help):

Building a Model (Simulation Interface Toolkit)

 

To create Mappings you will need to have an Indicator or Control on the Frontpanel of your VI, e.g. a Waveform Graph.

Please have a look at this link which explains this in Detail (Out of the SIT Help):

Creating Mappings (Simulation Interface Toolkit)

 

 

Hope this helps,

Christian

0 Kudos
Message 2 of 7
(7,045 Views)

Hello Christian,

 

I have already built the the model DLL. When I include this DLL file through the SIT Connection manager in Labview,

This dll model is equivalent to a block in the Block diagram file of the VI.

 

Now there are Signals generated in the same block diagram using the Signal generators of Labview.

So there are 2 different parts in the same Block diagram file now,

1. Model DLL

2. Signal Generators (Labview function)

 

The main thing here is, I have to connect the Output of Signal Generator (e.g Sine) to the Input Port of the Model DLL.

I am not able to access the Input ports of the model DLL in the Mapping Section of the SIT Connection manager.

 

I found One thing that can probably help me i.e Creating a Custom Driver VI.

But for this, First I have to Create 4 Custom VI's(Initialize, Read, Write, Close)  and place these VI's in the Generated

Modelname_Base Rate Loop.VI and make the connections.

 

I dont have enough Information about Creating a Custom VI (Model Interface VI) that can be used to Create a Custom Driver VI.

and also about Type Definitions and Strict Type Definitions.

 

If there is any simpler way to Pass the Labview Signals to the model DLL, Please let me know.

 

 

Thanking You,

Mandar. 

 

0 Kudos
Message 3 of 7
(7,034 Views)

Hey Mandar,

There are two possible ways to pass information back to the modell DLL.

 

1. Using the driver VI (RT)

In this case an array containing all the inputs of the model should be "manually" updated by the LabVIEW driver VI code. More information on this can be found here:

http://zone.ni.com/reference/en-XX/help/371504F-01/lvsithowto/sit_h_customdrivervi/

 

2. Using the host VI (non RT)

In this case the value property of a control element (that is already mapped to one of the parameters of the model) could be changed to the value of the LabVIEW signal generator.

Hope this helps,

Christian

 

0 Kudos
Message 4 of 7
(6,988 Views)

Hello Christian,

 

(1. Using the driver VI (RT)

In this case an array containing all the inputs of the model should be "manually" updated by the LabVIEW driver VI code. More information on this can be found here:

http://zone.ni.com/reference/en-XX/help/371504F-01/lvsithowto/sit_h_customdrivervi/ )

 

1. In case of Editing the Driver VI.

I have created the Custom VI's and using them I have made the connections. (In the Driver VI)..

But Now Where and How to connect the Input and Output ports?

The Edited Driver VI looks almost same as like the given example in Help file.

But I am not able to make the connections. (Input and Output port connections)

 

Can you give me an example?

1. model *.mdl, generated dll, Host VI, and the Custom driver VI, and some documentation about it.

Exactly how the Input and Output ports can be mapped?

 

( 2. Using the host VI (non RT)

In this case the value property of a control element (that is already mapped to one of the parameters of the model) could be changed to the value of the LabVIEW signal generator. )

 

Can you please specify this by giving a small example..

 

 

 

Thank you..

 

Mandar.

0 Kudos
Message 5 of 7
(6,971 Views)

I am trying to Simulate the DLL on the Local Host Machine and not on any Real Time Hardware..

0 Kudos
Message 6 of 7
(6,970 Views)
Solution
Accepted by topic author Sunny09

Hello Mandar,

 

the inputs and outputs of your model can be updated in the driver VI using a pre-sized data array as it is described in the SIT help (see link in one of the previous posts):

 

"To create a custom driver VI, you must correctly index into the pre-sized data array, which is where the Simulation Interface Toolkit places data from I/O channels. Refer to the modelname _portsReadme.txt file, located in the model DLL build directory, for a list of the ordering and widths of all model inputs and outputs. The index number of these arrays is the sum of the width of all previous elements. For example, the index number of element 3 equals the width of element 2 plus the width of element 1."

 

If you update the elements of this pre-sized data array with your own code, you can change the input values for your model for example. It is important that the information how the data is organized in this array is described in the modelname _portsReadme.txt file. This file is automatically generated by the Real-Time Workshop of Matlab/Simulink when the model dll is created from the .mdl file.

 

Best regards

 

Balazs

0 Kudos
Message 7 of 7
(6,919 Views)