Real-Time Measurement and Control

cancel
Showing results for 
Search instead for 
Did you mean: 

Sinewave simulation

Hi,

I have a simulink model in Labview and I created dll model and use Labview simulation interface toolkit to connect with labview. I set frequency and amplitude of sinewave through Labview , acquire value and generate to analog output pin of DAQ board and measure it by oscilloscope. I want to check sample time of labview and dll model. the result in oscilloscope is incorrect. It has a large delay , the sample rates is about 100ms. I set  sample rates in Simulink is 1ms and sample rates in AO config is 1ms. 

Download All
0 Kudos
Message 1 of 5
(3,463 Views)

Hello namsvmore,

 

After reading your message, it seems that there is a delay when you use LabVIEW to send out a sine wave. I looked at your code and I think the first step I would do would be to isolate your T-DAQ code and run it. In order to do this, I would copy this bit of code into another VI and run it. As you change Value, do you notice the 100ms delay still?

 

If you don't which I don't think you will, you would need to modify the rest of the code so that it updates Value at a faster rate. One of the reasons for the delay you are having is the wait in second while loop of 50ms which I have shown below.

 

 

timeout.jpg

 

 

Along with this, there is a delay for the code to execute and then send the data out to the card which could easily take up the other 50ms. In order to see if this is occurring, I would do some benchmarking in your code. The way I would do this would be to use two tick counts one before the SIT Signal Probe Data.vi and one after the SIT Check to Stop Client.vi. I have shown how to add this is below:

benchmarking.jpg

This benchmark will allow you to see how long it takes to run through the code in the true case. In other words, it will state how long it takes to create the value for the DAQ card. From here the other delay will be dealing with writing this data to the DAQ card. Using the same logic as benchmarking the creation of Value, you can see how long it takes to write the value.

 

I will say that no matter what you change in this, there will always be a delay with it due to the latency in Windows and how long it takes the code to execute.

 

I also noticed that you are using the TDAQ driver which isn't supported anymore by National Instruments. I would suggest that you switch to DAQmx and I have provided a link to this below:

 

http://joule.ni.com/nidu/cds/view/p/id/1614/lang/en

 

I hope this information helps you.

 

JimS

 


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 2 of 5
(3,445 Views)

Thanks Jim_S for reply.  I decreased the value of delay time in whileloop to 0 ms. but when I measured in the osciloscope, the Sample rate is about 10ms. It is too large for me. How can I improve this?

I  want to run " hardward in loop" system with the model in simulink, simulation interface toolkit.  The require is time for connecting data between labview and simulink , generating analog out put is less than 1ms. How can I do it with simulation interface toolkit 5.0 and DAQ board 6024E

Thanks so much!

0 Kudos
Message 3 of 5
(3,422 Views)

Hello Namsvmore,

 

After looking at your code in more detail, I believe that you are using the SIT Communication Manager. When using this, there is an option called Hardware I/O which will allow you to connect your hardware to your DAQ board. I have added some instructions how to implement this below but if you are looking for more information on it that isn't include here, the help file has a detailled explanation how this manager works. 

 

How to add Hardware in SIT Connection Manager:

 

1.) Open the SIT Connection Manager and add simulation DLL.

2.)  Under the Category list box, Click on Hardware I/O. 

3.) Click Configure HW I/O as shown in the picture below:

 

SIT connection Manager.jpg

 

 

4.) This will open a new window where you can add your hardware. Right click on Local Host and select Add Device>>NI-DAQ.

 

Adding device.jpg

 

5.) In the NI-DAQ Device properties, you can type in the Device Name of the card and how many analog inputs, outputs, etc. Click OK when finished. This can be seen in the image below:

 

Daqdeviceprop.jpg

 

 

 6.) On the Configure HW I/O Manager, click on the analog input, analog output, etc under the device tree and also click on the corresponding simulation input/output on the Model Tree.

7.) Click Add to create this connection between the hardware and the simulation model. The picture below is what the Configure HW I/O Manager will look like.

 

 

finalproduct.jpg
 

 

I believe this will help with the execution speed. If you have any more problems, feel free to post so we can work on it.

 

JimS

 


Jim St
National Instruments
RF Product Support Engineer
0 Kudos
Message 4 of 5
(3,405 Views)
Thanks Jim for your recommend. I will post question if I have any problems.
0 Kudos
Message 5 of 5
(3,384 Views)