AVR Ultrasonic Spheroid Levitation Device using ATMega16 microcontroller

Introduction

The goal of this project was to design and build a gaming device capable of levitating a ping pong ball at varying heights based on the proximity of the user to the device, utilizing a multi-tasking kernel on the ATMega16 platform.
Ultrasonic Spheroid Levitation Device Using Atmega644
The project incorporates a fairly complex mechanical system and utilizes many features of the ATmega platform including Analog-to-Digital conversion, SPI communication, Pulse Width Modulation, and real-time task scheduling. The designers, both electrical engineers, wanted to break the norm and build something more physically complex as the project involved a lot of physical construction, using materials like wood and Plexiglas. The game is intended to require significant physical motion on behalf of the participant, in the style of a Wii or Microsoft Kinect game.

High level design

Rationale
The true inspiration for this project was derived from a future project the designers intend to build in their spare time, during senior week. This project, a pneumatic, range-sensing soda can launcher will utilize the same sonar sensor and 7-segment display featured in the levitation game. Taking into account ABET criterion for senior design projects, the soda can launcher was tabled, and the levitation game was designed originally utilizing compressed air to levitate the Ping-Pong ball. A valve capable of regulating the output pressure of a compressed air tank proved too costly for the budgetary constraints of this project, and therefore several blower motors were tested for their adequacy based on their air volume movement ratings (CFM).
Intended to be both entertaining and interactive, the levitation game will be fun for children and adults alike, it is bright, loud, and attractive to those who are curious regarding the fundamentals of flight and the Bernoulli effect. Designed to sit on a tabletop, the game currently requires a large DC power supply to run the blower motor, but a 120v adapter could be easy incorporated if the game were to be more portable. The state machine diagram below shows the logical operation of the game. OCR2 is the PWM register (set to 0 delivers full power to the fan, set to 255 turns the fan off). When the gameStart flag = 1, all tasks are enabled, when gameStart = 0, only the checkSwitches task is enabled.

Background Physics/Math

The overarching physical principle behind the functionality of this project is Bernoullis Principle which states that for the flow of non-viscous fluids, an increase in speed of the fluid occurs simultaneously with a decrease in pressure. Applied to this project, as a high-speed stream of air is directed at a ping pong ball, the air molecules diverted around the ball speed up and therefore exert less pressure. Higher pressure air molecules surrounding the stream exert a restorative force on the ping pong ball, in the direction of higher to lower pressure. Therefore, if the ball is knocked off its equilibrium in the center of the air stream, it will be directed back toward the center by this restorative force.
To establish this high velocity stream two fan types were considered, axial and radial (centrifugal) fans. A quick comparison of these two fan designs indicates that centrifugal blowers are capable of delivering greater pressure throughout the range of air flow volumes. This sustained pressure is key for maintaining ball levitation even while varying the rpm of the fan.
Furthermore, the power output/consumption of centrifugal fans is proportional to the amount of air they are moving. This quality makes them ideal for linear PWM control since higher voltages and therefore higher current draw corresponds to increased power output.

Logical Structure

Care was taken to ensure the design was as simple, efficient, and as safe as possible. Beginning with the choice for a power source, a current-limiting power supply was chosen over a standard 12 volt battery. While a power supply is more cumbersome to operate than a 12v battery, it offers short circuit protection as well as impulse dampening. If a 12V battery was in use and during testing a hot, and ground wire came in contact the results would be catastrophic. Furthermore, the power supply allows us to limit the current while testing our PWM circuit. It is vital not to exceed the current ratings of the power transistor or the fan, so having control over the maximum current draw was quite useful.
All of the electronics selected for this project were chosen for their modularity and simplicity. Utilizing the TinyRealTime task-scheduling kernel, the software aspect of the project shares the same modularity of the hardware, which makes testing individual components as simple as commenting out a line of code, or removing a connector from the white board.
Finally, potential circuit failure modes were considered during the design process. Instead of taking the output from the photodiode (used for keeping score) and using this to trigger an external interrupt on the microcontroller, it was connected to a port pin which is checked several times a second. Since the photodiode-opamp circuit has the potential to become unstable and oscillate wildly if it loses calibration, this would result in an ISR being called so much that it would block the other functions of the CPU and halt the operation of the game. Also, to ensure the bilge blower has sufficient current to run at full capacity, we utilized heat sinks and a cooling fan directed at the BUZ71 power transistor since its current output capability drops drastically as it heats up. All switches are connected through grounds, to be sure the 12v hot line is isolated away from user interaction points.

Hardware/Software Tradeoffs

The game logic and peripheral control is handled in software by the ATmega16 microcontroller running TRT. There are no digital logic circuits external to the microcontroller, responsible for logic decisions. There are two embedded controllers used in the project: an ATmega328P which is integrated into the 7-segment display and is capable to of decoding SPI signals into the proper format for driving the display and a PIC controller which drives the sonar sensor. The overall input/output scheme is diagrammed below:
Considering the fact that the game operates on a human time scale and the limitations of the hardware sensors and displays, each task need only execute 10 times per second. The sonar sensor is capable of updating its analog output every 100milliseconds, and the seven segment display operates at 9600 baud. The hardware buttons simply connect a port pin to ground (the port pins are held high by pull-up resistors) when pressed. The software reads Port C every 100ms to determine if any of the buttons are depressed, and reads PIN D2 to determine if a goal has been scored (the photo sensor outputs a logic high 5V signal when the beam is blocked by the ball). Every 100ms the A/D conversion value is read and the register is reset so that the next value can be accessed when the task is called again.
The hardware output interfaces include a Pulse Width Modulated (PWM) signal to control the speed of the main blower fan, a digital output pin to trigger the 12v relay for the auxiliary fan, and a three-wire Serial Peripheral Interface (SPI) to control the 7-segment display. The duty cycle of the PWM output is updated every 100ms, allowing for a smooth response between sonar readings and blower velocity. Since the auxiliary blower is engaged based on the sonar readings, the digital output enabling or disabling it is also updated in the task governing the PWM output. Since the variables outputted to the 7-segment display are score and game time, there is no point to updating the display more than a few times per second thus a 250ms delay between task calls was chosen. Both the game time and score are broken into separate 8 bit (char) variables for each digit, then grouped into 4 byte (32 bit) packets and sent along the SPI interface.

Applicable Design Standards

Serial Peripheral Interface (SPI) is a full-duplex signaling standard developed by Motorola. The standard utilizes a master-slave configuration requiring the master device to output a clock signal which is used by the slave device for timing and synchronization. For this project, the ATmega16 microcontroller offers a built-in SPI interface; likewise the 7-segment display peripheral is designed to interpret SPI signals and thus the standard is strictly adhered to by the embedded hardware. The clock frequency used was 125 kHz (or clk/1024), is set to idle low, and sample on the rising edge (see program design section for additional SPI initialization details). Since there is only one slave device, the Slave Select (SS pin) could be wired to ground, however connecting it to the slave select pin on the microcontroller ensures that the peripheral is only listening when the MCU is transmitting, thus reducing the possibility of noise interference on the line.

Hardware Selection/Design

Fan Selection
In order to achieve an air steam capable of levitating a ping pong ball, a fan with high air volume and static pressure was required. Several fan styles were considered for this project including axial, radial, and tunneled axial. The first fan tested was a standard 80mm square 12VDC computer fan, rated at 45CFM pictured below.
After a few seconds of testing, it was quite clear that this style fan would not provide enough static pressure to levitate a ping pong ball. After attempting to collimate the stream down to two inches, most of the air was being blown back through the fan blades as opposed up at the ball.
This type of fan is used in marine applications to evacuate diesel fumes from boat engines. This blower is rated for 3.5 Amps @ 12VDC and will deliver 240CFM at full capacity the current demand is significantly higher than what a whiteboard will support, so we needed to design a PCB in order to handle the higher current load. The bilge blower is mounted in a tunnel and therefore produces a well-collimated stream of air, as shown in the picture above.
Ultrasonic Spheroid Levitation Device Using Atmega644
Once the fan had been chosen, a proper outlet port and 90degree connector was needed to ensure the ball levitation was stable and could reach an appropriate altitude. Several PVC pipe bend sections were salvaged from a now defunct engineering project team. Both 3 and 4 pipe bends were tested. The 3 bend caused the fan to draw more current at lower RPMs, limiting the total air flow possible without exceeding the fan motors current rating. Thus, it was decided that the 4 pipe bend was the best option to maximize airflow. With this bend alone, the ping pong ball would only levitate about 6. Several outlet ports were tried in order to see which maximize ball altitude while minimizing the back-pressure and current draw of the fan. The image below shows the first configuration, a 4 to 3 down converter, with a 2 diameter pipe, and a round outlet pattern while this configuration worked well to stably levitate the ball, it did not achieve a great altitude since the back-pressure limited the fans output.

Parts List:

Component List: Quantity Total Price Notes
ATMEL AVR ATMega16

1

Free

DIP Socket

1

$0.50

SIP Pin Headers

40

$2.00

Maxbotix LV-EZ1

1

$25.95

SPI 7 Segment Display

1

$12.95

Whiteboard

1

$6.00

4’x4′ Plexiglass Sheet

1

Free

Salvaged

12v Power Supply

1

Free

Previously owned

12V Bilge Blower

1

$11.00

Wood

1

Free

Salvaged

12V (25 cfm) centrifugal blower

1

$5.00

12V (2.5 cfm) centrifugal blower

1

Free

Bruce Donation

1″x1″ Solder Board

1

$1.00

6″ Solder Board

1

$2.50

Alligator Clipped Wires

3

Free

Previously owned

Resistor (330)

1

Free

Lab component

Resistror (10K)

2

Free

Lab component

Resistor (20K)

2

Free

Lab component

Resistor (100)

1

Free

Lab component

Resistor (1M)

2

Free

Lab component

Resistor (2K)

1

Free

Lab component

4N35 Optocoupler

1

Free

Lab component

1N4001 Diode

2

Free

Lab component

BUZ71 Transistor

1

Free

Lab component

LTE 4208 IR Emitter

1

Free

Lab component

LTR 4206 Phototransistor

1

Free

Lab component

10K Potentiometer

1

Free

Lab component

LM358 Op Amp

1

Free

Lab component

Absolute RLS125 Relay

1

Free

Salvaged

N3904 Transistor

1

Free

Lab component

Green LED

1

Free

Lab component

Various Nuts and Bolts

~50

Free

Salvaged

M-F Jumper Wire

3

$1.25

Ceramic Standoffs

4

Free

Bruce Donation

Push Button

2

$2.00

12VDC Toggle Switch

1

Free

Salvaged

Total

$70.15

For more detail: Ultrasonic Spheroid Levitation Device Using Atmega644


About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top