Project tutorial
Levitate a Ping Pong Ball Using Arduino and Simulink

Levitate a Ping Pong Ball Using Arduino and Simulink © GPL3+

This project uses Simulink to make an Arduino based blower fan that levitates a ping pong ball at a specified height.

  • 4,982 views
  • 4 comments
  • 11 respects

Components and supplies

Ardgen mega
Arduino Mega 2560 & Genuino Mega 2560
×1
3D Printed Parts
×1
IRLZ14 MOSFET
×1
Sharp Infrared Sensor GP2Y0A21YK
×1
Blower Fan
×1
7.4V Li-Po Battery
×1

Necessary tools and machines

3drag
3D Printer (generic)

Apps and online services

Simulink
H5g3etjnacmazg8oq17z
MATLAB

About this project

Overview:

This project utilizes Arduino and Simulink to control a blower fan, and levitate a ping pong ball to a specific height. It's a fun application that will help you learn about PID control and Simulink.

Hardware:

You can wire the hardware according to the provided schematic or you can follow the steps detailed below.

  • Connect the positive terminal of the battery to the power pin of the blower fan and the negative terminal of the battery will be connected to ground
  • Connect 5V to the power pin of the infrared sensor, ground pin to the ground pin of the sensor and analog pin 4Hard to the output pin of the sensor
  • Connect PWM pin 8 and a 1kΩ pull-down resistor to the gate pin of the IRLZ14 MOSFET
  • Connect the source of the MOSFET to ground and the drain of the MOSFET to the ground pin of the blower fan.

Software:

The speed of the blower fan can be controlled in two modes:

  • Manual Mode: You control the height of the ping pong ball by adjusting the speed of the blower fan with a knob inside the Simulink model.
  • PID Mode: The height of the ball is controlled by a PID controller that takes in data from an infrared sensor mounted on the top of the 3D printed tube. In order to accurately control the system, the PID's three gain parameters (proportional, integral and derivative) need to be tuned. You can easily adjust these parameters using the knobs in the Simulink model. Once the parameters are tuned, the PID will control the height of the ball.

Additional Note:

When your PID control algorithm is complete you can download it to your Arduino with the click of a button, after which it runs standalone on the device (i.e. independent of Simulink). If you want, you can also use Simulink external mode to interactively refine PID gain parameters. The video linked below explains external mode in more detail.

Documentation and Demonstration

To download the files for this project and see a video of the system in action, go to the following link:

https://www.mathworks.com/matlabcentral/fileexchange/58427-levitating-a-ping-pong-ball-using-arduino-and-simulink

Schematics

Circuit Schematic
Circuit schematic for the set up
Capture

Comments

Similar projects you might like

R/C Controller for Arduino and Simulink

Project tutorial by Team MATLAB Makers

  • 6,391 views
  • 2 comments
  • 7 respects

IR Proximity Sensors with Simulink and Arduino (Part 1)

Project tutorial by Team MATLAB Makers

  • 4,279 views
  • 3 comments
  • 10 respects

IR Proximity Sensors With Simulink And Arduino (Part 2)

Project tutorial by MATLAB Makers

  • 1,323 views
  • 0 comments
  • 0 respects

Magnetically Levitated Ball with MATLAB and Arduino

Project tutorial by Team MATLAB Makers

  • 7,806 views
  • 4 comments
  • 14 respects

Arduino Ping Pong Pinball

Project tutorial by joesinstructables

  • 5,002 views
  • 4 comments
  • 10 respects

Creating an Oscillating Fan Using Simulink and Arduino

Project tutorial by DanDoherty

  • 981 views
  • 0 comments
  • 5 respects
Add projectSign up / Login