LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I modify my code so that the count does not start with zero? (Read description and see code below)

Solved!
Go to solution

My Code:

GRCK5000_0-1663341240249.png

When I run my "code x-y*floor(x/y)" = 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3...

Note: I don't mind the rest of the zeros. I just don't want to see the first zero.

So I would like to see "code x-y*floor(x/y)" = 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1, 2, 3...

Also, I want my loop to keep running at 1000 milliseconds. Any idea how I can prevent the first 0 from showing. I have attached my code. 

0 Kudos
Message 1 of 10
(364 Views)

Hi,

just increment i (i+1).

0 Kudos
Message 2 of 10
(354 Views)
Solution
Accepted by topic author GRCK5000

Just insert +1 right after the index terminal.

raphschru_0-1663341934072.png

 

0 Kudos
Message 3 of 10
(352 Views)

If I increment with 1, now assume I want to collect data every 5 seconds. I will be collecting data every4 seconds instead of every  5 seconds. Just think about it. So what if I want to keep collecting data every 5 seconds, but still I don't want the first zero to show.

If what I am trying to say is not clear, I try to elaborate further with an example.

0 Kudos
Message 4 of 10
(337 Views)

The index is just offset by 1, but you still have cycles of 5 values: 1, 2, 3, 4, 0.
So for example if you acquire data only when the value = 0, it will be done every 5 iterations of your loop.

If this is not the explanation you are searching for, then you will have to specify a bit more your needs concerning this loop.

0 Kudos
Message 5 of 10
(335 Views)

Personally if I were looking to trigger some task at some frequency of time I would not use your approach but rather compare the actual time value. If your loop is delayed for some reason simply using the modulus method could create some jitter in your processing, especially if there was some significant delay introduced. So, if you run the loop at a faster rate and then check to see if your time period has elapsed you will get more accurate results.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 6 of 10
(318 Views)

@GRCK5000 wrote:

If I increment with 1, now assume I want to collect data every 5 seconds. I will be collecting data every4 seconds instead of every  5 seconds. Just think about it. So what if I want to keep collecting data every 5 seconds, but still I don't want the first zero to show.

If what I am trying to say is not clear, I try to elaborate further with an example.


Your statement is logically flawed.

Why do you show us a code fragment that does some math instead of the real problem showing how you "collect data". If you want to collect data every five seconds, just set the wait to 5000ms. If you want the loop to still run at 1Hz, you need to conditionally build the array. 

What is the purpose of the floor indicator and why does it need these restrictions on what to display to the user and when?

A numeric indicator always needs to show "something", it cannot be blank, so what do you want to show instead of the zero? (hide the entire indicator? Make it a string and format is as blank or a number depending on state?). If you want to do something every five seconds, you need to specify the edge cases.

 

Instead of trying to solve a potentially unnecessary side issue digging yourself into a hole,  please specify exactly what the program is supposed to do from a user perspective.

Message 7 of 10
(301 Views)

@GRCK5000 wrote:

If I increment with 1, now assume I want to collect data every 5 seconds. I will be collecting data every4 seconds instead of every  5 seconds. Just think about it. So what if I want to keep collecting data every 5 seconds, but still I don't want the first zero to show.

 


Irrelevant, because using wait(mS) and the Iteration counter is NOT the proper way to do timing for data collection.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 8 of 10
(271 Views)
Solution
Accepted by topic author GRCK5000

@GRCK5000 wrote:

If I increment with 1, now assume I want to collect data every 5 seconds. I will be collecting data every4 seconds instead of every  5 seconds. Just think about it. So what if I want to keep collecting data every 5 seconds, but still I don't want the first zero to show.


offset-increment.png

0 Kudos
Message 9 of 10
(191 Views)
Solution
Accepted by topic author GRCK5000

@GRCK5000 wrote:

If I increment with 1, now assume I want to collect data every 5 seconds. I will be collecting data every4 seconds instead of every  5 seconds. Just think about it. So what if I want to keep collecting data every 5 seconds, but still I don't want the first zero to show.


No, the collection will still be every five seconds, completely independent of the +1 increment.

 

altenbach_0-1663524200808.png

 

 

0 Kudos
Message 10 of 10
(172 Views)