solerpwr07 Posted July 4, 2008 Report Share Posted July 4, 2008 I have a chart that displays my load and indicators stating the current load values from test lab equipment. I've been asked to have my program also display ramp loading, so basically i have to chart the rate of change of the load. Can I some how graph the rate of change, or difference between a value and it's previous value? Quote Link to comment
mross Posted July 4, 2008 Report Share Posted July 4, 2008 Welcome single poster, Maybe I am paranoid, but this sounds like class work. You should be showing us what you have done (attach code or screen dumps of the block diagram) to encourage us that you are doing real work rather than trying to get a leg up on your classmates. I will give you a hint though. You need to understand and use shift regsiters on your loop structures. Then you must understand how to feed more than one plot to a chart or graph. All the information you need to do these things is part of the regular help and example code of LabVIEW. There are also a comprehensive knowledge bases that you should learn to use at ni.com. Best regards, Mike Quote Link to comment
solerpwr07 Posted July 4, 2008 Author Report Share Posted July 4, 2008 QUOTE (mross @ Jul 3 2008, 09:03 AM) Welcome single poster,Maybe I am paranoid, but this sounds like class work. You should be showing us what you have done (attach code or screen dumps of the block diagram) to encourage us that you are doing real work rather than trying to get a leg up on your classmates. I will give you a hint though. You need to understand and use shift regsiters on your loop structures. Then you must understand how to feed more than one plot to a chart or graph. All the information you need to do these things is part of the regular help and example code of LabVIEW. There are also a comprehensive knowledge bases that you should learn to use at ni.com. Best regards, Mike I appreciate the help mike. This isn't class work, it is code for an double slid ACTR (track roller) test machine. I did not write the (rather large amount of) code for it since its been in use long before i entered the company but i have been asked to modify it. I apologize that i can not post the code for our test rig. However, thank you for the direction. Anything else would be greatly appreciated Quote Link to comment
Neville D Posted July 4, 2008 Report Share Posted July 4, 2008 As Mike suggested, store the current value in a shift register, then on the next iteration use the shift reg value (prev val) and subtract from current value, and add that to the chart. should be easy enough. Look at examples on shift registers. I would advise spending a few days with the LabVIEW introduction books and manuals that came with the software. Or look through all the basic examples to get your head around LV. Changing complex code without knowing what your doing can be catastrophic. Neville. Quote Link to comment
mross Posted July 4, 2008 Report Share Posted July 4, 2008 QUOTE (solerpwr07 @ Jul 3 2008, 10:31 AM) I appreciate the help mike. This isn't class work, it is code for an double slid ACTR (track roller) test machine. I did not write the (rather large amount of) code for it since its been in use long before i entered the company but i have been asked to modify it. I apologize that i can not post the code for our test rig. However, thank you for the direction. Anything else would be greatly appreciated OK. Actually a shif register is not needed (but you should learn about them). Here is how to take an array and calculate the rate of change between points. I faked up a sine wave, calculated the slopes, put them together with the sine wave an show them in a graph. But the easy way that doesn't teach much is to take the derivative. It is kind of a dirty trick, but you will have to create all this yourself. Your penance for not posting your own code, so to speak. Quote Link to comment
Gary Rubin Posted July 4, 2008 Report Share Posted July 4, 2008 QUOTE (mross @ Jul 3 2008, 01:00 PM) Actually a shif register is not needed (but you should learn about them). Here is how to take an array and calculate the rate of change between points. I faked up a sine wave, calculated the slopes, put them together with the sine wave an show them in a graph. But the easy way that doesn't teach much is to take the derivative. I may be missing something, but this approach only works for post-processing, doesn't it? If that's all you need to do, this can also be done with a lot less real estate using the Rotate Array function. Quote Link to comment
mross Posted July 4, 2008 Report Share Posted July 4, 2008 QUOTE (Gary Rubin @ Jul 3 2008, 01:12 PM) I may be missing something, but this approach only works for post-processing, doesn't it? If that's all you need to do, this can also be done with a lot less real estate using the Rotate Array function. I suppose you are right - sort of. Since you must have more than one datum to get rate of change doesn't that make it always post processing? And you can't rotate an array until you have one. Hard to beat the derivative for real estate. I tend to do everything as post processing so it slipped my mind that he was sounding like it was on the fly. Another good reason to post code. No misunderstandings and no benefactors wasting time. As for on the fly, using a shift register to save that last datum allows one to calculate rate of change as each new point comes in. Quote Link to comment
Gary Rubin Posted July 4, 2008 Report Share Posted July 4, 2008 QUOTE (mross @ Jul 3 2008, 01:30 PM) Hard to beat the derivative for real estate. Funny, for some reason I never use the derivative. Here's my typical implementation of your example. http://lavag.org/old_files/monthly_07_2008/post-4344-1215106829.gif' target="_blank"> EDIT: Oops, the inputs to the minus are flipped from what they should be. Quote Link to comment
gb119 Posted July 5, 2008 Report Share Posted July 5, 2008 QUOTE (mross @ Jul 3 2008, 06:30 PM) I suppose you are right - sort of. Since you must have more than one datum to get rate of change doesn't that make it always post processing? And you can't rotate an array until you have one. Hard to beat the derivative for real estate. I tend to do everything as post processing so it slipped my mind that he was sounding like it was on the fly. Another good reason to post code. No misunderstandings and no benefactors wasting time. As for on the fly, using a shift register to save that last datum allows one to calculate rate of change as each new point comes in. LV 8.5 (PDS anyway) has a point-by-point differentiation vi, although I've never actually used it myself. What I've tended to do is to use a shoft register to store thae last n data points (and timestamps if the data is not being evenly sampled) using a rotate array and replace array element to insert the new data points and having initialised the array with the first datapoint repeated n times. You then feed that to a linear fit and use the slope as the first derivative. That is more robust against eexperimental noise than just using (y[n]-y[n-1])/t[n]-t[n-1]), although it does mean that the derivative lags behind the data by n/2 points, which is a problem if the data changes slope suddenly. You can work around this a bit at the expense of a noiser derivative by fitting a higher order polynomial and using the co-efficients of the fit to calculate the derivative. That's broadly what http://en.wikipedia.org/wiki/Savitzky%E2%80%93Golay_smoothing_filter' rel='nofollow' target="_blank">Savitsky-Golay filtering does. Quote Link to comment
solerpwr07 Posted July 8, 2008 Author Report Share Posted July 8, 2008 Hope all had a good holiday and long weekend. ive put up the area of code where it displays the loads put on each of the different (8) test specimens. can the change in load be carried out directly from (after) the doubles; replace the area where you all generated data? i know there is a space issue, but that can be taken care of. Quote Link to comment
mross Posted July 8, 2008 Report Share Posted July 8, 2008 Space issue...this is the fault of less than optimal coding preactice. I don't see a single sub-Vi on there and that is wrong. Very hard to read and hard to trouble shoot. You should make it a point to encapsulate functional sections of the code into sub-Vis. I understand that it doesn't add much value relative to proper coding up front, but it may have some merit just the same. When writing new code you should become familiar with the practice. Mike Quote Link to comment
LAVA 1.0 Content Posted July 8, 2008 Report Share Posted July 8, 2008 QUOTE (solerpwr07 @ Jul 7 2008, 06:14 PM) Hope all had a good holiday and long weekend.ive put up the area of code where it displays the loads put on each of the different (8) test specimens. can the change in load be carried out directly from (after) the doubles; replace the area where you all generated data? i know there is a space issue, but that can be taken care of. Hi, This code is unmaintaneble. I suppose it grows every week. What's the use of the 2D arrays? You can use 'concatenate arrays' (right click on the build array nodes) Why devide by 5, absolute, multiply by 5? Absolute would do. You should write wrappers around a lot of the functionality you use, you can place the feedback nodes inside those VIs Ton Quote Link to comment
soupy Posted July 9, 2008 Report Share Posted July 9, 2008 I get a live rate of change by taking the delta between the current and previous point (use a shift register). Average this delta value to get a steady result (a boxcar filter works nice http://forums.lavag.org/Boxcar-running-ave...rray-t6848.html) Cheers! Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.