Sie sind auf Seite 1von 10

ESD LAB- [6]

[ROLL N0.:-201501094]

DARSHAN| [ESD] |
Question [1]
ANSWER

void main() {

DDRA=0xFF;

while(1)

PORTA=0b11000000;//0

delay_ms(1000);

PORTA=0b11111001;//1

delay_ms(1000);

PORTA=0b10100100;//2

delay_ms(1000);

PORTA=0b10110000;//3

delay_ms(1000);

PORTA=0b10011001;//4

delay_ms(1000);

PORTA=0b10010010;//5

delay_ms(1000);

PORTA=0b10000010;//6

delay_ms(1000);

PORTA=0b11111000;//7

delay_ms(1000);

PORTA=0b10000000;//8

delay_ms(1000);

PORTA=0b10010000;//9

delay_ms(1000);

PORTA=0b10001000;//A

delay_ms(1000);

PORTA=0b10000011;//B

delay_ms(1000);

PORTA=0b11000110;//C

delay_ms(1000);
PORTA=0b10100001;//D

delay_ms(1000);

PORTA=0b10000110;//E

delay_ms(1000);

PORTA=0b10001110;//F

delay_ms(2000);

PORTA=0b10000110;//E

delay_ms(1000);

PORTA=0b10100001;//D

delay_ms(1000);

PORTA=0b11000110;//C

delay_ms(1000);

PORTA=0b10000011;//B

delay_ms(1000);

PORTA=0b10001000;//A

delay_ms(1000);

PORTA=0b10010000;//9

delay_ms(1000);

PORTA=0b10000000;//8

delay_ms(1000);

PORTA=0b11111000;//7

delay_ms(1000);

PORTA=0b10000010;//6

delay_ms(1000);

PORTA=0b10010010;//5

delay_ms(1000);

PORTA=0b10011001;//4

delay_ms(1000);

PORTA=0b10110000;//3

delay_ms(1000);

PORTA=0b10100100;//2

delay_ms(1000);

PORTA=0b11111001;//1

delay_ms(1000);
PORTA=0b11000000;//0

delay_ms(1000);

[Explanation of Steps]

STEP.1: Connect PORTA.B0 with a, PORTA.B1 with b, PORTA.B2 with c,


PORTA.B3 with d, PORTA.B4 with e, PORTA.B5 with f, PORTA.B6 with g,
PORTA.B7 with dp and Applying VCC to common of the 7 Segment LED
STEP.2: build the code on ATMEGA board.
STEP.3: run the code.

[Short Description]

In this program, the LED will be having different value displayed on


it after every one second delay and this value will go from 0 to F, and then from F
to 0. We can display the required value on LED by changing the PORTA value.
E.g. F can be displayed by changing PORTA=0x8E.

Question [2]
ANSWER

int
a[10]={0b11000000,0b11111001,0b10100100,0b10110000,0b10011001,0b1001001
0,0b10000010,0b11111000,0b10000000,0b10010000};

int count=0;

void ISR_INT0() org 0x002

count=(count==99)?(0):(count+1);

// SREG.B7=1;
// GIFR.B6 = 0;

void main() {

DDRA=0xFF;

DDRB=0xFF;

DDRD=0x00;

GICR = 0x40;

MCUCR = 0x03;

SREG.B7=1;

while(1)

PORTA=a[count/10];

PORTB=a[count%10];

delay_ms(300);

[Explanation of Steps]

STEP.1: For first 7 Segment LED, Connect PORTA.B0 with a, PORTA.B1 with b,
PORTA.B2 with c, PORTA.B3 with d, PORTA.B4 with e, PORTA.B5 with f, PORTA.B6
with g, PORTA.B7 with dp, Applying VCC to common of the first 7 Segment LED.
For Second 7 Segment LED, Connect PORTB.B0 with a, PORTB.B1 with b,
PORTB.B2 with c, PORTB.B3 with d, PORTB.B4 with e, PORTB.B5 with f, PORTB.B6
with g, PORTB.B7 with dp and Applying VCC to common of the second 7 Segment
LED.
STEP.2: Push Button is connected to VCC and PORTD.B2(INT0), and here, resistor
is connected between VCC and ground. This VCC is common connected between
resistor and the push button.

STEP.3 :Build program on uC.

STEP.4: run the code.


[Short Description]

In this Program, whenever the person enters in the deans office,


the counter is incremented. This is incremented using push button. When button
is pressed, the voltage goes high and due to which, PORTD.B2 goes high and
interrupt function is called. Counter is incremented in the interrupt function. This
value of counter is displayed on the LEDs.

Question [3]
ANSWER

/*

Project Description : Display Digital Clock

*/

int
SevenSegment_Cathod[]={0xC0,0XF9,0XA4,0XB0,0X99,0X92,0X82,0XF8,0X80,0X98}
;

// values to 7 segment display data values

unsigned int number=4805; // Number to be displayed

unsigned short int store[4];// Store hex values in an array

unsigned short int shift=1;

int temp,count=0,flag1=0,flag2=0,flag3=0,flag4=0;

int count_time2=125;

/*

In multiplexing, data and selection lines are changed at very small time

intervals. In this case 8 msec.

*/

void TIMER0_COMP() org 0x026

PORTA=0x00; // PORTA cleared


PORTA=shift; // select data selection line

PORTC=store[count];//Assign data to PORTC i.e. seven segment

shift=shift<<1; // left shift 'shift' till it reahes 0x80

if(shift==0x10)

shift=1; // Initialize once 0x80 is reached

count++; // increment count till it reaches 4

if (count==4)

count=0; // Initialize once it reaches 4

// delay_ms(500);

void main() {

// PORT declaration

DDRC=0xFF; // Configure data line port C as output

DDRA=0x0F; // Configure selection lines @ PORTA

PORTA=0x01; //Initialize

//Timer Set-Up

// Timer 0 CTC mode, pre-scaler 256 , count: 250

TCCR0=0x0B;

OCR0=0xF9;
//Interrupt Set-Up

SREG.B7=1; // Enable Global interrupt I

TIMSK.B1=1; // Enable Timer O Comp interrupt OCEI0

while(1)

//for(i=0;;i++)

if(flag1==10)

{ // store[0]=0;

flag1=0;

// store[0]=0;

flag2++;

// store[1]++;

if(flag2==6)

{ flag2=0;

// store[1]=0;

flag3++;

// store[2]++;

if(flag3==10)

{ flag3=0;

// store[3]=0;

flag4++;

// store[3]++;

if(flag3==4&&flag4==2)

{ flag1=0;

// store[0]=0;
flag2=0;

// store[1]=0;

flag3=0;

// store[2]=0;

flag4=0;

//store[3]=0;

store[0]=SevenSegment_Cathod[flag1++];

store[1]=SevenSegment_Cathod[flag2];

store[2]=SevenSegment_Cathod[flag3];

store[3]=SevenSegment_Cathod[flag4];

delay_ms(100);

/*temp=number%10u; // Calculate unit digit of number

store[0]=SevenSegment_Cathod[temp]; // Convert it to SevenSegment Common


cathode

temp=(number/10u)%10u;// // Calculate tens digit

store[1]=SevenSegment_Cathod[temp];// Convert it to SevenSegment Common


cathode

temp=(number/100u)%10u; // Calculate hundreds digit

store[2]=SevenSegment_Cathod[temp];// Convert it to SevenSegment Common


cathode

temp=number/1000u; // Calculate thousands digit

store[3]=SevenSegment_Cathod[temp];// Convert it to SevenSegment Common


cathode */

}
[Explanation of Steps]

STEP.1: connect 0,1,2,3,4,5,6,Vcc and GND pins of PORTC, 0,1,2,3 and GND
pins of PORTA with breadboard.
STEP.2: joint a four 7-segment LEDs and resistors with breadboard.
STEP.3: build the code on ATMEGA board.
STEP.4: run the code.

[Short Description]

There are four 7 segment LEDS use for this experiment. For
this 4 7 segment LED display we want 4 port but if we want to do any
project and need this digital clock than what to do? For that purpose we
change logic which use single port or double port so for that we use shift
delay which means in single port we will display 4 7-segment LEDS. We
use another port for shift which means when any bits of that port is 1 at
that time it display that port LED , For example here we use PORTA as
shifting so when PORTA.B1 is 1 than it will display LED 1 st . We wanted to
display HH-MM. means 2 LED for displaying hours , 2 LED for displaying
minutes and second display at last LED of minutes pointer means that
spot LED blinking 60 time and count 1 minute.
In code we use 4 flag for displaying 4 7-segment LEDS and
use PORTA for which 7-segment LED is display at a point in time. For
practical purpose, due to unavailability of enough wires, we have tried to
show the HH and MM part separately and increased the speed of clock in
order to check that all the resets are properly performed

Das könnte Ihnen auch gefallen