LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview case structure - can't get decimal out from the structure

Hello

 

I read current from NI 9208 (in A). I multiply it by 1000 to get mA and send it to the code you see below. I want the case structure to run when I have more than 4 mA. If I don't, I want the FT04 (indicator) to show 0 (the false case just got a 0 constant wired to the FT04). The code does what I want, but I can't seem to get decimal numbers out to FT04 (indicator). I get 15 instead of 15,4 (just an example). Am I missing something?

 

 

Skjermbilde.PNG

 

 

0 Kudos
Message 1 of 7
(3,653 Views)

Who knows what could be happening with that Dynamic Data Type.  Can you show more of your code?



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 7
(3,650 Views)

Yes of course I can. Wasnt sue how much I needed to show you.

 

Skjermbilde.PNG

 

Don't mind all the other wires going down. It just other signals from DAQ assisstant. All of them goes to different case structures.

 

1. Mulitply by 1000

2. Check if its over or under 4

3. Substract 4 and multiply by 6,25

4. Sends it to the indicator.

 

I tried to set a indicator inside the case structure. And it showed decimal numbers. But the one outside of the structure wont. The indicator placed inside the structure were a cope of the one outside.

0 Kudos
Message 3 of 7
(3,645 Views)

Hi ojb,

 

check your wires!

 

After the case structure you have a thin blue wire, which denotes any type of (scalar) integer. You will never ever get decimals from an integer…

 

Btw. there are a lot of coercion dots: they all have a purpose/reason!

 

Wasnt sue how much I needed to show you.

To comment this sentence: You need to show that other case too…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 7
(3,640 Views)

Thanks. I figured out the problem. The false case was the problem. The 0 were not a double, didn't  think it would matter. But it did I guess...

 

Next time I will post everything. I have learned my lesson.

 

Thanks again! 

0 Kudos
Message 5 of 7
(3,629 Views)

Plenty has been written here about not using DAQ Assistant and Dynamic Wires.  They hide too many details and ultimately take control away from you, the (Virtual) Instrument Designer.  It appears, here, that the DAQ Assistant has set the data type as Integer (probably I32, but possibly I16) and has wired this into the Dynamic wire.  Usually when you multiply an Integer by a Float, you not only get a Coercion dot (the red dot on an input) telling you one input's type has been coerced (or "forcibly convert") to another type, but it is the Integer being coerced to Float, so the answer becomes Float.  Here, you'll notice, the Float is being coerced (to Integer), so you are really not multiplying by 6.25, but by 6.

 

Get rid of the DAQ Assistant (read this White Paper) and bring your data out as "regular wires".  Now, if you specified I16 outputs (because that is what your device produces), the coercion when you multiply by 6.25 will coerce to a Float, and you'll get the "answer you expect" (instead of "the answer you asked for" with the Dynamic Wires).

 

Bob Schor

0 Kudos
Message 6 of 7
(3,625 Views)
You were half right. If the wires had been floats, LabVIEW would have coreced it to a float. But you were instead using dynamic datatype wire so LabVIEW didn't know what the data was supposed to be so it look to the one place in the snippet where you said what the wire should be - the integer constant.

Changing that datatype may cause the code to give you the results you expected, but it did not fix it. The real fix is to not use express VIs or the dynamic datatype wires they utilize.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 7 of 7
(3,622 Views)