Overview
This application note demonstrates how the integration between mechanical and simulation software (SolidWorks/COSMOSMotion) and a control development environment (National Instruments LabVIEW and NI SoftMotion) can help engineers slash machine design time for complex electromechanical systems.
Table of Contents
- Moving from Mechanical to Electromechanical Machine Design
- LabVIEW Interface VIs for SolidWorks and COSMOSMotion
- Improving Mechanical and Control Design with Closed-Loop Simulation
- Summary
Moving from Mechanical to Electromechanical Machine Design
As machine builders implement new technology and replace yesterday's coupled gears, cams, and line shafts with servo actuators for precision motion, sensors for diagnostics, and cameras for inspection, these machine builders are embedding more functionality in the controls of the machine as opposed to the mechanical components.

Figure 1. Today’s engineers use servo-driven actuators for precision motion.
Previously, with the mechanical approach, an engineer implemented a simple push/pull mechanism using a rocker arm connected to a cam and a motor that only needed an on/off signal for actuation. The engineer could easily control this system with a programmable logic controller (PLC) and determine the travel distance of the push/pull mechanism by the design of the cam. Machines today need flexible travel lengths to accommodate the production of multiple product designs on the same machine. Today, engineers design these machines using servo actuators and servo controllers and determine travel lengths by software parameters.

Figure 2. To achieve efficient machine design, engineers need to simulate the integrated mechanical and control design in software before moving to the prototype stage.
What used to be a purely mechanical design is now an electromechanical design, adding complexity to the design process. In the past, the mechanical engineer designed the complete system, and the controls engineer added simple on/off controls to actuate the machine. Now the mechanical engineer can design only part of the system, while the controls engineer designs the “brains” of the system without which the mechanical design is severely handicapped. To achieve efficient machine design, engineers need to simulate the integrated mechanical and control design in software before moving to the prototype stage. This helps them make trade-offs in the early stages of design, visualize the electromechanical system in action, and save money on creating prototypes after every design iteration.
LabVIEW Interface VIs for SolidWorks and COSMOSMotion
With mechanical design software such as SolidWorks, mechanical engineers can design machine parts and assemblies using a point-and-click interface with 3D visualization. COSMOSMotion, a SolidWorks add-on, helps simulate mechanism motion by taking into account mechanism dynamics, such as forces and friction, and generates information, such as position and kinetic energy.
While COSMOSMotion is well-suited for open-loop motion simulations, a typical electromechanical system involves closed-loop control. For a true closed-loop simulation, engineers need to simulate not only the dynamics of the mechanism but also the control algorithms that act on the mechanism. The mechanical simulation involves parameters such as friction, forces, and gravity, while the control simulation involves algorithms such as PID. NI LabVIEW is a graphical development environment with more than 650 analysis and control algorithms as well as functions like trajectory planning and spline interpolation. Engineers commonly use LabVIEW to design controls for complex machines that involve motion control, vision, and analog and digital I/O. After the simulation validates the control algorithm design, engineers can deploy the same LabVIEW programs to any programmable automation controller (ni.com/pac) in their machines.

Figure 3. The mechanical simulation involves parameters such as friction, forces, and gravity, while the control simulation involves algorithms such as PID.
Consider a simple example of a block moving on a surface. Applying a force to the block in the horizontal direction moves the block for a certain distance, depending on the friction between the block and the surface. Repeatedly applying a force to the block continues to move the block along the direction of the force. Consider this a simplified view of a linear motor stage. Applying a force to the block (analogous to the magnetic force) and simulating the dynamics of the system in COSMOSMotion generates the output of the position to which the block moves. This position acts as a process variable for the PID algorithm, and, given a setpoint, the PID algorithm calculates the next force to be applied. Engineers can apply this force in given steps of time, depending on the servo update rate at which engineers run the algorithm in the final system. Engineers now need an interface between LabVIEW and SolidWorks/COSMOSMotion to be able to run hundreds of iterations of this closed-loop control simulation.

Figure 4. The LabVIEW interface VIs for SolidWorks/COSMOSMotion provide a seamless interface between the two environments so engineers can simulate closed-loop control for complex electromechanical systems.
The LabVIEW interface VIs (functions) for SolidWorks/COSMOSMotion provide a seamless interface between the two environments so engineers can simulate closed-loop control for complex electromechanical systems. The interface VIs invoke the COSMOSMotion API via ActiveX to communicate between LabVIEW and SolidWorks/COSMOSMotion. Learn how to download these interface VIs below.
The LabVIEW interface VIs for SolidWorks/COSMOSMotion include basic functions to initialize, run simulation, and close the communication with SolidWorks/COSMOSMotion. It also includes advanced functions to set parameters such as forces and gravity in SolidWorks/COSMOSMotion and to get values in LabVIEW from SolidWorks/COSMOSMotion for parameters such as position, velocity, acceleration, and kinetic energy.

Figure 5. The LabVIEW interface VIs for SolidWorks/COSMOSMotion include basic functions to initialize, run simulation, and close the communication with SolidWorks/COSMOSMotion. It also includes advanced functions to set parameters such as forces and gravity in SolidWorks/COSMOSMotion and to get values in LabVIEW from SolidWorks/COSMOSMotion for parameters such as position, velocity, acceleration, and kinetic energy.
The interface VIs also includes advanced functions to set parameters such as forces and gravity in SolidWorks/COSMOSMotion and to get values in LabVIEW from SolidWorks/COSMOSMotion for parameters such as position, velocity, acceleration, and kinetic energy.
Improving Mechanical and Control Design with Closed-Loop Simulation
Closed-loop simulation between mechanical and control development environments can help drive design decisions for both the mechanical and control aspects of the design. For example, engineers may choose to replace a ball-screw stage with a linear motor when they discover the given load cannot be moved at the rate they want. They also can check for mechanical interference in the system, accounting for loads on the system and the control algorithm used. On the control side, engineers may choose to use PID with velocity feed-forward instead of regular PID to achieve better control. They also may want to replace PID with fuzzy logic or Model-Free Adaptive control for controlling nonlinear or higher-order systems.
Making decisions such as these on the mechanical and control sides gives engineers a streamlined machine design process. With fewer iterations needed through a physical prototype, engineers can get to market faster and at a lower cost. Virtual prototyping of both mechanical and control designs helps engineers develop proofs of concept before physical prototypes. They can check their control algorithm logic without risking damage to a physical system. Given that the dynamics of the system are accurately modeled, engineers can fine-tune algorithms against high-fidelity simulation.


Figure 6. Closed-loop simulation of a mechanical system with a PID algorithm shows the difference in settling times of a badly tuned and a well-tuned PID algorithm. Closed-loop simulations also require less energy to drive the system and result in smoother motion for longer machine life.
The NI SoftMotion Development Module for LabVIEW includes functions for trajectory generation, spline interpolation, and enhanced motion PID that engineers can use to simulate a complete custom motion controller in LabVIEW. With NI SoftMotion functions in LabVIEW, engineers can even create a closed-loop simulation of a multiaxis stage designed in SolidWorks/COSMOSMotion.

Figure 7. The NI SoftMotion Development Module for LabVIEW provides engineers with functions like trajectory generation and spline interpolation to create closed-loop simulation of multiaxis systems like an XY stage with SolidWorks/COSMOSMotion.
Summary
Closed-loop simulation with a control design environment such as LabVIEW and a mechanical design environment such as SolidWorks/COSMOSMotion can help streamline the design process for complex electromechanical systems. Download the LabVIEW interface VIs for SolidWorks/COSMOSMotion through the link below.
Reader Comments | Submit a comment »
The idea is very good, but this is not a
tutorial, labview does not provide more
detailed information and tutorial on this issue.
- Dec 14, 2007
The official LabVIEW-SolidWorks interface is now released
The official LabVIEW-SolidWorks interface for
digital prototyping of motion/machine control
systems is now released. For more
information, including training webcasts,
visit this site:
http://www.ni.com/digitalprototyping/
-
Brian MacCleery,National Instruments.
brian.maccleery@ni.com
- Aug 19, 2009
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
