06-19-2011 12:53 PM - edited 06-19-2011 12:54 PM
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
Solved! Go to Solution.
06-19-2011 01:00 PM
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.)
06-20-2011 12:41 PM
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.
06-20-2011 01:08 PM
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
06-20-2011 04:28 PM - edited 06-20-2011 04:29 PM
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.
06-20-2011 04:42 PM - edited 06-20-2011 04:42 PM
06-20-2011 04:54 PM
Thank you Altenbach.
It's a nice apporach.
Many thanks indeed for your help.
Hadiq