From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Storing a temperary value!

Dear Labview experts,
                                 I am new to Labview and I donot know much tricks. I have the following problem. I am using DAQmx card to acquire voltage from a IR receiver board. The output of this board varies for a small period of time due to the variation at the input. I can trace this change by delaying the signal and comparing with the current value of the voltage and then I use logical comparision to decide I have change(1) or no change(0). I can see the signal change  but I want to store the value to control another while loop. Meaning when I get 1 the while loop must stop execution.
 
For storing the value I tried by adding this value with the feedback loop. But I do not see any value at the output of the adder I always see 0. Where am I making mistake? please help me to solve this problem.  Any idea would be much helpful.
 
Advanced Thanks for the users.
 
0 Kudos
Message 1 of 9
(3,074 Views)

Suggesting a solution might be easier if you attached the vi you are working on...

You can right click on the side of your while loop and add a 'shift register'. It places a node on each side of the while loop, the right side to store newly acquired data in, the left side to retrieve the previous iterations data (or the initialized value for the first iteration).

If you want to detect a change in data and use that result to stop another while loop you can use a 'local variable' in the second loop to read the data written to an indicator inside the first loop.

There are probably are number of ways to achieve the functionality you desire without using local variables but without more information on the way your vi functions it is hard to guess at a solution. (Many in this forum recommend avoiding the use of local variables for a number of reasons including performance.)

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 2 of 9
(3,045 Views)

Hi Troy,

     THank you so much for your immediate reply. THat day I tried attaching my VI but unfortunately it was not attached. I am attaching the vi here. You see the first while loop from which I generate the the value to stop the 2nd while loop(top). Could you please help me out how to  solve this problem.

0 Kudos
Message 3 of 9
(3,000 Views)

I don't think this vi is working the way you want it to. You have three while loops. The problem is that the second two loops can not start until the one before it finishes (due to data flow).

I think you need to have everything in one loop to get the functionality you are aiming for (there are other ways to do it but we will keep it simple for now). Then, each time the loop cycles, you take a reading, compare it to the previous measurement (for your change detection) and send out data to your serial device accordingly.

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 4 of 9
(2,988 Views)

Hi Troy,

        I tried putting all the while loop in one while loop (meaning 3 while loops inside one while loop) and tried. Even then I couldnt see the vi working correctly as the way I want. Do you mean puttin all in only one VI? COuld you please suggest a way? I am really novice and I want to do this correctly.

Best Regards,

Maya

0 Kudos
Message 5 of 9
(2,980 Views)

Hi Troy,

        I even tried putting all the control in one while loop and tried. But the temperary value fromtop section is not stored by the adder with feedback to stop the while loop compleately. The temperary value appears for few seconds and this should be used to stop the whole process.

Am i making any mistakes here? how do i do it ? waiting for your responce.

 

Maya.

0 Kudos
Message 6 of 9
(2,968 Views)
I have no idea what happens when you wire a dynamic data type to a while loop's conditional terminal. Especially the results of an addtion. I try to avoid dynamic data whenever possible and I would suggest you convert the dynamic data to something known instead of letting LabVIEW do the conversion for you. In other words, you want a true or false wired to the conditional terminal.
0 Kudos
Message 7 of 9
(2,961 Views)
I wondered about that, too (numeric dynamic data to the loop termination). The top and bottom halves of the program have no data dependency other than being in the same loop. The initialization and closing of the serial port should be outside the loop rather than repeating every time the loop iterates.

Your string constants "R1" and the "" inside the case structure will NOT send carriage returns to your device! Either use the carriage return constant on the string palette or set the constants for '\' Display and type in "\r" (without the quotes).

Left to right wiring and a lot of clean up would make it much easier to see what is going on.

Lynn
0 Kudos
Message 8 of 9
(2,950 Views)
Hi,
   Yes thats my problem. I need to control the whole system based on the change in input which happens only for a short while. I made the changes you suggested ( like changing my serial connections outside the loops and changing my dynamic data to boolean). But I could not  see the loop termination based on the input variation.
 
 How can I use a temperary variable to control the whole process?  I want to store the change, thats why I am adding the value with feed back. This gives me output either 1 or 0. and I want to stop the loop when I get 1.
 
YOur suggestions would be great!
 
 
0 Kudos
Message 9 of 9
(2,911 Views)