Difference between revisions of "F21: Treasure Dive"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Hardware Interface)
(Hardware Interface)
Line 370: Line 370:
 
|}
 
|}
  
Pseudo code used for using the XBee wireless devices with UART:
+
Code snippet used for using the XBee wireless devices with UART:
  
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
Line 391: Line 391:
 
Two LED buttons were used to interface with the controller as inputs.  They were both set up using GPIO.
 
Two LED buttons were used to interface with the controller as inputs.  They were both set up using GPIO.
  
Code used for setting up the GPIO:
+
Code snippet used for setting up the GPIO:
 
<syntaxhighlight lang="c">
 
<syntaxhighlight lang="c">
 
static QueueHandle_t controller_queue;
 
static QueueHandle_t controller_queue;
  
void read_controller_input_task(uint8_t *last_input) {
+
void set_up_controller_input(void) {
  gpio_s A_control = {GPIO__PORT_0, 29};
 
  gpio_s B_control = {GPIO__PORT_0, 30};
 
 
   gpio_s A_button = {GPIO__PORT_1, 30};
 
   gpio_s A_button = {GPIO__PORT_1, 30};
 
   gpio_s B_button = {GPIO__PORT_1, 31};
 
   gpio_s B_button = {GPIO__PORT_1, 31};
 
  gpio__set_as_input(A_control);
 
  gpio__set_as_input(B_control);
 
 
   gpio__set_as_input(A_button);
 
   gpio__set_as_input(A_button);
 
   gpio__set_as_input(B_button);
 
   gpio__set_as_input(B_button);
 
  uint8_t new_input = *last_input;
 
  uint8_t curr_input;
 
 
  while (true) {
 
    new_input = *last_input;
 
    curr_input = new_input;
 
    if (gpio__get(A_control) == 1 || gpio__get(A_button) == 0)
 
      new_input |= 0b00000001;
 
    else
 
      new_input &= ~0b00000001;
 
    if (gpio__get(B_control) == 1 || gpio__get(B_button) == 0)
 
      new_input |= 0b00000010;
 
    else
 
      new_input &= ~0b00000010;
 
 
    if (new_input != curr_input) {
 
      if (!xQueueSend(controller_queue, &new_input, 0)) {
 
        printf("Queue is full\n");
 
      }
 
 
      *last_input = new_input;
 
 
      vTaskDelay(10);
 
    }
 
  }
 
 
}
 
}
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 08:52, 18 December 2021

Grading Criteria

  • 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.

Treasure Dive

Abstract

Treasure Dive is a modern one player game inspired by the popular arcade game Breakout, which was released by Atari in 1976. The ancients rambled about an unconfirmed tale of a shipwreck that saw no survivors. As an adventurous and skilled free diver, you are seeking treasure buried deep in an ocean abyss. You dove down all the way to the seafloor and found the buried treasure but need to make it back to the surface to see another day! The player uses a wireless controller to control an on-screen paddle to break bricks on the top of the screen. When enough bricks are broken, a passage is revealed, allowing you to get closer to the surface.

Objectives & Introduction

The objective of this project is to interface an LPC4088 to a VGA monitor by leveraging the LCD controller and use an accelerometer as the sensor for the player to control the paddle. Two Zigbees RF modules will be integrated for wireless communication between the controller and LPC4088 board via UART protocol. Digital audio output will be enabled by developing an I2S driver and porting an audio tracker library. The General Purpose Direct Memory Access (GPDMA) controller memory-to-memory function will be utilized to decrease memory write times when updating the video buffer. The DMA controller's memory-to-peripheral function will help reduce the frequent I2S interrupts when loading digital audio contents. An SD card peripheral driver to facilitate memory exchange between an SD card will also be implemented.

Team Members & Responsibilities

  • Brian Ho
    • Wiki project schedule planning
    • Interfacing the accelerometer
    • Digital to Analog Conversion resistor ladder design used to interface digital LCD controller signal with analog VGA port signal
    • PCB planning and acquisition
    • Procurement of controller hardware
    • Wireless communication via Zigbees RF modules and UART protocol
    • Wireless controller logic and integration
    • Ball movement and wall/brick collision logic
    • Hardware/software development and integration
    • Final testing and integration
  • Billy Lai
    • Wiki project schedule planning
    • Increased CPU clock rate from 96 MHz to 120 MHz
    • Initial memory write timing and measurements to estimate memory write capacity
    • DMA driver memory-to-memory implementation for transferring graphics data to video buffer
    • I2S with DMA memory-to-peripheral implementation to reduce memory-write interrupts when I2S Tx FIFO level is low
    • Paddle movement and paddle collision logic, testing and integration
    • Software development and integration
    • Final testing and integration
  • Jasdip Sekhon
    • Wiki project schedule planning
    • PCB design and planning
    • File loading method algorithm for storing loaded files in memory
    • Audio track and audio effects selection for gameplay audio
    • Palette manipulation for gameplay
    • Software development and integration
    • Final testing and integration
  • Isaac Wahhab
    • Wiki project schedule planning
    • DAC resistor ladder design and integration
    • Hardware procurement (LPC4088 board, Zigbees, VGA monitor, etc)
    • VGA driving through LCD controller
    • Audio tracker library port
    • Digital audio output using I2S
    • Palette scrolling feature implementation
    • Graphics rendering
    • Vertical scrolling implementation for the video buffer
    • Sprite testing and implementation for the ball
    • SD card peripheral driver for reading assets from SD card
    • Art assets acquisition
    • Hardware/software development and integration
    • Gameplay logic design
    • Gameplay audio and level design
    • Final testing and integration

Schedule

Week# Start Date End Date Task Status
1
  • 09/21/2021
  • 09/27/2021
  • Read previous projects, gather information and discuss among the group members.
  • Initial ordering of parts (LPC 4088 board, 64x64 LED screen)
  • Completed
  • Completed
2
  • 09/28/2021
  • 10/04/2021
  • Submit project proposals
  • Completed
3
  • 10/05/2021
  • 10/11/2021
  • Test if board can drive VGA
  • Test varying clock rates
  • Hardware cursor on VGA
  • Rough display driver
  • Completed
  • Completed
  • Completed
  • Completed
4
  • 10/12/2021
  • 10/18/2021
  • DAC resistor ladder
  • RGB channels
  • Palette shifting
  • Measure memory buffer writing timing
  • Wiki schedule planning
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
5
  • 10/19/2021
  • 10/25/2021
  • Calculate upper-bound for VGA refresh timings
  • Create GitLab repository for project
  • Joystick functionality
  • SD card driver
  • Completed
  • Completed
  • Completed
  • Completed
6
  • 10/26/2021
  • 11/01/2021
  • Audio peripheral
  • Wireless communication using Zigbee module
  • PCB planning
  • Accelerometer driver
  • Continue SD card driver
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
7
  • 11/02/2021
  • 11/08/2021
  • Continue audio peripheral
  • Continue wireless communication using Zigbee module
  • Continue accelerometer driver
  • PCB finalizing and ordering
  • Completed
  • Completed
  • Completed
  • Completed
8
  • 11/09/2021
  • 11/15/2021
  • Convert PNG data to graphics format
  • Game background functionality
  • Sprite functionality
  • User interface
  • Integrate components
  • Initial testing
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
  • Completed
9
  • 11/16/2021
  • 11/22/2021
  • Continue everything from last week
  • Game physics (wall collision and AI movement)
  • Measurements for wooden case
  • Art assets (audio and visual)
  • Completed
  • Completed
  • Completed
  • Completed
10
  • 11/23/2021
  • 11/29/2021
  • Fine-tune user experience
  • Make case
  • Completed
  • Completed
11
  • 11/30/2021
  • 12/06/2021
  • Continue fine-tune user experience
  • Integrate hardware
  • Completed
  • Completed
12
  • 12/07/2021
  • 12/16/2021
  • Final testing
  • Final demo
  • Completed
  • Completed




Parts List & Cost

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

Bill Of Materials

Item# Part Description Part Model & Vendor Quantity Cost
1 Microcontroller Board LPC4088-32 Developer's Kit 1 $300.00
2 Microcontroller Board SJ2 Board 1 $50.00
3 Bluetooth Module Digi XBee-S1 2 N/A
4 DAC PCB JLCPCB (Set of 5) 1 $15.00
4 Monitor Asus TFT Monitor 1 N/A
5 Mini Breadboard ELEGOO Mini Breadboard 1 $13.99
6 Arcade buttons EG STARTS LED Arcade Buttons 2 $11.99
7 VGA cable N/A 1 N/A
7 SD card N/A 1 N/A


Design & Implementation

Hardware Design

We designed our PCB using Autodesk EAGLE based on the tutorial on PCB design during class lecture. We ordered our PCB to be manufactured from JLCPCB. The PCB consists of a R-2R resistor ladder DAC for the purpose of converting the digital signal from the microcontroller to analog to display graphics on the VGA monitor. Five bits are passed to each of the red, green, and blue channels of the VGA in addition to other signals, such as Horizontal sync (HSYNC) and Vertical sync (VSYNC).

PCB Schematic
PCB Layout
Manufactured PCB
Soldered PCB


Hardware Interface

Two Digi XBee devices were used to communicate between the SJ2-Board controller and the LPC4088 board to control the paddle on the game. The XBee devices were programmed using the XTCU programming application provided by Digi International. The SJ2-Board used one XBee as a transmitted and the LPC4088 used another as a receiver. The two modules communicated using UART frames and a single byte represented any change of movement or button presses sent by the controller.

XCTU Transmitter Receiver
CH C C
ID 6969 6969
CE Coordinator Endpoint
Baud Rate 9600 9600

Code snippet used for using the XBee wireless devices with UART:

void wireless_send_task(void *p) {

  uart__init(UART__3, clock__get_peripheral_clock_hz(), 9600);

  uint32_t UART3_CON = 0b010;
  // set tx
  LPC_IOCON->P0_0 &= ~0b111;
  LPC_IOCON->P0_0 |= UART3_CON;

    uart__polled_put(UART__3, controller_value);
  }
}
XBee Device


Two LED buttons were used to interface with the controller as inputs. They were both set up using GPIO.

Code snippet used for setting up the GPIO:

static QueueHandle_t controller_queue;

void set_up_controller_input(void) {
  gpio_s A_button = {GPIO__PORT_1, 30};
  gpio_s B_button = {GPIO__PORT_1, 31};
  gpio__set_as_input(A_button);
  gpio__set_as_input(B_button);
}
LED Button


Controller Block Diagram


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

Appendix

You can list the references you used.