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: 

how can I reset the loop iteration while saving specific loop (30) data

Hello everyone

I want to save 30 iterations according to my requirement. I have attached my vi for more clarity. when I click save, it was not saving 30 iteration data. please help me.

0 Kudos
Message 1 of 10
(3,170 Views)

You cannot 'reset' the "I" terminal in a loop. You can create a counter in your loop that can count up or down depending on the logic you want.

 

If you want to save every 30 iterations of a loop, use the "Quotient and Remainder' function, input the loop interation counter "I" the divisor is 30..then the Quotient will increment = 1,2,3 etc only then the loop iteration is a divisor of 30 without a remainder.

Try it out...it's a useful function.

Regards

 

0 Kudos
Message 2 of 10
(3,160 Views)

Hi Rajesh,

 


@Rajesh10 wrote:

Hello everyone

I want to save 30 iterations according to my requirement. … when I click save, it was not saving 30 iteration data.


When you want to save data for 30 iterations then why do you compare with loop iteration counter directly?

Either create your own counter using a shift register - or store current loop iteration count in a shift register and compare with this one.

Or use a FOR loop set to iterate 30 times and start that FOR loop with a click on your "Save" button…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 10
(3,154 Views)

Hi JackHamilton

I think it will give every 30th iteration value.

0 Kudos
Message 4 of 10
(3,125 Views)

can anybody change my vi accordingly...

Thank you in advance..

(continuous 30 iterations to be saved) 

0 Kudos
Message 5 of 10
(3,117 Views)

Hi Rajesh,

 

a possible solution could look like this:

check.png

This is very basic LabVIEW programming: learn about shift register usage! (The "Save" button is changed to latched behaviour…)

 

I intentionally posted just an image of code to let you recreate this stuff and think about the code in the other case of the case structure. When you want someone else writing code for you then you should hire a programmer!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 10
(3,112 Views)

Thank you.

Problem solved

solved.JPG

0 Kudos
Message 7 of 10
(3,076 Views)

Hi Rajesh,

 

why is your counter an orange DBL?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 10
(3,074 Views)

when I gave a constant to shift register it automatically took orange, but it's working fine.

0 Kudos
Message 9 of 10
(2,790 Views)

Did you drop a floating point constant from the palette?  You should have dropped an integer constant.

 

But right click on the constant and  change the representation to an integer.  U8 would be fine since you'll always be less than 255 and never negative.

 

Counting operations should always be using integers.  Your double probably is okay, but whenever you start doing comparisons or math on doubles, you'll find that a number you though was an integer falls isn't exactly that integer and the comparison will fail.

 

Look up "floating point comparison".

0 Kudos
Message 10 of 10
(2,760 Views)