Docsity

Computer Controlled Foosball Table - Lecture Notes | ECE 395, Study Guides, Projects, Research of Electrical and Electronics Engineering

Partial preview of the text

Download Computer Controlled Foosball Table - Lecture Notes | ECE 395 and more Study Guides, Projects, Research Electrical and Electronics Engineering in PDF only on Docsity!

Foosbot

Computer Controlled Foosball Table

Andrew Ofisher, David Sheridan

Spring 2008

Table of Contents

  • Table of Contents
  • Abstract
  • Introduction
  • Hardware
    • Web Cam ‐ (Creative Live! Webcam)
    • Serial Port
    • PIC Microcontroller (PIC18F4620)
    • H‐Bridge (L6206 Dual Full Bridge Driver)
    • Stepper Motors
    • Power Supply (24V 12A Power Supply)
    • PCB...............................................................................................................................................
  • How to Get It Working.....................................................................................................................
  • The Future of Foosbot

Introduction

This project was first created in Fall ’06 by Steve Havlir, James Cavanaugh, and Micah Evans and then continued in Spring ’07 by Steve Havlir and James Cavanaugh. After a year of sitting idle, we decided to pick up where the project was left off in an effort to improve the hardware and game play. One of our largest challenges in picking up a previous project is understanding how all the parts work and how they tie together. Even with the help of the documents provided in the previous semesters, it was extremely hard to determine how the complete system worked. In this paper, we plan to not only detail our progress during this semester, but also provide greater detail into the workings of the system to make expanding this project even easier.

Hardware

Web Cam (Creative Live! Webcam)

The camera is the central point of the system. The camera is used to determine the position of the ball, the computer players, and the enemy players. Based on the data from the camera, the C++ software is able to determine what signals to send to the PIC in order to move the players in an appropriate way. The current camera is hardly ideal, but it seems to be the best current option. The current camera is a Creative Live Webcam which is not created for the high framerate, low latency application that would be optimal in our case. The Creative Live Webcam was chosen because it is relatively inexpensive, easily connects using USB 2.0, and has a wide angle lens to be able to view the full foosball table. The camera tends to get an acceptable framerate, but the latency is

Much of the PIC code was rewritten in an effort to clean it up and fix some long lingering bugs. The serial operation is now operated by an interrupt instead of polling. This fixes a previous bug where bytes would be lost if the Microcontroller was unable to poll the port in time. Also, the code was restructured in an attempt to make it cleaner and more versatile. The main part of the code is the drivemotors function. This function runs through six different states for each motor. These sates exist only to control the speed of the motor. There are four possible speeds: off, third speed, half speed, and full speed. The stepper motors require a series of four pulses in a specific order on the four input wires. Speed is controlled by disabling all four wires for one or two states thereby making the sequence take longer. The way the PCB is designed and the motors connected, the sequence is IN2, IN3, IN1, IN4. To spin at half speed, the output is IN1, OFF, IN3, OFF, IN1, OFF, IN4, OFF. The six states in drivemotors control whether or not to output the next sequence for the motor or an off state. Each motor has its own struct which consists of the current speed, direction and state. State is simply a counter from 0 to 3. The stepState function increases or decreases this counter depending on the current motor direction and accounts for wrap around.

H Bridge (L6206 Dual Full Bridge Driver)

The H‐Bridge is a device that is used to translate the lower voltage from the PIC into a higher voltage that is used to drive the motors. It is necessary to use an H‐Bridge because the voltage and current required by the motors would kill the PIC and we need to rapidly change the polarity of the output voltage. The H‐Bridge is able to supply the correct voltage and current to drive the motor safely. The original H‐Bridge used was the L298. These H‐Bridges only support up to 25W and have no current limit protection. Two in parallel were required to drive the sliding motors. We upgraded the H‐Bridges to the L6206 which can support a higher power and also have current limiting capabilities. With the new chips, only one H‐Bridge is necessary per motor. The H‐Bridges no longer need to be run in parallel to support a single motor. The current limit prevents the chips from burning up and will automatically disable the motor.

Stepper Motors

The stepper motors are used to make the rods move or slide. Stepper motors move a predetermined amount depending on the pulses that they receive from the H‐Bridges. The motors take in a certain pattern of pulses to move in one direction and the opposite pattern of pulses to move in the opposite direction. Because of the way stepper motors work, it would be feasible to implement a kicking algorithm instead of the current spinning algorithm that is being used. We were able to implement PIC code that kicked on command, but did not have time to restructure the PIC and C++ computer code to use it.

Power Supply (24V 12A Power Supply)

Originally, two of the power supplies in the lab were used to power the motors. With the new H‐Bridges, we can now use powers supplies that do not have current limiting. To get the 24V we need, we use two 12V 12A power supplies in parallel. The 5V needed for logic is achieved through use of a voltage regulator that scales down the voltage from 12V to 5V. The 24V is known as the VSa and VSb which are connected to the H‐Bridges and the 5V is known as the VCC/VDD which powers the PIC and any other necessary logic. The original version of the unit used two adjustable power supplies and the 5V power from the bench. This hardware was expensive in the case of the adjustable power supplies and unreliable in the case of the bench power supply. It was also inefficient to use several different power sources when a single power source could be used. With the setup now, only two relatively inexpensive power supplies are necessary. The whole design is now completely portable. These new power supplies also supply a much higher total current than the previous power supplies. The old power supplies provided 3A for kicking and 4A for sliding. The new power supply provides 12A total which should be able to provide enough current to power all 8 motors simultaneously at 1.5A each. This could be useful for allowing all motors to move at the same time to better prepare the computer player against a more highly skilled opponent.

PCB

The printed circuit board is where all of the digital hardware is mounted. It provides for a very clean setup as well as easy access to the H‐Bridges, should they need to be replaced in the future. The PCB was required because the H‐Bridges dissipate heat through the copper on the board. Do not try to run the H‐Bridges from a breadboard; it will melt.

the PIC. The power will need to be connected. The power connector is on the left side of the board and should be connected to the black and blue wires from the power supply. Negative, or the black wire, should be on the top. This is the 12V connection to the 5V voltage regulator. Do not connect the 24v motor supply while programming. There is a slight chance of exploding the H‐Bridges. Next switch PICNUM to be 0, rebuild, and program the bottom PIC. Remove the Programmer connection from the board and with the power supplies off, now connect the motor power supply. The motor power supply wires are the black and green wires from the power supplies that connects to the power connect on the top right side of the board. Ground, or the black wire, should go towards the top. Before turning on the power supply, start running the C++ program. Now turn on the power supply. You should now be able to play the Foosbot.

The Future of Foosbot

Without a doubt, the future of this project will be heavily software based. All of the parts that could feasibly be updated were updated this semester, and there appear to be very few hardware issues left. The only issue that seems to be left is the camera. The camera could be upgraded to an analog camera with capture card or possible a DV camera with very low latency. This might not be cost effective, however. If a better idea is determined in the future, it should be made a top priority. The PIC software and the computer software should not need any major modification. The PIC software can be modified with MPLab. Our current code simply makes the motors perform the action specified by the serial port continuously. One possibility would be to have the computer send a motor, direction, and time duration to run that motor. This way speed would not be needed and more accurate positioning could be obtained. Along with this concept, there could also be a command to perform a kick. This would perform a kick like a human would do on the foosball table, instead of simply spinning the rod. We did create workable kicking code which can be seen in the spintest MPLab project. The C++ computer software is the next software aspect that needs major rework. Basically the objective of the C++ code is to get the computer player, human player, and ball data and then determine an appropriate action which is sent via serial port. The code we looked through tended to not be very well commented. It also did not seem to follow a consistent structure nor take full advantage of the object orientated aspects of C++. It might be useful to completely rewrite the C++ code using the same basic algorithm. After that, it would be essential to implement more strategic gameplay elements. It would be a good idea to look up actual Foosball strategy and try to implement it via software. From there, it would be possible to implement different skill level settings. It may be helpful to try and get some background on artificial intelligence also, to determine the best way to have the computer play.

There are also many optional hardware additions that can be implemented. It would be interesting to have such features as a score display or ball return mechanism. If the Foosbot were to be marketed as an arcade machine, it would be useful to implement a way to take coins or game cards in order to play the Foosbot. It would also be interesting to add 8 more motors to control the other side so that the Foosbot could play against itself. Then there could be a mechanism to allow 1 or two human players to enter by releasing the rods from the motors. This would allow for many different styles of play.

  • High Priority o Kicking Implementation o Code Cleanup o Strategic Gameplay
  • Low Priority o Webcam Replacement
  • Optional o Score Display o Ball Return Mechanism o Coin/Card Swipe o Extra Computer Player o Option for 0, 1, or 2 Human Players