LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

writing ramp functions


@BowenM wrote:

If this hadn't been a one time use quick program, yes.  It would be a sub-vi and all of the "1000" constants would be variable instead.


I guess it's individual preference.  Being that coding speed is not one of my best suits, I'd probably choose the privided VI over coding it myself.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 11 of 15
(722 Views)

I'm trying to use the ramp by samples vi.  My big problem is populating the array after the math has taken place.  Because the output does not have to ramp every time there is an analog change, the array needs to populate with integer analog values and then values incremented in however many steps are necessary.  I'm trying to use a case structure where true designates a ramp from one value to the next, and a false just passes the values through.  The front panel would take analog values, a true or false on the ramp, and if true the number of ramp steps that need to occur.  I have this part down, but when the end array is built I can't get rid of the excess zeros that populate from the false structure.  I think I'm simply misunderstanding how to properly build the array.  Here's where my code is at so far, thanks for all the help and suggestions!

0 Kudos
Message 12 of 15
(712 Views)

This "fixes" your problem. Store the ramp in an initialized shift register, and then "build array" with concatenating indecies.

 

ramp.png

 

If I were you however, I would take very careful note that you are going to be feeding this waveform in to a D/A card. If you aren't ramping, you need to have a for loop in there to make sure that you are holding for the correct amount of time as you build your generic waveform to send.

0 Kudos
Message 13 of 15
(693 Views)

Thank you, that solution worked perfectly for generating the necessary array, and you are correct I am having issues clocking this out correctly.  I'm using the counter available on the board as an output clock, and it does implement the ramp, but also outputs the non ramping data too quickly.  Where would you recommend placing the for loop to make sure the non ramping signals hold for long enough?

0 Kudos
Message 14 of 15
(668 Views)

You need to know your output sample rate.  All of this is meaningless without it.

 

Once you know that, you make a for loop in your "False" statement, and send the "hold" voltage N times, where N = number of samples needed for that time.

 

For example, if yor output rate is 1,000 samples / second and you want to hold for 1/4 second at 4.3 volts, you will build an array of size 250, each element of which is 4.3 volts.

 

If your rate is 2000 samples / second, your "hold" array will be of size 500...  etc.

0 Kudos
Message 15 of 15
(659 Views)