LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how can I temporarily store or keep a counter input value

Solved!
Go to solution

Hi, I am evaluating labview and for this I’m trying to build one of my projects in labview. I use a USB-6211 module for data acquisition and to control a few relays. The data acquisition is working great, the control of the relays is working fine but I’m having difficulty’s finding a way to temporarily store the value of a counter input and I was wondering if someone on this forum could help me out.  

 

What I’m trying to do is the following:

I have a relay to control a pump and a flowmeter to measure how much fluid is pumped into the system. On the frontpanel I have a numeric control and when a value is entered I want to temporarily store the value of the flowmeter counter, add the value from the numeric control and then activate the pump. When the value of the flowmeter counter reaches the calculated value (old_flowmeter count+value numeric control), I want to stop the pump, reset the value on the front panel and wait until a new value is entered etc. A next step will be that the input value will not be entered manually on the front panel but calculated based on some other inputs (pressure and temperature).

 

I have done a search on this forum but I’m unable to find a way to temporarily store or keep keep the value of the flowmeter counter and a way to reset the value entered on the frontpanel (but I haven’t give this very much attention yet). I could really use some help on these issues.

 

I would really appreciate it if someone could help me out, thank you for your time and looking forward to your response.

 

Kind regards, Martin 

0 Kudos
Message 1 of 14
(4,029 Views)

Off the bat, I would say that storing the flowmeter counter could be done with a couple of different methods, a shift register (preferred), or if there is only one writer (to avoid race conditions), you could use a local variable.

 

It would make it easier to help you if you code post your code.

0 Kudos
Message 2 of 14
(4,027 Views)

Shift register is the key. 🙂

 

Since you most probably have a loop in your program you can add a shift register which'll keep information between loops, if you have several to keep track of, make it a cluster.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 14
(4,005 Views)

This part of the code is not very impressive I’m afraid, I have made a separate vi for experiments with the counter and because those where not a success I have removed them from the code.

 

Among other attempts I have tried a separate loop with a case statement and a shift register but I could not get it to work. I will take a closer look at the shift register but so far I have only used it to return the output value to the input for a thermostat with hysteresis and at this point it is not clear to me how I can store the value of counter input with a shift register.

 

If you have more information on how to store the value with a shift register to help me on the way it would be appreciated. 

0 Kudos
Message 4 of 14
(3,998 Views)

Do you have some details on how -keeping informartion between- loops works, how do I set this up?  

0 Kudos
Message 5 of 14
(3,994 Views)

This'll get you going.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
Message 6 of 14
(3,991 Views)
Solution
Accepted by Siddy

Actually, that won't work as the value for the shift register is not being pushed through in the timeout case.

 

Here is a revised version.

Message 7 of 14
(3,984 Views)

Yeah, it was a bit too fast. 🙂

 

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 8 of 14
(3,981 Views)

i'll give it a try. First to see if it works and second if i can understand how it works. Thanks and ill get back to you!

0 Kudos
Message 9 of 14
(3,973 Views)

A shift register simply returns to the beginning of the loop the value that was programmed in during the loop. If you simply pass the value from left to right (wire the two shift points together), you will get the same value each iteration of the loop.

 

In the example code, the shift register gets a new value when the count is changed in the numeric (the value is the most recent flowmeter count + user input) and the pump is turned on. In the timeout case, the pump will remain on until the current flowmeter count exceeds the value from the shift register.

 

And the reset of the numeric was omitted. You can fix that by using the "Value" property node.

0 Kudos
Message 10 of 14
(3,966 Views)