LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need guidance in getting data from condition and while loop

Solved!
Go to solution

Hi,

 

Yes, you are right; it was my mistake to add a FOR loop. With the help of guidance and suggestions shared by all, now, my code is working fine. I attached the code.

 

Kind regards

 

Hasham

 

 

 

0 Kudos
Message 51 of 61
(395 Views)

@Hasham622x wrote:

Hi,

 

Yes, you are right; it was my mistake to add a FOR loop. With the help of guidance and suggestions shared by all, now, my code is working fine. I attached the code.

 

Kind regards

 

Hasham

 

 

 


It doesn't look fine.  It looks like a mess.

Message 52 of 61
(388 Views)

You need to stop splattering the same ugly code all over the forum. You can always link to the other thread if needed.

Message 53 of 61
(379 Views)

Hi,

 

Thanks for your reply.

 

Could you please guide me on how I could make it neat and clean with the same working? I know I put time elapsed and same time average option then display and save average values in a separate file and also saved RAW data as well.

 

Kind regards

 

Hasham

0 Kudos
Message 54 of 61
(357 Views)

@Hasham622x wrote:

Hi,

 

Thanks for your reply.

 

Could you please guide me on how I could make it neat and clean with the same working?


The fact that you pose such a question means that you are incapable of seeing the messiness in your block diagram.  Which means that you will never be able to understand the concept of neat and clean code.

Message 55 of 61
(348 Views)

@Hasham622x wrote:

Could you please guide me on how I could make it neat and clean with the same working? I know I put time elapsed and same time average option then display and save average values in a separate file and also saved RAW data as well.


There is a cleanup button in the toolbar, and if you press it and the diagram gets worse, you have "clean code" in my definition (In your case is gets an order of magnitude cleaner, meaning it was a horrible hairball before!

 

altenbach_2-1721053446055.png

 

 

Here's your diagram and front panel, but I am sure you've seen it already. If you look up "messy diagram" on Wikipendia, you would probably find exactly this picture! 😄 If the number of wire bends is a very large multiple of the number of wires, something is wrong.

 

altenbach_0-1721052734428.png

 

In comparison, here's how it could look cleaned up:

 

altenbach_1-1721052920519.png

 

Here's how it could look (I don't have you serial stuff, so you need to again substitute that).

 

It is still not great to do file IO after the toplevel loop, because it will fail if the VI is aborted instead of stopped, but since you have all the non-averaged data saved, it can be reconstructed if needed.

Message 56 of 61
(340 Views)

Hi,

 

Thanks for your guidance and suggestions, and yes, you are right. My code is messy, and there are lots of wires of multiple colours that could confuse me. If you don't mind, could you please tell me if I want to run this same code by the FOR loop? I tried, and it was not working to execute the number of acquisitions for which I also put a separate post in this forum.

 

 

Kind regards

 

Hasham

0 Kudos
Message 57 of 61
(313 Views)

Hi,

 

Thanks for your reply I could neat and clean this code, but still, my code is not completed due to that I am not giving it a final look as still I need to introduce constant value which should subtract from all average values and then also average values should be subtracted from each other like average value1 - average value2, average value3 - average value4, average value5 - average value6, ...

 

then I will give it final look. So, if you don't mind, could you please guide me on how I could subtract a constant from all averages and subtract between these averages?

Kind regards

 

Hasham

0 Kudos
Message 58 of 61
(310 Views)

Hi Hasham,

 


@Hasham622x wrote:

how I could subtract a constant from all averages … ?


That is a very simple math operation, all you need is a subtract function and a constant…

 


@Hasham622x wrote:

and then also average values should be subtracted from each other like

average value1 - average value2,

average value3 - average value4,

average value5 - average value6, ...


Decimate your array of averages into two arrays, then subtract the 2nd array from the 1st…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 59 of 61
(300 Views)

Hi,

 

Sorry for disturbing you by controlling the while loop; I introduce a comparison function inside the loop, in which x represents required iterations and y starts from 0. As it reaches the required value, the loop will stop. Outside while loop from averages, first, subtract the same constant value from each average value, then subtract the average values like a veg Val1 - a veg Val2, .... Kindly please guide me if I am doing the correct stepping, or again I am making a mistake?

 

I also attached the LV code (LV19 version).

 

Kind regards

 

Hasham 

Hasham622x_0-1721475144299.png

0 Kudos
Message 60 of 61
(280 Views)