04-18-2012 05:23 PM
Hello,
Currently, I'm trying to create the COP graph to show the position of food steps. I have 3 channels, channel 3 is the Fz( Force in z direction), Channel 4 is Mx( Moment in x direction), and Channel 5 is My( Moment in y direction). To calculate X position, I do -My/Fz, and for Y position, I do Mx/Fz. According to these formula, when Fz is zero( no force in z direction), the output value should be undefined. Right now, I put those two output values into a XY graph with the "select" function, so when the output value is undefined, show 0 in the graph, if the output value is a number, show that number in the graph.
As you can see in my block diagram screen shot, I have everything wired correctly, no error appeared. The graph did show nothing when no z-force. However, when I have a force, the graph still not showing anything, the graph is changing the size( I have auto scale on) but nothing appeared in the graph. I'm wondering if there anyway to fix this problem. I dont know if theres any icon can tell u this number is undefined, so I use "Not a number/path/Renum" icon.
Thank you,
CKH
04-18-2012 07:41 PM
CKH,
Why not check for =0? before dividing? If the divisor is zero, use a case structure to set the output value you want for that case. Put the divide in the other case. If you make the divide by zero output NaN (= Not a Number), then that point will not show up on the graphs.
Lynn
04-19-2012 11:50 AM
Hi Lynn,
I understand the concept, but when I put that into a labview, this doesn't work.I pose a screen shot of what I'm thinking of structuring the function.
Thank you,
CKH
04-19-2012 12:31 PM
CKH,
You need a case structure after the =0? as shown below. I used the Random and the Slide to simulate your data sources.
Lynn
04-19-2012 12:55 PM
Hi Lynn,
This is great, but I'mnot really sure about the NAN vi, or is it the a constant that I type in? I tried to type the NAN for the true case, it gave me a broken arrow saying can not connect terminals with 2 different types. Here is the screen shot.
Thank you,
CKH
04-19-2012 03:44 PM
CKH,
Your VI uses the Waveform data type. My example uses a scalar number. On the Waveform palette is a Build Waveform function. I am not sure of the exact name as I do not have LV open now. Insert the NaN (or perhaps an array of NaN) into a waveform data type and you should be OK.
You lose all the timing information at the Y Input anyway, so you might be better off just doing everything with arrays rather than Waveforms and Dynamic Data Types.
I am not a fan of the Dynamic Data Type and many times find the Waveform data type more trouble than it is worth. But I started using LV long before either was availabel and learned how to do things without those types.
Lynn
04-20-2012 12:29 PM
Hi Lynn,
I'm still very fresh on Labview, so I keep making mistakes, hope you dont mind if I keep asking you some very obvious question. This is what I have so far, I still see some value on my graph, maybe I'm using the wrong function you suggested.
CKH
04-21-2012 05:26 PM
CKH,
You are feeding an empty array to the waveform and then creating an array of waveforms at the autoindexing output from the for loop. I have never looked at a graph made from a waveform with an empty array and I am not sure what it would display.
I looked at the detailed help for XY graphs. It says that three data types are permitted: Cluster of {x array, y array}, array of points (where a point is a cluster of {x value, y value}, and an array of complex. You have none of these. I have no idea what the Build XY Graph express VI does since I always build the data types from the primitives described above. It probably extracts the arrays from the waveforms. How it deals with arrays of waveforms and how it deals with empy arrays, I have no idea.
What is your data source? That is, what generates the array of waveforms in the parts of your diagram you have not shown?
Lynn
04-23-2012 05:10 PM
Hi Lynn,
The original code is actually made by the force plate company, I modified some items so it will be easier to work with. I believe, as shown in pic, all data sources go to a build waveform icon, then I use the data from there and build my COP base on that.
CKH
04-23-2012 05:35 PM
CKH,
That code may qualify for the Rube Goldberg thread. You just have to live with it. Sorry.
If you follow the data lines back, you see that the GET DATA VI produces a 1D array for each packet received. Then the 2D array from the for loop goes through what appears to be a Reshape Array function to convert it to a different 1D array which is placed in a buffer then converted back to a 2D array. Some complicated code appers to index out six columns and makes a new 2D array from those. Those are converted row by row to an array of waveforms (in two places) ...
I suspect that if we knew what all that was supposed to do, it could be done with about one third the code. You can certainly build an XY graph directly from the arrays with much less effort. The code following the Gen 5 Displayed1 and 2 appears to be identical. Therefore, Output Graph 2 has the same data as is fed to the Wavefrom Array Decimator above. Just branch the wire rather than duplicating code.
Lynn