FAQ: Why is the CPU load high when there is minimal logic executing?
Breadcrumb
Contact Us
contactUsAction
One common cause of the CPU load being higher than expected is caused by using a custom Function Block that uses a large structure connected as a VAR_INPUT instead of a VAR_IN_OUT.
When a variable is declared as a VAR_INPUT, the MPiec Controller copies the entire contents of the structure into the Function Block every scan. Other programming languages refer to this technique as “Passing by Value.” In this situation, the Function Block does not have the ability to alter the contents of the original data. When declaring a variable as VAR_IN_OUT, the MPiec Controller passes a pointer to the original location of the variable rather than a copy of the data. Other programming languages refer to this technique as “Passing by Reference.” The pointer is an internal 32 bit value, which is significantly more efficient than copying the entire contents every scan. This method also gives the Function Block the ability to alter the contents of the structure variable.
To show this example in practice, the attached document shows two scenarios. The first scenario scans a Function Block with a large structure as a VAR_INPUT and results in a high CPU load. The other scenario shows the same structure as a VAR_IN_OUT and has no impact on the CPU load.
The large structure is an array of an array creating 500,000 LREAL’s. There is nothing else in the program, the custom Function Blocks have no code.
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