LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to measure the slope of a triangle wave

Hi everyone,
 
 
I'm looking for a way to measure the slope of a triangle wave, which changes every half cycle of the wave. I have the triangle wave out of phase by 90 degrees so that it models the behavior of a cosine wave, and essentially all I want is a way to measure whether the slope is positive or negative. The idea is to use this information to stop another signal running at the same time at the halfway point of the cycle of the first signal, so the first wave can continue back to it's starting point and the second will start again at the completion of the first wave (as it begins the second cycle)
 
 
I'm using LabVEIW 8.2.1 if it makes a difference
 
 
Thanks,
 
 
Ben
 
 
 
PS. Is there a way to close threads you've previously posted on this forum? I started one yesterday (or possibly the day before) with a fairly vague question in it and it's now redundant after I made some headway on my own, and I don't want to clog the forums up
0 Kudos
Message 1 of 9
(7,856 Views)


bencarrick wrote:
Is there a way to close threads you've previously posted on this forum? I started one yesterday (or possibly the day before) with a fairly vague question in it and it's now redundant after I made some headway on my own, and I don't want to clog the forums up

Nope. But you can ask (send a report) moderator to delete the thread.
 
Mathan
0 Kudos
Message 2 of 9
(7,855 Views)
Thanks mathan, any ideas about the slope problem? I was thinking the easiest way to do it would be to insert a function to take the differential of the wave and thus get the slope, but I'm not having much joy in implimenting that
0 Kudos
Message 3 of 9
(7,833 Views)

A shift register in a while loop will retain the last value written to it, so you can compare your current data point with your previous data point.  If your current data point is larger than the previous, you have positive slope.  If your current data point is less than the previous, you have negative slope.  If they're equal, default to whichever state is safer for your experiment and setup.



Message Edited by JeffOverton on 06-12-2008 09:24 AM
0 Kudos
Message 4 of 9
(7,827 Views)

Hi Jeff,

 

How do I find the slope value? I searched through the help menu and tried a few things but either I'm using them incorrectly or they're not suited for the task. I'll post my vi incase it makes things clearer, the case structure isn't an important part of the code and can be removed if it's not helpful

 

Thanks,

 

Ben

0 Kudos
Message 5 of 9
(7,821 Views)
You can use the "Get Waveform Components" vi to pull out the Y-array of the waveform, which is just a bunch of datapoints.  Each datapoint is dt after the previous in time.  If your solution is simply to turn another control on or off, you could use a sin or cosine and check if the current datapoint is greater than zero, as that will also give you a fifty percent duty cycle.
0 Kudos
Message 6 of 9
(7,815 Views)

Hi Jeff,

 

Thanks, that's great. Can I just wire the vaules out of the loop and use them with a (greater than 0) connected to a the logic connection of a case structure?

If I'm not getting this could you walk me through the code? I've only been using LabVEIW for a week and a bit so I'm still learning

 

Thanks for the help,

 

Ben

0 Kudos
Message 7 of 9
(7,797 Views)
I'm not sure how you're using this data to control anything, so I'm not sure what the best implementation would be.  You will not be able to get any data out of the loop until it finishes (gets a True value at the Stop If True terminal (sort of)), so if you want to have the loop running constantly, you need to put your control code in the loop with the generated data.  Otherwise, you could generate your boolean array, and then wire it and your control array into a for loop, and do a point by point comparison to see if you should be controlling.
The new example.vi has two examples to give you a rough idea what I'm talking about.


Message Edited by JeffOverton on 06-12-2008 12:19 PM
0 Kudos
Message 8 of 9
(7,792 Views)

Hi Jeff,

 

That's ideal, it looks like this will do exactly what I'm trying to do

 

Thanks for the help,

 

Ben 

0 Kudos
Message 9 of 9
(7,774 Views)