LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Apply units to polymorphic units?

Is it possible to apply units to polymorphic units?  I am using polymorphic units to change user specified engineering units to encoder bits.  I am creating a manual option for the motor, and I need a dialog to tell the user to move the platform to a specific location.  I would like to indicate the engineering units.  However, If I try to apply the units, LabVIEW either indicates a broken wire or uses a question mark in front of the units I try to apply.  Is there anyway to do this, or should I just drop the polymorphic units?
0 Kudos
Message 1 of 6
(3,138 Views)

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

0 Kudos
Message 2 of 6
(3,100 Views)

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.

Download All
0 Kudos
Message 3 of 6
(3,081 Views)
I see a couple problems with your code and what you want to do with it. First, your subVI has an input of dollars and output of degrees. I think you get a ? in the label because labVIEW doesn't know how to convert dollars to degrees. If you convert the input control of the subVI to radians, then everything works okay because it understands a radians to degrees conversion. Second, how you want to use it will have the same problem. Let's say you are using degrees and everything works. But you said in the future you want to send it 6 inches. How will LabVIEW know how many inches is equivalent to degrees? That conversion is a geometry problem that would vary from one setup to another. I think your best bet is to not use units (I've rarely seen them used in any examples on the forums anyway) and just use hardcoded values. If necessary make your own set of VI's that will do the conversion and had the appropriate units label to the string display.
0 Kudos
Message 4 of 6
(3,067 Views)

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.

0 Kudos
Message 5 of 6
(3,059 Views)

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.

0 Kudos
Message 6 of 6
(3,053 Views)