LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

variant type conversion to boolean

Solved!
Go to solution

Hello,

We also get a very annoying error of a boolean variable read from a PLC register that is automatically converted to a variant. And as such, when we wire a boolean indicator (led) to it it gives me the 91 error:"The data type of the variant is not compatible with the data type wired to the type input"

Some people have got the same problem but I don't understand a bit of the work around/solution 😉 !

The variable involved is the one at the bottom, "F3 BLOKKAGE SCHROEF 2 OK"

Thanks for help

 

0 Kudos
Message 1 of 31
(10,259 Views)

I have to ask the stupid question.  Are you sure it is really a boolean?  Try putting a prob on the read variant and take a screen shot of it to show us what is really inside of the variant.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 31
(10,248 Views)

Yes we did put a probe and it is indeed boolean. When we create the default indicator at the output of the Variant to data conversion function we get also a display indicating the boolean value "FALSE" for the matter.

Thanks for your help.

0 Kudos
Message 3 of 31
(10,245 Views)

Hello pgo1,

 

Can you try something for me?

 

Can you create a new true constant from the function palette and wire it to your type input (so that you are not depending on any autoresolving things?

Can you then create a new indicator at the output of the variant function (but also keep the old one in parallel)?


Please do take screenshots of the probing and also show where the probes were placed.

 

Thanks in advance!

 

PS: One thing I do not really like is that you're not doing any kind of error handling.

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 4 of 31
(10,221 Views)

Hello Thierry,

here is the screen capture of what happens.

Indeed we should manage the errors. But we are beginners with labview and we still  have to learn a lot ! 😉

 

Download All
0 Kudos
Message 5 of 31
(10,203 Views)

So one of your many variant to data is making an error, but are you sure you are looking at the right one ?

 

And the prope picture is not really giving any meaning. Try making a indicator in the place where you have the probe, and then show us the frontpanel.

0 Kudos
Message 6 of 31
(10,196 Views)

It looks like the data in the variant is actually a number of some sort.  Try using an I32 and other representations to find the right data type.  You can then use Not Equal to 0 to turn the number into a boolean.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 31
(10,189 Views)

Ok we will try that on Monday.

But we are sure of looking at the right Variant to data block because when the error message appears the block is highlighted.

0 Kudos
Message 8 of 31
(10,185 Views)
Solution
Accepted by topic author pgo1

Also, you really should be supplying the data type when converting from a variant.  There is an input on the top of the Variant to Data node for Type.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 31
(10,181 Views)

Hello Crossrulz,

 

That's also what I was trying to ask them to do regarding the booleans:

"create a new true constant from the function palette and wire it to your type input (so that you are not depending on any autoresolving things)?"

Normally this should give the same error.

 

Thank you for elaborating on this with relation to integers so that they will always try to wire the type input.

Kind Regards,
Thierry C - CLA, CTA - Senior R&D Engineer (Former Support Engineer) - National Instruments
If someone helped you, let them know. Mark as solved and/or give a kudo. 😉
0 Kudos
Message 10 of 31
(10,157 Views)