FANDOM


Lab Manual for the VLSI and Microcontroller Lab.

VLSI Edit


Microcontroller Edit

Elevator Edit

The general logic of the elevator program is explained here:

lift1 declared as xdata *lift ,is the address of a 8bit no. if *lift=80h,it refers to (*lift='10000000') in binary so bottom most led glows in the lift1 sequence similarly to enable second floor 40h ie( 01000000) is entered


above holds good for lift2 also


for indicating the door status&error status we enter

*stat_out=03h to glow door led.(ie door open)

*stat_out=02h to stop door led of lift1(ie door of lift1 closed)

*stat_out=01h to stop door led of lift2(ie door of lift2 closed)

*stat_out=0bh to enable sire(ie error condition)

for accepting the floor the user wishes to go it is taken from stat_in initially check if *stat_in=0eh to check if data entry is recorded keep on checking till it is 0eh once it is true reaccept *stat_in if

*stat_in=00h error

*stat_in=01h error

*stat_in=02h error

*stat_in=03h error

*stat_in=04h error

*stat_in=05h error

*stat_in=06h error

*stat_in=07h error

*stat_in=08h error

*stat_in=09h user wants to go to floor7

*stat_in=0ah user wants to go to floor6

*stat_in=0bh user wants to go to floor5

*stat_in=0ch user wants to go to floor4

*stat_in=0dh user wants to go to floor3

*stat_in=0eh user wants to go to floor2

*stat_in=0fh error

Goto 4th floor and beep Edit

The following program will move lift1 to 4th floor and will give a beep.

/*--------------------------------------------------------------------
       Program to move lift1 to 4th floor and to give a beep
---------------------------------------------------------------------*/

#include<reg51.h>



xdata char *lift1;
xdata char *lift2;
xdata char *stat_in;
xdata char *stat_out; 

void delay();

void main()

{

	lift1=0x0ffc0;
	lift2=0x0ffc4;
	stat_in=0x0ffc8;
	stat_out=0x0ffcc;

	while(1)
	{
		*stat_out=0x03;
		delay();
		*stat_out=0x02; 
		*lift1=0x080;
		*lift2=0x01;
		delay();
		*lift1=0x040;
		delay();
		*lift1=0x020;
		delay();
		*lift1=0x010;
		delay();
		*lift1=0x08;
           	delay();
		*stat_out=0x0b;
		delay();
		*stat_out=0x03;
	}
}

void delay()
{
        unsigned int i,j,k,l;
        for(i=0;i<0x0ffff;i++);
       	for(j=0;j<0x0ffff;j++);
	for(k=0;k<0x0ffff;k++);
	for(l=0;l<0x0ffff;l++);
}

Nearest Lift Edit

The next program will find the nearest lift for a request from any floor.

/*----------------------------------------------------------------------------
   Program to find the nearest lift for a request from any floor
'''Update:'''Some changes that have not been tested have been done to this
  program. Please test the following code for accuracy.

This program represents how NOT-TO code in C language - Lot of goto statements,
a whole bunch of loops that don't acutally do significant work...
It would be very nice if someone could re-write the complete program, test it,
and report here.
-----------------------------------------------------------------------------*/

#include<reg51.h>

xdata char *lift1;
xdata char *lift2;
xdata char *stat_in;
xdata char *stat_out; 
xdata int a;
xdata int b;
xdata int i;

void delay();

void main()
{
	lift1=0x0ffc0;
	lift2=0x0ffc4;
	stat_in=0x0ffc8;
	stat_out=0x0ffcc;

	while(1)
	{
	start:
		*stat_out=0x03;
		*lift1=0x080;
		*lift2=0x01;
		delay();
	check:
		a=(*stat_in);
		if((a & 0xf0)!= 0xe0)
			goto check;
		a=(*stat_in);
		b=(a & 0x0f);
		a=b;
                if(a == 0x0f)
                        goto error;
		if(a <= 0x08)
			goto error;
		if(a < 0x0c)
			goto l_b;
	flr_a:
		*stat_out=0x02;
		a=b;
		if(a != 0x0e)
			goto flr_b;
		*lift1=0x40;
			goto stat;

	flr_b:
		if(a != 0x0d)
			goto flr_c;
		*lift1=0x40;
		delay();
		*lift1=0x20;
		goto stat;

	flr_c:
		*lift1=0x40;
		delay();
		*lift1=0x20;
		delay();
		*lift1=0x10;
		goto stat;

	l_b:
		*stat_out=0x01;
		a=b;
		if(a != 0x09)
			goto flr_e;
		*lift2=0x02;
		goto stat;

	flr_e:
		if(a != 0x0a)
			goto flr_d;
		*lift2=0x02;
		delay();
		*lift2=0x04;
		goto stat;
		
	flr_d:
		*lift2=0x02;
		delay();
		*lift2=0x04;
		delay();
		*lift2=0x08;
		goto stat;

	error:
		for(i=0;i<03;i++)
		{
			*stat_out=0x0b;
			delay();
			*stat_out=0x03;
			delay();
		}
		goto start;

	stat:
	//	*stat_out=0x0b;
        //delay();
	//	*stat_out=0x03;
		goto 	check;
	}
									
}

void delay()
{
        unsigned int i,j,k,l;
	for(i=0;i<0x0ffff;i++);
	for(j=0;j<0x0ffff;j++);
	for(k=0;k<0x0ffff;k++);
	for(l=0;l<0x0ffff;l++);
}

Goto ground or 7th floor Edit

The following program will take the lift to either ground floor or 7th floor for a request from any floor

/*----------------------------------------------------------------------
           Program to service a request from any floor to go to
                     ground floor or the 7th floor 
-----------------------------------------------------------------------*/

#include<reg51.h>

xdata char *lift1;
xdata char *lift2;
xdata char *stat_in;
xdata char *stat_out; 
xdata int a;
xdata int b;
xdata int c;
xdata int i;

void delay();

void main()
{
	lift1=0x0ffc0;
	lift2=0x0ffc4;
	stat_in=0x0ffc8;
	stat_out=0x0ffcc;

	while(1)
	{
	start:
		*stat_out=0x03;	 		//default doors in is.
		*lift1=0x080;			//indicates lift1 is in ground floor.
		*lift2=0x01;			//indicates lift2 is in 7th floor.
		delay();

	check:
		a=(*stat_in);
		if((a & 0xf0)!= 0xe0)
			goto check;

		a=(*stat_in);
		b=(a & 0x0f);
		if(b != 0x0f)
			goto err_1;
		else
			goto error;

	err_1:
		a=b;
		if(a <= 0x08)
			goto error;
		if(a < 0x0c)
			goto l_b;

	flr_a:
		*stat_out=0x02;
		a=b;
		if(a != 0x0e)
			goto flr_b;
		*lift1=0x40;
		c=0x40;
			goto stat;
   	
	flr_b:
		if(a != 0x0d)
			goto flr_c;
		*lift1=0x40;
		delay();
		*lift1=0x20;
		c=0x20;
		goto stat;
	
	flr_c:
		*lift1=0x40;
		delay();
		*lift1=0x20;
		delay();
		*lift1=0x10;
		c=0x10;

	stat:
		*stat_out=0x0b;
		delay();
		*stat_out=0x03;
		
	rept:
		a=(*stat_in);
		b=(a & 0xf0);
		if(b != 0xe0)
			goto rept;
		*stat_out=0x02;
		a=b;
		if(a != 0x0d0)
			goto up;
		
	down:
		a=c;
		if(a != 0x10)
			goto down_b;
		goto dwn_b;
	
	down_b:
		if(a != 0x20)
			goto down_a;
		goto dwn_a;
		
	down_a:
		if(a != 0x40)
			goto error;
		goto dwn_gn;

	dwn_b:
		*lift1=0x20;		
		delay();
		
	dwn_a:
		*lift1=0x40;		
		delay();

	dwn_gn:
		*lift1=0x80;		
		delay();
		goto stop_s;

   up:
   	if(a != 0xb0)
   		goto error;
   	a=c;
   	if(a != 0x40)
   		goto upp_b;
   	goto up_b;
   	
   upp_b:
   	if(a != 0x20)
   		goto upp_c;
   	goto up_c;

   upp_c:
   	if(a != 0x10)
   		goto error;
   	goto up_d;
   
   up_b:
   	*lift1=0x20;
   	delay();
   
   up_c:
   	*lift1=0x10;
   	delay();

   up_d:
   	*lift1=0x08;
   	delay();
   	*lift1=0x04;
   	delay();
   	*lift1=0x02;
   	delay();
   	*lift1=0x01;
   	delay();
   	*stat_out=0x0b;
   	delay();
   	*stat_out=0x03;
   	delay();
   	goto start;
		   			
	l_b:
		*stat_out=0x01;
		a=b;
		if(a != 0x09)
			goto flr_e;
		*lift2=0x02;
		c=0x02;
		goto stat_s;
	
	flr_e:
		if(a != 0x0a)
			goto flr_d;
		*lift2=0x02;
		delay();
		*lift2=0x04;
		c=0x04;
		goto stat_s;
		
	flr_d:
		*lift2=0x02;
		delay();
		*lift2=0x04;
		delay();
		*lift2=0x08;
		c=0x08;

	stat_s:

//		c=(*lift2);
		*stat_out=0x0b;
		delay();
		*stat_out=0x03;

	rept_s:
		a=(*stat_in);
		b=(a & 0xf0);
		if((a & 0xf0)!= 0xe0)
			goto rept_s;
		*stat_out=0x01;
		a=b;
		if(a != 0x0d0)
			goto up_s;

	down_s:
		a=c;
		if(a != 0x02)
			goto flo_e;
		goto fl_e;
	
	flo_e:
		if(a != 0x04)
			goto flo_d;
		goto fl_d;
		
	flo_d:
		goto fl_c;
		
	fl_e:
		*lift2=0x04;
		delay();
		
	fl_d:
		*lift2=0x08;
		delay();
		
	fl_c:
		*lift2=0x10;
		delay();
		*lift2=0x20;
		delay();
		*lift2=0x40;
		delay();
		*lift2=0x80;
		delay();
		goto stop_s;
		
	up_s:
		if(a != 0xb0)
			goto error;
		a=c;
		if(a != 0x08)
			goto u_e;
		goto uo_e;

	u_e:
		if(a != 0x04)
			goto u_f;
		goto uo_f;
		
	u_f:
		if(a != 0x02)
			goto error;
		goto uo_g;

	uo_e:
		*lift2=0x04;
		delay();		
		
	uo_f:
		*lift2=0x02;
		delay();		
	uo_g:
		*lift2=0x01;
		delay();		

	stop_s:
			*stat_out=0x0b;
			delay();
			*stat_out=0x03;
			delay();
		goto start;

	error:
		for(i=0;i<03;i++)
		{
			*stat_out=0x0b;
			delay();
			*stat_out=0x03;
			delay();
		}
		goto start;
	}
}

void delay()
{
        unsigned int i,j,k,l;
	for(i=0;i<0x0ffff;i++);
	for(j=0;j<0x0ffff;j++);
	for(k=0;k<0x0ffff;k++);
	for(l=0;l<0x0ffff;l++);
}

Digital to Analog Converter Edit


/*------------------------------------------------
   Program to obtain an output of 5volt at dac1
-------------------------------------------------*/

#include<reg51.h>

xdata	char	*dac;

void main()

{
	dac=0x0ffc0;
	while(1)
	{
		*dac=0xff;
	}
}


'Bold text'== Hex Keyboard ==


/*--------------------------------------------------------------
   THIS PROGRAM WILL GET THE DATA FROM THE KEYBAD(VPAC-13) AND 
              DISPLAY THE CHARACTER TO THE LED
----------------------------------------------------------------*/

#include<REG51.h>

xdata char *keycnt;
xdata char *keydat;
xdata char *keywr;
xdata char *keyrd;
xdata char *portc;
unsigned char value; 
int i;

void display(char);
void readkey();
 
void main()
{
	keycnt=0x0ff01;
	keydat=0x0ff00;	
   keywr = 0xFF0C;
	keyrd = 0xFF0D;
	portc=0x0ff0f;


	*portc=0x82;
	
	readkey();
}

void readkey()
{
unsigned int dat[04]={0xfe,0xfd,0xfb,0xf7};
unsigned char value;
unsigned char a,b,c;
while(1)
{
for (c=0;c<=0x03;c++)
        {
 	*keywr=dat[c];
 	a = *keyrd;
 	b = a & 0x0f;

      if ((c== 0x00) && (b == 0x07))
				{
					value=0x0d;
					display(value);
				}

        if ((c== 0x00) && (b == 0x0B))
				{
					value=0x49;
					display(value);
				}

        if ((c== 0x00) && (b == 0x0D))
				{
					value=0x9f;		
					display(value);
				}

        if ((c== 0x00) && (b == 0x0E))
				{
					value=0x0a;		
					display(value);
				}


        if ((c== 0x01) && (b == 0x07))
				{
					value=0x8f;				 
					display(value);
				}

        if ((c== 0x01) && (b == 0x0B))
				{
					value=0x28;				 
					display(value);
				}

        if ((c== 0x01) && (b == 0x0D))
				{
					value=0x2c;				 
					display(value);
				}

        if ((c== 0x01) && (b == 0x0E))
				{
					value=0x09c;
					display(value);
				}

        if ((c== 0x02) && (b == 0x07))
				{
					value=0x38;				
					display(value);
				} 

        if ((c== 0x02) && (b == 0x0B))
				{
					value=0x88;		
					display(value);
				}

        if ((c== 0x02) && (b == 0x0D))
				{
					value=0x0c;				 
					display(value);
				}

        if ((c== 0x02) && (b == 0x0E))
				{
					value=0x08;
					display(value);
				}

        if ((c== 0x03) && (b == 0x07))
				{
					value=0x0e8;				 
					display(value);
				}

        if ((c== 0x03) && (b == 0x0B))
				{
					value=0x68;
					display(value);
				}

        if ((c== 0x03) && (b == 0x0D))
				{
					value=0x19;
					display(value);
				}

        if ((c== 0x03) && (b == 0x0E))
				{
					value=0x06a;
					display(value);
				}    
        }
		}
}

void display(char dat1)
{
	*keycnt=0x0;
	*keycnt=0x0cc;
	*keycnt=0x095;
	*keydat=dat1;
}
  

LED - Seven segment Display Edit

Static Display Edit

/*---------------------------------------------------------------
  Program for Static Display on the Seven Segment LED - VBMB-01
----------------------------------------------------------------*/

#include<reg51.h>

xdata char *led;
xdata char *led1;
xdata char array[8]={0x088,0x38,0x6c,0x19,0x68,0xe8};

void main()
{
int i;
	led=0x0ffc2;
	led1=0x0ffc0;
	while(1)
	{
		*led=0x00;   //Initialize the LED for Static Display
		*led=0x0cc;  //Clear Display
		*led=0x090;  //??
		for(i=0;i<0x06;i++)
		{
			*led1=array[i];
		}
	}
}

Rolling Display Edit


/*----------------------------------------------------------------
  Program for Rolling Display on the Seven Segment LED - VBMB-01
------------------------------------------------------------------*/
#include<reg51.h>

xdata char *led;
xdata char *led1;

xdata char array[16]={0x0FF,0x0FF,0x0FF,0x0FF,0x0FF,0x0FF,
                      0x0FF,0x0FF,0x098,0x068,0x07c,0x0c8,
                      0x0FF,0x01c,0x029,0x0ff};
void delay();							

void main()
{
int i;
	led=0x0ffc2;
	led1=0x0ffc0;
	while(1)
	{
		*led=0x010;    //Initialize the Rolling Display
		*led=0x0cc;    //Clear Display
		*led=0x090;    //??
		for(i=0;i<=0x10;i++)
		{
			*led1=array[i];
			delay();
		}
	}
}

void delay()
{
int j;
for(j=0;j<=0xfFff;j++);
for(j=0;j<=0xfFff;j++);
for(j=0;j<=0xFff;j++);
for(j=0;j<=0xFff;j++);
for(j=0;j<=0xFff;j++);
for(j=0;j<=0xFff;j++);
}

LCD Display Edit

/*--------------------------------------------------------------------
  THIS PROGRAM WILL DISPLAY THE CHARECTER INTO THE LCD USING VBMB-18
---------------------------------------------------------------------*/

#include<reg51.h>

xdata char *sel174;
xdata char *lcdsel;
xdata int array[5]={0x38,0x01,0x80,0x06,0x0f};
xdata char array1[16]="vlsi lab";
xdata char array2[16]="  WELCOME YOU ";
xdata int i;

void init_lcd();
void busycheck();
void out_data();
void out_data1();
void delay();

void main()
{
	sel174=0x0ffc0;
	lcdsel=0x0ffc4;
	init_lcd();
	out_data();
	delay();
	out_data1();
}

void init_lcd()
{
        int i;
	for(i=0;i<0x05;i++)
	{
		busycheck();
		*sel174=0x00;
		*lcdsel=array[i];
	}
}

void out_data()
{
        int i;
	for(i=0;i<0x0F;i++)
	{
		busycheck();
		*sel174=0x01;
		*lcdsel=array1[i];
	}
}

void out_data1()
{
	int i;
        busycheck();
	*sel174=0x00;
	*lcdsel=0xc0;
	for(i=0;i<0x0F;i++)
	{
		busycheck();
		*sel174=0x01;
		*lcdsel=array2[i];
	}
}

void busycheck()
{
	int x;
	*sel174=0x02;
        while((x=*lcdsel) & 0x80);   //if the MSB returned in x is 1, then the LCD is still busy. Wait till the MSB is 0
	*sel174=0x00;
}

void delay()
{
        int j;
	for(j=0;j<0x32ff;j++);
}

DC Motor Edit


#include <reg51.h>

xdata *dac;

void main()
{
       dac = 0x0ffc0;
       while(1)
             *dac = 0x0ff; 
}

Stepper Motor Edit

Run Stepper Motor in one direction Edit


/*---------------------------------------------
        PROGRAM TO RUN THE STEPPER MOTOR
----------------------------------------------*/

#include<reg51.h>
xdata char *step;
xdata unsigned int array[4]={0x09,0x05,0x06,0x0a};
xdata int i;
void delay();

void main()
{
	step=0x0ffc0;
	while(1)
		for(i=0;i<0x04;i++)
		{
			delay();
			*step=array[i];
		}
}

void delay()
{
	int i,j,k,l;
	for(j=0;j<=0x0fff;j++);
        //for(i=0;i<=0x0ffff;i++);
	//for(k=0;k<=0x0ffff;k++);
	//for(k=0;k<=0x0ffff;k++);
			
}

Run Stepper Motor in both directions Edit


/*----------------------------------------------------------------
  PROGRAM TO RUN THE STEPPER MOTOR IN FORWARD & REVERSE ROTATION
-----------------------------------------------------------------*/

#include<reg51.h>

xdata char *step;
xdata unsigned int array[4]={0x09,0x05,0x06,0x0a};
xdata unsigned int array1[4]={0x0a,0x06,0x05,0x09};
xdata int i;
xdata int k;
void delay();

void main()
{
	step=0x0ffc0;
	for(k=0;k<0x33;k++)
	{
		for(i=0;i<0x04;i++)
		{
			delay();
			*step=array[i];
		}
	}
	for(k=0;k<0x33;k++)
	{
		for(i=0;i<0x04;i++)
		{
			delay();
			*step=array1[i];
		}
	}
}

void delay()
{
	int j;
	for(j=0;j<=0x0ff;j++);
	for(j=0;j<=0x0ff;j++);
	for(j=0;j<=0x0ff;j++);
}

Waveform generation Edit

Sine Wave Edit


/*-----------------------------------------------
    Program to output Sine Wave Using VBMB-02
-----------------------------------------------*/

#include<reg51.h>

xdata char *dac;
xdata int a[0x46]={0x80,0x8a,0x95,0xa0,0xaa,0xb5,0xbf,0xc8,
                   0xd1,0xd9,0xe0,0xe7,0xed,0xf2,0xf7,0xfa,
                   0xfc,0xfe,0xff,0xfe,0xfc,0xfa,0xf7,0xf2,
                   0xed,0xe7,0xe0,0xd9,0xd1,0xc8,0xbf,0xb5,
                   0xaa,0xa0,0x95,0x8a,0x80,0x74,0x69,0x5f,
                   0x53,0x49,0x3f,0x36,0x2d,0x25,0x1d,0x17,
                   0x10,0x0b,0x07,0x04,0x01,0x00,0x01,0x04,
                   0x07,0x0b,0x10,0x17,0x1d,0x25,0x2d,0x36,
                   0x3f,0x49,0x53,0x5f,0x69,0x74};
xdata int i;						

void main()
{
	dac=0x0ffc0;				//dac0
	while(1)
	{
		for(i=0;i<0x46;i++)
		{
			*dac=a[i];
		}
	}
}

Ramp Wave Edit


/*-----------------------------------------------
  Program to output Ramp Wave Using VBMB-02
-----------------------------------------------*/

#include<reg51.h>

xdata	char *dac;
xdata int i;

void main()
{
	dac=0x0ffc0;			//dac0
	while(1)
	{
	i=0x00;
	for(i=0;i<=0x0ff;i++)
	{
		*dac=i;
	}
	}
}

Square Wave Edit


/*-----------------------------------------------
  Program to output Square Wave Using VBMB-02
-----------------------------------------------*/

#include<reg51.h>

xdata char *dac;
xdata int i;
void delay();

void main()
{
	dac=0x0ffc0;		//dac1
	while(1)
	{
		*dac=0x00;
		delay();
		*dac=0x0ff;
		delay();
	}
}

void delay()
{
	for(i=0;i<0x0ff;i++);
} 

Triangular Wave Edit


/*-----------------------------------------------
 Program to output Triangular Wave Using VBMB-02
-----------------------------------------------*/

#include<reg51.h>

xdata	char	*dac;
xdata	int i;

void main()
{
	dac=0x0ffc0;				//dac0
	while(1)
	{
	      i=0x00;                       
	      for(i=0;i<=0x0ff;i++)
	      {
		   *dac=i;
	      }
	      i=0xff;                       
	      for(i=0x0ff;i>=0x00;i--)
	      {
		   *dac=i;
	      }
	}	
}

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.