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: 

LabView, Storing in array some dynamics variables (ENG - FR)

Solved!
Go to solution

Nice work.  That VI looks a lot better.  A single loop, clearer definition of the states, shift registers that will hold data between iterations.  I think you'll find your new VI will be a lot easier to work with and modify whenever you will need to add more actions to the VI in the future.

0 Kudos
Message 11 of 19
(769 Views)

This is not really a state machine, but overall looks somewhat better. There are still quite a few things that could be improved.

 

Does nbmesures typically change during the execution of the inner loop? If not, you should use a FOR loop there.

 

The way you wrap the phase to 0..360 using a FOR loop and case structure is a bit convoluted. (If you are autoindexing, you also should not wire N). Here's an alternative that does exactly the same things with one little operation, try it.

 

 

 

Instead of "insert into array" you should probably use a simple "build array".

 

Accumulating large amounts of data in concatenating tunnels, just to take the mean at the end is wasteful in terms of memory use. All you need to do is take a ptbypt mean inside the inner loop.

 

I am not sure why you are building a 2D string array. A 2D DBL array would serve the same purpose and would eliminate all these formatting operations. You can specify a format at "write to spreadsheet file".

 

....

0 Kudos
Message 12 of 19
(765 Views)

Yes, this VI is much pretty to read.

 

It's not really a state machine because I need to do myself some adjustements before doing a real state machine.

 

alenbach, your alternative is close to mine in result but i don't think it does what I want : When the phases differences is close to 0° , some values are -359° and some are 1° so I "return" thoses who are negative.

 

For the WHILE transform to FOR , I will see in the futur.

 

Yes, it's way better only with DBL array.  But I haven't found the ptbypt bloc ..

0 Kudos
Message 13 of 19
(751 Views)

MaxLamb wrote:

alenbach, your alternative is close to mine in result but i don't think it does what I want : When the phases differences is close to 0° , some values are -359° and some are 1° so I "return" thoses who are negative.


What do you mean by "return"? The two codes shown in my picture are equivalent when dealing withe the phase output you get from the subVI. Did you modify your code? (The code differ if you are dealing with higher of multiples of 360. Mine always wraps into the 0...360 range.

 


MaxLamb wrote:

Yes, it's way better only with DBL array.  But I haven't found the ptbypt bloc ..



The ptbypt mean is in the signal processing palette

 

 

0 Kudos
Message 14 of 19
(744 Views)

First , thank you a lot for your help ! 🙂

 

When I acquire thoses two signals, I calculate the phase difference and I have some values like this :

 

[1.35 ; 1.07 ; 1.27 ; -358.76 ; 1.16 ; ... ]

 

So I do :

 

1.35 -> (nothing) -> 1.35

1.07-> (nothing) -> 1.07

-358.76 -> (+360) -> 1.24

 

Like this my mean will be : 1.35 + 1.07 + 1.27 + 1.24 + 1.16 * 1/n

and this is not equal to : 1.35 + 1.07 + 1.27 + (-358.76) + 1.16 * 1/n

0 Kudos
Message 15 of 19
(719 Views)

@MaxLamb wrote:

....So I do :

 

1.35 -> (nothing) -> 1.35

1.07-> (nothing) -> 1.07

-358.76 -> (+360) -> 1.24


Well, My code does exactly the same, but with much less effort and code (no FOR loop, no boolean arrays, no autoindexing, no case structures, etc...)

 

Have you tried it? It's magic! 😄

 

 

0 Kudos
Message 16 of 19
(714 Views)

It was my fault , I had wire the y after the x so the constant was an array. But by setting y before x it works well.

 

I got a problem with the ptbypt mean , when I wire it, it say that I can't wire a 2D array to the ptbypt bloc (The array come from "Extract Single Tone Information.vi"

0 Kudos
Message 17 of 19
(704 Views)
Solution
Accepted by topic author MaxLamb

The ptbypt Vi requires a scalar at a time. If the 1D array is always the same lenght, you could just add a regular mean before it (taking the ptbypt mean of the mean of each acquisition result).

Message 18 of 19
(689 Views)

So now my VI works well, he need to be change into a true state machine at the end but now is fine.

 

I have an other question and I don't know if I have to create a new topic :

 

How can I Generate and Aquire some signals in the same Loop ?

- Generate 2 sine

- Aquire 6 signals

 

I use a DAQ USB X-Series 6356

0 Kudos
Message 19 of 19
(669 Views)