LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

one mean value out of a spreadsheet file

Hi there!

I'm desperately trying to get just one mean value out of one row of numbers in a spreadsheet file and write it to a text file when I'm pushing the button.

The process himself works pretty fine, but it alway writes many numbers at once down, and I need only one single mean value of these numbers.

I already tried different loops and mean.vi's but it's alway the same: way too much values.

So I hope someone can help me with this, because I'm already trying since two days...

 

 

0 Kudos
Message 1 of 7
(3,100 Views)

Hi once again,

 

I think the problem is the timing of the button I use to activate the case-loop. If i adjust is as latch when pressed, no data is written. And if I adjust it as latch when released, too much data is written. With a timer activating the case-loop, also nothing is written down.

So, is it possible to adjust the timing of a button or the timing of the case-loop? Because I think I can solve this problem through adjusting the time, so it can write down just value.

 

best,

philsen

0 Kudos
Message 2 of 7
(3,090 Views)
No, you cannot adjust the "timing" of a button from LabVIEW. That's an OS thing. You can adjust the timing of a loop by simply putting in a Wait function. However, the correct solution is to use an event structure. It will work much better and be consistent.
0 Kudos
Message 3 of 7
(3,084 Views)
Either a Latch When Pressed or Latched When Released will work and both will cause only a single file to be written with a single press of the Boolean. If it doesn't, then your Boolean is some other switch action. You are not showing the rest of your VI but I would assume it's inside a while loop. If you have problems with this code, post the entire VI as a VI, not an image so that it can be looked at.
Message 4 of 7
(3,079 Views)

Hi!

 

first of all, thanks for your reply, because I was already despairing!

Currently I'm working with the event-loop. It's really not simple, but I think I can handle it. 

I'm a newbie, and this is why I didn't post my whole vi. But if it's possibly helpful, I'll attach it now.

Do I need the Register for Event.vi to activate the event-loop with the Create Mean Button? Because now my whole program isn't working properly...

 

thanks in advance,

philsen

0 Kudos
Message 5 of 7
(3,067 Views)

You have several problems with your VI, most of which stem from not understanding dataflow programming. Note that all of this can be found out if you simply run the code with highlight turned on.

 

  • What is the purpose of having the string concatenation in the bottom left to be inside the loop? Are you trying to get a string that's based on the time when the loop ended
  • The "path 1" indicator will not have a value until the loop ends. This is because the tunnel's value cannot be set until the loop ends. This means that you trying to use the local variable of "path 1" will never work.
  • You have a fundamental logic error with "path 2". This value is not set unless the time elapsed. However, you try to use it regardless of whether it's set since its use is dependent only on whether you press the "Create Mean" button, which can happen at any time.
  • You are not using the event structure correctly. With no timeout event your event structure will block the loop. This means the rest of the code inside the loop will run once, and then the whole loop will wait until an event is triggered, which is what the event structure is waiting for. 
  • When you have a Boolean control with a "Latch" operation you should place the Boolean control inside the case handling the Value Change event so the Boolean can be reset.
  • It's not clear whether you are intending this "Create Mean" to act as a single-action operation, as in "create the mean now, and just once", or whether it's more like a switch, as in "log the mean while the switch is on". This will dictate the proper operation (latch or switch) of the control. If a switch operation is more applicable, then you shouldn't use an event structure.
Message 6 of 7
(3,058 Views)

thanks smercurio for you'r detailed answer!

1. the purpose of the string concatenation in the bottom left is, that with this I'm writing the header of the final file I want to get. The vi get's every half second a value, writes it down, and when the Create Measure Button is pressed, the mean value of these values is written into the final file. Later on there will be the time added with every push of the button.

2. I know the solution with te paths isn't the best, but at the moment it's working... and maybe I can handle the problem with path1 also with an event-structure

3. This Create Mean action is intended to work as a single operation every time I push the button. And this will be several times, but in undefined time intervals. So I think using the button as a latch should be appropriate.

 

right now I'm figuring out how the use the event structure correctly, but maybe later I will have some further questions... But first of all I'm very grateful for your help, because I think it was the hint I didn't have!

0 Kudos
Message 7 of 7
(3,037 Views)