LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

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

Highlighted

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
(682 Views)
Highlighted

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
(672 Views)
Highlighted

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
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 3 of 10
(666 Views)
Highlighted

Hi JackHamilton

I think it will give every 30th iteration value.

0 Kudos
Message 4 of 10
(637 Views)
Highlighted

can anybody change my vi accordingly...

Thank you in advance..

(continuous 30 iterations to be saved) 

0 Kudos
Message 5 of 10
(629 Views)
Highlighted

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
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 6 of 10
(624 Views)
Highlighted

Thank you.

Problem solved

solved.JPG

0 Kudos
Message 7 of 10
(588 Views)
Highlighted

Hi Rajesh,

 

why is your counter an orange DBL?

Best regards,
GerdW
CLAD expired, using LV2011SP1 + LV2017 (+LV2019 sometimes) on Win7+cRIO
Kudos are welcome Smiley Wink

0 Kudos
Message 8 of 10
(586 Views)
Highlighted

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

0 Kudos
Message 9 of 10
(302 Views)
Highlighted

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
(272 Views)