LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case Structure Not Working as Expected

Solved!
Go to solution

I have a Labview VI that is not acting as it should and I'm hoping someone can point out my error, I'm sorry, I can't seem to see it.

 

I would like to assign a different value to 10 individual voltage rails. Each assigned voltage rail could be one of 11 different inputs.

 

1. It could be one of the 8 measured inputs

2. It could be a fixed voltage of 3.3V, 5V or 12V.

 

So, in the example below, I would like to assign Rail 0 to Rail 1, Rail 1 to 3.3V, Rail 2 to Rail 3 and so on

 

RodWatt208_0-1749547529194.png

 

When I run the code, all the assigned rails seem to be determined by what every value I have in the last option. In this case, everything is assigned to what rail 9 is set to of 12V.

I'm assuming I am messing up the indexing.

 

VI attached.

 

Any pointers would be much appreciated thanks

Rod

0 Kudos
Message 1 of 7
(346 Views)

Hi Rod,

 


@RodWatt208 wrote:

VI attached.

 

Any pointers would be much appreciated thanks


Please downconvert the VI before attaching (again) so more people can actually open the code.

Most prefer LV2021 or older, I prefer LV2019…

 


@RodWatt208 wrote:

When I run the code, all the assigned rails seem to be determined by what every value I have in the last option. …

I'm assuming I am messing up the indexing.


Sound like the problem is in your code… 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(342 Views)
0 Kudos
Message 3 of 7
(332 Views)
Solution
Accepted by topic author RodWatt208

Hi Rod,

 


@RodWatt208 wrote:

Older version attached


Thanks.

 

Your VI does EXACTLY what you have programmed to do!

(Apparently you want something different than what you programmed…)

 

The FOR loop executes for each "Rail Selector 2" item (or as many samples as there are in the waveforms).

The last loop iteration determines the content of those "Rail x - Assigned" indicators!

 

  • Why don't you use senseful indicator labels (instead of those "Y x" indicators)?
  • Why don't you resize the IndexArray function?
  • Why don't you cleanup your code?

 

Try something like this instead:

Do you REALLY want to index those sample arrays at the FOR loop???

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
0 Kudos
Message 4 of 7
(303 Views)

This post edited due to Forum issue

Seriously Interesting. Double post! Haven't seen that in years.   


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 7
(276 Views)

Interesting. 

 

I doubt that your understanding of the Case structure is your worst problem!  Let's look at the For Loop.

 

For Loops with Autoindexed inputs iterate exactly as many times as the number of elements in the LEAST populous autoindexed array.  You actually CAN wire an indicator to the INSIDE of the For Loop "N" block to read that Number. <HINT: do that!>  

 

@Gerd, I'd unbundle the y[]components out of the array of waveforms INSIDE the autoindexing For Loop......I think that that silly breakout before the loop will probably be a "Face-Palm" correction for the OP.

 

NOTE: the number of Waveforms is definitely contained within the DAQmx Task as intrgal to all measurements of interest.  Explicitly indexing individual Waveform y arrays then looping over each y element is seldom RIGHT. I suspect one of the Waveforms indexed before the loop is empty ( default data with a 0 element y array leading to a 0 iteration For Loop - facepalmable)

 

Worse,  the DAQmx Task could have DACMxScales applied for each Channel .... making all of the gyrations after acquisition moot.


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 7
(272 Views)

Thank you GerdW, that worked as I intended.

0 Kudos
Message 7 of 7
(241 Views)