# LabVIEW

cancel
Showing results for
Did you mean:

Message 1 of 8
(1,137 Views)

## Re: LabView Code for myRIO not working

Start by learning about Shift Registers and Feedback Nodes.  These are used to hold values from a previous iteration of the loop.  So you can use a Feedback Node to subtract the previous displacement from the current displacement to get your velocity (assuming your dt is actually 1 second).  You can then use In Range And Coerce to check to see if the velocity is within your desired range and stop the loop.  Nothing should need to be done outside of the loop.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 8
(1,112 Views)

## Re: LabView Code for myRIO not working

Hi! Thank you for your quick response. I will try using those functions in my code and let you know how it goes or if I have further problems!

Message 3 of 8
(1,106 Views)

## Re: LabView Code for myRIO not working

So I did what you said with the shift register, while continuously inputting it into an array. But my dt is not 1 second, since it takes differing amounts of time between position changes. I tried doing a feedback node on position and time, but not sure how to pair them together. Any thoughts?

Message 4 of 8
(1,085 Views)

## Re: LabView Code for myRIO not working

Again, you can move everything into the loop.

1. Since the myRIO is a RealTime computer, make the loop a Timed Loop.  Now you should know the rate at which you are acquiring data, making the derivative calculation a lot simpler.  In the attached file, I set the rate to be 1ms, giving the simple subtraction a m/s result (mm/ms = m/s).

2. Change your graphs into Charts.  Charts keep at history for you, so you don't have to mess around with arrays.

3. Again, a simple Feedback Node is all you need to hold the previously read displacement.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 8
(1,078 Views)

## Re: LabView Code for myRIO not working

I can't make the loop a timed loop since the time between iterations will change. This is dependent on how long it takes for the position of the potentiometer to change, which will vary a lot. I have tried doing this instead, including feedback nodes to get change in displacement and then divide by the change in time to get velocity. Haven't put in the In range and Coerce function parameters yet, will do that today. Also, how did you happen to get the chart function? I didn't see it in the block diagrams but I did notice it on the front panel and you're right it looks much much cleaner than the graph function (waveform). It would be awesome if you could help with that. Please check out the new VI attached.

Message 6 of 8
(1,071 Views)

## Re: LabView Code for myRIO not working

@makrilavy79 wrote:

I can't make the loop a timed loop since the time between iterations will change. This is dependent on how long it takes for the position of the potentiometer to change, which will vary a lot.

No, your iterations should be the same.  This is the same as Sample Rate.  For your calculations to be useful, you need a consistent sample rate.

@makrilavy79 wrote:

Also, how did you happen to get the chart function?

I just replaced the graphs with charts on the front panel.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 8
(1,064 Views)

## Re: LabView Code for myRIO not working

Hi sorry I haven’t replied back in so long. I actually haven’t tried your solution yet, I’ll let you know when I get it done. Thanks!

Message 8 of 8
(1,043 Views)