Have you ever tried balancing a ball on a racket? If you have ever played table tennis, then you should have tried balancing the tennis ball on your racket. How long did you manage to hold the ball against the gravity? 30 seconds? 2 minutes? My personal best time is around 5 minutes. You know that it is all related with gravity. I think it is not surprising to find out that human beings' one of the most important invention is a circular object: Wheel. That might be the reason why it attracts our attention the most and we would like to experiment on a design that is engraved in our DNAs!

What about balancing the ball on a moving robotic-ish plate using some electronics, 2x servo motors and mechanics with a little bit of math and some voodoo! Not the last one hopefully. But something called PID (proportional–integral–derivative) controller would do the trick (and it has been doing many tricks for more than 100 years). Actually, a ball balancer, or a ball and plate experiment or a ball balancing table or many other fancy names point to the same classical control experiment that has been solved over and over. The idea is simple. Control the servomotors to change the orientation or inclination of a surface where a ball is moving freely with the aid of the gravity. Get some feedback either from some touch sensor or maybe through a camera. Use a closed-loop control system with a low-cost Arduino or maybe with a high-end NI myRIO by implementing a linear or non-linear control algorithm and track the ball and its position error.

Some implementations use simple algebraic techniques such as error reduction, on-off controllers. Others utilize advanced control theory topics like fuzzy control, adaptive algorithms and so on, for which we have provided a tasty glimpse of the concepts in our blog page, "Overview of Control Systems in the Universe"

Figure 1 - Acrome Ball Balancing Table keeping the ball right into the spot, well done calibration!

If we make a deeper dive into the system, we can find some much fancier use cases of our fellow ball balancer. Here is a good list that encapsulates what could be done with a decent quality ball balancer system:

**1) Plate Orientation Control (in 1D or 2D surface)**

Let's start with the simplest one. Definitely one can control each of the motors (one motor for 1D, 2 motors at the same time for 2D) to change the orientation of the plate and for what? Well you may work on the 2nd law of Sir Newton for physics experiments on inclined surfaces to analyze the effects of friction and acceleration and speed. Although a round ball is not the best item to analyze this problem, using any comparable size object is acceptable if you have a touch sensor for the feedback.

Figure 2 - Sir Isaac Newton and the infamous friction and acceleration exercise. Do you know which law one of his law's related with this problem? [Image is in courtesy of Khan Academy]

**2) Frequency Domain Analysis**

If you have studied a little bit of control theory or maybe signals and systems, then you should be familiar with the term called frequency domain analysis. Any physical (and electronic as well) system has a limited response to the rate of frequency that they are used with. And as with the previous sentence, it is always hard to visualize and fully understand the concept of frequency response. Not even mentioning about drawing a Bode Diagram to analyze the response.

Figure 3 - Ready to run Bode Analysis Example of ACROME Ball Balancing Table draws a bode plot with the system model. Detailed courseware available at Ball Balancing Table page.

A beautiful experiment that can be applied with a ball balancing table is the frequency response of the system and there should be no worries to make an error. It is a fully error free system. If you follow a circular trajectory with the ball on the table, then you will have a very safe and a quite easy to control system suitable for frequency domain analysis. By changing the speed of revolution, you will change the frequency of the system. Faster the ball revolute, higher the frequency of a system to control the rotation. This experiment is not widely known but it is very easy to implement. If you own a ball balancer, go ahead and give it a try. If you don't have a system currently, then you may consider enrolling to our webinars for a live demonstration.

**3) Real time Proportional–Integral–Derivative Control (PID Control)**

Assuming that we all know the PID (proportional–integral–derivative) controllers ... Or do we? Definitely, PID is not a rainbow that you can see in your daily life (or depending on where you live -hopefully not in Kalahari Desert- in weekly, monthly or at least a yearly time-frame).

Although PID is a mature[1] fundamental topic, most of the engineering students cannot experiment PID basics in the real world like moving, juggling, boiling or using a similar control equipment. With many other community references, we believe that success in education increases with something called applied learning.

Figure 4 - Results from a Google search of "Applied Learning"

According to an UNCW article, applied learning is a pedagogical model that places students in experiences requiring them to integrate theories, ideas, and skills they have learned in new contexts, thereby extending their learning. And it is always hard to reinforce engineering concepts -such as PID- with practical lab experiences. Sometimes difficulty comes from the installation and operational costs. Even if there are existing resources, sometimes students are getting buried under non-conceptual details due to the inefficient pieces. Common problems are loose cables, mechanical deficiencies, missing tools, missing software pieces, missing instructions or even lost user manuals. Virtual labs are not ready to provide quality service and coherentcontent.

An optimum solution is to have a user-familiar, open platform made with precision crafted mechanics yet with an acceptable price tag.

Closing the loop of the PID control; a ball balancing table is a good example of a real time PID controller to control the plate orientation for experimenting different PID parameters and controller types. Important concepts such as damping factor, overshoot-undershoot, integral windup; are all easy to use and easy to experiment by the most fundamental ball position control experiment (and with the help of a step input, which could be your hand).

**4) Trajectory Tracking**

If we have a real-time control system with some good response speed to control the ball's position then we can use the same system to arbitrarily place our ball into any location on our platform, well in this case on the table. Then what? Although there are many good usage examples such as reducing the vibration of CD-DVD players as explained in nice academic papers [2][3], we can use these systems to easily track some predetermined trajectories such as rectangular or circular paths, or arbitrarily drawn paths. You may check our ACROME Ball and Balancing Table below to see a good "infinite path" example.

**5) Linear and Nonlinear Control**

Choosing the type of the controller depends on system objectives and needs. Conventional control methods (such as PID described above) assume that the behavior of a system is linear, and the system transfer function is known. Hence, the controller parameters can be found mathematically by using the transfer function. What if the system is a non-linear one? Then a different approach should be used for controlling the system. One good method to control the non-linear system is with something called fuzzy logic controller, which was presented by Professor Lotfi Zadeh in 1965 but not as a control methodology in the beginning. Luckily later in 1972, he presented a new paper[4] and introduced the term fuzzy rules and linguistic variables in the control theory.

In contrast to conventional control methods, fuzzy logic does not require a system transfer function or a linear system. Fuzzy logic uses linguistic variables such as negative, zero, positive, small, medium and large. These linguistic variables which form fuzzy sets-inputs and outputs of the fuzzy controller- are formed by combining those fuzzy sets.Next, rule-base (aka linguistic rules) is obtained by using linguistic variables.Fuzzy inference process is used for determining which rules are relevant to the current situation by using rule-base. Finally, a single output is produced by using one of the defuzzification methods.

Wow! Somany academic definitions. But how can we use this information in real life? Naturally with a solidexperiment and some graphical user interface to reinforce the experiment. Below you may find a sketch of the fuzzy control system and the way we implement this system in our ball-balancing product. By the way, all the source code of the ACROME ball-balancing table is open source and you can read and modify the source code however you want.

Figure 5 - Fuzzy Logic's Block Diagramand User Interface to Implement

**6) System Model Derivation and Linearization**

If you are familiar with the control theory then you should have heard that, "give me the model of any system then I can control it with anything!"or maybe not. In reality, deriving the mathematical model of any physical system is a tedious and mostly a hard job involving mathematical operations, many observations and assumptions. Even though it is a simple experiment, a ball-balancing table is not an exception and there are multiple variables to deal with. The system model must take into consideration about 11 parameters to faithfully simulate the physical realm.

Figure 6 - Physical model of the Ball Balancing Table and its parameters involved in mathematical model

The first step of the modeling is to derive the equation of motion. The equation of motion describes the relationship between motion of the ball in (𝑥𝑏, 𝑦𝑏) plane and the two angles of the table (α, β). The equation of motion is available in our courseware and derived with two different methods, Lagrangian Method and Newton's Law of Motion (as described in above section). The aim of modeling is to derive the physical relationship between the outputs and inputs of a system. In our case, the outputs of the system are the coordinates of the ball in x and y-direction (𝑥𝑏, 𝑦𝑏). The inputs of the system are the motor angles (𝜗𝑥, 𝜗𝑦). To obtain the transfer function of the system, the differential equations should be linearized about the operating point (x=0, y=0). We are giving more insight into the linearization process in the courseware.

At the end of all above efforts (and many mathematical operations, formulas that we have fast-forwarded), we are able to end up with a validated transfer function and a block diagram of the ball balancing system as given in thefigure underlined below:

Figure 7 - Block diagram of the Ball Balancing Table

That's all from this blog post. Let us know which topics you want us to cover in our future posts. Also you can subscribe to our newsletter.

To learn more about our ball balancing table, mechanic tips and tricks, and application codes etc. join us in an upcoming webinar or feel free to send a message through info@acrome.net.

**Related Readings:**

[1]: PID Control History and Advancements blog written by Jim Cahill

[2]: Performance of an Automatic Ball Balancer With Dry Friction

[3]: Automatic Ball Balancer Using Permanent Magnets to Reduce Transient Vibration

**Disclaimer: **

Arduino is the trademark of Arduino AG and NI myRIO is under trademark of National Instruments. Other product and company names listed are trademarks and trade names of their respective companies.

**Disclaimer**:

Arduino is the trademark of Arduino AG and Raspberry Pi is a trademark of the Raspberry Pi Foundation. Matlab and Simulink are trademarks of The Mathworks Company. NI myRIO and LabVIEW are trademarks of National Instruments. Other product and company names listed are trademarks and trade names of their respective companies.