F19: Pocket tank

From Embedded Systems Learning Academy
Revision as of 09:42, 18 December 2019 by Proj user10 (talk | contribs) (Hardware Design)

Jump to: navigation, search
Pockettank.jpg

Pocket Tanks

Abstract

Pocket Tanks is a fast-paced and incredibly fun artillery game. It's a one versus one battle between two tanks the aim being to destroy your opponent with firepower or bury him by firing into the surrounding landscape..

Objectives & Introduction

Team Members & Responsibilities

  • Adithya Baskaran
    • Game development, PCB design,Mp3.
  • Tarun Chawla
    • Game development.

Schedule

Week# Date Task Status
1 10/1/2019
  • Submission of Project Proposal
  • Completed
2 10/15/2019
  • Research Required Components.
  • Submit plan for upcoming weeks
  • Completed
3 10/22/2019
  • Analyze the modules.
  • Order Parts and Identify Roles
  • Completed


4 10/29/2019
  • Finalize the circuit design.
  • Start with the ability to control each and every row and column.
  • In-progress
5 11/5/2019
  • Circuit Simulation and PCB Layout Design.
  • Finalize Components and placement on PCB.
  • Create a background for the game.
  • In-progress
6 11/12/2019
  • Start with the movement of the tanks.
  • Implement the collision logic.
  • In-progress
7 11/19/2019
  • Implement the Impact logic.
  • Attacks using on board buttons.
  • In-progress
8 11/26/2019
  • Joystick Integration with game.
  • In-progress
9 12/3/2019
  • Updating the existing Game Design & Testing it.
  • In-progress
10 12/10/2019
  • Complete end-to-end testing for various scenarios and conditions.
  • In-progress
11 12/17/2019
  • Testing and final bug fixes.
  • Complete wiki report.
  • In-progress

Parts List & Cost

Item# Part Manufacturer Quantity Cost($)
1 SJ Two Board Preet 1 50.00
2 Adafruit RGB LED Matrix Adafruit 1 62.00
3 Power Adapter Power Supply 1 7.95
4 JLC PCB JLC PCB 1 22.00
6 Miscellaneous (Jumper Wires, Connectors, Switches) Excess Solution 2.00
  • Total Cost: $143.95

Design & Implementation

The design section can go over your hardware and software design. Organize this section using sub-sections that go over your design and implementation.

Hardware Design

The Hardware design for Poket Tanks involves the use of two SJtwo LPC1758 microcontroller boards, 16x32 RGB LED Matrix and Active Buzzer as described below. Pin configuration information for integration with PCB and power source have been detailed.

LED Matrix

The Project uses 32x32 6mm pitch RGB LED Matrix consisting of 1024 RGB LEDs. 32 rows of LED matrix have been divided into 16 interleaved sections/strips. On the PCB is 12 LED driver chips. These are like 74HC595s but they have 16 outputs and they are constant current. 16 outputs * 12 chips = 192 LEDs that can be controlled at once, and 64 * 3 (R G and B) = 192. So now the design comes together. We can have 192 outputs that can control one line at a time, with each of 192 R, G and B LEDs either on or off. The LPC1758 controller selects which section to currently draw (using A, B, C and D address pins - 4 bits can have 16 values). Once the address is set, the controller clocks out 192 bits of data (24 bytes) and latches it. Then it increments the address and clocks out another 192 bits, etc until it gets to address #15, then it sets the address back to #0. To light up an individual pixel, appropriate row value is loaded on to the address pins A,B,C & D, Clock is set out to traverse the row and when required pixel is reached, the latch is set high to turn ON the LED.
We have used the Adaafruit GFX libaray. In this library a 3D array of size 32*32*3= 3072 bytes is used. This 3D array basically represents the whole matrix with the three RGB values. Each function in the library takes the arguments of rows and columns and just makes the corresponding byte high in the matrix. The update display function is called in a repetitive interrupt function. This function loads travesses the 3D array and selects the appropriate row and loads the row using clk pin and finally latches in the value.

Technical Specification:

Dimensions: 192mm x 96mm x 12mm (7.6" x 3.8" x 0.5")
Panel weight with IDC cables and power cable: 357.51g
5V regulated power input, 4A max (all LEDs on)
5V data logic level input
2000 mcd LEDs on 6mm pitch
1/16 scan rate
Indoor display, 150 degree visibility

Printed Circuit Board (PCB)
The PCB schematic and Layout have been designed using Eagle 9.2.2. The circuit board consists of single power supply which will be powering

  • SJtwo Board (5.0V)
F2.jpg

The Circuit uses LM7805 Voltage regulator IC from Texas Instruments to meet the power requirements. The output of voltage regulator will be typically 5V, 1.5A thus preventing excess current to SJtwo boards. 9V, 4A adapter was used to power the LED Matrix. The LED Matrix which comes with dual Molex headers. Each of the two were safely connected to LED Matrix and Circuit board to power them accordingly. The circuit design has been made robust and versatile. The voltage regulator uses decoupling capacitors placed in parallel at input and output. They bypass the AC component at the input and improve the transient response at the output. Further, a diode has been connected in shunt across the regulator to provide reverse bias protection.


Circuit Layout

Hardware Interface

Push Buttons

Three Push buttons are integrated to facilitate the movement of the tanks. The shooting angles are also mapped to these push buttons. The leftmost Push button is mapped for the left movement of the tank. The Center button is mapped for right movement of the tank. The rightmost button is meant to initiate shot selection. When the Rightmost button is selected, the movement buttons are overwritten for shot selection. The power percentage moves from 23, 45 and 90 percentage. The Left, center and right buttons handle these 23, 45 and 90 percentage shooting respectively. The pushbuttons consist of a GPIO pin and a ground pin. The GPIO pin is pulled up and the ground pin is connected to common ground. When the pushbutton is pressed, the GPIO will be grounded and pushbutton reaches logic low indicating button press.

Piezo Buzzer

Piezo Buzzer was used to give background Sound for the game. Piezo buzzer has two pins, A GPIO pin which channels PWM signals and a ground pin. Varying Frequency and Duty cycle can be used to produce sound at a different pitch. Piezo buzzer produces programmed sound at the end of the game after a player wins until a button is pressed.

Software Design

Show your software design. For example, if you are designing an MP3 Player, show the tasks that you are using, and what they are doing at a high level. Do not show the details of the code. For example, do not show exact code, but you may show psuedocode and fragments of code. Keep in mind that you are showing DESIGN of your software, not the inner workings of it.

J1.jpg

Implementation

This section includes implementation, but again, not the details, just the high level. For example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.

Testing & Technical Challenges

  • Non-availability of datasheet for ADAFRUIT 32x32 RGB LED Matrix was a major challenge. This made the understanding of pin configuration details difficult. Subsequently, we extracted ADAFRUIT GFX library and created an interface class to make it compatible with our project requirements.
  • It was hard to determine the refresh rate for LED Matrix. Low refresh rate would cause display to flicker and a high refresh rate would slow down the display update rate thereby causing overhead. Through trial and error, we came up with a value of 500us for interrupt which was an ideal refresh rate value.
  • It was great challenge to implement the pause feature in the game. We had to capture the real time movement of the attacks when the user hit pause and resume the game from same position. The push button switch on joystick was used to pause and game would resume with input direction.
  • Starting the game with initial tank position was challenging due to the designed algorithm. This was overcome by calculating the tank location before start of the game by hard-coding the default direction on game start.
  • Approach to design a PCB to meet the project requirements was complex. We had to redesign the circuit schematic and layout thrice to ensure that it was robust. Moreover, We had to import libraries from Sparkfun and adafruit for various components and also make sure that the same were available with Digikey.


<Bug/issue name>

  • The LED Matrix display was constantly flickering and we couldn't narrow down the reason behind it. Once we solidified the circuits it stopped.
  • The top-leftmost LED blinks whenever game restarts. This was bug which couldn't be resolved.

Conclusion

The project was a success both in terms of output and learnings. We were able to design the pocket tanks game which has been controlled via a handheld joystick using push buttons. It gave an exposure of working drivers for 16x32 RGB LED Matrix, push buttons and active buzzers. It helped us utilize the knowledge of FreeRTOS and GPIO driver gained through the CMPE-244 class.

Working as a team and having brainstorming sessions helped us in overcoming a lot bugs which we encountered during game design. Furthermore, it helped in expediting the integration, testing and debugging of the project days before final demonstration. On the whole, we had a wonderful experience of working in a team and developing a complete product using professional tools and techniques.

Project Video

Upload a video of your project and post the link here.

Project Source Code

References

Acknowledgement

We would like to sincerely thank Professor Preetpal Kang for his allround guidance, feedback and support. His classroom lectures were significant in imparting knowledge on embedded systems. Further, we would like to thank ISA team for their advice.

References Used

https://cdn-learn.adafruit.com/downloads/pdf/32x16-32x32-rgb-led-matrix.pdf?timestamp=1543806512/

Appendix

You can list the references you used.