Industrial Communications

cancel
Showing results for 
Search instead for 
Did you mean: 

Read shared variables with multiple datatypes

Hi all,

 

I am trying to read shared variables using 'Read Variable' vi.

But the problem is that this vi is reading variables of only one data type for eg. DBL certainly because 'DBL' is given to its input datatype terminal.

If I unwire this DBL from its input datatype terminal then i recieve an error.

Read Variable_DBL.jpg

How can I modify it to read variables with datatype U16 along with DBL ?

 

Thanks in advance!

 

Regards,

 

Rahul

Munich

0 Kudos
Message 1 of 3
(4,048 Views)

Read variable.vi can only read one data type you define beforehand therefore you can have to:

 

Ether create another read variable.vi with different data type

or

Convert all your data to 'variant', use variant data type for passing your information around in your code and then convert from varaint to whatwever data type you need once you need it. 

or

coeherence u16 to double and then pass it to read variable

 

There are many ways to go about this, it all depends on your code architecture to determine what fits the best. 

0 Kudos
Message 2 of 3
(4,044 Views)

Hi Miro_T,

 

Thanks for sharing your ideas.

 

Please find my below comments:

 

1. Either create another read variable.vi with different data type :

Yes, being the most obvious choice I have used this for the U16 and Double problem that I have mentioned in my earlier post.

But now again, similar problem, I have U16 and U32 data coming from my PDOs but I do not want to use separate 'Read variable.vi' as this increases the number of For-loops in my timed structure and in turn my CPU load.

 

2.Convert all your data to 'variant', use variant data type for passing your information around in your code and then convert from varaint to whatwever data type you need once you need it:

Can I pass 'variant' datatype to 'Read variable.vi' and read my data as variant and then convert it to whatever datatype I want?  (U16 an U32 in this case)

 

3. coeherence u16 to double and then pass it to read variable:

Could you please elaborate on this ?  I know datatype 'coercion' but unfortunately I don't have any idea about datatype coeherence. 😞

 

Thanks in advance!

Rahul

Certified LabVIEW Associate Developer

Germany

 

 

0 Kudos
Message 3 of 3
(3,856 Views)