Combining mechanical design in Onshape with dynamic simulation in Simscape means that virtual tests of your integrated system are now limited only by your imagination.

Mechatronic systems are everywhere. You probably have at least one in your pocket or your bag right now! Robots, phones, and even cars are considered mechatronic systems. They are a mix of mechanical, electrical, thermal and software systems all rolled up into devices that make our lives easier. The individual pieces used to be developed separately in separate tools, and engineers would cross their fingers and hope that it would all work together in the end.

But hope isn’t the best thing to rely on. Hope leads to redesign after redesign, broken parts and something that can melt a hole in your table and your budget. We clever engineers, however, have figured out a magical way to test integrated designs long before the parts even exist.

Testing without hardware sounds like magic, and it kind of is. Sure, you know how to whip up a 3D design in Onshape, but if your next step is to send it to a 3D printer, you’re still relying on hope. Instead, you can import your Onshape models into Simscape from MathWorks, where they can be tested in dynamic simulation. You can figure out how strong the parts need to be, how big the motors need to be to move them and even how the software will react if the sensor fails. Let’s see how this works by looking at a robotic system.

The image at the top of this blog is a mechanical model of a pick-and-place robot arm we created in Onshape (see the full design here). Within Onshape, we can define parts, contours and even specify how parts move with respect to one another. Our robot has the potential to lift, grab, turn, flip and release any object that will fit in its gripper. To unlock that potential and complete the design, we need to attach motors and a control system.

This is where Simscape comes in. Models in Onshape can be exported to Simscape. A single MATLAB command will allow us to breathe life into our robot by automatically converting it into a dynamic simulation model. Geometry, mass, inertia and joints are all transferred to the Simscape model we will use to complete the rest of the design.

##### And Now for the Heavy Lifting

It is time to put that robot to work. We need to pick the motors we will use in our robot, and to do that we need to know how much torque they need to produce and what levels of force will be exerted at the joints. With Simscape, we can run that robot through a battery of tests, including worst-case scenarios. We can test maximum load, maximum speed and worst-case friction, all to ensure that the motors we pick will do everything the robot needs to do, and nothing more.

With this list of motor requirements in hand, we can look at data sheets and pick the right motor for the job. Those data sheets give us exactly the values we need to parameterize our electrical model. Once those models are hooked up to the robot, we can re-run our tests to see how well the robot performs. What’s more, we can explore the electrical aspects of our design. With all the motors connected in an electrical network, we can see how much power is drawn and use that information to size the power supply or battery that is connected. We can also look at the heat generated and size heat sinks. It’s alive!

And have you noticed how much we have accomplished in our design so far without a single piece of hardware? But wait, we’re not done yet…

##### It Ain’t Easy Being Green

It is no good spending all that effort on a great design and then forcing the robot to spend all day every day throwing money away. Our robot needs to transport a heavy object from one conveyor belt to another. If we don’t invest the time to pick a good path for the arm to follow while moving those boxes, we will be using much more power than we need. In this age of green design, it would be irresponsible to stop now.

Optimization algorithms in MATLAB enable us to find the trajectory that minimizes power consumed. As parameters that define waypoints in the trajectory are modified automatically, the electrical power consumed is calculated and that is our cost function. Thousands of tests later, our robot is consuming 17% less power. Maybe it isn’t so difficult to be green after all.

##### The Brains of the Operation

We have given our robot brawn, now it needs brains. The algorithm that controls the conveyor belts and the robot arm is most efficiently described using a state machine. Weight sensors and light curtains inform the controller where the boxes are. That information lets the algorithm know what is happening in our system, and it can decide when to move to the next state – turning belts on and off, moving the robot arm between different positions and opening and closing the gripper.

This state machine is integrated in the same simulation model as our model of the robot and conveyor belt. We can develop and tune the algorithm, and even see how it reacts when sensors fail. Imagine testing that on real hardware… on second thought, let’s not.

##### Measure Twice, Cut Once

After all this virtual testing, we can build our first prototype with much higher confidence that the design will not only work, but work really well. Sure, there will be aspects that the simulation didn’t get just right, but it will be a matter of fine-tuning the result, not a complete redesign. What makes this possible is the ability to test without hardware. Virtual tests of the mechanical design in Onshape combined with multi-domain dynamic simulation in Simscape and algorithms in Simulink let us measure thousands of times in thousands of ways before making our first cut.

So, I think we can safely say testing without hardware is a reality. You can try it yourself by downloading Robot Arm with Conveyor Belts from the MATLAB Central File Exchange.

Try Simscape Today