Logic Project- Lights Off

  • Upload
    nichole

  • View
    218

  • Download
    0

Embed Size (px)

Citation preview

  • 7/25/2019 Logic Project- Lights Off

    1/14

    Author : Mohit Lamba Branch : ECE

    Year : 2nd year Institute : NSIT (Intern)

    LIGHTS OFF (GAME)

    A remake of the famous 1995 game

    The rules of the game are very simple. The game consist of a 5 X 5 LED

    matrix with a push button(one for each LED). On pressing any of the push

    button, the LED associated with it and the four neighbouring LEDs get

    toggled. Our aim is to turn off maximum number of LEDs (all if you can) in

    minimum presses.

  • 7/25/2019 Logic Project- Lights Off

    2/14

    Lights Off 2

    INTRODUCTION:

    Lights Out was a fabulous game launched in 1995 by TIGER ELECTRONICS.Soon after its launch it became hugely popular. My project Lights Offwas to remakethat game.

    The game consists of a 5 X 5 grid of LEDs with switches. For the first 10 seconds theplayer can choose one of the five stored pattern to initially turn on some of the LEDs.Then when the pattern is locked the player can start press buttons to toggle the itsassociated LEDs as well as the four adjacent LEDs. The aim of the player is to turnoff maximum number of LEDs in minimum number of switch presses.For the first ten seconds a red LED glows on driver circuit to indicate that the player

    can choose the initial pattern. After ten seconds a timer interrupt causes that LED toblink indiacating that the pattern has been locked.

    JUSTIFICATION :

    I was completely new to the embedded electronic field and had no past experienceof project of any kind(except for some C/C++ coding). My main intention was to learnsome basic application like LED MULTIPLEXING, use of transistors in practicalcircuits, etc. Lights off project conceptually, appeared to me to be fairly simpleproject. At the first instant of visualizing only I was able to see how my finalproduct(roughly) would be with all the top level details. There was no ambiguity in mymind of what i had to do. At the same place from implementation point of view itseemed moderately challenging. So considering all this i was very much tempted todo this project.

  • 7/25/2019 Logic Project- Lights Off

    3/14

    Lights Off 3

    HARDWARE :

    Following are the components that i required for my project:-1. USB connector(1)2. LM1117 3.3V voltage regulator(1)

    3. 10 uF capacitors(2)4. 1 uF capacitors (3)5. 10xx OMRON switches (26)6. 10k, 1k, 330, 220 and 50 resistors7. 2.7 V zener diode (5)8. 557b PNP transistors (5)9. BC337 NPN transistor (5)10. 20 pin IC connector(1)11. MO5(3) and MO4(1) connectors12. Green SMD LED(100) and red LED(1)13. Female jumper wires(20)14. Berg strip15. PCB board- 1.6mm and 0.7mm

    JUSTIFICATION OF HARDWARE:

    1. MSP430 is powered at 3.3V and the green SMD LEDs are powered at 5V. Sooriginally the circuit is powered by a 5V supply coming from laptop/ powerbank. For this reason a USB connector has been used.(Refer to schematic)

    2. LM1117 buck regulator is used to step down 5V to 3.3V to power MSP430

    microcontroller.3. 10uF and 0.1uF capacitors have been used to remove any ripples present insupply and decoupling purposes.

    4. 10k resistors connected at 2, 3, 4, 5 and 6 at MSP430 (refer to schematic) arepull up resistors which are used for reading 5 switch columns on the otherboard.

    5. Five PNP transistors and and five NPN transistors have been used for highside and low side switching respectively. Because my LED circuit is poweredat 5V and MSP430 provides a high of only 3.3V, they will always drive thePNP transistors to saturation whether MSP430 pin is high or low. For thisreason 2.7 V zener diodes have been provided to drive the transistors in both

    saturation and cut-off state. A link for detailed reading of this has beenprovided in references.

    6. Three MO5 connectors have been used for driving the five rows and fivecolumns of LED and 5 columns of switches of the matrix board.

    7. MO4 connector has been provided to connect the driver circuit to the MSP430launchpad for burning the code to the MSP430 chip.

  • 7/25/2019 Logic Project- Lights Off

    4/14

    Lights Off 4

    SELECTING APPROPRIATE PNP AND NPN TRANSISTORS:-

    Drop across 1 green led = 2.2V

    Current required for appropriate brightness of LED = 2.5 mABecause with every switch instead of 1 there are 4 LEDs current required = 2.5 X 4 =10mA

    Duty cycle = 1/5=>Actual current required = 10 X 5 = 50mA

    Because in ROW MULTIPLEXING, in a particular column, only one LED is lit up at atime PNP transistor should be able to provide 50mA of current.557b PNP transistors have a current rating of 100mA so it has been used in theproject.

    But for rows this is not the case. For a particular row at the same time all LEDs canbe lit up.Hence current to be supplied by NPN transistors = 50 X 5 = 250mA.However to support even greater brightness, meaning more current, BC 337 highpower NPN transistors have been used which have a current rating of 800mA.

    (Schematic of driver circuit and 5X5 LED matrix on next page)

  • 7/25/2019 Logic Project- Lights Off

    5/14

    Lights Off 5

    Schematic for

    DRIVER CIRCUIT

    and

    5X5 LED matrix circuit

    with switches (next page)

  • 7/25/2019 Logic Project- Lights Off

    6/14

    Lights Off 6

  • 7/25/2019 Logic Project- Lights Off

    7/14

    Lights Off 7

    FINDING VALUES OF RESISTORS(USING KVL):-

    This is a small cut-out from my schematic which I used to actually calculate thevalues of resistors.

    FINDING R2

    Applying KVL from 5V supply to the ground, the KVL equation is

    (Q1 and T1 are in saturation and drop across geen LED is 2.2V)

    Hence R2 was taken as 50

    FINDING R3

    The high from MSP430 is 3.3V. So again applying we get,

  • 7/25/2019 Logic Project- Lights Off

    8/14

    Lights Off 8

    (Maximum current that MSP430 can sink/source is 10mA, so I is taken 10mA)

    Hence R3 was taken 330 , because 260 is not a standard value of resistors and Iwanted to limit current even below 10mA.

    The value of resistor with red LED on the driver board was found similarly using KVL.

    Values of all other resistors is mentioned in the schematic and their values weredecided by experience(under the guidance of seniors) and not by KVL.

  • 7/25/2019 Logic Project- Lights Off

    9/14

    Lights Off 9

    SOFTWARE IMPLEMENTATION:

    For making the schematic and board layout of my project I used CADSOFT EAGLEversion 6.4.0. The reason for using this software are :-

    Its is a open source software so there are no copyright issues involved andfor the same reason a lot of online online support is available.

    It has a very high learning curve, it takes only a day to become familiar andstart using the various features of the software. IT ELLEGANTLY DOESWHAT IT IS MEANT TO DO.

    It has a whole variety of the various devices one can imagine to use in onesproject.

    Many companies have readily provided the footprint of their devices. Sofinding a device and its corresponding footprint was not an issue. If notpresent by default, as mentioned before, there is a lot of online support.

    The code to be burned into the MSP430 chip was written in CODE COMPOSERSTUDIO version 5.5.It is the software that TI recommends for its chip, so I went with them without makingany further considerations.

    TESTING:

    Testing 5X5 LED matrix board

    As per my schematic the negative terminal of all LEDs belonging to a row areconnected. Similarly the positive terminal of all LEDs belonging to a column areconnected.

    Test 1:

    First I set the multimeter to continuity mode.So now if I touch the black lead of multimeter to the negative of any LED of a row

    then that negative supply is provided to all the LEDs of the row. So if one by one, Itouch the red lead of multimeter to different columns, keeping the black lead contactfixed, the LEDS of that row and that column should light up. I made sure that onlyred lead contact is changed every time.Same procedure was applied for rest of the rows.

    Many a times LEDS dint lit when they were expected to. There werethe onlypossible reason of error :-

    1. Two copper tracks were getting short due to soldering where clearance wasvery little. This was taken care by removing excess solder by continuouslyrubbing with a pointed object like compass needle.

    2. Too little solder was applied that proper connectivity was missing. Orsoldering was not done at all at some places.

  • 7/25/2019 Logic Project- Lights Off

    10/14

    Lights Off 10

    3. The 5x5 LED matrix board is a double sided board so 0.7mm PCB board hasbeen used. But this made the copper tracks very vulnerable to get cut atmany places. These cuts had to be identified by closely examining the boardboth by eyes and multimeter. Wherever some cuts were suspected jumperwires were soldered and finally continuity was tested using multimeter.

    After this test I was sure that all rows and columns are connected properly.

  • 7/25/2019 Logic Project- Lights Off

    11/14

    Lights Off 11

    Test 2:

    NOTE: This test is optional. There is no need of this test if everything workedproperly(or was rectified) in TEST 1 only. I did this test only to help myself accuratelypin point where the fault in my board was.

    In this test rather than keeping the black lead(of multimeter) fixed and moving thered lead, we just do the opposite. Everything else is same.

    TEST1 corresponds to ROW MULTIPLEXING and TEST2 corresponds to COLUMNMULTIPLEXING.

  • 7/25/2019 Logic Project- Lights Off

    12/14

    Lights Off 12

    Test 3:

    Now that all the LEDs were working properly it was time to test whether the MSP430would read the switches or not.I have used row multiplexing for both LEDs as well as the switches. As TEST1 had

    already been performed I assumed that all switches in a row were wellconnected(because all discontinuities in the rows were rectified).So in this test I concentrated on whether all switches in the same column wereconnected or not. This part was easy. I simply put my multimeter in continuity mode.Then put any lead to one of the switches and moved the other lead one by one to theother switches in the column. Wherever multimeter dint produce sound one of thethree problems as mentioned above were there.

    After these three tests I was sure that now my 5x5 LED matrix board with switcheswas perfectly fine.

    Testing the driver board:-

    Test 4:

    In this test my aim was to see whether 5V was coming from the USB connector ornot and whether LM1117 was stepping down 5V to 3.3V.

    First via laptop and USB cable, board was powered up. Then the black lead ofmultimeter was touched with the ground of the LM1117 and the other with theremaining two terminal.Initially voltage reading was 0.00V !!!!! And the LM1117 got very very hot that onecould not touch it.Seniors guided me that this indicated a short. The same three problems asmentioned in TEST1 were searched for and removed appropriately.

    Test 5:

    Now it was time to put everything together and do an integrated test.The two boards were connected using 15 female connectors and initially a simple

    code of LED multiplexing was burned into the MSP430 chip. This proved that my5X5 LED matrix board and the driver circuit were perfectly fine.Then a code to simply toggle a LED by reading a switch in pull up configuration wasburned. This made sure that even the switches were soldered correctly.It also confirmed that the code logic was also correct as the final code, till someextent, is just merging together both the codes( although a lot more complexbecause now both LED and switch multiplexing had to be done together ).

  • 7/25/2019 Logic Project- Lights Off

    13/14

    Lights Off 13

    People who made it possible :

    First of all I would like to thank Prof. Dhananjay V. Gadre for organizing the TIUniversity Program workshop funded by Texas Instruments. I had heard of variousother embedding system workshops from my friends. But after completing this

    workshop, its very clear, its best of all of them. Even my friends readily agree to thisfact. They say, Wow, you have attended a very nice .His theory lectures in the mini auditorium, I think, if not more but surely equallyvaluable as my working project. But there is one thing which make those lecturesmore important. My project can be replicated with major improvements and repeatedmany times. But those lectures on ASIC, RISC vs CISV, UART, high side and lowside switching, etc are rare. They cannot be replicated. Ill miss them more.

    Next I would like to thanks all the seniors at CDET, saral sir, ritika maam, ishaan sirand nikhilesh sir.Ritika maam taught me MSP430 G2553LED blinking, PWM, ADC, etc.

    Saral sir, literally, visualised the entire project for me. From schematic to board file ineagle, from drilling and soldering to rectifying the board, everything was guided bysaral sir. His efforts in making the double sided board are exceptional. He reallytolerated me throughout the hardware issues with a smile.

    Next I would like to thank Ishaan sir. The really complex part of merging the twologics (I mentioned before), of simultaneously doing LED multiplexing and switchmultiplexing, was guided by Ishaan sir. His unique idea of reducing the variablesusing left shift() operators was not less than a breakthrough in

    my project.

    I cannot also forget the overall guidance of nikhilesh sir.

    And finally I would like to thanks all the volunteers, Gaurav tyagi, ketan, kshitij,saddam and many more for everything else. They helped very nicely in making theboard, grinding, drilling, getting the components, etc.

    I cannot imagine my project to have progressed an inch without there help andguidance.

    Click on the link to for a video of my project:http://youtu.be/me6P4XTSXnQ

    http://youtu.be/me6P4XTSXnQhttp://youtu.be/me6P4XTSXnQhttp://youtu.be/me6P4XTSXnQ
  • 7/25/2019 Logic Project- Lights Off

    14/14

    Lights Off 14

    Refernces :-

    1. For learning how to code in MSP430, especially GPIO interrupts and polling, Iused the book,MSP430 Microcontroller Basics

    AUTHOR - John H. DaviesISBN- 978-0-7506-8276-3PUBLISHER- NewnesEDITION 2008

    2. To study in detail how high side and low side switching works, especiallywhen zener diode is used refer to following linkhttp://www.edn.com/design/systems-design/4431122/Zener-level-shifter-drives-high-side-switchby Dhananjay Gadre& Nidhi Sharmaon June 16, 2014