**By Peter Nikiforov, Mechanical Engineer**

**INTRODUCTION**

For Engineers, solving complex problems involves both analytical and empirical techniques to find comprehensive solutions. Engineers often use analytical approaches to solve problems, but in many cases, analysis combined with empirical findings lead to a complete solution. It is important to realize engineering is strongly dependent on both approaches and that they are not mutually exclusive methodologies.

Often we’re asked by clients to assess the feasibility of projects. This stage is often highly analytical, but in many cases analysis is not enough. The real world is complex and chaotic; foreseeing all possible conditions and outcomes is practically impossible. Therefore, we build prototypes and test to gain insight and discover solutions that otherwise could be overlooked. A great example showcasing the importance of using both analytical and empirical methods, is my very own mechanical engineering masters project.

**PROJECT DESCRIPTION**

The project challenge was to design and build a cube that could balance on one of its corners (see Figure 1). Balancing the cube was achieved by applying controlled torques to the body using flywheels actuated by DC motors. A microcontroller was used to read orientation data from 3 inertial measuring units (IMUs) fixed on three faces of the cube. Each IMU included a three axis gyroscope and a three axis accelerometer. A control algorithm used the IMU orientation data, and the flywheel velocity to apply appropriate voltages to the DC motors to balance the system.

**TRANSFER FUNCTION**

Designing a controller to send the appropriate voltage involves knowing the transfer function of the system. A transfer function is the mathematical relationship between a systems input and its resulting output. In the case of the cube, the input is the voltage to the motors and the output is the associated angular displacement of the cube’s body. This relationship is directly used to design a controller to balance the cube. Deriving this relationship was done both analytically and empirically.

**BACKGROUND**

In control theory a cube balancing on a corner is referred to as a 3D inverted pendulum. A 3D inverted pendulum in many ways is similar to a 2D inverted pendulum (see Figure 2), like a Segway, only with additional degrees of freedom. Extensive research literature describes the analytical transfer function derivation of many 2D inverted pendulum systems. Research related to 3D inverted pendulums, on the other hand, is sparse and not generally applicable.

**PROTOTYPE**

Given the lack of supporting literature and the complexity of the 3D inverted pendula, I used a semi-empirical approach to balance the cube on its corner. The first step involved developing a 2D inverted pendulum (a prototype). A cube balancing on its edge, is a simplified 2D inverted pendulum version of the cube on its corner. And, rather than building a full cube, to develop edge balance, a simplified mathematically equivalent prototype was constructed (see Figure 3).

The transfer function for the prototype system was derived analytically and was used to successfully balance the system. The control method implemented is a somewhat modern method referred to as state space control. A state space controller requires measuring specific states of the system to produce a control signal. The specific states of the system are determined from the system’s transfer function. In the case of the prototype the necessary measured states are: the position of the body (θ_{b}), the angular velocity of the body (ω_{b}), and the angular velocity of the flywheel (ω_{w}) (this is important later).

**CORNER BALANCE THEORY**

Gaining insight from the prototype system, I developed a theory for how corner balance could be achieved. Rather than deriving a holistic transfer function for the cube (a mathematical nightmare), instead the control algorithm from the prototype was implemented independently for each of the three faces of the cube with flywheels. Each flywheel is responsible for maintaining balance of its respective face. If each of the three faces is balanced, the cube as a whole will balance. This theory was verified using CAD; the constraints that each independent flywheel provided were simulated, resulting in a fully constrained system.

**IMPLEMENTATION**

The cube was constructed and the controller implemented resulting in an unstable system, in other words, the cube failed to balance. Something unsuspecting happened: the cube would initially balance, then slowly begin to rotate about its corner. The wheel velocities slowly increased until the motors reached an rpm limit and turned off. Then, the cube would cease to balance.

The failure to balance was related to the rotation of the cube being inadvertently measured by the IMUs, causing an error in angular position estimate. In other words, the sensors interpreted the cube rotating as the cube falling. To compensate, the wheel velocities increased, which in turn induced additional rotation of the cube.

**SOLUTION**

Needless to say this phenomenon was unexpected. Without building the cube and implementing the controller, this was quite difficult to predict. But having observed the phenomenon, a solution started to become apparent.

If the wheel velocities were kept from increasing (and inevitably shutting off the motors), the cube would maintain balance. But as it was, the three wheel velocities were controlled independently and their effects on one another caused a cascading increase in the wheel velocities.

So, to address this, an additional state was added to each of the three independent control algorithms. The state was the average velocity of all three wheels (ω _{w-average}). By doing this, each control face additionally attempted to control the average wheel velocity of the system, making the three control algorithms interdependent.

The revised controller was implemented and resulted in a cube that balances on its corner indefinitely! Check it out in this video.

The complete solution for balancing the cube on its corner was not immediately apparent. Only after the cube was constructed and the original algorithm implemented did a problem even become apparent. However, without the initial analytical derivation of the prototype transfer function, finding any solution would have been akin to shooting in the dark. The complete solution involved both analytical and empirical methods.

**CONCLUSION**

This project exemplifies the importance of using both analytical and empirical approaches in the development of any product. Often engineering challenges can give results that are not anticipated or that don’t quite match calculations. Discovery throughout multiple iterations of the cube made it clear that both approaches were necessary to arrive at a complete solution.

Through experience as a Mechanical Engineer, I’ve cultivated the process of using a combination of analytical and empirical methods during any product development project. This good practice continuously leads to insight on how to proceed and ultimately to the best, holistic product solutions.