LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Start, Stop, Step array builder

Solved!
Go to solution

I would like to enter the start, stop, and step frequency to build an array that will hold the value's to feed to a sweep generator.

I have something that works, except for one thing; the stop value. I can't seem to get this thing to stop on the stop frequency value. The step value seems to affect this too. So could anyone take a look at my vi, and help me with this? also, the code looks a little complex for what might seem like a simple thing to do.

0 Kudos
Message 1 of 8
(5,898 Views)

Unfortunately, I do not have LV 9, but perhaps you are trying to do a equal test on a double?  If so, try using a test that uses a <=, >=, < or > operator.

 

 

A

0 Kudos
Message 2 of 8
(5,892 Views)

No need to make your own! Use the ramp pattern with option "ramp by delta".

 

Your code is way too complicated anyway. At least you need to insert a "+1" before wiring to N.

0 Kudos
Message 3 of 8
(5,883 Views)
Solution
Accepted by topic author Rivetm

Anyway, here's a slightly simpler implementation of your code. As you can see, you codes was way more complicated than needed! 😄

 

Shown below is the ramp pattern implementation (recommended). Both give the same result for sane inputs.

 

I would definitely use the ramp pattern, because it has better error handling (e.g. if the delta is zero or max is +Inf, etc.).

You can look at the code of it to learn something. 😉

 

 

You need to be a bit careful with possible accumulations of binary errors, especially with fractional steps that cannot be fully represented in binary (e.g. 0.1) 

Download All
Message 4 of 8
(5,871 Views)

All I can say is "wow". That's good stuff. I knew that my code was clumsy, for sure. But I just couldn't get myself out of it. You have shown me how to improve on my own idea, and also shown me something I have never seen before. I cannot thank you enough.

0 Kudos
Message 5 of 8
(5,851 Views)

Wouldn't it be nice if we had a For Loop option to set Start, Stop, and Step?  Just like in any other programming language?

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 8
(5,844 Views)

 


@tbob wrote:

Wouldn't it be nice if we had a For Loop option to set Start, Stop, and Step?  Just like in any other programming language?


You mean like this?

 

0 Kudos
Message 7 of 8
(5,828 Views)

@altenbach wrote:

 


@tbob wrote:

Wouldn't it be nice if we had a For Loop option to set Start, Stop, and Step?  Just like in any other programming language?


You mean like this?

 


Yes!  It would be nice if more people would Kudo the idea.  This feature is long overdue.

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 8
(5,803 Views)