Understanding PID Control: 2-DOF Ball Balancer Experiments

This article explains how to use PID controllers to solve a real-world balance problem. We need to calculate PID gains to do so. Let’s start first with the Ziegler-Nichols method:

Ziegler-Nichols Method

Ziegler-Nichols method is very useful for calculating the controller gains. This method begins by zeroing the integral and differential gains. After this step, the proportional gain is increased until the system oscillates. After finding the proportional gain that makes the system oscillate, the other gains of the controller are calculated with the help of the table below.

Ziegler-Nichols Method table
Figure 1: Ziegler-Nichols Method



To use this method, you can follow the steps below:

Figure 2: (Algorithm to calculate the PID gains using the Ziegler-Nichols method


Damping

In the real world, friction affects the behavior of the systems. If there were no frictions, the systems wouldn’t stop and oscillations would continue indefinitely.

Figure 3: The balls would keep hitting forever if there weren’t any friction (even though the video loops)

If friction becomes zero, some systems can behave infinitely like Figure 3.

If the damping ratio gets close to zero, the system will spend more time stopping. If the system can’t stop, it is called oscillation. In the oscillation, the system moves between some of the points. The step response is a commonly used method to analyze systems’ behavior. The system’s behavior can be followed by a step response. In figure 4, we can easily see the relevance between the damping ratio and system behavior. For example, the system can directly reach the set point when ζ=1 however if  ζ=0, the system can’t stop and reach the set point.

We can classify the damping ratio for its oscillation types. We can show the damping ratio with the ζ (Tau) symbol and it is classified as follows:

  • ζ<1 The system is underdamped
  • ζ>1 The system is overdamped
  • ζ=1 The system is critically damped

We can easily understand what the damping ratio means in real life using Acrome’s Ball Balancing Table. The animations below show different damping ratios which are changed using the controller’s PID parameters.

Figure 4: Critically damped PID controller exercise using Ball Balancing Table

In figure 4, the ball movement shows a critically damped behavior. It can reach to set point fastly with zero error. We can consider that the ball’s ζ is close to 1.

Figure 5: Underdamped PID controller exercise using Ball Balancing Table

Figure 6: Overdamped PID controller exercise using Ball Balancing Table

In Figure 6, the ball behaves overdamped. It reaches a set point slowly, which means the ζ>1.

Figure 7: Unstable PID controller exercise using Ball Balancing Table

In Figure 7, the ball behaves in unstable behavior. It can’t reach the set point. Also, the ball draws a random direction on the table

Figure 8: Step response of the 3 different step response types.

Balancing is a very common problem in the industry. Some of the systems are affected by balance. So the system’s balance should be under control. For example, planes can change direction by balance. Moreover, you have already seen in MotoGP™ riders change motorbikes’ slopes instead of turning the handlebar for changing direction.

Figure 9: MotoGP™ is a place where vehicle dynamics + driver abilities combine with each other for controlling the balance of the motorbike.

One Dimensional Balance Problem

Aircraft Roll Motion can also be considered as another real-life example of a balancing problem.

Figure 10 – Roll Motion of the Aircraft. Similar to BBT’s counter motor action, a counter aileron movement is required to control the rolling action.

Rotation around the front to the back axis is called roll. On the outside of a wing, there are small hinged portions called ailerons. An airplane can produce a rolling motion by using its ailerons. Ailerons usually work in opposite positions. For both wings, the lift force (Fr or Fl) of the wing section through the aileron is applied at the section’s aerodynamic center, which is some distance (L) from the aircraft’s center of gravity. This creates a torque T=F x L

Figure 11: Force vectors, CoG, and Resulting Motion happening during the aircraft’s roll motion.

If the ailerons are not controlled correctly, the aircraft will move undesirably. It is exactly what happens in a 1-D ball-balancing application. It can be simulated in a controlled lab using experiment systems such as ACROME’s Ball and Beam System. The Ball and Beam System is one of the real-life applications of the rolling event. Students can experiment with this 1-D balancing application and work with the PID controllers to understand the effect of the ailerons.

Figure 12: ACROME’s Ball and Beam


You can watch using the Ball and Beam Video

You can read more on how Ball and Beam works.

Two Dimensional Balance Problem

The Acrome Ball balancing table is a good experiment for 2-D PID control.

acrome Ball Balancing Table
Figure 13: Unlike Ball and Beam, the Ball Balancing Table controls the position of the ball in 2 dimensions.

Now let’s focus on another angle of control of the airplanes: The Pitch angle. The pitch angle of the planes can be controlled by another wing set called the Elevator. Similar to the ailerons, the elevator is also controlled (up and down) to control the pitch angle of the airplanes.

Figure 14 – The elevator is used to control the pitch (the nose) angle of the airplanes.

This is analogous to controlling the ball with 2 servo motors. How can we do that? 

One of the motors can  control x dimension and the other motor control y dimension.Each motor has different PID controlersl so one motor can only control one dimension.

pitch and roll of the Acrome Ball Balancing Table’s top plate
Figure 15: The two servo motors are used to control the pitch and roll angles of the Ball Balancing Table’s top plate.

You can read more on how the Ball Balancing Table is working.

This concludes our blog about the PID controller. We hope you enjoyed this document.

Feel free to contact us with your questions or recommendations about the PID controllers.

Delta Robot and Conveyor Example: A Glimpse into Industrial Automation

Part 1: What is a Delta Robot and What Does It Do?

In today’s world, robotics is transforming how we teach and learn about automation. One such educational tool is the Delta Robot, a precision parallel robotic arm with three degrees of freedom (3-DOF), meaning it can move its end-effector in X, Y, and Z coordinates. The Delta Robot serves as a scaled-down version of the large robotic arms commonly used in industries but is primarily used for educational purposes in school laboratories.

Its main purpose is to show to students, particularly in Control and Automation fields, the fundamental principles of robotic arms, including kinematics and precision handling. Large industrial robotic arms are not feasible for lab environments due to their size and complexity, so the Delta Robot provides a more manageable and safer alternative for hands-on learning.

Figure 1: Acrome Delta Robot

Part 2: Kinematic Equations – The Core of Robotic Motion

At the core of the Delta Robot’s functionality lies kinematic equations, which describe the robot’s motion. These equations allow us to calculate the exact position and orientation of the robot’s end-effector based on joint angles. There are two primary types of kinematic equations:

  • Forward Kinematics: This method calculates the position of the robot’s end-effector based on the angles of its joints, effectively converting angles into X, Y, and Z coordinates.
  • Inverse Kinematics: This is the reverse process, where we specify the desired position of the end-effector, and the system calculates the necessary joint angles to achieve that position.

By mastering these equations, students can understand how robots are programmed to move accurately within their workspace.

Part 3: Conveyor Example Using a Delta Robot

In this educational setup, we applied the Delta Robot in a conveyor system example. A conveyor is a mechanical device that moves objects from one location to another. This project demonstrated how a Delta Robot can be integrated with a conveyor to recognize objects and perform precise handling tasks. While industrial robots are often seen in factories working alongside conveyors, in this case, the Delta Robot will be able to operate in a school lab environment, showcasing a similar yet smaller-scale interaction.

The custom conveyor designed for this setup allows the Delta Robot to detect various materials moving along the belt and place them in specific positions. One of the most intriguing parts of this process was object recognition—where the robot identifies objects, detects their shapes, and calculates their position in real-world coordinates.

Figure 2: Flow Chart for Conveyor App

Part 4: Converting Pixel to Real-World Coordinates

To accurately place objects, the Delta Robot must first convert the objects’ position from pixel coordinates (captured by the camera) into real-world coordinates that it can understand. We achieved this using the following formula:

Formulas to calculate the pixels vs real-world coordinates
Scaling calculations

Where:

  • OffsetX and OffsetY are real-world offsets,
  • PixelX and PixelY are the object’s position in the camera’s field,
  • CenterX and CenterY are the pixel coordinates of the camera’s center,
  • ScaleX and ScaleY are the scaling factors converting pixel distance to real-world units.

By using this conversion, the robot can accurately map the detected object’s position on the conveyor belt, ensuring it picks up and handles objects precisely.

Part 5: Detecting Shapes with the Delta Robot

In our object recognition process, the Delta Robot first captures an image of the conveyor system. Using image processing techniques such as thresholding and contour detection, the system identifies shapes like squares, triangles, and circles. Once a shape is detected, the robot calculates its centroid (center of the shape) and applies the pixel-to-real-world conversion formula to determine its precise location on the conveyor.

Below is the algorithm and pseudo code that explains how to detect the object.

Detect and Pixel to Real Coordinate Algorithm:

The Delta Robot first captures an image of the conveyor system in the object recognition process. Using image processing techniques such as thresholding, eroding and contour detection, it identifies shapes like squares, triangles, and circles. When a shape is detected, the robot calculates its centroid and applies the pixel-to-real-world conversion formula to determine its precise location. The algorithm begins by initializing the camera and capturing an image, which is then flipped horizontally. A perspective transformation is applied using predefined corner points, and the resulting image is converted to grayscale. Next, binary thresholding and erosion operations are used to enhance the shapes in the image. Contours are detected, and properties such as the centroid, bounding shapes, and aspect ratio are calculated for each contour.

If the Y-coordinate of the centroid is near a specified value, the type of shape is determined, and labels such as square, triangle, or circle are displayed on the console. The centroid of each shape is marked, and the current time is recorded. If the shape has not been logged before, its data is recorded with a timestamp, and the coordinates are converted to the robot’s real-world system. When the coordinates are valid, they are printed along with the shape name, and the coordinates are returned. Throughout this process, the robot adjusts its movements based on the detected shape, allowing it to pick up and place objects accurately.


Detect and Pixel to Real Coordinate Pseudo Code:

FUNCTION detect()
    INITIALIZE camera
    READ frame from camera
    FLIP frame horizontally
    DEFINE centroids as predefined coordinates
    DEFINE pts1 and pts2 for perspective transformation
    APPLY perspective transformation to the frame
    CONVERT transformed image to grayscale
    APPLY binary threshold
    ERODE  the threshold image
    FIND contours in the image
    DEFINE line_y as 350
    DRAW horizontal line on the image
    FOR each contour DO
        APPROXIMATE contour shape
        CALCULATE contour properties (centroid, bounding rectangle, aspect ratio)
        IF centroid_y is near line_y THEN
            PRINT width and height
            DEFINE shape_name as empty string
            DETERMINE shape based on sides and aspect ratio
                IF square THEN DISPLAY "Square"
                ELSE IF triangle THEN DISPLAY "Triangle"
                ELSE IF circle THEN DISPLAY "Circle"
            DRAW circle at centroid position
            GET current_time
            IF shape is new THEN
                LOG shape data with timestamp
                CONVERT coordinates to robot's real-world system
                IF coordinates are valid THEN
                    ADJUST and PRINT coordinates with shape name
                    RETURN coordinates and label
    RETURN None
END FUNCTION

Depending on the detected shape, the robot can adjust its movements to ensure the object is picked up and placed correctly. For instance, if the robot identifies a square, it uses the centroid coordinates to guide its gripper to the correct position, showcasing the power of automation.

Conclusion: Bringing Automation to the Classroom

This project showed the Delta Robot’s potential for students, highlighting its ability to perform tasks such as object recognition, precise motion, and shape detection—skills essential for real-world automation. Although the conveyor project has not yet been integrated into the educational environment, the progress made with the Delta Robot lays a promising foundation for future applications. It continues, and will continue, to serve as a valuable teaching tool, preparing students for the complexities of industrial automation systems.

Items used in the example system
Figure 3: Camera View of the Delta Robot, Detect Centroid Algorithm

In conclusion, this project shows the Delta Robot’s potential for students, highlighting its ability to perform tasks such as object recognition, precise motion, and shape detection — the essential skills for real-world robotic process automation (RPA). Although this is a conceptual digital conveyor project, the progress made with the real Delta Robot hardware lays a promising foundation for real-world applications.

ACROME’s Delta Robot continues to be a valuable teaching tool, preparing students for the complexities of industrial automation systems.

References:

Craig, J. J. (2005). Introduction to robotics: Mechanics and control (3rd ed.). Pearson.