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

@Hasham622x wrote:

sorry, my bad data is in 12-bit format 0 to 3000 


There is no 12 bit datatype, but it seems to arrive as U16, even if not all bits are actually used. (12 bits allows 4096 different values)

 

I have asked you many times to attach a simple string as received, why don't you. Run your VI until "buffer" displays valid data. Stop the VI. Right-click the buffer terminal and "create constant". Copy that constant to a new VI and attach it here (LabVIEW 2020 or below).

Message 41 of 61
(610 Views)

Hi,

 

Thanks for your reply,

 

I attached old version of code.

 

Kind regards

Hasham

0 Kudos
Message 42 of 61
(590 Views)

Hi,

 

Thanks for your reply. if you don't mind, could you please guide me as I did not get these points as I am not good in selecting appropriate subVIs and trying my best to learn them.

  1. Place the averaging code in a subVI, with a 2D array input and a 1D array output.

so, it means the averaging part remains outside of the main while the loop 

 

  1. Run your mainVI, have the subVI open while running.

How I could run both VIs 

 

  1. After stopping the mainVI you set all values in your subVI as default and save the subVI.

please guide..

  1. Attach the subVI so we can debug it…
0 Kudos
Message 43 of 61
(584 Views)

@altenbach wrote:
  • Why do you think you need three autoindexing output tunnels and three transpose arrays instead of branching after the transpose operation?
  • Why do you have terminals with no labels? It is a bad habit to set labels to an empty string. You can always show the caption or hide the label on the front panel, but they need to show in the diagram to avid confusion!
  • Taking the array sum of U16 can easily overflow (wraparound), so don't do that! The solution with the mean is all you need.
  • In what way is the result wrong? Is the U32 data correct? Maybe you have the wrong byte order?
  • Please use my technique! 80% less code and easier to maintain and debug.
  • Autoindexing on a while loop output can be problematic, because you will run out of memory if the program runs forever. Also, if you abort the VI (instead of correctly stopping the loop), all data is lost forever!
  • Please do not maximize the front panel to the screen. Super annoying!
  • Do a few more basic tutorial and simplify, simplify!
  • etc. etc.
  •  

As an example, let's have a look at your inner loop. All three produce the same output, but some versions are arguably simpler!

 

altenbach_0-1720052316347.png

 

 


I'll take a stab at some of your questions.
Some of my former cow-orkers either couldn't, or wouldn't bother to, think things through.
Their approach seemed to be to semi-randomly toss something together, then hack at it until it worked. And that was the only thing they cared about; nothing else mattered.
They never had any interest in learning anything unless it would solve an immediate problem.
One of them would produce code so twisted and convoluted that I wondered if he had a psych problem (schizophrenia? psychosis? psychopathy?). I kind-of lean toward psychopathy because at a personal level, he seemed normal.

Message 44 of 61
(580 Views)

Hi Hasham,

 


@Hasham622x wrote:

so, it means the averaging part remains outside of the main while the loop 

How I could run both VIs 

please guide..


As you have problems doing basic steps in LabVIEW I recommend you start with Training courses offered at the top of the LabVIEW board!

Proceed with your VI once you have done those courses…

 

Creating/using subVIs and setting default values is VERY basic LabVIEW stuff!

Best regards,
GerdW


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

@Hasham622x wrote:
  1. Attach the subVI so we can debug it…

You now attached three different VIs, all with exactly the same file name. Trying to sort out your attachments is like herding cats. I won't be sorting through all that to see what the differences are and what could possibly the one we are supposed to look at. You need to keep your ducks in a row and never attach the same VI twice and give each attachment a unique name so we can immediately see what's newest.

Message 46 of 61
(571 Views)

Hi,

 

Thanks for your reply. I attached the same code with the 2020 and 2019 older versions.

0 Kudos
Message 47 of 61
(555 Views)

Hi,

 

First of all, thanks for the guidance. I tried both options to simplify the code. A Simpler approach is working, and the best approach, unflatten/flatten sub VI based, is not working in which I am making any wrong connection within a FOR loop / conditional loop due to that it is giving only for columns of an array whose all values are zeros.

I attached both codes (LV19) with this message.

 

Kind regards

Hasham 

Hasham622x_0-1720669694442.png

Hasham622x_1-1720669720889.png

 

 

Download All
0 Kudos
Message 48 of 61
(524 Views)

Hi,

 

First of all, thanks for the guidance. I tried both options to simplify the code. A Simpler approach is working, and the best approach, unflatten/flatten subVI based, is not working in which I am making any wrong connection within a FOR loop / conditional loop because it is giving only for columns of an array whose all values are zeros.

I attached both codes (LV19) with this message.

 

Kind regards

Hasham 

Hasham622x_0-1720669694442.png

Hasham622x_1-1720669720889.png

Download All
0 Kudos
Message 49 of 61
(523 Views)

Your code is still completely wrong. Why would you use a FOR loop to do the exact same operation 16x in a row and using a shift register where you never read from it?

 

altenbach_0-1720813431818.png

 

Nobody ever told you to unflatten to a 1D DBL array. My example had a 1D U16 array as type, right? And why would you convert your string to a byte array just to convert it back to a string (16 times!!!) a nanosecond later???

 

You need to go back to the basic tutorials and understand the difference between datatypes. We are not getting anywhere.

Message 50 of 61
(506 Views)