LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do i sweep two voltage at the same time by using for loop ?

Hello, Can anyone help me on this topic ?
My problem is to sweep Vds and Vgs as same time vs Id in MOSFET by using for loop. I also use the Agilent power supply source. Let me tell a litle bit about what i'm doing. For different value of Vds, i will get Vgs vs Id curve. (The x axis is Vgs, the y-axis is Id).
I started to create two for-loop, the inner to sweep Vgs, and the outer one to sweep Vds. My problem is don't know how to connect all the wire in  the for loop.
In the for loop i saw N, i icon. Suppose I have the two variable for Vgs such as Vgs start and Vgs_stop. Should the Vgs_start( or Vgs_stop) be connected to N or leave it in the for_loop ?
 for example: I want to sweep Vgs from 0(for Vgs_start)  to  5(Vgs_strop) V, and the step increment is .5V how do i connect these variables in the for loop ?
Thank you for your time
Ti Nguyen
0 Kudos
Message 1 of 9
(3,386 Views)
There's lots of ways that this can be done. One way is to use a for loop and calculate the number of iterations based on start, stop, and step size. Another way is to use a while loop and keep stepping the voltage as long as it's not greater than the stop point. both of these methods are shown in the attachment. There is also the shipping example called Frequency Response. It uses a start, stop, and number of steps and calculates the step size.
0 Kudos
Message 2 of 9
(3,376 Views)
It is easier to use a while loop.  Dennis beat me to the punch.  Here is my solution:
 
 
You can remove the flat sequence structure if you use Error In and Error Out to ensure the execution flow will occur in the proper order.  Be sure to include the delay time in the loop so that your vi doesn't hog all the CPU time.
 

Message Edited by tbob on 10-17-2005 01:00 PM

- tbob

Inventor of the WORM Global
Message 3 of 9
(3,372 Views)

I've been using this structure successfully for several implementations. However, now I want the while loop to run through a set of values (6 out of range values for voltage reading). Any tips on what data type I should input to the shift register? Or should I use a for loop instead?

0 Kudos
Message 4 of 9
(2,994 Views)

@livermor wrote:

I've been using this structure successfully for several implementations. However, now I want the while loop to run through a set of values (6 out of range values for voltage reading). Any tips on what data type I should input to the shift register? Or should I use a for loop instead?


 

If you will be using 6 known values, put the values into an array and use a For loop.  Wire the array into the For loop with indexing enabled (which is the default setting).  No need for start, stop, or increment.


 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 9
(2,984 Views)

Ok, tried that. But now it looks as if the value is passed into N and the shift register, but the loop does not execute. (Have highlighted it a couple times to see the flow)

 

code_snip.png

0 Kudos
Message 6 of 9
(2,958 Views)

The "N" input of a For Loop tells the For Loop how many times to run.

Your Enum item called "0.125" probably has a numeric value of "0".

0 Kudos
Message 7 of 9
(2,943 Views)

So I should use some kind of size of array thing and wire that to N maybe? I'll try to do something like that. 

 

EDIT:

Changing the enum to an array and then using the size thing worked.

0 Kudos
Message 8 of 9
(2,935 Views)

If you are using an array, just wire the array to the For Loop border and you will see a hollow box on the border.  This means that indexing is enabled.  This means that the For loop will index each element out of the array on each iteration, and it will run until the last array element is processed.  You don't need the size thing and you don't need to wire anything to the N.  Try it.  If the hollow box is solid instead, right click on the box and select Enable Indexing.  This turns a solid box to a hollow one.  When indexing is disabled (solid box), the entire array is passed inside the loop instead of just one element at a time.

- tbob

Inventor of the WORM Global
0 Kudos
Message 9 of 9
(2,921 Views)