LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

complex data polymorphism with functions

Hi Labview forum,

I just came across several bugs in my VIs processing of complex data.
I created the VIs with real data as inputs and outputs.  Then later wanted to use them with complex data input.
I think the VI threw away the imaginary components of my data.  Can some one confirm this is labview's behaviour?

Now the question is, can I make VIs which recognise whether the input and operational output is real or complex and treat it as such?  Or should I set all my data types to be complex unless I know for sure they will be real.  The indicator displays don't look so nice when there are a whole series of +0i's.

Regards,
Jamie
Using Labview version 8.0
0 Kudos
Message 1 of 5
(3,061 Views)

Jamie,

You are correct in your first statement that LabVIEW "throws away" the imaginary components of your data if you connect a complex data type to a real number indicator (i.e. UINT8, 16, etc). You can tell that a transformation is occuring because a coercion dot appears at the corresponding terminal on the block diagram.

One method to recognize whether or not the input data is complex is to use a case statement to determine if LabVIEW should treat/display the number as complex or real. I have attached a quick sample example that implements this design.

One note with the code within the case statement is that it uses references to the indicators and property nodes to make the correct indicator visible. To see more information on this feature consult the LabVIEW help documentation.

Cheers,

Jonah Paul
Applications Engineer
National Instruments

Jonah Paul
Marketing Manager, NI Software
0 Kudos
Message 2 of 5
(3,047 Views)
Hi Jonah,

Thanks for your reply.

Unfortunately I was not able to load the "simple example" as it seems it is too advanced for my (out of date already?) labview version 8.0, resulting in the following error message:

load code error 9: VI version (8.2.1) is newer than labview version (8.0)

Would you be able to post an 8.0 compatible version please?

Regards,
Jamie
Using Labview version 8.0
0 Kudos
Message 3 of 5
(3,033 Views)
Here is the conversion for you.
0 Kudos
Message 4 of 5
(3,025 Views)
If you have the LabVIEW Professional Development System, you can build Polymorphic Vis. A polymorphic VI is a set of regular VIs with similar connector panes. The advantages is that you can pick a specific instance of your VI while editing using either a selector under the VI, or simply by wiring a different data type to the terminal that allows LabVIEW to automatically pick the right instance.

For instance, you could create a polymorphic VI called Process Data.vi that calls one of two specific instances: Process  Complex.vi and Process Real.vi. The two instances could be completely identical except for the numeric representation of the input and output values. Then if you drop the polymorphic VI down on the block diagram, you can either use its selector to pick the complex or real version, or just wire a complex or real number into the input.

You could achieve the same functionality without the polymorphic VI, but it adds a level of convenience. If you've ever used the DAQmx VIs to acquire data, you've used polymorphic VIs.

http://zone.ni.com/reference/en-XX/help/lv/71/lvhelp/Using_Polymorphic_VIs/
Jarrod S.
National Instruments
0 Kudos
Message 5 of 5
(3,021 Views)