FAQ: How is integer division accomplished when using MotionWorks+?
Breadcrumb
Contact Us
contactUsAction
MotionWorks+ software uses C/IEEE standard of performing mathematical functions. When an integer is divided by another integer, the result is an integer. The same holds true if integer division is performed as part of a greater operation.
-----------------------------------------------------------------------
Example 1: PosFloat= (60/75) * mPosition_Actual
"mPosition_Actual" is a floating point number and "PosFloat" is a floating point variable.
It would be expected that "PosFloat= (60/75) * mPosition_Actual" would return 0.8 * mPosition_Actual, but MotionWorks+ evaluates the integer pair (60/75) as an integer (0), so the result is also 0. To make this equation work correctly, the equation that must be used is "PosFloat = (60.0/75.0) * mPosition_Actual".
-----------------------------------------------------------------------
Example 2: Distance_Float = Distance / Conversion
Variables "Distance" and "Conversion" are both integers, and the variable "Distance_Float" is a floating point variable.
"Distance_Float = Distance / Conversion" will evaluate as integers, with the result being the integer result of the division stored as a float. If Distance=21 and Conversion=4, the result of this division will be 5 instead of the expected 5.25. To make this equation work properly, the integer variables must be converted to floating point values BEFORE the division.
The correct equation would be "Distance_Float = (Distance * 1.0) / (Conversion * 1.0)." It is important to use the floating point number 1.0 in the equation, and not the integer 1. As long as one of the first two elements in the division (either Distance or Conversion) is floating point, then the internal registers will treat it as a floating point calculation.
SAFETY PRECAUTIONS AND INSTRUCTIONS FOR USE OF FAQ INFORMATION!
Please read and understand the product instruction manual before installing, servicing or operating Yaskawa products. FAQ content and illustrations are provided as technical advice to augment the information in manual, not supersede it. It is not possible to give detailed instructions for all types of installation or support activities. The information described in the FAQs are subject to change without notice to improve the product or FAQ. Yaskawa assumes no responsibility for errors or omissions or damages resulting from the use of the information contained in any FAQ. All warnings, cautions and product instruction for product use must be followed. Installation, operation and maintenance should be carried out by qualified personnel. Failure to observe these and other precautions highlighted in the product manuals will expose the user to high voltages resulting in, serious injury or death. Qualified personnel are defined as individuals who are familiar with the installation, starting, operation and maintenance of Yaskawa products of the type described and have proper qualifications to perform the work.
Phone
If you have an urgent request, please call: 1-800-YASKAWA (927-5292) or 1-847-887-7000.Electronically
To contact us electronically, please select your type of request and complete the form.Yaskawa America, Inc. - Drives & Motion Division
2121 Norman Drive South
Waukegan, IL 60085