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: 

Seeds sorting using size and array... NEED HELP!

I am new and learning LabVIEW. I'm trying to make a program that will run for 20 iterations. Here 20 are the seed that needs to be separated between normal size and abnormal size. 'Numeric2' where I will set the size such as 2.5 mm. So, if greater than 2.5 the seed is normal and the counter will count it. similar, if false then the counter will count the abnormal seeds. I need to export both data on an excel sheet.

saadtariq16_0-1646743414824.png

 

0 Kudos
Message 1 of 9
(940 Views)

First thing: The random number returns numbers between 0 and 1. So they're all going to be below 2.5.

You mention "mm" but I'm not sure how you propose applying units to your control. "Numeric 2" doesn't tell us if it's in "mm" or "m". This is important. Because with 0.025 your code may work, with 2.5 it won't.

 

Aside from that, you are re-initialising your counter to zero on each of the 20 iterations. This will cause each of your 20 iterations to start a loop running until you press the "stop" button. This results in each of the 20 iterations each having a variable number of iterations themselves. That may be what you're looking for, but it sounds wrong to me.

 

Maybe try getting rid of the while loop altogether and initialising the shift register on the left-side of the FOR loop instead.

0 Kudos
Message 2 of 9
(924 Views)

Thanks for replying...

I followed your steps and removed the while loop. Now, the program works but only abnormal values are counted. While my focus is to get more normal seeds in the counter than abnormal.

Can anyone show me the use array to collect both counter's data and export an MS excel file?

0 Kudos
Message 3 of 9
(911 Views)

Have you tried running your code with execution highlighting active?

Message 4 of 9
(905 Views)

You will need a shift register to keep your "normal" count and another shift register to keep your "abnormal" count.  I would also move the indicators to be after the FOR loop has ran.


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 5 of 9
(901 Views)
  • Counts are integer. The should be no orange anywhere except at the random generator.
  • All you need is one loop. If you only have 20 seeds, why is there an inner loop?
  • We cannot debug pictures, especially if most of the code is hidden. Attach your code if you want help.
  • You either need counters for normal and one for abnormal or just for one of those, because the balance can be calculated from [i], which is the sum of both. Or you could use an array of two elements in the shift register.
  • Running the inner loop with a 2000ms wait is quite boring.
  • What's the purpose of the outside wait??? It runs in parallel to the rest of the code and thus does absolutely nothing because it is faster.
  • "Numeric 2" control should not be inside the loop unless you allow the user to change it during the run, which would make all results unpredictable. The control probably belongs outside the loops.
  • I can think of better labels than "Numeric" and "Numeric 2"...
  • So you want to write the two final values to a file. Why excel?
  • ...
Message 6 of 9
(885 Views)

I want to use an array for both elements but I don't know how to.

It just can be a .txt file...

Sorry, I should've attached the file earlier.

0 Kudos
Message 7 of 9
(840 Views)

Can you please fix my code? Leave the output export. I want to try that myself...

Thanks

0 Kudos
Message 8 of 9
(816 Views)

@saadtariq16 wrote:

Can you please fix my code? Leave the output export. I want to try that myself...

Thanks


Could you at least show some effort?  You were given a bunch of advice and you didn't even try to implement them.  We are volunteers who are here to help, not do your work for you.


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 9 of 9
(789 Views)