LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW case structure boolean case selector erratic function

Solved!
Go to solution

Hellow,

I In my VI there is a boolean selector (called measured values/Test values) meant to select between measured signals or test signals to be displayed on two indicators. I use a case loop for simply boolean "or" function to redirect the signal from a manually input test value or measured value to the indicator. The loop named Viscosity source selector works properly ( seeattached screen shoots in two modes: measurement and test). In measurement mode the signal at probe 4 (zero with some noise) is the same as probe 6 ("zero"), while manually input tst value is 1 at probe 5. But the caseloop called Temperature source selector does not work at all. In measurement mode the measured value is -40 at probe 3, but the output from the "or" function is "not executed" at probe 2 and "zero" at probe 7. In test mode the viscosity works properly too, the probe 5 is 1 and the probe 6 is 1 too. But the Temperature is even more weired: the probe 1 is 50, but probes 2 and 7 are -6.

Can you suggest me where to find my mistake? I attached my VI saved in 2017 version.

0 Kudos
Message 1 of 5
(173 Views)
  • The "OR" of two floating point values is not a defined operation and they will get coerced to an integer followed by a bitwise operation.
  • You only need a single case structure containing all code.
  • Please don't do "show terminals" on the OR function. That's confusing.
  • Don't do the "array to cluster...unbundle" dance if you could just use an index array.
  • When switch is true, the output will be zero, i.e. the default value for the datatype because the output tunnel is not wired.
  • Please don't maximize the front panel and diagram to the screen, that's just annoying.
0 Kudos
Message 2 of 5
(142 Views)
Solution
Accepted by topic author Pikey

See if making the two cases of the same case structure as follows gives the desired behavior:

 

altenbach_0-1753924086139.png

 

Message 3 of 5
(137 Views)

Before you try to put together a complex VI made from "pieces" of code lifted from pieces of the Example code that ships with LabVIEW, I recommend you do the following:

  1. Print out the Block Diagram from your Viscosity Test vi.
  2. Create a new LabVIEW Project (maybe call it "Viscosity Debug").
  3. Choose one channel (say the Viscosity Channel).
  4. Using your Printout as a reference, create the code that will read only the Viscosity Channel.  You might even choose to abandon the Example code, which assumes you know and understand how DAQmx works.  
    1. One suggestion, since you are so unfamiliar with LabVIEW and DAQmx, is to start by choosing the (Dreaded) DAQ Assistant.  [I generally dislike recommending the DAQ Assistant, which explains my initial "D" in calling it the DDA, but I don't think you are ready for full DAQmx].
    2. With the DAQ Assistant, you will be "walked through the process of considering all the "bits and pieces" you need to specify to get your one Channel properly set up.  
    3. Look up some examples (or search the Web) using the DDA.  You'll want to put it in a While Loop (with a Stop Button) and also put some form of visualization (maybe a Waveform Chart) to see if/how it works.  Of course, the DAQmx Stop and DAQmx Quit belong on the Error Line that comes out of the While Loop.
    4. Once you learn how to write DAQ code for one instrument, you can write similar code for a second instrument.  Try this second code "in isolation", and when you have two working inputs, try putting them in the same "Master" VI.
    5. Finally, when you get a "beginner" routine using the DDA to do one channel of I/O, you can (I think it's a Right-Click) get the DDA to expand itself and replace itself with the underlying DAQmx code.  Assuming the DDA code worked, you can compare the "revealed" DAQmx code with the relevant code in the VI you submitted and see if there are inputs or wires that you didn't pay attention to.  [Ooo, a dangling "to" -- ... or wires to which you didn't pay attention.]

     Writing your own code gets you to really look at and (hopefully) understand the various functions and operations on the Block Diagram palettes.  If you follow the exercise I suggested above, you might find some Parameters or wires that are missing.  Do try to keep your wires straight and horizontal (particularly the Error Line).  Try to make your code all fit on a single laptop screen -- being able to see all the code is a great boon in understanding the code (without having to slide the diagram left, right, up, down while trying to remember where the data are going.

 

Bob Schor

0 Kudos
Message 4 of 5
(132 Views)

Yes now it works. Many thanks for reminding. I completely misunderstoodd the Idea of the loop. I am a very beginner with a little experience dated on 2012 but I did not used LV since that time. Now I recall how this loop works. Thanks a lot for the help and advice regarding the Index Array too. Regards.

0 Kudos
Message 5 of 5
(67 Views)