Homework 9: Software Design Considerations

Similar documents
Movement of the pieces

YourTurnMyTurn.com: chess rules. Jan Willem Schoonhoven Copyright 2018 YourTurnMyTurn.com

If a pawn is still on its original square, it can move two squares or one square ahead. Pawn Movement

Chess Handbook: Course One

Knight Light. LED Chess. Nick DeSantis Alex Haas Bryan Salicco. Senior Design Group 16 Spring 2013

Triple Challenge.txt

CHESS SOLUTION PREP GUIDE.

ChesServe Test Plan. ChesServe CS 451 Allan Caffee Charles Conroy Kyle Golrick Christopher Gore David Kerkeslager

a b c d e f g h i j k l m n

The game of Paco Ŝako

ELCT 912: Advanced Embedded Systems

Lab 2.2 Custom slave programmable interface

Controlling DC Brush Motor using MD10B or MD30B. Version 1.2. Aug Cytron Technologies Sdn. Bhd.

Project Final Report: Directional Remote Control

Chess, a mathematical definition

NSCL LUDI CHESS RULES

EE 314 Spring 2003 Microprocessor Systems

ZKit-51-RD2, 8051 Development Kit

3.3V regulator. JA H-bridge. Doc: page 1 of 7

DASL 120 Introduction to Microcontrollers

Welcome to the Brain Games Chess Help File.

Essential Chess Basics (Updated Version) provided by Chessolutions.com

Preliminary Design Report. Project Title: Search and Destroy

After learning the Rules, What should beginners learn next?

Standard single-purpose processors: Peripherals

LEARN TO PLAY CHESS CONTENTS 1 INTRODUCTION. Terry Marris December 2004

John Griffin Chess Club Rules and Etiquette

Perry High School. 2 nd Semester!

District Fourteen Chess Fest 2012 Information Sheet

ECE 477 Digital Systems Senior Design Project Rev 8/09. Homework 5: Theory of Operation and Hardware Design Narrative

Chess Rules- The Ultimate Guide for Beginners

TLE9879 EvalKit V1.2 Users Manual

NOVAG AGATE INSTRUCTION

Algebraic Chess Notation

3. Bishops b. The main objective of this lesson is to teach the rules of movement for the bishops.

Introduction to Using the PIC16F877 Justin Rice IMDL Spring 2002

Google DeepMind s AlphaGo vs. world Go champion Lee Sedol

Design and Development of Smart. Harmonic Analyzer

RF4432 wireless transceiver module

OCTAGON 5 IN 1 GAME SET

Digital-to-Analog Converter. Lab 3 Final Report

Microchess 2.0 gives you a unique and exciting way to use your Apple II to enjoy the intellectually stimulating game of chess. The complete program lo

K I NG M A STER (911 ) T R AVEL KING M A STER II (16 9 ) USER MANUA L

Embedded Robotics. Software Development & Education Center

Its topic is Chess for four players. The board for the version I will be discussing first

In this lecture, we will look at how different electronic modules communicate with each other. We will consider the following topics:

BLE 4.0 Module ZBModule User Manual 1 / 15

Training Schedule. Robotic System Design using Arduino Platform

Overview... 3 Starting the Software... 3 Adding Your Profile... 3 Updating your Profile... 4

Mapping Peripheral Capabilities When Migrating From 8-bit to 16-bit PIC MCUs

ADVANCED EMBEDDED MONITORING SYSTEM FOR ELECTROMAGNETIC RADIATION

Chess for Kids and Parents

NEW CHESS NOTATION SLAVOLJUB STOJANOVIĆ - SLLAVCCO

PIC Functionality. General I/O Dedicated Interrupt Change State Interrupt Input Capture Output Compare PWM ADC RS232

DELUXE 3 IN 1 GAME SET

Brian Hanna Meteor IP 2007 Microcontroller

32-bit ARM Cortex-M0, Cortex-M3 and Cortex-M4F microcontrollers

Hello and welcome to this Renesas Interactive Course that provides an overview of the timers found on RL78 MCUs.

Application Note. Smart LED Dimmer Controlled via Bluetooth AN-CM-225

i1800 Series Scanners

Eight Queens Puzzle Solution Using MATLAB EE2013 Project

M.Sinduja,S.Ranjitha. Department of Electrical & Electronics Engineering, Bharathiyar Institute of Engineering For Women, Deviyakurichi.

I hope you have completed Part 2 of the Experiment and is ready for Part 3.

2D Floor-Mapping Car

Unit. The double attack. Types of double attack. With which pieces? Notes and observations

ARTICLE 1. THE CHESSBOARD

Catalog

Programming and Interfacing

Structured Programming Using Procedural Languages INSS Spring 2018

Roland Kammerer. 13. October 2010

JUMA-TRX2 DDS / Control Board description OH2NLT

RF NiceRF Wireless Technology Co., Ltd. Rev

THROUGH THE LOOKING GLASS CHESS

ECE 511: FINAL PROJECT REPORT GROUP 7 MSP430 TANK

Driving LEDs with a PIC Microcontroller Application Note

Imaging serial interface ROM

Your first step towards nobility

PWM LED Color Control

CALIFORNIA SOFTWARE LABS

Hello, and welcome to this presentation of the STM32 Digital Filter for Sigma-Delta modulators interface. The features of this interface, which

5008 Dual Synthesizer Configuration Manager User s Guide (admin Version) Version valontechnology.com

Unit level 5 Credit value 15. Introduction. Learning Outcomes

Hello, and welcome to this presentation of the FlexTimer or FTM module for Kinetis K series MCUs. In this session, you ll learn about the FTM, its

SNIOT702 Specification. Version number:v 1.0.1

Lab 3: Embedded Systems

COMPARISON OF FIDE AND USCF RULES

The Game. Getting Sarted

Serial Communication AS5132 Rotary Magnetic Position Sensor

Index Terms IR communication; MSP430; TFDU4101; Pre setter

νµθωερτψυιοπασδφγηϕκλζξχϖβνµθωερτ ψυιοπασδφγηϕκλζξχϖβνµθωερτψυιοπα σδφγηϕκλζξχϖβνµθωερτψυιοπασδφγηϕκ χϖβνµθωερτψυιοπασδφγηϕκλζξχϖβνµθ

Micro-controller based hardware-in-the-loop controller for electric drives

Lab 1.2 Joystick Interface

Motor Control using NXP s LPC2900

Embedded Test System. Design and Implementation of Digital to Analog Converter. TEAM BIG HERO 3 John Sopczynski Karim Shik-Khahil Yanzhe Zhao

GICAA State Chess Tournament

Architecture, réseaux et système I Homework

Design of Low Cost Embedded Power Plant Relay Testing Unit

RF4463F30 High Power wireless transceiver module

SPI Slave to PWM Generation

Technical Information - NOVAG BERYL

Transcription:

Homework 9: Software Design Considerations Team Code Name: Treasure Chess Group No. 2 Team Member Completing This Homework: Parul Schroff E-mail Address of Team Member: pschroff @ purdue.edu Evaluation: SEC DESCRIPTION MAX SCORE 1.0 Introduction 5 2.0 Software Design Considerations 30 3.0 Software Design Narrative 30 4.0 Summary 5 5.0 List of References 10 App A Flowchart/Pseudo-code for Main Program 10 App B Hierarchical Block Diagram of Code Organization 10 TOTAL 100 Comments: Comments from the grader will be inserted here.

1.0 Introduction Our project is a voice-controlled chess game that uses two 16x32 RGB LED matrix panels to display the chess board. A player can input the moves to play through a microphone or a keypad. Thereafter, the game logic checks if the move played is correct or not in two ways: if the square the piece is being moved to is empty or occupied by the opponent s piece, and if the move played by the respective piece is correct for example rook only travels horizontally or vertically, bishop only travels diagonally, etc. Once the game logic has assessed the move, it then sends the output to the RGB LED matrix panel to display the current state of the chessboard. Our design also has provision for displaying the possible moves for a piece selected by the player to move. Additionally, we will be using OLEDs to display time and other in-game statistics during the game. 2.0 Software Design Considerations The main microcontroller of our design PIC24EP512GU810 has on-chip flash memory of 512 KB. For the purpose of this document, we will refer to this microcontroller as PICEP. We will use the Run-Time Self-Programming method to program the flash memory which allows the user application to modify Flash program memory contents [1]. Most of this memory is utilized for game logic. The program memory map for the PICEP can be seen in Figure 3 (Appendix C). User Program Flash Memory is restricted to the address range 0x000200 to 0x0557FE. Data storage for our design is limited to the current state of the chessboard, any pieces lost during the game, total number of moves played, status of pawns and status of rooks and kings (for implementing en passant capturing and castling respectively), corresponding color of player 1 and 2 and the checkmate status that checks if the game has reached to an end or not. All of these are extern global variables that are stored in the data segment of the program memory [12]. The executable instructions for program are stored in the text segment. The voice recognition microcontroller dspic33fj128gp202 has an on-chip flash memory of 128 KB which is used for packing the inputs (1-8 and a-h) for the coordinates of the square of the piece received through the microphone. For the purpose of this document, we will refer to this microcontroller as dspic. For both the microcontrollers, we are using the RPn/RPIn pins for any of the remappable peripherals. -1-

We are using the MPLAB Integrated Development Environment for programming and debugging in C for both the microcontrollers [2]. MPLAB ICD 3 In-Circuit Debugger probe is connected to the PC using a high-speed USB 2.0 interface and to the microcontroller development board using an RJ-11 header. Microchip C 30 Toolsuite provides the MAPLAB C30 C Compiler which uses pic30-gcc to compile C code used for the project. Voice input from the microphone will first get transmitted to the Si3000 voice band codec [3] which will perform the analog to digital conversion. Each of the input goes through a mixer prior to ADC conversion. Subsequently, data is sent to the dspic for completing the voice recognition and packing in the inputs received. Transmission between the two microcontrollers is accomplished by using the UART channel [4]. UART will use the UxCTS (clear to send) and UxRTS (request to send) hardware controlled pins. This will allow it to operate in flow control mode. This works similar to the handshake protocol. Unless the PICEP is ready to receive another input from the dspic, data will not be transmitted between the two microcontrollers. UART will run at the standard speed mode that is, 16x baud clock. For the UART mode register, UARTEN, UEN <1:0> and BRGH will be used and ABAUD (Auto-Baud) will be disabled. Data bits <7:0> will be accordingly used for the UART Receive and Transmit register to transfer the characters. UART Baud Rate Generator Register <15:0> will store the value such that the baud rate value is 9600 at an oscillating frequency of 7.37 MHz The Type A Timer in asynchronous counter mode for the PICEP will be used timing the game [5]. Register T1CON controls the Type A Timer. Bit 15, TON, either starts or stops the timer; TSYNC is set to 0 to disable external clock input synchronization and Bit 1, TCS is set to 1 to enable input from external clock; Bits 5-4, TCKPS <1:0> are set to 00 for a prescale value of 1:1. TMR1, timer count register (initialized to 0) and PR1, period register (set to 32767) are also used with the required values. Output from the PICEP to the OLEDs is sent through the SPI module. SPI is used under the Master mode of operation as the master (PICEP) will just be outputting the data to the OLED (slave) [6]. 8-bits are transferred at a time as the shift register being used in our design is an 8-bit parallel out shift register [7], hence, for SPIxCON1 register, MODE16 is set to 0. Bit 11 of the same register, SDOx (serial data output pin), is controlled by the module therefore DISSDP is set to 0. Bits CKE, SMP and CKP are also set to 0 under the Master mode. MSTEN is set to 1 as we -2-

are running the module under Master mode and setting SPIEN to 1, enables the SPI module. Register SPIxCON2 is set to 0 as we are not performing framed SPI operation. In addition to voice input, a player can also manually send the moves to play through 16- key keypad. Input from the keypad directly goes to the PICEP microcontroller. For scanning the keypad, we will use the sequential exploration of rows method [8]. In this method, all the rows are configured as output and the columns as inputs to the microcontroller or vice versa. Default input for all the column lines is set to 1. The keypad is then scanned by setting the rows to 0 one at a time and reading the columns. This method even though scans 16 keys, only requires 8 pins on the micro (Figure 5, Appendix C) making it more efficient. PWM channels for the display are used to increase the speed of refreshing the RGB LED Matrix panel [9]. It will work under the independent output mode (PMOD=11). GPIO Pins A, B and C are used to control which rows the data will go to. Overall organization of the application code is command driven (Application Code 3) as our design depends on the user input and also runs through the same code every time (Figure 1, Appendix A). Unless the player has provided any input, we do not want the game to run. Once the move is entered, the program checks if it is legal and/or displays the possible moves for the selected piece. Once the move is correctly assessed, chessboard is displayed on the RGB LED matrix panel. Therefore, even though, same code is implemented, running the program continuously in an infinite loop is not required. The game and hence the executable code end when either of the kings has been checkmated. 3.0 Software Design Narrative Figure 1 in Appendix B depicts the hierarchical view of the various code modules. Chessboard layout on the RGB LED matrix is shown in Figure 6 (Appendix C). The rows (ranks) are numbered 1 through 8 bottom-up, and the columns from a through h, left to right. White pieces are placed on rank 1 and 2 (bottom two rows) and the black pieces are placed on rank 7 and 8 (first two rows). Upon start-up, input is received from either the microphone or the keypad according to user preference. The player will speak out or press the coordinates of the current position of the piece and that of the next position they want to move to. The input from the microphone will be transmitted to the PICEP (game and display logic microcontroller) after passing through the Si3000 voice band codec and the dspic (Section 2). -3-

The PICEP performs the game logic and sends the correct output to the RGB LED matrix panel. Once the coordinates are received from the player, the game logic begins its magic. Most of the functions to check if the move played by the player is legal or not are under one source file. At first, the piece that occupies the current position as provided by the player is retrieved. Then the square to which the player wishes to move is checked if it is empty or occupied by an opponent piece. Then for each piece, we check if the corresponding move is possible or not. For example: a rook can only move horizontally or vertically, a bishop can move diagonally, queen can move either like a rook or a bishop, king can move to any of the 8 surrounding squares or engage in castling in conjunction with a rook provided it does not result in the king being in a check state, a knight can jump in an L-shape; rules for en passant capturing for pawns is also taken into consideration [10]. Our game also has provision to display the possible moves for a piece selected by the player to play [11]. Whether the possible moves will be displayed each time a player makes a move, or it will be an option using a pushbutton, is still undecided. After the move is ascertained to be legal, the game logic will reset the current state of the chessboard and send the output to the RGB LED Matrix. For displaying various pieces on the RGB LED Matrix panel, each piece utilizes 4x4 RGB LEDs of the two 16x32 matrices. Having RGB LEDs gives us the freedom to pick any color for the players and the squares; exact colors being used still need to be determined. For each piece, we will display it using a corresponding letter: C for rook, H for knight, B for bishop, K for king, Q for queen and P for pawn (Figure 4, Appendix C). Our design will also keep track of the number of pieces lost during the game and the time elapsed since the game has started. Both of these statistics will be displayed on the OLED screens as an output. This provision is simply for the convenience of the players. Almost all of the game logic has been successfully coded and tested in pure C, that is, it compiles using gcc. Interfacing it with the PICEP microcontroller is the next step which might require minor changes syntactically; code for voice recognition and output display still needs to be written and tested. -4-

4.0 Summary Our project is a voice controlled chess game that takes the input from a microphone or a keypad and uses the RGB LED matrix panel to display the chess board. Our design not only checks if the moves played by each player are legal or not, but also displays possible moves for each selected piece. Additionally, we are using OLEDs to output various in-game statistics. Transmission between the two microcontrollers is handled by the UART protocol. The game and display logic microcontroller (PIC24EP512GU810) sends the data to the OLEDs using the SPI module and uses the PWM for fast refreshing of the RGB LED matrix. Our overall organization of the application code is command driven. Even though we repeat the same instructions after a move is played, the game does not progress unless the player has played correct moves. -5-

5.0 List of References [1] "Section 5. Flash Programming," Microchip, [Online]. Available: http://ww1.microchip.com/downloads/en/devicedoc/70609d.pdf. [Accessed 21 March 2013]. [2] "MPLAB ICD 3 In-Circuit Debugger," Microchip, [Online]. Available: http://www.microchip.com/stellent/idcplg?idcservice=ss_get_page&nodeid=1406&ddo cname=en537580. [Accessed 21 March 2013]. [3] "Si3000 Voice Band Codec with Microphone/Speaker Drive," Silicon Labs, [Online]. Available: https://www.silabs.com/support%20documents/technicaldocs/si3000.pdf. [Accessed 21 March 2013]. [4] "Section 17. UART," Microchip, [Online]. Available: http://ww1.microchip.com/downloads/en/devicedoc/70582d.pdf. [Accessed 21 March 2013]. [5] "Section 11. Timers," Microchip, [Online]. Available: http://ww1.microchip.com/downloads/en/devicedoc/s11.pdf. [Accessed 21 March 2013]. [6] "Section 18. Serial Peripheral Interface (SPI)," Microchip, [Online]. Available: http://ww1.microchip.com/downloads/en/devicedoc/70569c.pdf. [Accessed 21 March 2013]. [7] "SN54LV164A, SN74LV164A 8-Bit Parallel-Out Shift Registers," April 2005. [Online]. Available: http://www.ti.com/lit/ds/symlink/sn74lv164a.pdf. [Accessed 21 March 2013]. [8] "Lab 18: Matrix keypad interfacing," Embedded Lab, 25 August 2011. [Online]. Available: http://embedded-lab.com/blog/?p=3428. [Accessed 21 March 2013]. [9] "Section 14. High-Speed PWM," Microchip, [Online]. Available: http://ww1.microchip.com/downloads/en/devicedoc/70645c.pdf. [Accessed 21 March 2013]. [10] P. Schroff, "Check If Legal," Treasure Chess, March 2013. [Online]. Available: https://engineering.purdue.edu/477grp2/nb/game%20logic/checkiflegal.c. [Accessed 21 March 2013]. [11] P. Schroff, "Possible Moves," Treasure Chess, March 2013. [Online]. Available: https://engineering.purdue.edu/477grp2/nb/game%20logic/possiblemoves.c. [Accessed 21 March 2013]. [12] P. Schroff, "Main Declarations," Treasure Chess, March 2013. [Online]. Available: https://engineering.purdue.edu/477grp2/nb/game%20logic/maindeclarations.h. [Accessed 21 March 2013]. [13] "16-Bit Microcontrollers and Digital Signal Controllers with High-Speed PWM, USB and Advanced Analog," Microchip, [Online]. Available: http://ww1.microchip.com/downloads/en/devicedoc/70616g.pdf. [Accessed 21 March 2013]. [14] "Keypad Scan," [Online]. Available: http://esd.cs.ucr.edu/labs/decode_key/decode_key.html. [Accessed 21 March 2013]. [15] E. Scimia, "How to Set Up a Chess Board," About.com, [Online]. Available: http://chess.about.com/od/rulesofchess/ss/boardsetup_7.htm. [Accessed 21 March 2013]. -6-

Appendix A: Flowchart/Pseudo-code for Main Program Figure 1: Main program flow. The same steps are repeated for both the players after resetting the chess board. -7-

Appendix B: Hierarchical Block Diagram of Code Organization Figure 2: Hierarchical Block Diagram -8-

Appendix C: Related Images Figure 3: Memory Organization for PIC24EP512GU810 [13] Figure 4: Characters display on the RGB LED matrix (4x4) -9-

Figure 5: Connections for Keypad Scanning [14] Figure 6: Chessboard Layout [15] -10-