# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution

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

My Code:

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.

Message 1 of 10
(364 Views)

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

Hi,

just increment i (i+1).

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

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

Just insert +1 right after the index terminal.

Message 3 of 10
(352 Views)

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

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.

Message 4 of 10
(337 Views)

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

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.

Message 5 of 10
(335 Views)

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

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
Message 6 of 10
(318 Views)

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

@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.

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)

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

@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 ===
========================
Message 8 of 10
(271 Views)
Solution
Accepted by topic author GRCK5000

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

@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.

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

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

@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.

Message 10 of 10
(172 Views)