LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running voltage from negative to positive to negative value again using a case structure

Solved!
Go to solution

Hi there,

 

I have a VI which runs a DAQ device (not shown) and would like to do the follwoing with it:

 

By feeding the starting value (the negative maximum value of the voltage), increment (positive), and the end value (positive maximum), the voltage supplid to the DAQ device (should be

showed in the numeric indicator) should go change gradually from negative to positive maxima and doing the reverse process returning to the start value

which is the negative maximum.   

 

e.g.

 

if I put -3V for the start value, 0.5 as increment, +3 V for the end value, I should get the following:

 

-3, -2.5, 2, ....,.0,.......,2.5,3 and then 2.5,2.....,0,......,-2,2.5,-3 and then stops.

 

 

I managed to get the first run which is from negative to positive maxima but it never do the opposite. Can anybody help in sorting this out.

 

Many thanks,

 

Hadiq

Islam means peace
0 Kudos
Message 1 of 7
(3,410 Views)

You need a second shift register (e.g. containing a boolean, that holds the current "direction". Flip it whenever you reach one of the limits and use its value for the case structure.

 

(Personally, I would also increment an integer for the ramp, then scale it later. All these comparison operations with DBLs scare me.)

Message 2 of 7
(3,407 Views)
Solution
Accepted by topic author Hadiq

Study the attached example.  Instead of just having a graph show each DC voltage at each iteration, I made a graph that updates to show all of the steps as they happen.  The waveform scaling stuff is to size the graph properly so you can see each step without having the graph resize with each loop iteration.  You can feed the values to your DAQ device to get the real output.

 

I used a second shift register for direction as suggested by Altenbach.  This is the best way (maybe the only way) to go.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 3 of 7
(3,375 Views)

Many thanks tbob for the nice editing. It works nicely and indeed it's what I'm looking for.

 

Also thanks for Altenbach for his suggestion.

 

 

Hadiq

Islam means peace
0 Kudos
Message 4 of 7
(3,367 Views)

Here's another version. This one does not stop after one cycle. If you really want to stop after one cycle, I would recommend to simply create an up-down ramp as array and then autoindex in a FOR loop.

 

 

 

Download All
0 Kudos
Message 5 of 7
(3,351 Views)

And here's the idea with the ramp:

 

 

Download All
0 Kudos
Message 6 of 7
(3,342 Views)

Thank you Altenbach.

 

It's a nice apporach.

 

Many thanks indeed for your help.

 

Hadiq

Islam means peace
0 Kudos
Message 7 of 7
(3,333 Views)