LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update a value when push button is pressed

Solved!
Go to solution

Hi all,

 

Fairly new to Labview.

I'm taking voltage readings from a load cell and trying to use that to measure weights.

 

I've calibrated the scale to identify my scale's sensitivity (in V/g) to convert the sampled voltage value to output the weight.

 

The issue I'm having is, my calibration for 0g is hard set to a specific voltage value (0 V). However, when I run LabView, my NI-DAQ doesn't always read a zero load situation as 0 V, it will be offset by a certain amount up or down. 


I'm trying to create a LabView VI that responds to a Push Button on the block diagram. What I'd like is that when this PB is pressed, LabView will update my zero loading value to the current reading. This way, I don't have to manually update the zero offset every time I run the program.

 

I'm fairly well versed with software development, and this normally wouldn't be challenging on a traditional language, but I'm having trouble how to execute this with LabView. I presume I want to set the zero loading value into a variable and the PB should call for a function that updates the variable to the current reading. Can someone point me in the right direction? 

0 Kudos
Message 1 of 6
(5,261 Views)

Without seeing exactly how you program looks, assuming you are "constantly" reading the scale value, all you need to do is, when the button is pressed (latch), store that offset value into a shift register.  Your final value should then be the reading less the offset.

0 Kudos
Message 2 of 6
(5,249 Views)

Well, in most cases when you want something to happen when you press a button, start with an Event structure in a while loop and go from there.

0 Kudos
Message 3 of 6
(5,248 Views)

Hi! Thanks for replying. Please take it slow, I'm still learning. Can you clarify what you're asking to do? I've updated the original post with screenshots.

0 Kudos
Message 4 of 6
(5,224 Views)

Hi! Thanks for your reply. What you've suggested actually makes a lot of sense.

Here is what I've done.

 

I created an event structure that responds to the PB being latched. What I want it to do is read the average value into a variable and that's the variable I submit into my formula node as input z. 

 

Currently, the issue is that I've created a test variable that stores the average value when the event is triggered. This test variable is what feeds the z input in the formula node. But, when I set the test variable to write, I'm getting an error that the test variable in an input, not an output. If I set it to read, then it acts as an output, but it gives weird values for my y-output of the formula node.

 

What gives?

0 Kudos
Message 5 of 6
(5,222 Views)
Solution
Accepted by mmotiwala

In this situation, I would actually advice against the Event Structure.  You can handle it all with just a single loop.

1. Turn your Set Zero button to an actual button that latches.

2. Store the "zero" offset in a shift register.  You can use a Select function to choose between the current value or the stored value.  Update the shift register with the selected value.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 6
(5,211 Views)