LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using the for loop iteration number as variable outside loop

I've very little experience with labview, and trying to design a program which generate a signal inside a for loop and each iteration the frequency of the signal is increased, basically I need to be able to use the for loop iteration number (i.e whether it's iteration 1, 2, 3 etc.) to multiply with a step size to add to the initial start frequency. I've tried shift registers etc. but can't seem to get it too work, any help would be greatly appreciated.

 

 

0 Kudos
Message 1 of 20
(3,628 Views)

Do you see the little "index" terminal, blue square with "i" inside it on the lower left?  This is the For loop index, starts at 0 and increments by 1 for every loop.  Just wire it ...  This generates an array of even numbers, 0 .. 18.

Evens.png

Bob Schor

0 Kudos
Message 2 of 20
(3,616 Views)

I think that code (or very similar) is already placed in at least a dozen of posts, so only a screenshot:

 

FrequencyStepping.PNG

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 3 of 20
(3,604 Views)
Consider the Ramp Pattern function to create an array of frequencies that you need and just write the array into a for loop.
0 Kudos
Message 4 of 20
(3,594 Views)

Thanks for both replies, Norbert your solution was perfect, I had the logic located outside the loop and was getting different kinds of errors etc. but it's working perfect now thanks again.

0 Kudos
Message 5 of 20
(3,586 Views)

There is also the simple Ramp Pattern VI that you could use to generate your points of interest.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 20
(3,583 Views)

I'll have a look at this and try implement it, thanks 

0 Kudos
Message 7 of 20
(3,575 Views)

One final question, I've searched the forums but can't seem to find an answer for a for loop, for testing I'm viewing the generated signal on an oscilliscope, but the loops execute far too quicky to see it, is there any way to hold a loop for a desired amount of time before beginning the next iteration. I've found lots of solutions for while loops.

0 Kudos
Message 8 of 20
(3,570 Views)

Put a wait function inside of the For Loop.

Message 9 of 20
(3,561 Views)
Why would the solution for a for loop be any different than a while loop?
0 Kudos
Message 10 of 20
(3,544 Views)