03-30-2009 05:21 PM
03-31-2009 10:20 PM
Matthew
The advantage of using polymorphic units is that you let labview handel simple unit conversions automaticly. Check out this help doc, it walks through the use cases. What kind of units do you want to use?
Hunter
04-01-2009 10:16 AM
Hunter,
It works fine internally. My problem is that since I need to support a manual implentation of this motor, I need to convert the polymorphic unit back to the original enginnering unit to prompt the user to move the motor to the specified location.
I have attached a simple example of my issue. The example takes the input in degrees sends it to a subVI with polymorphic unit which attempts to generate a string for the user. As you will see I cannot apply the original engineering units to the polymorphic unit for display purposes. I am trying to determine if there is a way around this, or am I going to have to drop the polymorphic units and hard code the units into the code.
The reason I am attempting to use the polymorphic units is for future use. Currently, all I care about is the rotational angle. However, if I were to connect this to linear stage, I coud simply say that one rotation is 6 inches instead of 360 degrees, and none of the driver code actually has to be modified.
04-01-2009 08:33 PM
04-01-2009 10:46 PM
The $1 is what LabVIEW uses for polymorphic units. Basically, the subVI will take any units wired to it. You will see the Main.VI wires degress into it and the wire is not broken. Internally, LabVIEW appears to store it as radians (but with the polymorphic unit, $1), but the point is that in my object, I use these polymorphic units. So, I have a property VI which sets the Engineering units per revolution of the motor, say 360º, or 6". My Method VI, which sets the motor to a position, also uses the polymorphic units, so the I can set the motor to be at 30º or 2". My code does the math to determine the number of encoder bits needed to move the motor the specified number of engineering units. All of this works, because regardless of how LabVIEW handles it internally, the math on the numbers works.
The issue is that I need support for a manually controlled motor. So I created a Manal Motor object. Since it is manual, the user needs to be prompted to move the motor to the specified location, and this is where it is falling apart, because everywhere internal to the code the units are polymorphic, and it does not appear that LabVIEW allows you to assign units to polymorphic units.
My example shows the basic steps that are occuring in the code, somewhere I wire 30 deg into a value with polymorphic units (Main.vi call to format string.vi). Then I need to take the value that's been stored in the polymorphic units (format string.vi) and display it with the units applied. As you can see from the question mark is that LabVIEW claims the conversion is invalid. I was hoping that there is a way to get around this,but I amlosing hope that this can be done.
04-01-2009 11:12 PM
Thanks. Now I've learned something about units and the $1. I've stayed away from using units and certainly polynomial units. I've never seen an advantage to using them.
It certainly seems like the format into string is what can't handle the units. The polymorphism type seems to be incompatible with the {deg} listed in the format code. If there was a format code {something} where "something" was compatible with the $1, perhaps it would work. Neither {$1} nor {*} (thinking of some sort of wildcard character, worked.
Perhaps you could use the property node of Unit Label.Text and pass that into the subVI as a string. Then build that text into the Format Into String function to show the label as part of your string.