introduction - 8085 projects : the compendium –...

26
BULLS AND COWS: A CODE BREAKING MIND GAME EC 316: Microprocessors Lab Project Netaji Subhas Institute of Technology, New Delhi (University of Delhi) TEAM DETAILS:- 1. Kusha Sahu : 84/EC/13 2. Lakshay Arora : 85/EC/13 Description: An ancient mind game, now used in several video games as a sub part, has been implemented using 8085 microprocessor using peripheral interface IC 8255, LED’s, LCD, DIP switches and other required controls. An 8k RAM and ROM has been used and 8255 has been I/O mapped. It is a 2 player game, with one of them setting a secret code using the DIP switches and an enter button. The second player guesses the code using the same switches. The digits which are correct in face and place value are referred to as BULLS and those with only face value correct are referred as COWS are

Upload: dangkhue

Post on 23-Apr-2018

220 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

BULLS AND COWS: A CODE BREAKING MIND GAME

EC 316: Microprocessors Lab ProjectNetaji Subhas Institute of Technology, New Delhi

(University of Delhi)

TEAM DETAILS:-1. Kusha Sahu : 84/EC/132. Lakshay Arora : 85/EC/13

Description: An ancient mind game, now used in several video games as a sub part, has been implemented using 8085 microprocessor using peripheral interface IC 8255, LED’s, LCD, DIP switches and other required controls. An 8k RAM and ROM has been used and 8255 has been I/O mapped. It is a 2 player game, with one of them setting a secret code using the DIP switches and an enter button. The second player guesses the code using the same switches. The digits which are correct in face and place value are referred to as BULLS and those with only face value correct are referred as COWS are displayed once the second player has entered his/her guessed code. At the end it shows which player has won.A website has been made to cover the progress of the project throughout the semester.

www.microprocessor8485.wordpress.com

Page 2: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

Acknowledgement

With profound respect and gratitude, we take the opportunity to convey our sincere thanks to Prof. Dhananjay V. Gadre for introducing us to such practicality of the subject and providing valuable guidance and resources leading to the accomplishment of the project titled as “BULLS AND COWS” based on Intel 8085 Microprocessor.

Special thanks to our seniors and peers in CEDT for their constant support and guidance. We would also like to thank the various lab assistants who patiently helped us during the course of the project work.

We would also like to thank www.pcbpower.com for precise manufacture and timely delivery of the project board.

Kusha Sahu (84/EC/13) Lakshay Arora (85/EC/13)

Page 3: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

Table of Contents

INTRODUCTION........................................................................................4

PROJECT DESCRIPTION............................................................................5

A little about 8085.................................................................................7

A little about 8255.................................................................................8

SCHEMATIC DIAGRAM AND BOARD LAYOUT.........................................10

SOFTWARE: CODE AND FLOWCHART....................................................14

TESTING AND DEBUGGING....................................................................17

PROJECT PROGRESS USING GANTT CHART............................................18

BIBLIOGRAPHY.......................................................................................20

Page 4: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub
Page 5: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

INTRODUCTION

We had heard from our fellow friends that BULLS and COWS has always been the start project for application development. This gave us the idea of developing a hardware version of this game and starts our development using microprocessors.

In this project, we have designed and developed the game using LCD for output and DIP switches for the input of the secret code. The objective of this game is to guess the secret code set up by Player 1 successfully within 4 chances. The LCD will give the number of chances left, the number of BULLS (digits with correct face and place value) and COWS (digits with correct face value) which gives hints to what could the secret code be.

The game involves the player one to set the secret code, one digit by one, by switching ON the corresponding switch on the DIP switches and an enter button placed next to them. Once the secret code has been accepted, its player 2’s turn to guess. The player has got 4 chances, to successfully crack the code using his mind to understand and apply the information of number of bulls and cows given on LCD after each guess to his/her profit.

Throughout the development, we have encountered numerous hurdles which helped us learn and cleared our basics to how the microprocessor and other devices work and various methods to test and debug each device. A practical project such as this, intrigues the engineers’ mind to go beyond and not only learn but apply such ideas to his/her daily life for the better.

Page 6: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

PROJECT DESCRIPTION

The project’s heart lies in the microprocessor 8085 which controls the logic, the peripherals and the memory. As this project doesn’t involve any interrupt logic, the interrupt pins have been pulled down. A sliding switch is connected to the SID pin which was not only used to test the microprocessor using SID-SOD test but to control the player mode. The address lines latched are connected to various points such as chip selects of RAM,ROM and 8255.

A 8k RAM and 8K ROM has been used for the memory, 8255 has been used to interface the input DIP switches on PORT A and LCD data lines on PORT B. 8255 is therefore used in Mode 1 I/O. PORT C lower pins are used for control pins of LCD and upper port C is used to input the 2 of 10 digits and an enter button is connected. A micro-USB connector has been used to power the board. A crystal of 4MHz has been used as a clock.

On powering the board, the LCD shows ‘BULLS AND COWS’. The sliding switch will be used to start the game for player 1 to set the secret code. Using the enter button after setting the desired digit on the DIP switch the code is saved in the RAM. Again using the sliding switch to go in player 2 mode to guess the code in the same procedure. After each guess, the LCD will give the information about the number of BULLS and COWS and the number of chances left. Till the user doesn’t press the enter button, the next chance will not start, for he/she can take this time to make their strategy. If successfully guessed the code, the LCD will display ‘PLAYER 2 WINS ’ or else it will display ‘PLAYER 1 WINS’.

A Block Diagram has been included for a clearer reference.

8255 has several modes, here used in mode 0, makes the job of taking input and output easier as well as saves a lot of decoding circuitry otherwise.

Components of the Project are:-

1. 8085 microprocessor, the CPU of the game system an 8 bit microprocessor.

Page 7: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

2. 8255 is a general purpose programmable I/O device. It provides 24 I/O pins which may be individually programmed in 2 groups of 12 and used in 3 major modes of operation.

3. 74HCT573N an octal latch used to latch the address bits.4. Electrolytic and ceramic capacitors.5. Resistors and resistor networks. The latter saves a lot of space on the

board.6. 2 Push buttons: One for ‘enter button’ and the other to reset the system.7. Sliding switch: To change player mode.8. 74HCT138N: 3x8 Decoder with active-low output9. 16x2 LCD used for display.10. 2 3MM LEDs for Power light and testing purposes.11. M10 Quick Connectors: They were used for debugging.12. 2864 ROM13.6264A RAM14. Micro-USB for power port.15. Crystal for clock input

Page 8: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

A little about 80858085 is an 8 bit microprocessor introduced by Intel in 1976. This 40 pin IC is an update over the microprocessor 8080 requires less support circuitry, allowing simpler and less expensive microcomputer systems to be built. It uses a multiplexed address/data bus which reduced the number of PCB tracks to memory segments.

While it has the conventional von Neumann design based on 8080, it does extends to incorporate 3 maskable vectored interrupts (RST 7.5,6.5,5.5), a non-maskable vectored interrupt (TRAP) and a maskable non-vectored interrupt (INTR).All the interrupts are enabled using the instruction EI and disabled using DI. INTA’ is used to send an acknowledgement to the device which requested an interrupt.

It can accommodate slower peripherals using the READY pin through externally generated wait states. It can drive itself using the crystal externally connected to X1 and X2, while a internal clock generation uses a divide by 2 frequency circuitry.

Although it does require demultiplexing of addresses line to generate the lower byte of the address, which can be done using a latch whose enable pin is connected to ALE pin of the 8085.ALE pin goes high at the start of every machine cycle, which enables the address latch.

Page 9: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

CLKOUT can be used to drive external device with the same clock as that of 8085. While HOLD and HLD are used for DMA transfer between input/output devices and memory, while 8085 relinquishes all its control over the address and data bus.

The processor has seven 8 bit registers A,B,C,D,E,H,L which are available to the programmer and 2 internally registers(W and Z) used by 8085 itself. A is accumulator , while the others can be used as pairs (16-bit register).HL pair can be used to access memory space whose address is given by the value in HL. A flag register which contains Sign, Zero, Carry, Aux-Carry and parity bits telling the status. It also has two 16 bit registers: Program Counter (PC), Stack Pointer(SP)

8085 follows little-endian, lower address on lower bytes and higher on higher byte, which is for example used while storing the address when a register pair is pushed in the stack.

There are 8-bit instructions like MOV, ADD, SUB etc while 16 bit instructions are also available such as LXI, DCX, INX, PCHL, XCHG. PCHL exchanges value of PC with that of HL, so it acts likes a unconditional jump.

This amazing microprocessor supports upto 256 input/output port.

A little about 82558255: Programmable Peripheral Interface device, first developed for 8085 has also been used for its descendents like 8086 etc. Also a 40 pin IC has 24 i/o pins in all. These are divided into three 8 bit ports A, B, C. Port A and B can be used as input output ports while the port C can be used as a single 8 bit port or as two separate 4 bit ports or used to generate handshake signals for port A and B. These are divided into 2 groups.

A0 A1 Part Selected0 0 Port A0 1 Port B1 0 Port C1 1 Control Register

Page 10: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

Group A: Port A and Upper 4 bit Port C(PC4-PC7)Group B: Port B and Lower 4 bit Port C(PC0-PC3)

8 data lines are available to read or write data onto these ports.2 address lines A0 and A1 are used to decode the address for ports or the control register.

There are 2 basic operational modes of 8255.

1. BSR(Bit set reset): In this mode characterized by D7=0, one can set or reset individual bits of Port C. The bit can be selected by D3-D1 bits and set/reset by D0 while other bits (D4-D6) are don’t care.

2. I/O mode: (D7=1) This further has 3 modes in this the ports can operate. Mode 0, input ports are not latched and output ports are latched, a simple I/O mode. Mode 1 operated using handshake signals. Both Port A and B can operate in this mode using their respective Port C part as handshake signals pins. Mode 2, available for only Port A, is used for bidirectional data transfer.

In this project we have used 8255 in Mode 0 of I/O operation.

Page 11: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

SCHEMATIC DIAGRAM AND BOARD LAYOUT

Page 12: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

Here are few images of our project.The following is just after our board arrived:

After Completion :

Page 13: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

SOFTWARE: CODE AND FLOWCHART Software tools used in this project:

1. EAGLE CAD for schematic and board layout 2. OSHON Soft assembler

The code has been broken down in several parts as show in the various flowcharts. This helped us to ensure that small points of codes, edge cases are not missed.

For examples, we have included few instances of our code.

Reading and storing a digit of numberREADBUTTON_1_1: IN 02H RAL JC READBUTTON_1_1 IN 00H ; FCH read port A STA 0E000H SUI 0FFH

JZ eight11 JMP DE

eight11: IN 02H ANI 030H STA 0E000H

Checking one digit with each digit of guessed code to determine Bull or a Cow

CHECK_1: LDA 0E000HMOV E,A

Page 14: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

LDA 0E100HCMP ECZ BULLLDA 0E101HCMP ECZ COWSLDA 0E102HCMP ECZ COWSLDA 0E103HCMP ECZ COWS

Incrementing BULLS and COWSCOWS: PUSH PSW

PUSH DINR CPOP DPOP PSWRET

BULL: PUSH PSWPUSH DINR BPOP DPOP PSWRET

Several instructions have to be carefully used in order to properly affect the flags to our use. Care was also taken to push and pop register pairs properly so as to not change the original values of the register being differently used in the sub routine.

The code total of 858 lines and 077A in size as given in the following screenshot.

Page 15: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

TESTING AND DEBUGGING

Several methods were employed to test the board. On the arrival of the board, after soldering, the first test was SID-SOD test . A sliding switch is connected to the SID pin and an LED on the sod. Program was written on the ROM. Here we tackled our first hurdle. The SOD pin LED was not glowing. To debug it, an oscilloscope was used to check all the pins of 8085. Through this method we were able to find out that the decoding circuit of generation of control signals was a bit wrong. With the help of our teacher and a senior we were able to reconnect the correct connection and so did the SID-SOD test successful.

Next was testing the 8255. With the help of a multimeter, when program of written for each port to be output with digital value 1, we checked every port pin of 8255 which was being used to be high. The next hurdle was again a hardware

Page 16: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

mistake. Unlatched data bus lines A0-A1, for chip select were used, which was causing it to not latch the input DIP Switches. We then connected these pins to A8,A9,A15 respectively .But this doesn’t make 8255 memory mapped as during the IN-OUT instructions the value on both lower byte and higher byte of address is the same.

Then it was the time to test the LCD. Using the theory given in our course book, we developed the code suited for hardware and tested it. After a few tries we were able to display sample characters on the LCD.

After successfully displaying a sample text on LCD, we first tested our game for 1 digit. Here we first wrote the code, where the input was just one digit and the second player needs to guess it. A lot problems came in the way that made us think about the edge cases and we modified our code thereafter.

We then first wrote the code for 4 digits and one chance and then moved on for 4 chances.

Days later we had successfully completely implemented the game.

Page 17: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

PROJECT PROGRESS USING GANTT CHART

A Gantt chart is an excellent way to illustrate the start and finish dates of the terminal elements and summary elements of a project. It also shows the dependency of one task on another.

The following was originally proposed set of events.

Page 18: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

But as the time followed we had to change the timeline. The final Gantt chart is as follows:-

As clear from the charts, we did fell behind schedule, but we worked harder and completed our project before the final deadline.

Gantt chart is a wonderful tool which highly elaborately helps the members to work according to the schedule. We have grown to appreciate its usefulness and will extensively use it our next projects.

Page 19: INTRODUCTION - 8085 Projects : The Compendium – …8085projects.in/.../uploads/2016/12/84EC13-85EC13.docx · Web viewAn ancient mind game, now used in several video games as a sub

BIBLIOGRAPHY

Reference was taken from the following to complete out project:

1. Microprocessor Architecture, Programming, and Applications with the 8085 , (5th Edition) By Ramesh Gaonkar

2. http://www.cpu-world.com/Arch/8085.html3. https://www.youtube.com/watch?v=I78iyzXQrP4 : working of 8085

microprocessor Animation4. http://gradestack.com/Microprocessors-and/Architecture-of-8085/

Architecture-Of-The-8085/19310-3912-37489-study-wtw5. http://microprocessorforyou.blogspot.in/2012/05/arithmetic-instruction-in-

8085.html6. https://en.wikipedia.org/wiki/Intel_80857. http://www.brighthubengineering.com/diy-electronics-devices/51225-

architecture-of-8085-microprocessors-part-one/8. https://en.wikipedia.org/wiki/Intel_82559. http://8051-microcontrollers.blogspot.in/2015/02/module-3-learning-unit-9-

of.html