Complete Project R3d led cubeeport

53
3D LED CUBE A project report submitted in the partial fulfillment of the requirement for the award of degree of Bachelor of Technology (Electronics and Communication Engineering) (Session: 2010-2014) Supervised By: Mr. Nikhil Marriwala Astt. Prof. ECE Submitted By: Tushar Chawla(2510010) Ajay Singh(2510012) Varsha(2510013) ~ 1 ~

description

it includes the report of the 3d led cube and its source code

Transcript of Complete Project R3d led cubeeport

3D LED CUBE

A project report submitted in the partial fulfillment of the requirement for the award of degree ofBachelor of Technology (Electronics and Communication Engineering)(Session: 2010-2014)

Supervised By:Mr. Nikhil MarriwalaAstt. Prof. ECESubmitted By:Tushar Chawla(2510010)Ajay Singh(2510012)Varsha(2510013)

University Institute of Engineering and TechnologyKurukshetra University, Kurukshetra 136119

Declaration

We,Tushar Chawla, Ajay Singh, Varsha, students of Bachelor of Technology (Electronics and Communication Engineering), in the University Institute of Engineering and Technology, Kurukshetra University, Kurukshetra, under class Roll No.2510010,2510012 and 2510013 respectively, for the session 2010-2014, hereby, declare that the dissertation entitled 3D LED CUBE has been completed by us in 8th semester. We hereby declare, on behalf of ourselves that: i. The matter embodied in this project is an original work and has not been submitted earlier for award of any degree or diploma to the best of my knowledge and belief. Moreover, the project does not breach any existing copyright or any other third party rights.ii. The project contains no such material that may be illegal and offensive.

We hereby agree to indemnify UIET and its Teaching Staff against any and all losses incurred in connection with any claim or proceeding assert plagiarism and/or copyright infringement if the investigation carried out to determines that our work is the plagiarizing or infringing work.

Date: (Tushar Chawla) (Ajay Singh) (Varsha)

University Institute of Engineering & TechnologyKurukshetra University, Kurukshetra

Mr. Nikhil MarriwalaAstt. Prof. ECE

Certificate

It is certified that Mr. Tushar Chawla, Mr. Ajay Singh and Ms. Varsha, a student of Bachelor of Technology (Electronics and Communication Engineering), under class Roll No.2510010, 2510012 and 2510013 respectively for the session 2010-2014, has completed the project entitled 3D LED CUBE under my supervision. The project report is, in my opinion, worthy for consideration for the award of Bachelor in Electronics and Communication Engineering in accordance with the rules and regulations of University Institute of Engineering and Technology, Kurukshetra University.I wish them all success in their all endeavors.

(Nikhil Marriwala)

AcknowledgementsFirst, we would like to express our best regards to our project guide and mentor Mr. Nikhil Marriwala, whose valuable guidance, encouragement, and provision of necessary facilities made this work possible.

We are also thankful to our respected Head of the Department Dr. C.C. Tripathi whose help and shared knowledge was the main support to complete our project. Many thanks are owed to our classmates for their useful discussion and timely suggestions. Their technical support and encouragement helped us to finalize our project. We are also thankful to our respected Director Dr. Dinesh Kumar for the encouragement and necessary facilities required to make this project possible. We are grateful to all non-teaching staff for their assistance which is key factor behind our success. We would also like to express our gratitude towards the college for providing us with the best facilities and proper environment to work on our project.

Finally we offer our great thanks and regards to our family for their support which helped us through the difficulty and hardships of life to earn this achievement.

(Tushar Chawla)(Ajay Singh)(Varsha)

List of FiguresFigureFigure TitlePage no

Figure 1.1Block Diagram of Circuit9

Figure 2.1Led Interfacing13

Figure 2.2Microcontroller Circuitry15

Fgure 2.3Transistor Circuitry16

Figure 2.4LED Connections17-21

Figure 2.5Power Supply21

List of Tables

TableTable NamePage no

Table 2.1List Of Components26

Contents

Chapter 1. Introduction 81.1 Overview of the Project 91.2 Block Diagram

Chapter 2.Technology Description112.1 Designing the 3D Led cube 122.2 Hardware Description142.3 Software Description 22

Chapter 3.Components 253.1 List of Components 263.2 Component Description 27

Chapter 4. Source Code 30

Chapter5. References 395.1 References

Chapter 1.

INTRODUCTION

1.1 Overview of the Project1.2 Block Diagram

1.1 Overview of the ProjectOur project, in one sentence, is an orientation independent 3D LED display. We built a 5x5x5 LED cube display and controller board which interfaced the cube to an AT89s52 microcontroller. We can display a wide range of low resolution 3D images One of the main considerations when first designing our cube was deciding how large to make it. Obviously more LED's would give better resolution and allow us to display some more interesting images but at the same time we were limited by how large of a cube we could fabricate in the given time and even more so by how many LED's we could reasonably control given the limited number of port pins and the limited processing power of the 8052. We eventually settled on a 5x5x5 cube as a reasonable trade off between size and practicality.The next major consideration was how we would control all of the LED's. A 5x5x5 cube made for 125 LED's which was far more LED's than ports on the 8052. So here we used multiplexing. So now we need only 30 pins to control the 125 LEDs.The main problem with controlling each LED individually was that to do so we would need to run at least 1 wire to each and every LED. This problem quickly got out of hand; at the bottom of the cube we would have at least 6 wires running off of each of the 25 columns. All of these wires would have made for an aethstetically unpleasing cube and present the question of how we would route all these wires together and fit them into the base of the cube. We realized we would need to wire the LED's together in a way that we could address them individually without having to run a separate wire to each one. This was a tricky problem since a typical addressing scheme such as selecting a column, then a row, then a level would have the undesirable side effect of lighting more LED's than we wanted.

1.2 Block Diagram of Circuit

Figure 1.1

POWER SUPPLY

3- D LED CUBETRANSISTORS

MICRO - CONTROLLER

Chapter 2.

Technology Description

2.1 Designing the 3D Cube 2.2 Hardware Description 2.3 Software Description

2.1 Designing the CubeThere was a lot of circuitry that had to be constructed in order to realize this project. First, we had to build the LED cube itself which actually turned out to be a much more difficult task then we first anticipated due to the shear number of LED's. We built each horizontal 5x5 plane individually by laying the LED's flat on top of wire and soldering all the negative terminals of the LED's onto the wire and leaving the positive terminal hanging. This essentially connected all the negative terminals of the LED's in the same level to the same ground plane. We then had to carefully solder the 5 horizontal planes together by first mounting them on the side of a cardboard box and taping them into place in a upright position and then soldering 1 wire to connect all the LED's in a vertical column together for each of the 25 columns.In addition to building the LED cube itself we also had to design and build our own custom LED driver circuit. This circuit had to take inputs from a limited number of microcontroller pins and decode them into something that could control the cube. If we had simply taken the input of each column and each ground level directly from a microcontroller pin this would have taken 30 pins which would have taken up most of the 32 port pins of the Mega32 microcontroller. This would have been alright for our final application (which only needed two extra pins for the accelerometer input) but would make it hard for future projects to utilize our design. Instead, we decided to come up with a clever way to decrease the bus size and simplify the interface between the driver and the microcontroller.We created a decoding circuit (Figure 1) that could control 24 columns using only 5 pins. The remaining 25th column and the 5 ground levels were controlled directly from the microcontroller; this resulted in using a total of only 11 pins to control the entire cube.To control the LED's using the outputs of the decoders we used 25 pMOS transistors as high side switches and 5 nMOS transistors as low side switches (Figure 2). The pMOS transistors use the output of the decoder circuit as a sort of enable and supply the LED's with 5V when they are turned on. However, since pMOS transistors turn on with a low gate to source voltage, and the decoders we used were active high, we had to feed the output of the decoders through inverters before we connected them to the transistors. In a similar way the MCU ports are used to control nMOS transistors that connect the LED's to ground, however, since the control comes directly from a port pin there is no need for inverters here. Another problem that we encountered involved the amount of current that we could drive. The power now comes directly from a 5V regulator that is rated to supply at least an amp of current, which was more than enough, but the pMOS transistors that we used are only rated to supply 160 mA of continuous current.

Figure 2.1

2.2 Hardware Description

Here we are using AT89s52 microcontroller which is an 8-bit microcontroller. It consists of 4 I/O ports each consisting of 8 bits. Features: 8KB flash ROM, 256 bytes of RAM, 32 I/O lines, one serial port, three timers/counters. The LED cube is of 5x5x5 dimension, so here we have 125 cathodes and 125 anodes of the LEDs. To solve the problem of controlling each LED individually we have shorted the entire positive terminals of a face and thus here we have a single line for all the positive terminals of a single face. Thus there are a total of 5 anode terminals each belonging to a face. Now were left with 125 negative terminals of the LEDs. Now we have shorted the negative terminals of the LEDs belonging to the same column. Each column consists of 5 LEDs. Thus the control lines will be reduced to 25 (125/5) lines.All the negative terminals are connected directly to the output pins of the microcontroller. Ports P0, P1, P3 and P1.7 of the microcontroller are connected to the negative lines. The positive terminals are connected to emitter of 5 power transistors (BD139). The transistors takes input signal from the microcontroller and activates the corresponding rows. The base of the transistors are connected to P1.0 P1.4. Here we are using BD139 medium power transistors.The circuit uses 6V regulated dc power supply. 230V ac is stepped down to 12V ac using a step down transformer. This ac is then converted into 12V dc using a bridge rectifier. As the rectifier doesnt produce pure dc so here we have connected a 1000uF capacitor in parallel to the output of the rectifier to filter out the ripples. Now this 12V dc is regulated to 6V dc using an LM7806 IC. LM7806 is a 6V positive voltage regulator. Now whole circuit use this supply.The lightning scheme is shown in the figure below:

CIRCUIT DIAGRAMSMICROCONTROLLER CIRCUITRY

TRANSISTOR CIRCUITRYFigure 2.2

Figure 2.3

LEDs CONNECTIONS1. SLICE 1

Figure 2.4(A)2. SLICE 2

Figure 2.4(b)

3. SLICE 3

Figure 2.4(c)

4. SLICE 4

Figure 2.4(d)

5. SLICE 5

Figure 2.4(e)

POWER SUPPLYFigure 2.5

2.2 Software Description

The control software for the LED cube has a very simple structure.

First we initialized two flash arrays with pre-rendered columns for all possible digits and letters so that we could look these up easily for string display on the cube. In our case we could have just hard coded the string since we have only one intro string, but we decided to do this and use an initialization routine so that this could perhaps be utilized in future projects that attempt an LED cube and want to display text. It also saved some memory space.

We made an initialization routine that we call at the very beginning of the main function to set up the directionality of the ports that we used to control the cube. We basically just needed the bottom two bits of PORTA for our analog to digital conversion to be inputs for the two accelerometer lines, all of the port pins of PORTC and the bottom 3 port pins of PORTB to be output to control the lighting of the cube. The actual layout of pins are described in detail in the comments of the code in the initialization routine. We set up timer 0 to reset on compare-match with a prescaler of 64, set the OCR register to 249, and enabled the compare-match interrupt. This gave us an interrupt that triggered once per millisecond. With this millisecond time base, we could schedule a task precisely. We also initialize a counter for scheduling our task. We initialize the analog to digital converter to run at 125KHz, to first convert the 0 channel when a conversion is started, and to interrupt on conversion done so that we can do two conversions in a row easily. We then call our initialize sensors routine to initialize the bias values of our accelerometers and then our initialize intro routine to initialize an array of column values for use in displaying our introduction string. Finally, we initialize our state variables and start a conversion of the accelerometer values.

The calibrate sensors routine does just what its name suggests. Assuming the cube starts standing on its base (up and down orientation), we figure out the zero bias of both of the sensors. We simply do three conversions of each of the two accelerometer values and divide by three to get the average value. We save these values as our x and y accelerometer conversion biases (to be subtracted from the reading when we do future conversions).

The analog to digital conversion done interrupt service routine is used to do two consecutive conversions (of the x and y accelerometer values) quickly without slowing down the rest of the program or doing some other more complicated coding trick. We wanted the two conversions values to be done at very similar times and available together. We used a state variable to keep track of which channel we were converting, and checked it in this routine. If it is the first of the two, we grab the conversion value, change the analog to digital multiplexer to multiplex the next channel, change the state variable to reflect that we are converting the next value, and initialize the next conversion. When this next conversion gets back to the ISR, we save the conversion value and set a global flag which signals that the conversion data is ready so that the rest of the program can use the conversion values.

We have only one task in the software which is our display task. It is scheduled once every 16 mS using a counter that counts down from 16 in our millisecond interrupt tick (and a simple if statement in the main loop which checks for when the counter becomes zero). This delay gives rise to a calling rate of 62.5Hz which is well above the refresh rate of a display that a human eye can perceive. Thus, we were not able to detect any flickering in the LED's. Despite its name, it actually does a couple of other things as well. At the beginning of the display task, we check our animation/demo state and update a frame buffer with the current frame of the animation. The frame buffer consists of an array of 25 bytes. Each byte in the frame buffer corresponds to a column in the LED display. The index number in the array corresponds to the number of the column. The columns of the cube are laid out as follows assuming we are looking at the cube from above with the front of the cube at the bottom of the screen:

0 1 2 3 45 6 7 8 910 11 12 13 1415 16 17 18 1920 21 22 23 24

The bottom five bits of each byte in the frame buffer represent which of the five LED's in that column are currently lit. The least significant bit of the byte is the bottom LED in the column and the 5th least significant bit is the top LED. A 1 represents on whereas a 0 represents off.

Next, the display task checks whether there is an acceleration conversion ready, converts it to a floating point value and subtracts the bias that we calculate when we initialize the system, and finally starts a new conversion (putting the conversion in the first state of converting y acceleration). This gives us a scaled value of the accelerations in the x and y axes. We actually ended up using only the x acceleration, but left the code for how to do two conversions in a row as an example for how future students could perhaps accomplish this. The additional data could even be used in an extension of this project along with a state machine to give more complex state information for how the cube is oriented. With a little bit of debugging using the USART of the Mega32, we found that 1g of gravity was about +-74 ADC units of the conversion of the x axis accelerometer (after bias). We use this to detect whether the cube is tipped on its side. We basically say it is tipped on the positive x side if the value of the acceleration in the x axis is greater than 65 and it is tipped on the negative x side if the acceleration in the x axis is less than -65. This gave us pretty good performance when we tested it. In the case that the board is tipped, we had to copy the current frame buffer to a temporary buffer and then "flip the buffer" 90 degrees to the correct side. This turned out to be a non-trivial calculation and can be seen in this section of the display task code in the appendix. The basic idea is as follows:

Looking at the front of the cube, we can think of the problem in the context of a 2D display since all of the slices of the cube had to be rotated the same way and we could just construct a loop that iterated through the 5 slices back to front doing the same thing with just a simple offset.

Chapter 3.

COMPONENTS

3.1 List of Components 3.2 Components Description

3.1 Component List

S. No.ComponentPieces

11N4007 DIODES6

2BLUE LEDs125

3LM78061

510uF CAPACITOR1

6TACTILE SWITCHES1

711.0592 MHZ XTAL1

8BD139 TRANSISTOR5

9AT89S521

1110K RESISTOR10

1222pf CAPACITOR2

131000uF capacitor1

Table 3.1

3.2 Component Description1.AT89S52 MICROCONTROLLERFEATURES Compatible with MCS-51 Products 8K Bytes of In-System Programmable (ISP) Flash Memory Endurance: 1000 Write/Erase Cycles 4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz Three-level Program Memory Lock 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Full Duplex UART Serial Channel Low-power Idle and Power-down Modes Interrupt Recovery from Power-down Mode Watchdog Timer Dual Data Pointer Power-off Flag

DESCRIPTIONThe AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8Kbytes of in-system programmable Flash memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pin out. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications.2. VOLTAGE REGULATORThe Digital board can use any power supply that creates a DC voltage between 6 and 12 volts. A 5V voltage regulator (7805) is used to ensure that no more than 5V is delivered to the Digital board regardless of the voltage present at the J12 connector (provided that voltage is less than 12VDC). The regulator functions by using a diode to clamp the output voltage at 5VDC regardless of the input voltage - excess voltage is converted to heat and dissipated through the body of the regulator. If a DC supply of greater than 12V is used, excessive heat will be generated, and the board may be damaged. If a DC supply of less than 5V is used, insufficient voltage will be present at the regulators output.

3. PRINTED CIRCUIT BOARD (PCB)Printed circuit boards have copper tracks connecting the holes where the components are placed. They are designed specially for each circuit and make construction very easy. Electronics Club members will receive an etched PCB that will need cleaning and drilling before soldering. Cleaning & Drilling Clean off the protective coating from the PCB using a PCB rubber or steel wool so that all the copper tracks are bright and shiny.. Drill the holes with a 1mm diameter bit. This is easiest with a proper electric PCB drill in a stand, but a hand-held miniature electric drill can be used if you take care to avoid twisting and snapping the small drill bit. A few may holes may need to be larger, for example preset resistors usually need a 1.5mm diameter hole. It is simplest to re-drill these special holes afterwards. Check carefully to make sure you find all the holes. Even with experience it is easy to miss one or two. PCB CONSTRUCTIONLayout of desired circuit diagram and preparation is first and most important operation in any printed circuit board manufacturing process. First of all layout of component side is to be made in accordance with available component dimensions. The following points are to be observed while forming the layout of PCB:

1. Between two components, sufficient space should be maintained.2. High wattage/max. Dissipated components should be mounted at a sufficient distance from semiconductor and electrolytic capacitors.

The single sided PCB is used for general purpose application where the cost is to be low and the layout is simple.

PRECAUTIONS 1. The quantity of soldering of component on PCB should be good quantity.2. The component fitted on the PCB should loosely fit.3. Do not touch the PCB layer with hands and for fitting component use long nose liers only.4. Use 25 w pencil bit soldering iron only.

Chapter 4.SOURCE CODE//this source code prints different patterns and letters in a 3d led cube.#include

void delay(unsigned int);void disc();void dise();void disi();void disj();void diso();void disp();void diss();void dist();

void dis1();void dis2();void dis3();void dis4();void dis5();void dis6();void dis7();void dis8();void dis9();void dis0();

void disall();void display();

sbit a1 = P1^0;sbit a2 = P1^1;sbit a3 = P1^2;sbit a4 = P1^3;sbit a5 = P1^4;

sbit c11 = P0^0;sbit c12 = P0^1;sbit c13 = P0^2;sbit c14 = P0^3;sbit c15 = P0^4;sbit c21 = P0^5;sbit c22 = P0^6;sbit c23 = P0^7;sbit c24 = P1^7;sbit c25 = P3^0;sbit c31 = P3^1;sbit c32 = P2^7;sbit c33 = P3^2;sbit c34 = P2^6;sbit c35 = P2^5;sbit c41 = P2^4;sbit c42 = P3^3;sbit c43 = P3^4;sbit c44 = P3^5;sbit c45 = P3^6;sbit c51 = P3^7;sbit c52 = P2^0;sbit c53 = P2^1;sbit c54 = P2^2;sbit c55 = P2^3;

void main(){

unsigned int i;P0 = 0xff;P1 = 0x10;P2 = 0xff;P3 = 0xff;

while(1){delay(50);a1 = a2 = a3 = a4 = a5 = 0;

for(i = 0; i