Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

HELP-How does made the simulink model run in the RT model

I am using the Simulation Interface toolkit to connect a simulink model to Labview, and I know convert the simulink model to a DLL file, it can be run in the RT model. What I do not know is that what should I do after converting the  simulink model to a DLL file.Much time has gone, but it is not solved, I need your help. Thank you.
 
 
Regards
 
Vivian
0 Kudos
Message 1 of 16
(6,306 Views)
Hi Vivian,
 
If you have compiled your model into a DLL then the next step is to use the SIT Connection Manager to link your controls and indicators to the model parameters and signals and your inports and outport to hardware.
Check the following link
 
 
This is the LabVIEW Simulation Interface Toolkit online tutorial.
Since you have already done the DLL you can go straight into Creating a Host VI
 
If this doesn't help, please let me know what specific problem do you have and versions of LabVIEW and SIT.
 
Ricardo Santa Olalla
National Instruments
0 Kudos
Message 2 of 16
(6,292 Views)

Hi

Thank you for your help. Now I have another question: if I want to realize communication with hardwire, must I use RT model?

Now I describe my problem

I tried it according to the tutorial, but when it come to configures the  hardwire, I do not understand the mean about remote system, because there is nothing in the remote system on my PC. And I do not understand how to build a target. Look forward to your reply. 

Labview 8.2.1

SIT 3.0.2

VC++ 6.0

0 Kudos
Message 3 of 16
(6,286 Views)

Hi,

There are two ways you can connect your model to hardware.  It all depends on the target and hardware that you are using.

If you are using your PC to run the simulation, then what you to do specify the execution host to be : Driver VI on local host.  This will run the DLL in your PC and will give you access to hardware that is connected locally in your PC.

Executing a Model DLL on a Windows Computer (Simulation Interface Toolkit)

If you are using an RT system such as a PXI RT controller or cRIO controller then the execution host needs to be : Remote Target or RT Target.  This will run your model DLL in the RT system and will give you access to the hardware connected to the RT box.

Hope this helps.

Ricardo Santa Olalla

National Instruments

0 Kudos
Message 4 of 16
(6,275 Views)

Hi

Thank you for your help. I think I do not install RT system, just in the tool of Labview has the RT model, and I tried it according to the Labview help. But an error emerges, I do not understand it. The error is the following:

Error 63 occurred during host VI initialization:

Unable to open VI Server connection to target.

Check the following:

1)      You specified the correct IP address in the SIT Connection Manager dialog box.

2)      You enabled VI Server on the target with the following options:

i)                    TCP/IP access is enabled on the default port.

ii)                   The host computer is in the TCP/IP access list.

iii)                 The driver VI is in the Exported VIs list.

Do you want to launch the SIT Connection Manager dialog box and reconfigure the simulation?

At first, the default port displaying on the Matlab command window is 6011 port, do I need to change the port? How can I change it? Look forward to your reply. Thank you!

I send the error picture to you via accessory.

 

Regards and Thanks

 

Vivian

0 Kudos
Message 5 of 16
(6,272 Views)

Hi Vivian,

If I understand correctly, what you want is to run the simulation in your PC as a built DLL; is this correct?  If this is true then your selection as Real-Time Target is correct.  This option will create the Driver VI for you that will run the model DLL.  This driver VI will run in your PC along with the Host VI if your Real-Time Target is your localhost.  Has the connection manager generated the Driver VI? Review the links I gave you before on how to create a Driver VI if you still haven't done this part.  If you have a driver VI, then whatever port you specified in the Connection Manager, should be the port used in the SIT Server running inside the Driver VI.  Since you want to run the model as a DLL you only have to worry about the port specified in the SIT server inside the Driver VI.

Just make sure that the port you specify in the Connection Manager is the same one you used to create the Driver VI.  If is different, the easiest thing is just to change the port in the connection manager to match the Driver VI port.

When you run the Host VI, LabVIEW should launch the driver VI by itself and then connect to it.  Just make sure that the Host VI and the Driver VI don't exist in the same LabVIEW project.  The Driver VI should have its own LabVIEW project.  If you have them on the same project then what you need to do is run first the Driver VI and then the Host VI.  This should work.

Hope this helps

Ricardo Santa Olalla

National Instruments.

0 Kudos
Message 6 of 16
(6,263 Views)

Hi

Thank you for your help. I have done it according to your direction. Now I describe what I have done.

1)      I stop the SIT Server in the Matlab command window according to the LABCIEW help (it is also your link).

2)      I choose the hardwire I/O of the SIT Connection Manager dialog box, and configure the mappings.

3)      The port next to Real Time Target is the port of the DAQ which I use.

4)      After I configure the mappings, build the Driver VI.

5)      All of the VIs and DLL file are in the work folder of Matlab.

6)      In the end, I first run the driver VI ,it has a warning: the current appointed net address is used, I click continue, and then run the host VI, BUT  the error emerges again.

  Error 63 occurred during host VI initialization:

Unable to open VI Server connection to target.

Check the following:

1)      You specified the correct IP address in the SIT Connection Manager dialog box.

2)      You enabled VI Server on the target with the following options:

i)                    TCP/IP access is enabled on the default port.

ii)                   The host computer is in the TCP/IP access list.

iii)                 The driver VI is in the Exported VIs list.

Do you want to launch the SIT Connection Manager dialog box and reconfigure the simulation?

 

But I do not find the IP address in the SIT Connection Manager Dialog box, I do not know correct it where. And when the examples of the NI run, the same error emerges.

 

And I have another question. In my PC there is real time module; do which presume that the simulation can run in the RT System?

 

If I want to output a digital signal with DAQ, should I how to do it, because in the SIT Connection Manager Dialog box, the hardwire I/O, in the DAQ, there are two Analog output and seven Analog input, there is no digital output.

 

Thanks and Regards

 

Vivian

0 Kudos
Message 7 of 16
(6,257 Views)

Hi Vivian,

The problem seems to be in your step number 3.  The port next to the Real Time Target should be the port used by the SIT Server, not the DAQ board port.  In this case the default port is 6011.   You are receiving error 63 because LabVIEW cannot open VI Server on the port you are specifying because most likely that port is used by another program.  The default port (6011) should not be used by any other program. Try using that port first.

Before running the Host VI, open the Driver VI and run it.  Then run the Host VI.  This should work. 

Check that you have VI server enabled in LabVIEW.  The following is from the SIT readme file

**************

If you run a driver VI on a non-RT target and want to connect to the driver VI by using a networked PC, you must run the driver VI before attempting to connect to it from the networked PC. You also must complete the following steps on the PC running the driver VI.

  1. Launch LabVIEW and open the driver VI.
  2. Select Tools»Options from the pull-down menu.
  3. Select VI Server: Configuration in the Category list.
  4. Place a checkmark in the TCP/IP checkbox.
  5. Select VI Server: Machine Access in the Category list.
  6. Click the Add button, and enter the IP address of the networked PC in the Machine name/address text box.
  7. Select VI Server: Exported VIs in the Category list.
  8. Click the Add button, and enter the path and name of the driver VI in the Exported VI text box.
  9. Click the OK button.

********************

If this doesn't work, please tell me what your setup is:  What is your target? What is the hardware that you want to use, etc?

Ricardo

0 Kudos
Message 8 of 16
(6,244 Views)

Hi Ricardo

Thank you for your help. I have done something to my target. I changed the port to 6011. In the driver VI, select TOOLS>>Options from the pull-down menu, select VI Server, then place a checkmark in the TCP/IP. Then run the driver vi, and then host VI. But the signal can not be run in the real time, and it can not be sent to hardwire, it can not be detected by oscillograph.

I send my target via accessories. And I want to use THE I/O channel of DAQmx, but in the Hardwire I/O, there is not I/O channel. I want to output digital signal. Look forward to your reply. Thank you!

 

Thanks and Regards

 

Vivian

0 Kudos
Message 9 of 16
(6,224 Views)
Hi Vivian,
 
I assume that with the changes you made, you don't get error 63 anymore, is this correct?
I want to explain one quick thing.  If you don't have a Real Time system, the model will not run in Real Time.  For what I have understood from our conversation, you want to run the model DLL in a Windows PC, is that correct?  If this is true, then it is important to understand that even though you are selecting Real-Time as the execution host, the model won't run in Real-Time.  The reason why you need to select Real-Time as execution host is so that SIT generates a Driver VI.  This Driver VI in your case will run in the Windows PC and that is why you specified localhost as the execution host IP address.
 
You can verify these steps in the links I gave you or in your SIT help that installs with the product.  Just open the help and go to Simulation Interface Toolkit How to --> Configuring a Simulation on a Real Time Target --->Executing a Model DLL on a Windows Computer (Simulation Interface Toolkit)
 
In that same help, under the Configuring a Simulation on a Real-Time Target ---> Creating  a Driver VI, there is a section for Creating Mappings for a National Instruments DAQ Device.  This is what you will see:
 
Creating Mappings for a National Instruments DAQ Device (Simulation Interface Toolkit)

Specify the model DLL and real-time (RT) target.
1. Click the Hardware I/O tab of the SIT Connection Manager dialog box.
2. Place a checkmark in the NI DAQ checkbox.
3. Click the Configure NI DAQ button to launch the Configure DAQ Device wizard.
4. Select the value from the DAQ Device Number list that matches the device number of the DAQ device you want to use in the simulation. You can use National Instruments Measurement & Automation Explorer to see the device number of a DAQ device.
5. Click the Next button.
6. Choose a DAQ input or output from the DAQ Channels tree. This tree displays analog inputs ai0 through ai7. This tree also displays analog outputs ao0 and ao1. To use other inputs or outputs, you must manually edit the driver VI.  Note  You can create mappings only between DAQ inputs and model DLL inputs and only between DAQ outputs and model DLL outputs.
7. Select a model DLL input or output from the Model Inputs/Outputs tree.
8. Click the Add button to add the mapping. The Current Mappings table updates to show the mapping you added. Note  To remove a mapping, select a row in the Current Mappings table and click the Remove button. To remove all mappings, click the Clear button.
9. Click the Finish button to return to the SIT Connection Manager dialog box. The Hardware Mappings table updates to show any mappings you made.
10. Click the Build Model Files button to generate the driver VI for the configuration.
11. Click the OK button to generate the block diagram code for the host VI.
 
Hope this helps.
 
Ricardo Santa Olalla
National Instruments
0 Kudos
Message 10 of 16
(6,210 Views)