ECE 477 Digital Systems Senior Design Project Rev 9/12 Homework 5: Theory of Operation and Hardware Design Narrative

Team Code Name: Hackers of Catron Group No. 03 Team Member Completing This Homework: Joshua Hunsberger E-mail Address of Team Member: jhunsber@ purdue.edu

Evaluation:

SEC DESCRIPTION MAX SCORE 1.0 Introduction 5 2.0 Theory of Operation 20 3.0 Hardware Design Narrative 20 4.0 Summary 5 5.0 List of References 10 App A System Block Diagram 10 App B Schematic 30 TOTAL 100

Comments: ECE 477 Digital Systems Senior Design Project 9/12

1.0 Introduction Hackers of Catron is an electronically enhanced version of the popular Settlers of Catan board game. Game setup will be automated, placement of physical pieces on the board will be tracked, and resource trading will be handled through handheld devices. These enhancements to the game will make the game easier to set up and play, resulting in a much improved game play experience. The display of board setup requires that each hexagon (hex) be recognizable as one of the five resource types or the desert and must be associated with a rarity that corresponds to a possible sum of two thrown dice. In order to accomplish this, the design utilizes a combination of RGB LEDs to designate resource types and two-digit seven-segment displays to designate the rarities. In order to sense the position of all the pieces the design uses a grid of Hall Effect sensors which indicate when a magnet has been placed above them.

2.0 Theory of Operation The Hackers of Catron circuit comprises three major functional subsections: The Hall Effect sensor array, the RGB LED array, and the seven-segment display array. In addition there are several minor functional subsections including the power supply, the Raspberry Pi interface, and an additional Hall Effect sensor which did not fit in the array. Across all subsections, all ICs are powered by the 3.3V supply rail, chosen primarily to eliminate the need for voltage level translation since the Hall Effect sensors and microcontroller (MCU) both operate at 3.3V [1][2]. The operating mode and conditions for each functional block are summarized at the end of this section. The purpose of the Hall Effect sensor array is to sense the presence and position of pieces placed on the playing surface. The presence of a piece is indicated by the output of a Hall Effect sensor. The position of the piece can be determined by correlating each sensor to a physical position (implemented in MCU code). To save pins, sensors are grouped into 18 “columns” of 8 “rows” each. The MCU can access any row of 18 sensors by outputting the correct address on 3 select pins of discrete multiplexers into which each column is fed. The RGB LED array is designed to represent a hex’s resource type with unique, distinguishable colors. The array will also be used as feedback during game play to indicate improper piece placement or piece placement confirmation as needed. In order to control the

-2- ECE 477 Digital Systems Senior Design Project 9/12 color and brightness of the RGBs, the MCU sends commands via a two-wire interface to 7 nine- channel LED driver chips. The driver chips can communicate at up to 5MHz [3], so there should be no issues with updating the state of the RGBs quickly. The driver chips also have their own data line buffers, echoing the data and clock lines on a pair of output pins, so the chips will be daisy-chained together. The LED control outputs are open-drain, which allows the LEDs themselves to be powered by the 5V rail. This is done because the green and blue LEDs have typical forward voltages of 3.2V and up to 4.0V [4], making it unfeasible to drive them with the 3.3V rail. Furthermore, each channel will control two LED’s in parallel in order to increase light coverage on each hex. The seven-segment display array is used to represent the relative rarity of each hex. Since the possible value for each hex can go up to 12, two digits are required for each hex, making a total of 38 digits. To control all these seven-segment displays, the MCU uses SPI to shift control data to 5 eight-digit control chips. Each chip requires a load-enable or slave-select line to be driven low in order to accept control data, but will also shift out control data as long as the load- enable line is not driven high again[5]. This allows the MCU to shift data into all 5 chips at once while only using one load-enable line. The chips are connected to both the anode and cathodes of each digit, and only a single resistor is required to set the current for each segment. In order for players of Hackers of Catron to user their mobile devices to play the game, a Raspberry Pi acts as a server and a wireless access point. To retrieve the status of the game and communicate the state of the economy back to the MCU, several data lines must be used. I2C is supported by both the MCU [1] and the Raspberry Pi, so only two lines are required to connect the two devices. However, because the Raspberry Pi already has a 26 pin header, for simplicity the PCB will also feature a 26 pin header, to which any pins not assigned tasks will be routed. The Raspberry Pi is powered by 5V unregulated and uses a USB interface to get this power. The board requires two voltage rails. The RGB LEDs and the Raspberry Pi are powered by 5V unregulated, while everything else is powered by 3.3V regulated power. Therefore, a simple 5V AC adaptor is used to draw power from a typical AC outlet. This is then regulated down to 3.3V to power the more sensitive ICs on the board. In order to protect the rest of the board during construction and testing, several jumpers are used to isolate the power supply and the regulator from everything else.

-3- ECE 477 Digital Systems Senior Design Project 9/12

Table 1 Operating Mode Summary

Subsection Component Function Operation Sensor Hall Effect sensor Detect piece 3.3V, active low, open drain, .47uF bypass cap, 15kΩ Pull up resistor Multiplexer Organize sensors, reduce pin 3.3V, complemented output, count 3 SEL lines, 8:1 RGB RGB LED Distinguish hex resources 5V, 15-20mA, parallel, common anode 9CH LED driver Control RGB color 3.3V, open drain, Input: 1 data, 1 clock line Output: 1 data, 1 clock 7Segment 2digit 7seg display Display resource rarity 3.3V, 20mA/segment 8digit driver Control 7seg display 3.3V, 160mA/digit, SPI Input: 1 data line, 1 load- enable, 1 clock Output: 1 data line

3.0 Hardware Design Narrative To communicate and coordinate all the major subsections of the circuit, the MCU utilizes the SPI, I2C, and general purpose subsystems. Port selection was done on a restrictive-first basis, so that subsystems with the least flexibility in pin selection were assigned pins first. I2C is used to communicate with the Raspberry Pi. The I2C subsystem is a part of the MCU’s Two Wire Interface (TWI) subsystem. Since the TWI interface only has one choice for its pin, it was given a pin assignment first. SPI, used to communicate with the seven-segment display array, was the next most restrictive subsystem. This pin assignment was made so that all four pins used are physically close to each other (see Appendix B), which should simplify routing. To drive the select line of all 18 multiplexers present in the sensor array subsection, three of the MCU’s four high-drive pins were chosen as address lines. Although the 1mA driving capability of any GPIO pin should be sufficient, having the capability to drive 4mA on the high- drive pins may prove beneficial in the future. The 18 return lines from the multiplexers along with the output of the solitary Hall Effect sensor are assigned to the remaining pins on Port A.

-4- ECE 477 Digital Systems Senior Design Project 9/12

Finally, the two pins used to communicate with the nine-channel LED drivers were assigned to two pins next to each other on Port B. There were several pins unavailable for assignment, including PortA pins 0-2 for JTAG programming requirements. Any pin left unassigned will be routed to a header pin for debug or communication with the Raspberry Pi. Furthermore, all communication signals are routed to the header pin for debugging during fabrication. The MCU can be powered with single or dual power supplies. All IO pins and the analog subsection are powered by 3.3V, while the core and PLL are powered by 1.8V. We decided to utilize the MCU’s internal voltage regulator to supply the 1.8V from the 3.3V rail. For this to work 3.3V must be attached to the VDDIN pin and the VDDOUT pin must be routed to the VDDCORE and VDDPLL pins. In order to avoid supply rail ripples, bypass capacitors are required on both the 3.3V and 1.8V lines. Because our design does not utilize any analog functions, the ADVREF pin is tied to ground in order to save power, as recommended by the MCU’s datasheet. Table 2 Port Assignment

Ports Subsystem Function PA09, 10 TWI Raspberry Pi communication PA14...16, 28 SPI Control 7seg display PA20...22 GPIO Select address lines for sensor array PA03...08, 11...13, 17...19, 23...27, 30, 31 GPIO Sensor array return lines PB10, 11 GPIO Control RGB display RESET_N, VDDIO, TCK, PA00...02 On-Chip Debug Programming via JTAG interface

4.0 Summary The Hackers of Catron circuit must accomplish 4 basic tasks: sense pieces, display a playing board, facilitate trading, and provide enough power to accomplish the first three tasks. The first two tasks are accomplished via arrays of sensors and LEDs controlled by a string of drivers. The third task requires a communication protocol between the Raspberry Pi and the MCU which is fulfilled with I2C. All power will be provided by a 5V unregulated supply regulated down to 3.3V for the CMOS devices. The MCU interface is primarily concerned with serial communication to other devices. The only exception is the sensor array, which uses 3 address lines to select the row of 18 sensors the MCU will read.

-5- ECE 477 Digital Systems Senior Design Project 9/12

5.0 List of References

[1] Atmel, “32-bit ATMEL AVR Microcontroller,” 3 2012 [Online]. Available: http://www.atmel.com/Images/doc32059.pdf. [Accessed 13 2 2013].

[2] Toshiba, “TCS20DLR,” 2 2011. [Online]. Available: http://www.semicon.toshiba.co.jp/info/docget.jsp? type=datasheet&lang=en&pid=TCS20DLR. [Accessed 13 2 2013] [3] Omron, "LED Control IC W2RF004RM," 8 2012. [Online]. Available: http://components.omron.com/components/web/pdflib.nsf/0/A59093552C8ED1C186257 A5D0077B1D2/$file/W2RV004RM_0812.pdf. [Accessed 13 2 2013]. [4] AMS, "AS1116 LED Driver IC," [Online]. Available: http://www.ams.com/eng/Products/Lighting-Management/LED-Driver-ICs/AS1116. [Accessed 13 2 2013]. [5] Cree, “Cree® PLCC4 3 in 1 SMD LED CLV1L-FKB,” [Online]. Available: http://www.cree.com/~/media/Files/Cree/LED%20Components%20and %20Modules/HB/Data%20Sheets/CLV1L%20FKB%201238.pdf. [Accessed 13 2 2013]

-6- ECE 477 Digital Systems Senior Design Project 9/12

Appendix A: System Block Diagram

-7- ECE 477 Digital Systems Senior Design Project 9/12

Appendix B: Schematic

-8- ECE 477 Digital Systems Senior Design Project 9/12

-9- ECE 477 Digital Systems Senior Design Project 9/12

-10- ECE 477 Digital Systems Senior Design Project 9/12

-11- ECE 477 Digital Systems Senior Design Project 9/12

-12- ECE 477 Digital Systems Senior Design Project 9/12

-13- ECE 477 Digital Systems Senior Design Project 9/12

-14- ECE 477 Digital Systems Senior Design Project 9/12

-15- ECE 477 Digital Systems Senior Design Project 9/12

-16- ECE 477 Digital Systems Senior Design Project 9/12

-17- ECE 477 Digital Systems Senior Design Project 9/12

-18- ECE 477 Digital Systems Senior Design Project 9/12

-19- ECE 477 Digital Systems Senior Design Project 9/12

-20- ECE 477 Digital Systems Senior Design Project 9/12

-21-