Difference between revisions of "F20: Space Invaders"

From Embedded Systems Learning Academy
Jump to: navigation, search
(PRINTED CIRCUIT BOARD)
(PRINTED CIRCUIT BOARD)
Line 399: Line 399:
 
[[File:spaceinvaders_pcb_top_244.png|thumb|left|600px|PCB Top Layer]]
 
[[File:spaceinvaders_pcb_top_244.png|thumb|left|600px|PCB Top Layer]]
 
[[File:spaceinvaders_pcb_bottom_244.png|thumb|right|600px|PCB Bottom Layer]]
 
[[File:spaceinvaders_pcb_bottom_244.png|thumb|right|600px|PCB Bottom Layer]]
 +
 +
<br>
  
 
== '''LED MATRIX''' ==
 
== '''LED MATRIX''' ==

Revision as of 19:20, 16 December 2020

Space s20cover.png
Spaceinvaders.gif



ABSTRACT

Space Invaders is a fixed one person shooter style video game. The player controls a laser cannon by moving it horizontally across the bottom of the screen and firing at the aliens descending toward the cannon from the top of the screen. There are aliens descending towards the cannon and the player's main goal is to defeat an alien and earn points by shooting it with the laser cannon and destroying it. As more aliens are defeated, the aliens' movement speeds up. The alien invasion is declared successful and the game ends when the aliens have successfully reached the bottom. The final score of total kills is projected after the game ends. The mp3 decoder connected to the speaker will play sound effects required.

INTRODUCTION & OBJECTIVES

About the Game

The object of the game is, basically, to shoot the invaders with your laser cannon while avoiding their shots and preventing an invasion. Amassing a high score is a further objective and one that must be prioritized against your continued survival. Each game screen starts with 3 rows of 4 invaders.

Objective

  • Interface the 64x64 RGB LED Matrix with SJ-Two Microcontroller.
  • Interface the VS1053 MP3 Decoder with another SJ-Two Microcontroller.
  • Interface MAX98357A Mono Amplifier via I2S.
  • Establish UART communications between the two SJ-Two Microcontrollers.
  • Create simple coding logic for displaying required characters and game objects.
  • Have required sound effects at different functions of the game.
  • Have multiple display screens at different stages of the game.

Team Members

Technical Responsibilities

Administrative Roles
  • Game Logic Development
Salvatore Nicosia & Akash Vachhani
  • PCB Design
Akhil Cherukuri
  • LED Display Driver
Salvatore Nicosia
  • Graphics Driver
Salvatore Nicosia & Akhil Cherukuri
  • Splash Screen Graphics Driver
Akhil Cherukuri
  • Mp3 Decoder
Akash Vachhani
  • Enclosure
Salvatore Nicosia
  • Hardware Integration
Salvatore Nicosia & Akhil Cherukuri

Administrative Responsibilities

Administrative Roles
  • Team Leader
Salvatore Nicosia
  • Git Repository Managers
Salvatore Nicosia & Akash Vachhani
  • Code Reviewers
Salvatore Nicosia & Akash Vachhani
  • Wiki Report Manager
Akhil Cherukuri
  • Bill of Materials Manager
Akhil Cherukuri


SCHEDULE

Week# Start Date End Date Task Status
1
  • 10/12/2020
  • 10/18/2020
  • Read previous projects, gather information, and discuss among the group members.
  • Create a GitLab repository for the project [10/13/2020]
  • Completed
  • Completed
2
  • 10/19/2020
  • 10/20/2020
  • Acquire parts: LED Matrix, VS1053 Mp3 decoder breakout board by Adafruit
, 2X Analog 2-axis thumb joystick with select button + breakout board

  • Completed
3
  • 10/26/2020
  • 11/01/2020
  • Read and familiarize with LED Matrix Datasheet
  • Read and familiarize with MP3 Decoder VS-1053 datasheet.
  • Completed
  • Completed
4
  • 11/02/2020
  • 11/08/2020
  • Develop graphics driver for LED matrix and implement initial game objects
  • Develop driver for MP3 decoder
  • Read MP3 data from Micro SD Card
  • Completed
  • Completed
  • Completed
5
  • 11/09/2020
  • 11/15/2020
  • Finalize wiki schedule [11/10/2020]
  • Circuit Simulation in EasyEDA/Eagle Tool.
  • PCB Layout Design in EasyEDA/Eagle Tool.
  • Finalize component placement on PCB.
  • Order PCB from JLCPCB.
  • Create 3D printed enclosure and extra accessories
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
6
  • 11/16/2020
  • 11/22/2020
  • Assemble components to circuit boards
  • Extensively test circuit boards in two rounds
  • Develop game logic for space ship movement and monsters respawn
  • Develop splash screen and menu selection
  • Finalize selection of MP3 tracks for in-game sounds
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
7
  • 11/23/2020
  • 11/29/2020
  • Implement game difficulty logic as enemies count decreases
  • Integrate circuit boards and check proper connections to the components and the microcontrollers
  • Integrate game logic code with LED matrix
  • Integrate game sounds with game logic
  • Completed
  • Completed
  • Completed
  • Completed
8
  • 11/30/2020
  • 12/06/2020
  • Additional Features: Lives, Health Level Bars
  • Integrate subsystem and ensure proper connection and communication between peripherals
  • Integrate all components and finalize 3D printed enclosure
  • Update the wiki page.
  • Completed
  • Completed
  • Completed
  • Completed
9
  • 12/07/2020
  • 12/13/2020
  • Address bugs during testing of the integrated system
  • Test play/restart functionality
  • Test music and effects are synchronized with the game
  • Completed
  • Completed
  • Completed
10
  • 12/14/2020
  • 12/16/2020
  • Update Gitlab repo with complete and working code.
  • Create Project Demo video and upload it to YouTube.
  • Update the wiki page to the final version.
  • Final Demo [12/16/2020]
  • In progress
  • In progress
  • In progress
  • Not started


BILL OF MATERIALS

Item# Part Description Part Model & Vendor Quantity Cost
1 Microcontroller Boards SJ2 Boards (Purchased from Preet Kang) 2 $100.00
2 LED Matrix Display Sparkfun RGB LED Matrix Panel - 64x64 1 $80.00
3 Arcade Buttons and Joystick Kit Arcade Buttons and Joystick Kit EG STARTS 1 $25.94
4 Capacitive Touch Switch Button Self-Lock Module DAOKI TTP223 Capacitive Touch Switch Button Self-Lock Module 2 $7.56
5 MP3 Decoder Adafruit VS1053 Mp3 Decoder Breakout Board 2 $24.95
6 Black PLA 3D Printer Filament HATCHBOX PLA 3D Printer Filament 1.75mm 1 $25.12
7 White PLA 3D Printer Filament HATCHBOX PLA 3D Printer Filament 1.75mm 1 $25.12
8 Power Supply 5V 18A MEAN WELL LRS-100-5 AC/DC Switching Power Supply 90W 5V 18A Single Output 1 $21.30
9 Rocker Switch Power Socket Inlet Module Plug 3Dman 15A 250V Rocker Switch Power Socket Inlet Module Plug 5A Fuse Switch with 18 AWG Wiring 3 Pin IEC320 C14 1 $8.73
10 Speaker 3" Adafruit Accessories Speaker 3" (1 piece) 1 $6.58
11 Mono Amplifier Adafruit I2S 3W Class D Amplifier Breakout - MAX98357A 2 $5.95
12 USB DC Buck Step Down Module HiLetgo 5pcs DC-DC Buck Step Down 6-24V to 5V 3A USB Module 1 $7.59
13 Prototype PCB LampVPath (Pack of 2) PCB Prototype Board 1 $6.99
14 Ribbon Cables 40pin Antrader 30CM 40-Pin IDC Connector Flat Ribbon Cable 1 $9.99
15 Ribbon Cables 16pin Antrader 30CM 16-Pin IDC Connector Flat Ribbon Cable 1 $8.99
16 Header Pins 2 x 8 pin Antrader 30PCS 16 Pin 2 x 8 Male Box Header 1 25.60
17 Header Pins 2 x 20 pin Antrader 24Pcs 2 x 20 Pin 40 Male Box Header 1 9.99
18 PCB JLCPCB Set of 5 1 25.60


PRINTED CIRCUIT BOARD

Design And Architecture

The complete printed circuit board was designed using EasyEDA online software. Implemented both SJ-Two board connectors along with required connections to buttons, led matrix, touch sensors, joystick, VS1053 MP3 Decoder, and MAX98357A I2S Amplifier.

Fabrication

  • PCB was sent to fabrication to JLCPCB China which provided PCB with an order of 5 and 2 layers of PCB and common grounded the rest of the copper area.

DRC elements (in mm)

  • Track Width = 0.254
  • Clearance = 0.152
  • Via Diameter = 0.61
  • Via Drill Diameter = 0.305


PCB Schematic


PCB Top Layer
PCB Bottom Layer


LED MATRIX

Hardware Interface

This project utilizes as a display a 64x64 RGB LED Matrix Panel with a scan rate of 1/32. The LED matrix panel has 4096 RGB LEDs which can be controlled and addressed individually. Because 4069 LEDs would be impossible to connect to the sjtwo board since it does not have sufficient GPIOs, this LED Matrix utilizes only 13 digital GPIOs to provide full control of each individual LED. To achieve this, the LED matrix uses a decoder to select the rows and a 64-bit shift register which enables the desired color on the selected column. When the row selection is low the columns are selected by clocking in data into the shift register. This 64x64 LED matrix has 6 64-bit shift registers for R1, G1, B1 R2, G2, B2 where each color of the LED is controlled by one bit of the shift register. Since this display uses shift registers which are daisy chained, there no capability to control each LED using PWM and therefore the display only supports 8 colors. The basic mechanism of how this LED matrix works is as follows:

For each row of leds we repeate these steps:

  1. Set the latch and output enable pins to low to clock in the next row of data and enabling the output so that the leds are turned on
  2. For each column, clock in the data for the current row one bit at a time into the shift registers (R1, G1, B1, R2, G2, B2)
  3. Set the latch and output enable pins high to allow the row of data to reach the output driver while disabling the output so that no LEDs are on while switching rows
  4. Select the row by driving the appropriate row select lines (A,B,C,D,E)


LED Matrix
LED Matrix Schematic

LED Matrix Driver

<Discuss here about led matrix driver>

<Discuss here about led matrix hardware>

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.

MP3 DECODER

Hardware Interface

In this section, you can describe how your hardware communicates, such as which BUSes used. You can discuss your driver implementation here, such that the Software Design section is isolated to talk about high level workings rather than inner working of your project.

<Discuss here about MP3 decoder hardware>

MP3 Decoder Driver

<Discuss here about MP3 player driver>

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.

3D PRINTED ENCLOSURE

Design & Implementation

<Discuss here about 3D Printed Enclosure. Attach images of both design and final result>

  • 3D Print Model (Front)
  • 3D Print Model (Back)
  • 3D Print Model
  • 3D Print Model (Top)
  • 3D Print Model (Bottom)
  • 3D Print Model (Volume Buttons)

TESTING & TECHNICAL CHALLENGES

LED Matrix Displaying Incorrect Colors

While testing the driver it was identified an issue with the LED matrix not displaying the correct colors or at times not displaying them at all in certain parts of the display. To analyze this problem different objects were drawn in different sections of the display to understand the cause of this behavior. While testing it was noticed that the LED matrix would display the correct color only when both the top 32 rows and bottom 32 rows were active or when at least one row was active in both sections. After debugging the code and ensuring that the logic to display the pixels was correct the problem turned to be that the cable that connects to HB75E connector of the LED matrix had a few defective pins which were causing issues on some of the registers that control the RGB colors. After extensively testing by drawing more objects it was deduced that the root cause of this issue was a bad cable.

PCB Design

While testing the ribbon cables, we have identified out that the purchased double row ribbon did not invert pin rows as a normal ribbon cable does.

CONCLUSION

Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learned from this project. How has this project increased your knowledge?

ACKNOWLEDGEMENT

We would like to express our gratitude to Professor Preetpal Kang for providing valuable insight and knowledge with us and for guiding us through the completion of this project. We would also like to thank Vidhusi Jain(ISA) for her valuable advice code reviews, and constructive feedback. Also a big shout-out to all of our classmates, for the great Slack discussions which provided solutions and necessary feedback.

APPENDIX

Project Source Code

Project Video

References

LED MATRIX

MP3 DECODER

GENERAL