LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Case structure default

Solved!
Go to solution

My entire code is in a while loop with a 100 ms  clock. My code uses a feedback control to set temperature, This takes a few iterations. Once the temperature sets, I need to acquire a value and store it. I am doing this using a case structure followed by shift registers. The problem is that the case structure outputs the read value to the shift register for true case, but in false case I am forced to make it read default value (0). This is just completely erasing my registers due to the iterations when temperature is being set. Is there a better solution to this?

0 Kudos
Message 1 of 12
(5,141 Views)

You aren't forced to do anything.  Right-click the output tunnel and deselect the "Use Default if Unwired."

 

If you want to keep the old value, just wire it straight through from the input to the output.  Then, the old value will last through the false case.

 

Quick edit:  Change to shift registers instead of feedback to get the easy ability to wire through.

Message 2 of 12
(5,138 Views)

If I deselect the option, it gives me a broken arrow. Is it because it is a subVI? 

 

Also, I do not want to feed through during false condition. I need to not store any values. 

 

Essentially, I need to set 6 different temperatures, wait for it to set and at each temp, get a voltage reading. But with the default, between two set temperatures, it is reading 0s.

0 Kudos
Message 3 of 12
(5,126 Views)

It breaks because you're not giving it an output.  This means the next point in that wire will never receive an input.  This breaks data flow and your VI would hang infinitely if it was allowed to run.

 

Here's what we need to figure out.  What do you want to happen during a false case, exactly?  What do you want to happen in a true case, exactly?  If you're using feedback or shift registers, you need to put something into that space.  What data structure do you want?  Do you only want to read six data points?  If so, throw an array onto a shift register and add the element inside the true case.  Wire it straight through the false case.  This means nothing gets added to it in this case.  In the true case, it grows by one.

 

Really, if you show your code or describe what it is you're trying to do with more detail, it'll make it easier to help you.

Message 4 of 12
(5,121 Views)

If you want to retain the current value in the false case, you need to wire the value across unchanged.

Message 5 of 12
(5,113 Views)

My project involves setting a temperature difference across a sample. I have set up temperature measurements and a simple control loop using the measured temperature to make it reach set temperature from the room temperature. Now, my experiment is that I need to vary temperature difference across the sample and measure parameters. So, like I said, I have managed setting temperature. But that takes some time to set. The whole setup is within a single while loop with 100ms delay. Once it has set, I have gievn a case statement with a condition that the measured temperature is within 0.05 degrees of set temperature. Once the condition is satisfied, I pass the value through the case structure onto the shift register (on the outer while loop). The shift register has 6 register which are intended to store the 6 values at 6 different delta T. The values stored in these registers are then passed into a 6 element 1D array. This array is then plotted against the another array. But, because I use the default condition, I am feeding 0 to the same shift register, which I don't want to do. These zeroes are flushing out my stored values. 

 

Your idea to add an array to the shift register which adds element in true case seems like a good option. But will I be able to take the array element out of the case structure after the array is completed/all 6 values are stored? 

 

Thank you for your help

0 Kudos
Message 6 of 12
(5,106 Views)

When I feed the input through to the output for false case, will it not overwrite my shift register? 

0 Kudos
Message 7 of 12
(5,105 Views)

@Vishwaramesh wrote:

When I feed the input through to the output for false case, will it not overwrite my shift register? 


No. It will retain the current value in the shift register.

Message 8 of 12
(5,101 Views)

Sorry but I am a bit unclear. I feed it to a string of 6 registers (I don't know how to say it. I have one upward arrow register in the right with 6 downward arrows in the left of the loop.)

 

So now, in false case, if I feed through 4, and in my previous true case I stored say 5 wouldn't the 5 move down the register chain and after 6 iterations of the loop be erased? 

 

My code runs continuously in between two set temperatures when the control loop is slowly incrementing the temperature. 

0 Kudos
Message 9 of 12
(5,096 Views)

@Vishwaramesh wrote:

 

Your idea to add an array to the shift register which adds element in true case seems like a good option. But will I be able to take the array element out of the case structure after the array is completed/all 6 values are stored? 

 

Thank you for your help


When you leave the loop, whatever is on the shift register can be wired out.  Just use some basic logic to stop the aquisition loop once you have the 6 data points you desire.

 

If you wire the data from the left shift register to the right shift register, will it overwrite?  Technically, yes.  But, do we really care?  Let's say the shift register is an integer (just for ease).  If the left has a value of 3 and we wire this into the right, the right now has a value of 3.  Has it been overwritten?  Yes.  Has the value changed?  No.  That's why you move the logic to add the element within the True case.  If the logic is inside the True case, you don't need to add anything from the False case.

Message 10 of 12
(5,094 Views)