LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to output data when converting labview vi into matlab mex functions

Hi,
I am a fairly new user to labview and am currently working on labview 7.1. I have created a labview vi which can extract data from ni daq 6070e in real time. The problem is that this code has to be converted so that it can be used with matlab.in order to do that i am using math interactive tool kit which converts the labview code into mex files which can then be used in matlab. Unfortunately i have not been able to figure out how to output this data so that it can be processed in matlab easily. i cannot afford any loss of information and all the output must happen in real time. the o/p must take place after the fft has been done. i am attaching the vi for convenience.There are 10 broken wires ,and this is the place where i want the o/p to be generated.
Also do let me know if this vi can be further improved.

Regards
0 Kudos
Message 1 of 13
(3,248 Views)
Morning Manuj,
 
unfortunately the company does not have a licensed copy of MATLAB on any computer here and so I can't actually debug/improve your MATLAB code.
Could you attach the LabVIEW code instead please?
 
Also a little more information as to what exactly is going wrong would help me to pinpoint the actual problem in the LabVIEW code.
It might be worth your while contacting MathsWorks to help you sort out the "output this data so that it can be processed in matlab easily" problem.
 
It may also be worth your while to look at LabVIEW 8 and the extra functionality that has been introduced.  This may help you further in your application.
 
Regards
 
AdamB
NIUK
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 2 of 13
(3,240 Views)
Morning Adam,
Thanks for ur reply
Please find attached the labview code with the message. With this program the objective is to acquire data from a 6070e at very high speeds and process it such that we dont lose any data. In order to do it we acquire the data and add a delay to it and then do the fft of it.
I am trying to convert this code into matlab using math interface toolkit as already mentioned in the initial post. the problem is when i try to convert this into the mex files all the inputs and outputs kind of disappear ...to better understand if you follow the link http://zone.ni.com/devzone/conceptd.nsf/webmain/EEFA8F98491D04C586256E490002F100 you will see that you can configure your inputs and outputs but in my case i actually cannot - becasue i dont see those inputs and outputs and that is what the problem is.
Any  help will be greatly appreciated

Manuj
0 Kudos
Message 3 of 13
(3,239 Views)
Manuj,
 
You may notice that on your vi the icon and connector pane is not configured for inputs and outputs.
What you need to do is (in the vi you have created) connect up the terminals on the icon of the vi.
This will then be recognized by the Toolkit when converting to a mex file and should solve your problem.
The link you have sent me shows the connector pane "Viewing the VI Connector Pane". 
 
If you do not know how to create input and output terminals then please refere to the follwing links:
 
Has this solved your problem?
 
Regards
 
AdamB
NIUK
 
Applications Engineering Team Leader | National Instruments | UK & Ireland
Message 4 of 13
(3,236 Views)
Thanks AdamB,
That was well spotted.Problem solved indeed.

Now can i ask for another favour...can you have a look at the program and see if it can be optimised in any way or is there a better way of doing it. someone had suggested me to use queues but i decided on the contrary so as to avoid data loss.

Thanks
Manuj
0 Kudos
Message 5 of 13
(3,232 Views)
Manuj,
 
Well after looking at your code it does seem pretty optimized.
However I do have a few questions that may help you to optimize the code yourself.
You have used a toggle switch (changing from true to false using a feedback node.)
It might be better to use a shift register and a NOT function on a Boolean value.
(I also noticed that the case structure this toggle switch controls has the same code in both false and true)  is this intended.. if so then you don't need to use the case structure at all.
 
Finally, always initialize all of your shift registers and feedback nodes.  This ensures that the program does not deal out false information on the first iteration.
 
Hope this all helps
 
Regards
 
AdamB
NIUK
Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 6 of 13
(3,227 Views)
AdamB,
The case structure has the same code for a reason..it is actually processing the data from the other case what that means is that data from the true case goes to the false case and gets processed and similarly data from the false case gets processed in the true case which helps us to prcess as well as shift data at same time. i dont think i will be able to do the same with the shift register.
If you find this to be a little confusing let me know and i will elaborate in detail

regards
0 Kudos
Message 7 of 13
(3,225 Views)

Manuj,

You seem to have misunderstood the way in which LabVIEW processes data.  The code that you have produced will run in exactly the same way without the need for the case structure.

The code does not actually run the data from the previous case. It is merely processing data from the previous loop iteration, regardless of the case. If you were to remove the case structure, leaving only one copy of the code intact, and remove the toggle switch you have produced, or used the shift register which, I assure you would have worked, then you will have exactly the same functionality.

I have attached an example that uses the shift register to toggle cases, but also iterates that the case structure is not needed by using the same feedback node (and code) without a toggle switch or case structure.

Hope this helps you optimize your code

Regards

AdamB

Applications Engineer

National Instruments UK

Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 8 of 13
(3,222 Views)
AdamB,
Does this mean that the data from the previous case is getting discarded in anyway?
we thought the while loop in itslef will process data step by step like in a c code and while it is processing we wanted to acquire the data in the background, hence the case structure so that we can process and acquire the data at the same time and in the process not lose data.

Let me try to explain to you in detail:
we are trying to acquire the data at a very high speed and consequently do post processing on it. becasue the data is being acquired at high speed and the post processing (which i must mention requires a lot of computer resources) must be done at the same time we decided to develop this method in which we have 2 data pipes...where 1 is acquiring while the data of the other is being processed and vice versa.
If i were to remove the case structure then it would only acquire and THEN process the data.

Do you think my program is actually overdoing what it was actually intended to do. Or as already asked at the starting of this post..is it discarding some information..or can it be programmed to work faster and without losing data.
Please let me know.

Regards
Manuj
0 Kudos
Message 9 of 13
(3,218 Views)

Manuj,

With the case structure you are taking the data first... Then you  do the proccessing on the previous data,whilst also indexing the new set of data.  Then you pass that indexed data to the feedback nodes to be stored till the next itteration

If you take out the case structure:

The data is aquire, at the same time the processing is occuring on the previous peice of data.  Then  the data that has just been aquired is indexed and stored for the next loop itteration.  If you do not use a case structure you will find that the code will tend to run in a more parallel fasion.

A more reliable method would be to use a producer consumer template to cue the data for processing when the computer resources are not being used up by the aquisition.

The LabVIEW Basics I and II courses on offer, here in Newbury, may be benificail if you want to expand your knowledge of dataflow concepts and Producer Consumer loops which are paramount to coding efficiently. 

Kind Regards

 

AdamB

NIUK

Applications Engineering Team Leader | National Instruments | UK & Ireland
0 Kudos
Message 10 of 13
(3,213 Views)