F19: Tetris

From Embedded Systems Learning Academy
Revision as of 04:47, 16 December 2019 by Proj user1 (talk | contribs) (PCB Power Circuit)

Jump to: navigation, search

Grading Criteria

(Take out Later)

  • How well is Software & Hardware Design described?
  • How well can this report be used to reproduce this project?
  • Code Quality
  • Overall Report Quality:
    • Software Block Diagrams
    • Hardware Block Diagrams
      Schematic Quality
    • Quality of technical challenges and solutions adopted.

Project Title

LED Matrix Tetris


Tetris.png

Abstract

Our project is creating the game of Tetris using the LED matrix as our display and creating the driver for the game using the SJSU2 board from the class.

Objectives & Introduction

Show list of your objectives. This section includes the high level details of your project. You can write about the various sensors or peripherals you used to get your project completed.

Team Members & Main Responsibilities

Administrative Roles
  • Team Leaders
Kevin Chan & Lawrence Wan
  • Git Repository Manager
Kevin Chan
  • Wiki Report Manager
Yuming Cheng
  • Bill of Materials & Cost Manager
Yuming Cheng
  • Grammar Check
Lawrence Wan & Kevin Chan

Technical Responsibilities

Technical Responsibilities
  • Gaming Logic
Kevin Chan & Lawrence Wan & Yuming Cheng
  • LED Matrix Driver
Kevin Chan
  • Enclosure
Yuming Cheng & Lawrence Wan
  • PCB
Lawrence Wan
  • BGM (MP3 Decoder)
James Ding & Lawrence Wan

Schedule

Show a simple table or figures that show your scheduled as planned before you started working on the project. Then in another table column, write down the actual schedule so that readers can see the planned vs. actual goals. The point of the schedule is for readers to assess how to pace themselves if they are doing a similar project.

Team Deliverables Schedule

WEEK

START DATE

END DATE

TASK DETAILS

STATUS

1 8 Oct 2019 21 Oct 2019

Create and establish GitLab repository
Establish slack channel and invite Preet
Look through previous years projects and study it
Distribute major roles among team members
Select and order Parts
Start rough version of Wiki Schedule

Complete
Complete
Complete
Complete
Complete
Complete
2 22 Oct 2019 4 Nov 2019

Create a Bill of Materials.
Reading on the Data sheet of LED matrix
Create the rough version of Report and Presentation slide

In Progress
Complete
In progress
3 5 Nov 2019 11 Nov 2019

Finalize the Wiki schedule for submission
Driver for the Tetris
Gaming Logic for the Tetris

In progress
Complete (Basic function complete)
In Progress (working on rotation)
4 12 Nov 2019 18 Nov 2019

Received the PCB and start working on connections
Implementing the new features (Save piece, preview pieces)
Update the diagram onto the wiki when possible
Updating the Wiki
Ordering the Enclosing Materials

In progress ( Waiting for PCB )
In progress
In progress
In progress
In progress
5 19 Nov 2019 25 Nov 2019

Starting to assemble the enclosing
Finish the Gaming logic and achieve the basic feature of Tetris
Add additional features
Create the Test Cases for the possible errors.
Include the BGM effects if there are no other additional features to add.

Waiting for Materials
In progress
In progress
Not Started
Not Started (Debating accordingly to our progress)
6 26 Nov 2019 2 Dec 2019

Polishing the Hardware and Software for project.
Revise and improve on small details or minor bugs discovered
Updating the Report, Cost, References, and circuit design.
Update the Wiki Schedule.

Not Started
Not Started
Not Started
In progress
7 3 Dec 2019 9 Dec 2019

FIELD TESTING - CRITICAL WEEK
Test all the possible test cases to debug.
Establish complete connection on PCB
Update wiki with details.

Not Started
Not Started
Not Started
Not Started
8 10 Dec 2019 17 Dec 2019

All hands on testing and final bug fixes.
Finish all the progress that's not finished
Create the semester long project activity video and upload to YouTube.
Update and finalize wiki.

Not Started
Not Started
Not Started
Not Started
Final 18 Dec 2019

DEMO: Final Project
SUBMISSION: Final Project Wiki

In progress
In progress

Parts List & Cost

Give a simple list of the cost of your project broken down by components. Do not write long stories here.


PART NAME

PART MODEL & SOURCE

QUANTITY

COST (USD)

  • SJSUDEV2 Board
  • LPC 4078 (Purchased from Preet Kang)
  • 4 ( One for each group member )
  • $ 50.00 each ( Total: $ 200 )
  • RGB LED Matrix Panel 32x32
  • Sparkfun
  • 3 ( To increase the progress of project )
  • $ 55.90 each ( Total: $ 167.70 shipment cost of $14.61 for each member is not included )
  • Power Supply - 12V/5V (2A)
  • Sparkfun
  • 1 ( To increase the progress of project )
  • $ 11.94 each ( Total: $ 11.94 shipment cost of $14.61 is not included )
  • PCB Assembly & Sample
  • Online
  • 5
  • $ 1.728 Each for Assembly + $1.46 each for Sample ( Total: $ 32.75 shipment cost of $16.81 is included )
  • Voltage Regulator
  • Digi-Key
  • 3
  • $ 1.49 each ( Total: $ 4.47 shipment cost of $4.99 is not included )
  • 4 Pins Molex Connecter
  • Digi-Key
  • 3
  • $ 1.6 each ( Total: $ 4.80 shipment cost of $4.99 is not included )
  • SparkFun ATX Power Connector Breakout Board
  • SparkFun
  • 1
  • $ 1.95 each ( Total: $ 1.95 shipment cost of $13.33 is not included )
  • Screw Terminals 5mm Pitch (2-Pin)
  • SparkFun
  • 2
  • $ 0.95 each ( Total: $ 1.90 shipment cost of $13.33 is not included )
  • DC Barrel Power Jack/ Connector (SMD)
  • SparkFun
  • 3
  • $ 1.50 each ( Total: $ 4.50 shipment cost of $13.33 is not included )
  • ATX Right Angle Connector - PTH 4-pIn
  • SparkFun
  • 1
  • $ 0.50 each ( Total: $ 0.50 shipment cost of $13.33 is not included )
  • Wall Adapter Power Supply - 5V DC, 2A (Barrel Jack)
  • SparkFun
  • 1
  • $ 5.95 each ( Total: $ 5.95 shipment cost of $13.33 is not included )


Total Cost:
  • Price:


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 initial design approach of the project consisted of one SJTwo micro-controller, a 32x32 LED matrix display, and a PCB to help simplify interfacing the two in terms of power and wiring. Having made good development progress, it was decided to include music along with the game, which involved interfacing with a (VS1053) MP3 decoder. Approximately a week later, development for the MP3 decoder was delayed due to unexpected behavior in interfacing with the MP3 decoder while using SPI bus 2. Unfortunately, by the time the decision to add music was confirmed, a PCB design was already made and had been sent to manufacture. Consequently, the pre-determined pin configurations (used to interface to the LED matrix) had occupied the other SPI buses such that using another SPI bus instead was not possible. After thorough contemplation and debate, development with a second SJTwo micro-controller began as soon as possible to interface with the decoder using SPI1 instead.

Micro-controller 1 and 2 Pinout/Schematic

PCB Design

The PCB design began with the primary objective of interfacing the SJTwo micro-controller with the LED Matrix Display with ease. Initially, the second objective was to create a power circuit to power the SJTwo micro-controller and led matrix, however, later decisions have led to re-purposing the circuit post-manufacturing of the PCB. The third objective was to create circuits for external buttons to operate the game.

 Schematic of for PCB Design

PCB SJTwo Micro-controller to LED Matrix Pin Connections

Interfacing the microcontroller and matrix with ease meant avoiding the use of loose wiring as much as possible. Since the matrix itself came with a ribbon cable, it was decided that we design a PCB around using the ribbon cable to interface it with the micro-controller. It was decided to slot the PCB with the micro-controller with 2x20 through-hole headers (labeled as MICROCONTROLLER_PIN_SLOT in the schematic below). The pre-selected pins needed from the micro-controller to interface with the matrix are then connected to 2x8 header pins (labeled as MATRIX_DATA_PINS) which correspond to the pinout of the 32x32 LED Matrix data pins.

PCB Power Circuit

The initial design of the PCB power circuit was to power one micro-controller and the led matrix. The power circuit consists of a barrel jack connector(labeled JACK as shown in the schematic) connected to a 5V voltage regulator. The voltage regulator Vin and Vout terminals are connected to 0.1 micro-farad and 10 micro-farad capacitors, respectively, to ensure that 5V is supplied to the hardware connected. As mentioned before, later decisions to add the VS1053 decoder had re-purposed the power circuit to power both SJTwo micro-controllers and the decoder, whereas the matrix had an independent 5V power supply.

PCB External Button Circuit

6 GPIO input circuits were included in the PCB design to include the attachment of external buttons, as shown in the PCB schematic below. On the PCB itself, the button circuits are labeled "sw1" through "sw6," as shown in PCB manufacture model. The pins configured as inputs for button use are P0.6(sw1), P0.7(sw2), P0.8(sw3), P0.9(sw4), P0.26(sw5), and P0.25(sw6).


 PCB Manufacture Design Model

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.

Configuration of the 32x32 LED Matrix

The 32x32 LED matrix was purchased from Adafruit. The pinout diagram below shows the pins that are needed to be interfaced with SJTwo Microcontroller. Descriptions of each of the pins are provided in the following sections. The most straight forward of the pins below is ground, where each of the ground pins were connected to a ground plane on the PCB where it was grounded with the SJTwo board.

Interfacing the RGB LED Matrix Display
Label Name Function Pin Connection
1 R1 High R data Pin 2.2
2 G1 High G data Pin 2.4
3 B1 High B data Pin 2.5
4 R2 Low R data Pin 2.6
5 G2 Low G data PIn 2.7
6 B2 Low B data PIn 2.8
7 A A line selection Pin 1.31
8 B B line selection Pin 1.30
9 C C line selection Pin 1.20
10 D D line selection Pin 1.23
11 CLK CLOCK Pin 2.0
12 LAT LATCH Pin 2.1
13 OE Output Enable Pin 0.17
14 GND GND Pin GND

The panel is broken up into two 16x32 pixel panels and uses 32 bit shift registers to draw an image to the display. Each row has its own shift register that requires pixel colors to be shifted in, and have the output enable (OE) to be toggled to display one frame. It should be noted that latch is required to have the shift register retain a drawn row. To make it appear to have a moving or still image, the frames must be drawn quickly enough (in our case its 100 Hz) such that the human eye can't detect that the image is being drawn.

Color Inputs (R1,R2,G1,G2,B1,B2)

R1,R2,G1,G2,B1,B2, correspond to the color (Red, Green, Blue) that will be shifted in the shift register that will be displayed onto the LED matrix. On our display, the colors are shifted in from left to right. The number associated with each pin, determines if it is on the top or bottom half of the display. For example, if R1, B1 and G1, are set to high, then the output color will be white. GPIO pins from the SJTwo board were used to configure these pins to control color. To reduce the amount of clock cycles to draw an image, we draw both top and bottom images at the same time. More explanation of this is seen below.

Address Inputs (A B C D)

A, B, C, D, pins correspond to the addressing of each row that the colors R1,R2,G1,G2,B1,B2 will be written to. GPIO pins were used to select which row was being drawn, with D being the most significant bit. The address inputs controls both top and bottom partitions of the display at the same time. So, you can draw both top and bottom at the same time by configuring your colors separately inputs separately.

CLK, OE, LAT

OE is for output enable. Without this pin pulled low (active low), nothing will be displayed on the matrix. To have better visual effects, it should be toggled low on the completion of clocking in one row. If it remains low the entire duration of drawing, you can visually see the pixels move from left to right. CLK is the clock signal for shifting in colors for the shift registers. For more control, we used a GPIO pin instead of PWM to manage the cycles of how we draw one frame/image. The LAT single is used for when a full frame is put into shift register, and is ready to be outputted to the display. For us, this signal was toggled at the same time as output enable.

Interfacing with the VS1053 MP3 Decoder

Label Name Function Pin Connection
1 MP3-DREQ Decoder Data Request Pin 0.1
2 MP3-CS VS1053 Chip Select Pin 0.22
3 MP3-DCS VS1053 Data CS Pin 0.0
4 MP3-RST VS1053 Reset Pin 0.18
5 MOSI SPI Bus (Master Output Slave Input) Pin 0.9
6 MISO SPI Bus (Master Input Slave Output) Pin 0.8
7 SCK SPI Clock Pin 0.7
8 +5V +5V PCB Vout
9 GND GND GND

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.

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

Describe the challenges of your project. What advise would you give yourself or someone else if your project can be started from scratch again? Make a smooth transition to testing section and described what it took to test your project.

Include sub-sections that list out a problem and solution, such as:

<Bug/issue name>

Discuss the issue and resolution.

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 learnt from this project. How has this project increased your knowledge?

Project Video

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

Project Source Code

References

Acknowledgement

Any acknowledgement that you may wish to provide can be included here.

References Used

List any references used in project.

Appendix

You can list the references you used.