LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

step function

I have created a step function using a case structure within a while loop using shift registers. (I'm sure this probably isnt the best way to make a step function but its the only way I know how) Anyways I have two questions regarding my step function.  First: How do I make the function start at 0 each time I start the program? If I stopped the program at 4, it will begin at 4 when I restart the program.  I want it to begin from 0 next time I restart the program, even if I stopped it at 4 the previous run.  Second: The graph of my step function looks like a sawtooth wave rather than a step function because it is only taking one measurement before moving on the the next step.  How do I get it to look more like a step function? I have attached the VI of my step function.  I would also appreciate it if somebody shows me how to make a step function in a more efficient way. I know there is a step function VI but I could not figure out how it works.

0 Kudos
Message 1 of 4
(2,848 Views)

Hello CrashMcLars1,

 

To answer your two questions:

 

1) You need to initialize your shift register to some value (wire a default value into it), otherwise you'll retain the last value from the last time the function was run (until the VI leaves memory.) 

This tutorial has more information on initializing shift registers:

 

Tutorial: Passing Data Between Loop Iterations in NI LabVIEW

http://www.ni.com/gettingstarted/labviewbasics/shiftregisters.htm

 

2) Your VI currently transitions from one value to the next with each loop iteration.  If you want the steps to plot multiple points on your chart, you need to write that value to your chart multiple times.  This could be done several ways, but you'll probably just want to write a 1-D array of identical values to your chart rather than a single scalar value.  Where is this going to be used?  Does the timing of the output matter?

 

Regards,

Tom L.
0 Kudos
Message 2 of 4
(2,842 Views)

Thanks a lot Tom L! I got my first question answered. I'm not entirely sure how I would write a 1-D array of identical values to the chart though. Do you think you could explain that a little better?  This is gonna be used as a voltage ramp output and I want the users to be able to see that they are getting a step function and not a sawtooth function.  The timing of the output does matter.

0 Kudos
Message 3 of 4
(2,838 Views)

I found this on the forums a while ago and I am actually using it in a project right now. So, I can't take credit for coming up with this. I definitely suggest doing a search before posting, because often times your question will already be answered. This essentially does a ramp pattern, and uses rounding of decimals to round the numbers off to a flat line if you're between two step values. You can find the ramp pattern VI in the palettes. 

 

 

0 Kudos
Message 4 of 4
(2,815 Views)