Cart | Help
 You are here: NI Home > NI Developer Zone > NI Discussion Forums Select Community English Français Italiano 日本語 한국어 Español 简体中文 繁体中文 Português (BR)

Member
Posts: 1

# How create a variable that changes (by 0.05) on each iteration in a loop?

We are trying to control  New Era Syringe pumps using Labview. We want that those pumps could dispense different volumes on wells. For example 0.05ml in well one (using actuators we can move the wells),  0.1ml in well 2, 0.15ml in well 3 and so on. We think that we may need a "For loop" in which the number of iteration is the number of wells, but we do not know how to create a variable, inside the loop that can increase .05 on each iteration, and then we can use that variable as a "volume input" in our program.

Proven Zealot
Posts: 7,181

# Re: How create a variable that changes (by 0.05) on each iteration in a loop?

Hi AnaChavez,

what about (i+1)/20? Simple math, uh? ("i" is the iterator terminal of a loop...)

Best regards,
GerdW

CLAD, using 2009SP1 + LV2011SP1 on WinXP+Win7+cRIO
Kudos are welcome
Trusted Enthusiast
Posts: 4,078

# Re: How create a variable that changes (by 0.05) on each iteration in a loop?

You can use a shift register and any incremental value as shown below:

- tbob

Inventor of the WORM Global
Proven Zealot
Posts: 7,181

# Re: How create a variable that changes (by 0.05) on each iteration in a loop?

[ Edited ]

Hi tbob,

multiple add operations with floats may induce more errors than a multiply/divide due to floating point representations (especially on numbers that can't be represented exactly, like 0.05)... The next step in this routine might be a comparison of setpoint and measurement value

Message Edited by GerdW on 05-10-2010 08:04 PM
Best regards,
GerdW

CLAD, using 2009SP1 + LV2011SP1 on WinXP+Win7+cRIO
Kudos are welcome
Trusted Enthusiast
Posts: 4,078

# Re: How create a variable that changes (by 0.05) on each iteration in a loop?

I ran the loop one million times.  The output was 50000.0000007.  Then I tried dividing as you mentioned ((i+1)/20).  The output was 50000.0000000.  So multiplying is a little more accurate.  However, I don't think it makes any significant differnece if you are adding 50000.0000000 or 50000.0000007 mL of substance to a mix unless this is some super-duper accuracy is needed.  So either method will work.

- tbob

Inventor of the WORM Global
Proven Zealot
Posts: 7,181

# Re: How create a variable that changes (by 0.05) on each iteration in a loop?

Hi tbob,

yes, I know the difference is not much, but it's there...

I wanted to warn AnaChavez to think about number representation and other possible side effects - especially on such a noob question (sorry AnaChavez, don't want to offense you). Just a warning - when other operations like comparisons and similar are comin' your way...

Best regards,
GerdW

CLAD, using 2009SP1 + LV2011SP1 on WinXP+Win7+cRIO
Kudos are welcome