Manual Final
Manual Final
ROLL NUMBER:
2
INDEX
PSPICE 6
CMOS INVERTER 7
NAND GATE 8
2:1 MULTIPLEXER 9
ARDUINO 10
LED FADE CIRCUIT 11
ASCII CHARACTER MAP 13
DISTANCE MEASUREMENT USING ULTRASONIC SENSOR 15
TEMPERATURE SENSOR 17
LDR INTERFACE WITH ARDUINO 19
ACCELERATION MEASUREMENT USING
ACCELEROMETER SENSOR 21
8051 23
SWITCH CONTROLLED LED USING 8051 24
TIMER PROGGRAMMING WITH 8051 25
EXTERNAL INTERRUPT WITH 8051 27
STEPPER MOTOR INTERFACING WITH 8051 28
ADC INTERFACING WITH 8051 30
KEYPAD AND LCD INTERFACING WITH 8051 32
PIC 37
INTEFACING OF LED WITH PIC16F877A 38
INTERFACING OF LCD WITH PIC16F877A 40
3
INTERFACING ADC WITH PIC16F877A 42
INTERFACING STEPPER MOTOR WITH PIC16F877A 44
INTERFACING TIMER WITH PIC16F877A 46
INTERFACING PWM MODULE WITH PIC16F877A 48
AVR 50
INTERFACING LED 51
MSP430 MICROCONTROLLER 52
INTERFACING WITH LCD 53
BLINKING OF LED 56
NUVOTON 58
GPIO_LED BLINKING 59
LCD INTERFACING 61
SEVEN-SEGMENT DISPLAY 63
VERILOG 65
FULL ADDER 66
MULTIPLEXER 69
DECODER 71
FOUR BIT ADDER 73
ARITHMETIC AND LOGIC UNIT 75
RAM 77
VENDING MACHINE CONTROL 80
MATLAB 85
LINEAR CONVOLUTION 86
4
CIRCULAR CONVOLUTION 88
SAMPLING 91
FIR LOW PASS FILTER 94
FIR HIGH PASS FILTER 96
IIR FILTER 98
FFT 100
LabVIEW 103
SEQUENCE DETECTOR 104
ODD/EVEN NUMBER CHECKER 107
TRAFFIC SIGNAL SIMULATOR 110
5
PSPICE
PRE-REQUISITES:
SOFTWARE REQUIRED:
HARDWARE REQUIRED:
6
CMOS INVERTER
AIM:
To design inverter circuit using CMOS transistor.
CIRCUIT DIAGRAM:
OUTPUT:
RESULT:
Thus, inverter circuit was designed and simulated successfully.
7
NAND GATE
AIM:
CIRCUIT DIAGRAM:
OUTPUT :
RESULT:
Thus, NAND circuit was designed and simulated successfully.
8
2:1 MULTIPLEXER
AIM:
To design a 2:1 mux using transmission gates.
CIRCUIT DIAGRAM:
OUTPUT:
RESULT:
9
ARDUINO
PRE-REQUISITES:
SOFTWARE REQUIRED:
HARDWARE REQUIRED:
10
LED FADE CIRCUIT
AIM:
To write an Arduino sketch program to fade a set of LEDs up
and down one at a time.
PIN CONFIGURATION:
Use 8 LEDs with 8 x 220ohm resistor for each.
Connect the anodes (A) of each LED to pins 2 to 9 through a 220ohm
resistor.
Ground all the Cathode (K) pins of LEDs to the board.
CODE:
int led = 9;
int brightness = 0;
int fade = 5;
void setup()
{
pinMode(led,OUTPUT);
}
void loop()
{
analogWrite(led,brightness);
brightness += fade;
if(brightness == 0 || brightness == 255)
{
fade = -fade;
}
delay(30);
}
11
OUTPUT:
RESULT:
12
ASCII CHARACTER MAP
AIM:
To write an Arduino sketch program to display ASCII values of each
character input.
CODE:
void setup()
{
Serial.begin(9600);
while (!Serial)
{
; // wait for serial port to connect. Needed for native USB port only
}
// send an intro:
Serial.println("send any byte and I'll tell you everything I can about it");
Serial.println();
}
void loop()
{
if(Serial.available()>0)
{
int thisByte=Serial.read();
Serial.write(thisByte);
13
OUTPUT:
RESULT:
Thus, the Arduino sketch to display ASCII values was implemented.
14
DISTANCE MEASUREMENT USING
ULTRA SONIC SENSOR
AIM:
PIN CONFIGURATION:
Digital 18 : Trig
Digital 17 : Echo
GND : ground
5V : Vcc
CODE:
#define trigPin1 8
#define echoPin17
long duration, distance, UltraSensor;
void setup()
{
Serial.begin (9600);
pinMode(trigPin1, OUTPUT);
pinMode(echoPin1, INPUT);
}
void loop() {
SonarSensor(trigPin1, echoPin1);
UltraSensor = distance;
Serial.println(UltraSensor);
}
void SonarSensor(int trigPin,int echoPin)
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(2);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
15
distance = (duration/2) / 29.1;
delay(100);
}
OUTPUT:
RESULT:
Thus, the Arduino sketch to measure distance using Ultra Sonic Sensor
was implemented.
16
TEMPERATURE SENSOR
AIM:
PIN CONFIGURATION:
CODE:
int val;
int tempPin = 1;
void setup()
{
Serial.begin(9600);
}
void loop()
{
val = analogRead(tempPin);
float mv = ( val / 1024.0) * 5000;
float cel = mv / 10;
float farh = (cel * 9) / 5 + 32;
Serial.print("TEMPERATURE = ");
Serial.print(cel);
Serial.print("*C");
Serial.println();
delay(1000);
17
OUTPUT:
RESULT:
18
LDR INERFACE WITH ARDUINO
AIM:
PIN CONFIGURATION:
CODE:
#include <SoftwareSerial.h>
int sensorPin = A0; // select the input pin for the LDR
int sensorValue = 0; // variable to store the value coming from the sensor
int led = 3;
void setup()
{
// declare the ledPin as an OUTPUT:
pinMode(led, OUTPUT);
Serial.begin(9600);
}
void loop()
{
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue);
if (sensorValue < 100)
{
Serial.println("LED light on");
digitalWrite(led,HIGH);
delay(1000);
}
digitalWrite(led,LOW);
delay(sensorValue);
}
19
OUTPUT:
RESULT:
20
ACCELERATION MEASUREMENT USING
ACCELEROMETER SENSOR
AIM:
PIN CONFIGURATION:
CODE:
void setup()
{
// initialize the serial communications:
Serial.begin(9600);
21
void loop(
{
Serial.print("x:");
Serial.print(analogRead(xpin));
Serial.print("\t");
Serial.print("y:");
Serial.print(analogRead(ypin));
Serial.print("\t");
Serial.print("z:");
Serial.print(analogRead(zpin));
Serial.println();
delay(1000);
OUTPUT:
RESULT:
22
8051
PRE-REQUISITES:
SOFTWARE REQUIRED:
HARDWARE REQUIRED:
23
SWITCH CONTROLLED LED USING 8051
AIM:
To write a program to get a value through a switch from port 0 (P0) and
send it to port 1 (P1) connected to LED.
C PROGRAM:
#include <reg51.h>
#define SW P0 //Connect switch to Port 0
#define LED P1 //Connect LED to Port 1
void main(void)
{
P0 = 0xff; //Switch as an input
P1 = 0x00; //Led as an output
while(1)
{
LED = ~SW;
}
}
RESULT:
24
TIMER PROGRAMMING WITH 8051
AIM:
C PROGRAM:
#include<reg51.h>
sbit mybit = P1^5; //Set pin to output square wave
sbit SW = P1^7; //Switch to control frequency
void delay(unsigned char);
void main(void)
{
mybit =0;
SW =1;
while(1)
{
mybit = ~mybit;
if(SW==0)
delay(0);
else
delay(500);
}
}
void delay(unsigned char c)
{
TMOD = 0x01;
if(c==0)
{
TL0 = 0x00;
TH0 = 0x00;
}
else
{
TL0 = 0x75;
TH0 = 0xFF;
}
TR0 = 1;
while(TF0==0);
TR0 = 0;
25
TF0 = 0;
}
RESULT:
26
EXTERNAL INTERRUPT WITH 8051
AIM:
C PROGRAM:
#include<reg51.h>
sbit green = 0xa1; //Connect led to P2.1
void main()
{
while(1)
{
IE = 0x81; //Configure interrupt enable register
green = 0;
}
}
void led(void)interrupt 0 //Interrupt service routine
{
green = 1;
}
RESULT:
27
STEPPER MOTOR INTERFACING WITH
8051
AIM:
C PROGRAM:
#include<reg51.h>
#include<stdio.h>
void clockwise();
void anticlockwise();
void delay(unsigned int);
void main(void)
{
P0 = 0;
while(1)
{
clockwise();
delay(500);
P0 = 0;
anticlockwise();
delay(500);
P0 = 0;
}
}
void clockwise(void)
{
unsigned int i;
for(i=0;i<50;i++)
{
P0 = 0x01; delay(200);
P0 = 0x02; delay(200);
P0 = 0x04; delay(200);
P0 = 0x08; delay(200);
}
}
28
void anticlockwise(void)
{
unsigned int i;
for(i=0;i<50;i++)
{
P0 = 0x08; delay(200);
P0 = 0x04; delay(200);
P0 = 0x02; delay(200);
P0 = 0x01; delay(200);
}
}
RESULT:
29
ADC INTERFACING WITH 8051
AIM:
C PROGRAM:
#include<reg51.h>
#define input P0 //Input port to read the values of ADC
#define output P2 // Output port, connected to LED's.
// Function to read the values from ADC and display on the LED's.
void adc()
{
rd=1;
wr=0;
delay(1);
wr=1;
while(intr==1);
rd=0;
output=input;
delay(1);
intr=1;
}
30
void main()
{
input=0xff; // Declare port 0 as input port.
while(1)
{
adc();
}
}
RESULT:
31
KEYPAD AND LCD INTERFACING WITH 8051
AIM:
To interface a 4*4 matrix keypad with 8051 and print the pressed key
in the LCD interfaced with 8051.
C PROGRAM:
#include<reg51.h>
//Function declarations
void cct_init(void);
void delay(int);
void lcdinit(void);
void writecmd(int);
void writedata(char);
void Return(void);
char READ_SWITCHES(void);
char get_key(void);
//Pin description
/*
P2 is data bus
P3.7 is RS
P3.6 is E
P1.0 to P1.3 are keypad row outputs
P1.4 to P1.7 are keypad column inputs
*/
// Define Pins
32
sbit RS = P3^7; //RS pin for LCD
sbit LED = P0^1;
// Main program
int main(void)
{
char key; // key char for keeping record of pressed key
int i;
LED=0;
cct_init(); // Make input and output pins as required
lcdinit(); // Initilize LCD
while(1)
{
key = get_key(); // Get pressed key
if(key!='n')
{
LED=1;
for(i=0;i<30000;i++);
LED=0;
}
writecmd(0x06); // Increment cursor right
writedata(key); // Echo the key pressed to LCD
}
}
void cct_init(void)
{
P0 = 0x00; //not used
P1 = 0xf0; //for generating outputs and taking inputs from Keypad
P2 = 0x00; //used as data port for LCD
P3 = 0x00; //used for RS and E
}
void delay(int a)
{
int i;
for(i=0;i<a;i++); //null statement
}
void writedata(char t)
{
33
RS = 1; // This is data
P2 = t; //Data transfer
E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);
}
void writecmd(int z)
{
RS = 0; // This is command
P2 = z; //Data transfer
E = 1; // => E = 1
delay(150);
E = 0; // => E = 0
delay(150);
}
void lcdinit(void)
{
///////////// Reset process from datasheet /////////
delay(15000);
writecmd(0x30);
delay(4500);
writecmd(0x30);
delay(300);
writecmd(0x30);
delay(650);
/////////////////////////////////////////////////////
writecmd(0x38); //function set
writecmd(0x0f); //display on, cursor on, blink on
writecmd(0x01); //clear display
writecmd(0x06); //entry mode, set increment
}
char READ_SWITCHES(void)
{
34
RowA = 0; RowB = 1; RowC = 1; RowD = 1; //Test Row A
35
SIMULATION WITH PROTEUS:
RESULT:
Thus, the keypad and LCD are interfaced and the output is verified with
both software and hardware successfully.
36
PIC
PRE-REQUISITES:
SOFTWARE REQUIRED:
HARDWARE REQUIRED:
37
INTERFACING OF LED WITH PIC16F877A
AIM:
To interface led with pic16f877a and creating pattern.
PROGRAM:
#include <htc.h>
#include<pic16f877a.h>
__CONFIG(0X3F7E);
#define _XTAL_FREQ 8000000
void main()
{
TRISB=0X00;
PORTB=0X00;
while(1)
{
PORTB=0XAA;
__delay_ms(500);
PORTB=0X55;
__delay_ms(500);
}
}
OUTPUT:
38
RESULT:
39
INTERFACING LCD WITH PIC16F877A
AIM:
PROGRAM:
#include<pic.h>
#include<htc.h>
__CONFIG(0X3F7A);
#define _XTAL_FREQ 4000000
void port_configuration();
void lcd_cmdwrite(unsigned char command);
void data(unsigned char dat);
void port_configuration()
{
TRISB=0X00;
PORTB=0X00;
TRISC=0X00;
PORTC=0X00;
}
void lcd_cmdwrite(unsigned char command)
{
PORTB=command;
__delay_ms(100);
RC0=0; __delay_ms(20);
RC1=1;
__delay_ms(100);
RC1=0;
__delay_ms(100);
}
void data(unsigned char dat)
{
PORTB=dat;
__delay_ms(100);
RC0=1;
__delay_ms(100);
40
RC1=1;
__delay_ms(100);
RC1=0;
__delay_ms(100);
}
void main()
{
port_configuration();
lcd_cmdwrite(0X38);
lcd_cmdwrite(0X01);
lcd_cmdwrite(0X0C);
lcd_cmdwrite(0X02);
data(0X48);
__delay_ms(100);
data(0X45);
__delay_ms(100);
data(0X4C);
__delay_ms(100);
data(0X4C);
__delay_ms(100);
data(0X4F);
__delay_ms(100);
data('O');
}
OUTPUT:
RESULT:
41
INTERFACING ADC WITH PIC16F877A
AIM:
To interface ADC with pic16f877a.
PROGRAM:
#include<htc.h>
#include<pic.h>
void ADC_Init()
{
` ADCON0 = 0x41; //ADC Module Turned ON `ADCON1
= 0xC0; //All pins as Analog Input
//With reference voltages VDD and VSS
}
do
42
{
a = ADC_Read(0); //Reading Analog Channel 0 PORTB = a; //Lower
8 bits to PORTB
PORTC = a>>8; //Higher 2 bits to PORTC __delay_ms(100);
//Delay
}while(1); //Infinite Loop
}
OUTPUT:
RESULT:
Thus, the interfacing of adc with pic16f877a has been completed
successfully.
43
INTERFACING STEPPER MOTOR WITH
PIC16F877A
AIM:
To interface stepper motor with pic16f877a.
PROGRAM:
#include<pic.h>
__CONFIG(0X3F3A)
;
#define _XTAL_FREQ 4000000
void main()
{
TRISD = 0b0000000; // PORT D as output port PORTD
= 0b1111111;
do
{
PORTD = 0b00000011;// energizing two phases at a time
__delay_ms(500); // delay of 0.5s
PORTD = 0b00000110;
__delay_ms(500);
PORTD = 0b00001100;
__delay_ms(500);
PORTD = 0b00001001;
__delay_ms(500);
}while(1); // loop executed infinite times
}
44
OUTPUT:
RESULT:
Thus, the interfacing of stepper motor with pic16f877a has been
completed successfully.
45
INTERFACING TIMER WITH PIC16F877A
AIM:
To interface timer with pic16f877a.
PROGRAM:
#include<htc.h>
#include<pic.h>
__CONFIG(0X3F39);
void main()
{
int count=0;
TRISB=0X00;
PORTB=0X00;
TMR0=0X00;
OPTION_REG =0X07;
while(1)
{
while(!T0IF);
T0IF=0;
count++;
if(count==8) //3SEC delay
{
PORTB=0X01;
}
if(count==15)
{
PORTB=0X02;
}
if(count==30)
{
PORTB=0X04;
count=0;
}
}
}
46
OUTPUT:
RESULT:
Thus, the interfacing of timer module with pic16f877a has been
completed successfully.
47
INTERFACING PWM MODULE WITH
PIC16F877A
AIM:
To interface pwm module with pic16f877a.
PROGRAM:
#include<pic.h>
#define _XTAL_FREQ
8000000 __CONFIG(0X3F7A);
void main()
{
unsigned char dc ;
48
OUTPUT:
RESULT:
Thus, the interfacing of pwm module with pic16f877a has been
completed successfully.
49
AVR
PRE-REQUISITES:
SOFTWARE REQUIRED:
HARDWARE REQUIRED:
50
INTERFACING LED
AIM:
To interface led with atmega32.
PROGRAM:
#include <avr/io.h>
int main(void)
{
while(1)
{
DDRB=0XFF;
PORTB=0XFF;
for(int i=0;i<10000;i++);
PORTB=0X00;
for(int i=0;i<10000;i++);
}
}
OUTPUT:
RESULT:
Thus, the interfacing of led with atmega32 has been completed
successfully.
51
MSP430
MICROCONTROLLER
PRE-REQUISITES:
SOFTWARE REQUIRED:
Operating system : Windows 7/8/xp
Application Software : Code composer studio v6
HARDWARE REQUIRED:
Development Board : MSP430g2553
Interfacing Circuits : N/A
52
INTERFACING WITH LCD
AIM:
To write a program for interfacing the LCD module with
msp430g2553.
PROGRAM:
#include <msp430g2231.h>
// uC Port definitions
#define lcd_port P1OUT
#define lcd_port_dir P1DIR
void lcd_reset()
{
lcd_port_dir = 0xff; // output mode
lcd_port = 0xff;
__delay_cycles(20000);
lcd_port = 0x03+LCD_EN;
lcd_port = 0x03;
__delay_cycles(10000);
lcd_port = 0x03+LCD_EN;
lcd_port = 0x03;
__delay_cycles(1000);
lcd_port = 0x03+LCD_EN;
lcd_port = 0x03;
__delay_cycles(1000);
lcd_port = 0x02+LCD_EN;
lcd_port = 0x02;
__delay_cycles(1000);
}
53
lcd_port = ((cmd >> 4) & 0x0F);
__delay_cycles(4000);
}
void lcd_init ()
{
lcd_reset(); // Call LCD reset
lcd_cmd(0x28); // 4-bit mode - 2 line - 5x7 font.
lcd_cmd(0x0C); // Display no cursor - no blink.
lcd_cmd(0x06); // Automatic Increment - No Display shift.
lcd_cmd(0x80); // Address DDRAM with 0 offset 80h.
lcd_cmd(0x01); // Clear screen
}
int main()
{
// Stop Watch Dog Timer
WDTCTL = WDTPW + WDTHOLD;
54
// Initialize LCD
lcd_init();
while (1);
}
OUTPUT:
RESULT:
Thus, LCD interfacing program has been executed successfully.
55
BLINKING OF LED
AIM:
To write a program for making the LED to blink with finite delay.
PROGRAM:
#include <msp430g2553.h>
/*
* main.c
*/
int main(void) {
long int i,j;
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
P1DIR=0X02;
while(1)
{
P1OUT=0x02;
for(i=0;i<2000;i++)
for(j=0;j<50;j++);
P1OUT=0x00;
for(i=0;i<2000;i++)
for(j=0;j<50;j++);
}
return 0;
}
56
OUTPUT:
RESULT:
Thus, the program for blinking LED with finite delay has been
executed successfully.
57
NUVOTON
PRE-REQUISITES:
SOFTWARE REQUIRED:
Operating System : Windows
Application Software : Keil µvision IDE
Nu-
link_keil_driver_1.24.6211
Supporting Tools : nil
HARDWARE REQUIRED:
Development board : NUC140VE3CN
Interfacing Circuits : N/A
58
GPIO_LED BLINKING
AIM:
To write a program for making on-board LEDs to blink with finite
delay.
PROGRAM:
// Smpl_GPIO_LED1 : GPC12 to control on-board LEDs.
#include "NUC1xx.h"
#include "Driver\DrvSYS.h"
#include "Driver\DrvGPIO.h"
void delay_loop(void)
{
uint32_t i,j;
for(i=0;i<10;i++)
{
for(j=0;j<60000;j++);
}
}
int main(void)
{
//First set the clock input to the processor.
//The choices are internal clock or external crystal.
/* Unlock the protected registers */
UNLOCKREG();
//We will use the internal 22.1184Mhz
DrvSYS_SetOscCtrl(E_SYS_OSC22M,1);
59
/* HCLK clock source. 0: external 12MHz; 7:internal 22MHz RC oscillator
*/
DrvSYS_SelectHCLKSource(7);
/*lock the protected registers */
LOCKREG();
//Configure GPIO - GPC- pin 12 as output port pin. LEDS are connected
on 12, 13, 14, 15.
DrvGPIO_Open(E_GPC, 12, E_IO_OUTPUT);
while(1)
{
DrvGPIO_SetBit(E_GPC,12);
delay_loop();
DrvGPIO_ClrBit(E_GPC,12);
delay_loop();
}
}
OUTPUT:
RESULT:
Thus, the program for blinking LED with finite delay has been executed
successfully.
60
LCD INTERFACING
AIM:
To write a program for interfacing on chip LCD module with
NUC140VE3CN.
PROGRAM:
// Smpl_LCD_Text: display 4 lines of Text on LCD
#include <stdio.h>
#include "NUC1xx.h"
#include "SYS.h"
#include "GPIO.h"
#include "LCD.h"
int main(void)
{
//First set the clock input to the processor.
//The choices are internal clock or external crystal.
61
LOCKREG();
Initial_pannel(); //call initial pannel function
clr_all_pannal();
OUTPUT:
RESULT:
Thus, the LCD interfacing program has been executed successfully.
62
SEVEN-SEGMENT DISPLAY
AIM:
To write a program for seven segment display with NUC140VE3CN.
PROGRAM:
// Smpl_seven segment display
#include <stdio.h>
#include "NUC1xx.h"
#include "Driver\DrvSYS.h"
#include "Driver\DrvGPIO.h"
#include "Seven_Segment.h"
void delay_loop(void)
{
uint32_t i,j;
for(i=0;i<3;i++)
{
for(j=0;j<60000;j++);
}
}
int main(void)
{
int i=0,j=0;
/* Unlock the protected registers */
UNLOCKREG();
/* Enable the 12MHz oscillator oscillation */
DrvSYS_SetOscCtrl(E_SYS_XTL12M, 1);
63
// SysTimerDelay(5000);
OUTPUT:
RESULT:
Thus, the program for interfacing seven segment display with
NUC140VE3CN has been successfully executed.
64
VERILOG
PRE-REQUISITES:
SOFTWARE REQUIRED:
Operating System : Windows 7/8 or above
Application Software : Xilinx ISE (14.7)
Supporting Tools : N/A
HARDWARE REQUIRED:
Development Board : N/A
Interfacing circuits : N/A
65
FULL ADDER
AIM:
To verify the operation of full adder using structural, behavioral and
data flow modelling in Verilog.
PROGRAM:
STRUCTURAL MODELLING:
module full_adder_structural(
input a,
input b,
input cin,
output s,
output cout
);
wire s1,c1,c2;
xor(s1,a,b);
xor(s,cin,s1);
and(c1,a,b);
and(c2,s1,cin);
or(cout,c1,c2);
endmodule
66
BEHAVIORAL MODELLING:
module full_adder_behavioral(a,b,cin,s,cout);
input a;
input b;
input cin;
output reg s;
output reg cout;
always@(a,b,cin)
begin
s=a^b^cin;
cout=(a & b)|(b & cin)|(cin & a);
end
endmodule
67
OUTPUT:
RESULT:
Thus, the operation of Full adder was verified in Verilog.
68
MULTIPLEXER
AIM:
To verify the operation a multiplexer using data flow modelling in
Verilog.
PROGRAM:
DATA FLOW MODELLING:
module multiplexer4_1 ( a ,b ,c ,d ,x ,y ,dout );
output dout ;
input a ;
input b ;
input c ;
input d ;
input x ;
input y ;
assign dout = (a & (~x) & (~y)) | (b & (~x) & (y)) | (c & x & (~y)) | (d & x &
y);
endmodule
69
OUTPUT:
RESULT:
Thus, the operation of multiplexer was verified in Verilog.
70
DECODER
AIM:
To verify the operation of decoder using behavioral modelling in
Verilog.
PROGRAM:
BEHAVIORAL MODELLING:
module decoder_3x8(Data_in,Data_out);
input [2:0] Data_in;
output [7:0] Data_out;
reg [7:0] Data_out;
always @(Data_in)
case (Data_in)
3'b000 : Data_out = 8'b00000001;
3'b001 : Data_out = 8'b00000010;
3'b010 : Data_out = 8'b00000100;
3'b011 : Data_out = 8'b00001000;
3'b100 : Data_out = 8'b00010000;
3'b101 : Data_out = 8'b00100000;
3'b110 : Data_out = 8'b01000000;
3'b111 : Data_out = 8'b10000000;
default : Data_out = 8'b00000000;
endcase
endmodule
71
OUTPUT:
RESULT:
Thus, the operation of decoder was verified in Verilog
72
FOUR BIT ADDER
AIM:
To construct and verify a four bit adder using structural modelling in
Verilog.
PROGRAM:
STRUCTURAL MODELLING:
module fourbit (
input [3:0]a,
input [3:0]b,
output [3:0]s,
output cout );
wire w1, w2, w3;
fulladdr fa1(a[0],b[0],s[0],0,w1);
fulladdr fa2(a[1],b[1],s[1],w1,w2);
fulladdr fa3(a[2],b[2],s[2],w2,w3);
fulladdr fa4(a[3],b[3],s[3],w3,cout);
endmodule
module fulladdr(a,b,s,cin,cout);
input a,b,cin;
output s,cout;
wire s1,c1,c2;
xor (s1,a,b);
and (c1,a,b);
73
xor (s,s1,cin);
and (c2,s1,cin);
or (cout,c1,c2);
endmodule
OUTPUT:
RESULT:
Thus, the operation of Four bit adder was verified in Verilog.
74
ARITHMETIC AND LOGIC UNIT
AIM:
To verify the operation of ALU using behavioral modelling in Verilog
PROGRAM:
BEHAVIORAL MODELLING:
module alu(out,a,b,s);
input [7:0]a,b;
input [3:0]s;
output [7:0]out;
reg [7:0]out;
always@(s)
begin
case(s)
4'b0000:out=a+b; //8-bit addition
4'b0001:out=a-b; //8-bit subtraction
4'b0010:out=a*b; //8-bit multiplication
4'b0011:out=a/b; //8-bit division
4'b0100:out=a%b; //8-bit modulo division
4'b0101:out=a&&b; //8-bit logical and
4'b0110:out=a||b; //8-bit logical or
4'b0111:out=!a; //8-bit logical negation
4'b1000:out=~a; //8-bit bitwise negation
4'b1001:out=a&b; //8-bit bitwise and
4'b1010:out=a|b; //8-bit bitwise or
4'b1011:out=a^b; //8-bit bitwise xor
75
4'b1100:out=a<<1; //left shift
4'b1101:out=a>>1; //right shift
endcase
end
endmodule
OUTPUT:
RESULT:
Thus, the operation of ALU was verified in Verilog
76
RAM
AIM:
To verify the RAM operations using behavioral modelling in Verilog.
PROGRAM:
BEHAVIORAL MODELLING:
module rammod (clk, we, addr, din, dout);
input clk;
input we;
input [4:0] addr;
input [3:0] din;
output [3:0] dout;
reg [3:0] ram [31:0];
reg [3:0] dout;
always @(clk)
begin
if (we)
ram[addr] <= din;
else
dout <= ram[addr];
end
endmodule
77
TEST BENCH:
initial begin
clk = 0;
we = 0;
addr = 0;
din = 0;
#10 we=1’b1;
#10 addr=5’b00001;din=4’b0001;
#10 addr=5’b00010;din=4’b0010;
#10 addr=5’b00011;din=4’b0011;
#10 addr=5’b00100;din=4’b0100;
#10 addr=5’b00101;din=4’b0101;
#10 addr=5’bxxxxx;din=4’bxxxx;
#10 we=1’b0;
#10 addr=5’b00001;
#10 addr=5’b00010;
#10 addr=5’b00011;
#10 addr=5’b00100;
#10 addr=5’b00101;
end
always #10 clk = ~clk;
initial #150 $stop;
endmodule
78
OUTPUT:
RESULT:
Thus, the operation of RAM was verified in Verilog.
79
VENDING MACHINE CONTROL
AIM:
To construct a vending machine controller using Verilog using
behavioral modelling. In this vending machine, it accepts only three coins,
nickel (5 cents) dime (10 cents) and quarter (25 cents). Whenever total of
coins equal to 40 cents, then user will get softdrink. If total exceeds 40 cents,
it gives back the change.
PROGRAM:
BEHAVIORAL MODELLING:
module vmc_1_mod(clock, reset, coin, vend, state, change);
input clock;
input reset;
input [2:0]coin;
output vend;
output [2:0]state;
output [2:0]change;
reg vend;
reg [2:0]change;
wire [2:0]coin;
//my coins are declared as parameters to make reading better.
parameter [2:0]NICKEL=3'b001;
parameter [2:0]DIME=3'b010;
parameter [2:0]NICKEL_DIME=3'b011;
parameter [2:0]DIME_DIME=3'b100;
parameter [2:0]QUARTER=3'b101;
80
parameter [2:0]IDLE=3'b000;
parameter [2:0]FIVE=3'b001;
parameter [2:0]TEN=3'b010;
parameter [2:0]FIFTEEN=3'b011;
parameter [2:0]TWENTY=3'b100;
parameter [2:0]TWENTYFIVE=3'b101;
//AS ALWAYS THE STATES ARE DEFINED AS REG
reg [2:0] state, next_state;
//MY MACHINE WORKS ON STATE AND COIN
always @(state or coin)
begin
next_state=0; //VERYFIRST NEXT STATE IS GIVEN ZERO
case(state)
IDLE: case(coin) //THIS IS THE IDLE STATE
NICKEL: next_state=FIVE;
DIME: next_state=TEN;
QUARTER: next_state=TWENTYFIVE;
default: next_state=IDLE;
endcase
81
TEN: case(coin) //THIS IS THE THIRD STATE
NICKEL: next_state=FIFTEEN;
DIME: next_state=TWENTY;
QUARTER: next_state=TWENTYFIVE; //change=DIME
default: next_state=TEN;
endcase
82
begin //WHENEVER I GIVE A RESET I HAVE TO MAKE THE STATE
TO IDLE AND VEND TO 1
if(reset) begin
state <= IDLE;
vend <= 1'b0;
// change <= 3'b000;
end //THE CHANGE ALSO HAS TO BECOME NONE
else state <= next_state;
case (state) //HERE WE DECIDE THE NEXT STATE
//ALL THE STATES ARE DEFINED HERE AND THE OUTPUT IS ALSO
GIVEN
IDLE:
begin vend <= 1'b0;
change <=3'd0;
end
FIVE:
begin vend <= 1'b0;
if (coin==QUARTER) change <=NICKEL;
else change <=3'd0;
end
TEN:
begin vend <= 1'b0;
if (coin==QUARTER) change <=DIME;
else change <= 3'd0;
end
FIFTEEN :
83
begin vend <= 1'b0; if (coin==QUARTER) change
<=NICKEL_DIME; else change <= 3'd0; end
OUTPUT:
RESULT:
Thus, the operation of Vending machine controller was verified in
Verilog.
84
MATLAB
PRE-REQUISITES:
SOFTWARE REQUIRED:
Operating System : Windows 7/8 or above
HARDWARE REQUIRED :
Development Board : NA
Interfacing circuits : NA
85
LINEAR CONVOLUTION
AIM:
To perform linear convolution between two discrete sequence.
PROGRAM:
close all
clear all
x=input('Enter x:')
h=input('Enter h:')
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0;
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
stem(Y);
ylabel('Y[n]');
xlabel('--->n');
title('Convolution of two signals');
86
OUTPUT:
Inputs: x=[1 3 2 4]
h=[1 2 1]
RESULT:
Thus, linear convolution between two discrete sequence is performed
using MATLAB.
87
CIRCULAR CONVOLUTION
AIM:
To perform circular convolution between two discrete sequences using
MATLAB.
PROGRAM:
clear all
close all
g=input('enter the first sequence');
h=input('enter the second sequence');
N=input('enter the number of points in the output sequence');
N1=length(g);
N2=length(h);
for n=1:N
y(n)=0;
for i=1:N;
j=n-i+1;
if(j<=0)
j=N+j
end
y(n)=y(n)+g(i)*h(j)
end
end
subplot(3,1,1);
stem(g);
xlabel('n');
88
ylabel('g(n)');
title('first sequence');
subplot(3,1,2);
stem(h);
xlabel('n');
ylabel('h(n)');
title('second sequence');
subplot(3,1,3);
stem(y);
xlabel('n');
ylabel('y(n)');
title('circular convolution');
89
OUTPUT:
Inputs: x=[1 2 3 4]
h=[1 2 3 4]
RESULT:
Thus, circular convolution between two sequences is performed
through MATLAB.
90
SAMPLING
AIM:
To perform sampling of continuous time signal with different sampling
frequency in order to study aliasing effect.
PROGRAM:
clc;
clear all;
close all;
t=-10:.01:10;
T=10;
fm=1/T;
x=cos(2*pi*fm*t);
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
n1=-4:1:4;
xn1=cos(2*pi*n1*fm/fs1);
subplot(2,2,1);
plot(t,x);
xlabel('Time in sec');
ylabel('x(t)');
title('Continuous time signal');
subplot(2,2,2);
stem(n1,xn1);
hold on
91
subplot(2,2,2);
plot(n1,xn1);
xlabel('n');
ylabel('x(n)');
title('discrete time signal with aliasing effect fs<2fm');
n2=-5:1:5;
xn2=cos(2*pi*n2*fm/fs2);
subplot(2,2,3);
stem(n2,xn2);
hold on
subplot(2,2,3);
plot(n2,xn2);
xlabel('n');
ylabel('x(n)');
title('Discrete time signal with no aliasing effect fs=2fm');
n3=-20:1:20;
xn3=cos(2*pi*n3*fm/fs3);
subplot(2,2,4);
stem(n3,xn3);
hold on
subplot(2,2,4);
plot(n3,xn3);
xlabel('n');
ylabel('x(n)');
title('discrete time signal with no aliasing effect fs>2fm');
92
OUTPUT:
RESULT:
Thus, the sampling is performed with different signal frequencies
and aliasing effects are studied.
93
FIR LOW PASS FILTER
AIM:
To design a FIR LPF using rectangular window.
PROGRAM:
clear all;
close all;
rp=input('Enter passband ripple in dB');
rs=input('enter stopband ripple in dB');
fp=input('Enter passband frequency in Hz');
fs=input('Enter stopband frequency in Hz');
f=input('Enter sampling frequency in Hz');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
den=14.6*(fs-fp)/f;
n=ceil(num/den);
disp('the order of filter');
disp(n);
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=boxcar(n1);
b=fir1(n,wp,y);
94
[h,om]=freqz(b,1,256);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('Gain in dB');
xlabel('Normalised frequency');
subplot(2,1,2);
plot(om/pi,an);
ylabel('Phase in radians');
xlabel('Normalised frequency');
OUTPUT:
RESULT:
Thus, the FIR LPF is designed using rectangular window.
95
FIR HIGH PASS FILTER
AIM:
To design FIR High pass filter using rectangular window in
MATLAB.
PROGRAM:
clear all;
close all;
rp=input('Enter passband ripple in dB');
rs=input('enter stopband ripple in dB');
fp=input('Enter passband frequency in Hz');
fs=input('Enter stopband frequency in Hz');
f=input('Enter sampling frequency in Hz');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
den=14.6*(fs-fp)/f;
n=ceil(num/den);
disp('the order of filter');
disp(n);
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;
end
y=boxcar(n1);
96
b=fir1(n,wp,'high',y);
[h,om]=freqz(b,1,256);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
ylabel('Gain in dB');
xlabel('Normalised frequency');
subplot(2,1,2);
plot(om/pi,an);
ylabel('Phase in radians');
xlabel('Normalised frequency');
OUTPUT:
RESULT:
Thus, an FIR HPF is designed using rectangular window.
97
IIR FILTER
AIM:
To design a Butterworth IIR filter using MATLAB.
PROGRAM:
clear all;
close all;
format long
rp=input('Enter the passband ripple');
rs=input('enter stopband ripple in dB');
wp=input('Enter passband frequency in Hz');
ws=input('Enter stopband frequency in Hz');
fs=input('Enter sampling frequency in Hz');
w1=2*wp/fs;
w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn);
disp('the order of filter');
disp(n);
w=0:.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(2,1,1);
plot(om/pi,m);
title('iir filter using impulse invarient method');
ylabel('gain in db-->');
98
xlabel('(a)Normalised freq-->');
subplot(2,1,2);
plot(om/pi,an);
xlabel('(b)Normalised freq-->');
ylabel('Phase in radians-->');
[bz,az]=bilinear(b,a,fs)
[bz,az]=impinvar(b,a,fs)
OUTPUT:
RESULT:
Thus, Butterworth IIR filter was designed using MATLAB.
99
FFT
AIM:
To generate sine wave and to plot its fast fourier transform .
PROGRAM:
clear all;
close all;
fs=1000;
T=1/fs;
L=1000;
t=(0:L-1)*T;
x=0.7*sin(2*pi*50*t)+sin(2*pi*120*t);
figure
plot(fs*t(1:200),x(1:200));
title('sinusoidal signal with 50Hz and 120Hz');
xlabel('time(ms)');
y=x+2*randn(size(t));
figure
plot(fs*t(1:200),y(1:200));
title('signal corrupted with zero mean random noise');
xlabel('Time(ms)');
NFFT=2^nextpow2(L);
y=fft (y,NFFT) /L;
f = fs/2 * linspace (0,1,NFFT/2);
figure
plot(f,2*abs(y(1:NFFT/2)));
100
title('single sided amplitude spectrum of y(t)');
xlabel('frequency(Hz)');
ylabel('|y(f)|');
OUTPUT:
101
RESULT:
Thus, FFT of the sine wave was generated and plotted.
102
LabVIEW
PRE-REQUISITES:
SOFTWARE REQUIRED:
Operating System : Windows 8/10
Application Software : NI LabVIEW 2016
Supporting Tools : VI Package Manager
HARDWARE REQUIRED:
Development Board : N/A
Interfacing circuits : N/A
103
SEQUENCE DETECTOR
AIM:
To create a program to realize the sequence recognizer for the following
conditions using LabVIEW.
• Identify the pattern as 1010 and produce an output as ‘1’ at the fourth
input bit for successful identification.
• Produce an output as ‘0’ at the fourth input bit if the pattern fails.
PROCEDURE:
• Create a New VI and place the required Boolean Control buttons and
the Boolean Indicator LEDs on the Front Panel.
• Place all the logic circuits required in the bock diagram.
• Click RUN button to get the results.
CODE/DIAGRAMS:
Front Panel
104
Block diagram
OUTPUT(S):
105
RESULT:
Thus, a simple Sequence Recognizer circuit was realized using
LabVIEW.
106
ODD/EVEN NUMBER CHECKER
AIM:
To create a program to realize the Odd or Even Number checker using
LabVIEW.
PROCEDURE:
• Simulate and note the Create a New VI and place the required Controls
and Indicator on the Front Panel.
• Create a While Loop and place all the logic circuits required.
• Wire them all and create a stop button for the loop.
• Click RUN button to results.
CODE/DIAGRAMS:
Front Panel
107
Block Diagram
OUTPUT(S):
108
RESULT:
Thus, a simple Odd or Even Number Checker program was realized
using LabVIEW.
109
TRAFFIC SIGNAL SIMULATOR
AIM:
PROCEDURE:
• Create a New VI and place the required Controls and Indicator on the
Front Panel.
• Create a While Loop and place all the logic circuits required (for traffic
signal we need stacked sequence loop for which we need to place flat
sequence loop and then convert it into stacked on clicking right).
• Wire them all and create a stop button for the loop.
• Click RUN button to simulate and note the results.
CODE/DIAGRAMS:
Front Panel
110
Block Diagram
OUTPUT(S):
RESULT:
Thus, a Traffic Signal Simulator was realized using LabVIEW.
111
NETWORK SIMULATOR-2
PRE-REQUISITES:
Software required:
Operating system : Ubuntu/linux
Application Software : NS2 (Network Simulator Software)
NAM(Network Animator)
Gedit(or any other text editor)
Supporting Tools : Java Runtime Environment (Open
JDK Java6 Runtime)
Hardware Required:
Development Board : Nil
Interfacing Circuits : N/A
112
FAMILIARIZATION OF NS2
AIM:
To familiarize NS2 programming environment and to develop a program
to create two nodes and to establish a link between them.
PROGRAM:
#create simulation environment set
ns [new Simulator]
#open a file in write mode to capture the simulation results
set nf [open out.nam w]
#initiate the trace $ns
namtrace-all $nf proc
finish {} {
global ns nf $ns
flush-trace close $nf
exec nam out.nam
exit 0
}
#create two nodes set n0
[$ns node] set n1 [$ns
node]
#create a duplex link between the nodes
$ns duplex-link $n0 $n1 1Mb 10ms
DropTail $ns at 5.0 "finish"
$ns run
113
OUTPUT:
RESULT:
Thus, the program was compiled and executed and the plot of a network
with two nodes and a link was observed in the Network Animator Window.
114
CREATION OF A NETWORK TOPOLOGY
AIM:
PROGRAM:
OUTPUT:
RESULT:
The program was compiled and executed and the plot of a network with
6 nodes was observed.
116
STUDY OF CONGESTION
AIM:
PROGRAM:
set ns [new Simulator]
set nf [open twoflows.nam w] $ns namtrace-
all $nf
$ns color 1 Blue $ns color 2 Red
proc finish {} {
global ns nf $ns flush-trace
close $nf
exec nam twoflows.nam & exit 0
}
set n0 [$ns node] set n1 [$ns
node] set n2 [$ns node] set n3
[$ns node]
$ns duplex-link $n0 $n2 1Mb 10ms DropTail $ns duplex-
link $n1 $n2 1Mb 10ms DropTail $ns duplex-link $n3 $n2
1Mb 10ms SFQ $ns duplex-link-op $n2 $n0 orient left-up
$ns duplex-link-op $n2 $n1 orient left-down $ns duplex-
link-op $n2 $n3 orient right
set udp0 [new Agent/UDP] $udp0 set
class_ 2
$ns attach-agent $n0 $udp0
set cbr0 [new Application/Traffic/CBR] $cbr0 set
packetSize_ 500
$cbr0 set interval_ 0.005 $cbr0 attach-
agent $udp0 set udp1 [new Agent/UDP]
$udp1 set class_ 1
$ns attach-agent $n1 $udp1
set cbr1 [new Application/Traffic/CBR]
$cbr1 set packetSize_ 500 $cbr1 set
117
interval_ 0.005 $cbr1 attach-agent
$udp1 set null0 [new Agent/Null]
$ns attach-agent $n3 $null0 $ns
connect $udp0 $null0 $ns connect
$udp1 $null0 $ns at 0.5 "$cbr0 start"
$ns at 1.0 "$cbr1 start" $ns at 4.0
"$cbr1 stop" $ns at 4.5 "$cbr0 stop"
$ns at 5.0 "finish" $ns run
OUTPUT:
RESULT:
Thus, the topology with 3 links was created and packet drop was
observed at the intermediate nodes.
118
CREATION OF TCP AND UDP TRAFFIC
AIM:
To construct a topology with traffic parameters for TCP and UDP type
of traffic.
PROGRAM:
set ns [new
Simulator] set tr
[open out.tr w] $ns
trace-all $tr
set namtr [open out.nam
w] $ns namtrace-all
$namtr $ns color 1 Red
$ns color 2 Blue
set n0 [$ns
node] set n1
[$ns node] set
n2 [$ns node]
set n3 [$ns
node] set n4
[$ns node] set
n5 [$ns node]
$ns duplex-link $n0 $n1 1Mb 10ms
DropTail $ns duplex-link $n2 $n0 1Mb
10ms DropTail $ns duplex-link $n3 $n0
1Mb 10ms DropTail $ns duplex-link $n4
$n1 1Mb 10ms DropTail $ns duplex-link
$n5 $n1 1Mb 10ms DropTail $ns duplex-
link-op $n0 $n1 orient right
$ns duplex-link-op $n0 $n2 orient left-up
$ns duplex-link-op $n0 $n3 orient left-
down $ns duplex-link-op $n1 $n4 orient
right-up
$ns duplex-link-op $n1 $n5 orient right-
down set udp0 [new Agent/UDP]
119
$ns attach-agent $n3
$udp0 $udp0 set class_ 1
set null0 [new Agent/Null]
$ns attach-agent $n5
$null0 $ns connect $udp0
$null0
set cbr0 [new
Application/Traffic/CBR] $cbr0 set
rate 2Mb
$cbr0 attach-agent $udp0
set tcp0 [new Agent/TCP]
$ns attach-agent $n3 $tcp0
$tcp0 set class_ 2
set sink0 [new Agent/TCPSink] $ns
attach-agent $n4 $sink0 $ns connect
$tcp0 $sink0
set ftp0 [new Application/FTP] $ftp0
attach-agent $tcp0
$ns at 1.0 "$cbr0 start" $ns at
5.0 "$cbr0 stop" $ns at 1.2
"$ftp0 start" $ns at 6.2 "$ftp0
stop" proc finish {} {
global tr namtr close
$tr close $namtr
exec nam out.nam & exit
0
}
$ns at 10.0 "finish" $ns
run
120
OUTPUT:
RESULT:
Thus, the CBR and FTP applications generated UDP and TCP data from
node3 was received by node4 and node5 respectively.
121
MICRO ELECTRO
MECHANICAL
SYSTEMS
PRE-REQUISITES:
SOFTWARE REQUIRED:
Operating system : Windows 7/8/xp or above
Tools : Comsol ver4.4
HARDWARE REQUIRED:
Development Board : N/A
Interfacing Circuits : N/A
122
CANTILEVER BEAM
A cantilever is a beam anchored at only one end. The beam carries the load
to the support where it is forced against by a moment and shear stress. Cantilever
construction allows for overhanging structures without external bracing.
Cantilevers can also be constructed with trusses or slabs.
PROCEDURE
After opening comsol, the model wizard appears. Choose 3-D for two
dimensional objects in space dimensions. Click next.
The window changes to add physics. Choose solid mechanics under
structural mechanics and then click next.
The select study type window appears. Choose stationary in preset studies
and click finish. On the left hand side the model builder pane appears.
Right click on Geometry to create one rectangle with the following
dimension.
Rectangle :- Object Type -Solid
Size - 1.width -10e-3m 2.Height -1e-3m
3.depth- 1e-3m Position - 1.Base -Corner 2. x:
0m 3.y:0m 4.z:0m
123
Click Build all.
Right click materials and click open materials browser. Add silicon
dioxide. Assign silicon dioxide to rectangle.
Right click on solid mechanics and select fixed constraint. Fix one corner
of the blocks. Right click solid mechanics and select boundary load.
Choose the load type as pressure and give the value as (10pa) and choose
the side to which load has to be applied.
Right click on study and give compute.
The result will appear on the window after some time.
124
2-D Output
125
GAS SENSOR
PROCEDURE:-
NEW
MODEL WIZARD
126
GLOBAL DEFINITIONS
GEOMETRY 1
Rectangle 1
Right-click Component 1>Geometry 1 and choose Rectangle. In the
rectangle settings window, locate the Size section.
In the Width edit field, type 4.
In the Height edit field, type 22.5.
Locate the Position section. In the y edit field, type -22.
Rectangle 2
Rectangle 3
127
Rectangle 4
DEFINITIONS
Axis
128
PIEZOELECTRIC DEVICES
MAT E R I A L S
Material 1
129
Material 2
131
On the Home toolbar, click Add Material.
ADD MATERIAL
Go to the Add Material window.
In the tree, select Built-In>Aluminum.
In the Add material window, click Add to Component.
MATERIALS
Aluminum
132
MESH 1
Size
STUDY 1
133
Parametric Sweep
Step 1: Eigenfrequency
The default plot shows the total displacement for an eigenmode near 837
MHz. Switch to the resonance SAW mode near 839 MHz:
In the 2D Plot Group settings window, locate the
Data section. From the Eigenfrequency list,
choose 8.387092e8.
134
Adjust the deformed shape plot to see the effect of the wave
localization near the
surface.
In the Model Builder window, expand the Results>Displacement
(pzd)>Surface 1 node, then click Deformation.
In the Deformation settings window, locate the
Scale section. Select the Scale factor check box.
In the associated edit field, type 100.
On the 2D plot group toolbar, click
Plot. Compare the resulting plot to
that in Figure 3.
In the Model Builder window, click Displacement (pzd).
In the 2D Plot Group settings window, locate the
Data section. From the Eigenfrequency list,
choose 8.489836e8.
On the 2D plot group toolbar, click Plot.
To visualize the electric potential distribution for the eigenmodes,
follow these steps:
Potential (pzd)
135
In the associated edit field, type 1.
In the Model Builder window, under Results>Potential
(pzd) click Surface 1. In the Surface settings window, locate
the Coloring and Style section.
From the Color table list, choose Wave.
Right-click Results>Potential (pzd)>Surface 1 and choose
Height Expression. In the Model Builder window, click
Potential (pzd).
In the 2D Plot Group settings window, locate the
Data section. From the Eigenfrequency list,
choose 8.489836e8.
On the 2D plot group toolbar, click Plot.
136
MOS TRANSISTOR (MOSFET)
The MOSFET (metal oxide semiconductor field-effect transistor) is by far
the most common semiconductor device, and the primary building block in all
commercial processors, memories, and digital integrated circuits. Since the first
microprocessors were introduced approximately 40 years ago this device has
experienced tremendous development, and today it is being manufactured with
feature sizes of 22 nm and smaller.
PROCEDURE:
NEW
MOD E L W I Z A RD
GLOBAL DEFINITIONS
Define parameters for the drain and gate voltages that we will later use
when performing parametric sweeps.
Parameters
The geometry can be specified using COMSOL's built in tools. First choose to
define
geometry objects using micrometer units.
In the Model Builder window, under Component 1 click
Geometry 1. In the Geometry settings window, locate the Units
section.
From the Length unit list, choose μm.
Next create a rectangle to define the geometry extents.
Rectangle 1
139
GEOMETRY 1
In the Model Builder window, right-click Geometry 1 and
choose Polygon. In the Polygon settings window, locate the
Object Type section.
From the Type list, choose Closed curve.
Locate the Coordinates section. In the x edit field, type 0 0 1 1.75
3.25 4 5 5. In the y edit field, type 0.5 1 1 1 1 1 1 0.5.
Click the Build All Objects button.
MATERIALS
140
Semiconductor Doping Model 1
141
Then define the width and height of the uniformly doped
region. In the W edit field, type 1.6[um].
In the H edit field, type 0.25[um].
Choose the dopant type and the doping level in the uniformly doped region.
Locate the Doping Distribution section. From the Dopant type list,
choose Donor doping.
In the ND0 edit field, type 1e20[1/cm^3].
Next specify the length scale over which the Gaussian drop off occurs. If
doping into a background dopant distribution of opposite type (as in this
case), this setting specifies the junction depth. In this model different
length scales are used in the x and y directions.
Select the Specify different depths for each direction
check box. Specify the dj vector as
142
From the Selection list, choose All domains.
Locate the Doping section. From the Dopant distribution list,
choose Gaussian. Locate the Uniformly Doped Region section.
Specify the r0 vector as
Metal Contact 1
On the Physics toolbar, click Boundaries and choose Metal Contact.
143
The Metal Contact feature is used to define Metal-
Semiconductor interfaces of various types. In this instance
we use the default Ideal Ohmic contact to define the source.
Select Boundary 5 only.
Note that the Metal Contact feature in COMSOL is a terminal boundary
condition. By default a fixed potential of 0 V is applied, which is
appropriate in this instance, since the source is grounded. The terminal
can also be set up to specify a constant current or to connect to an
external circuit.
Add a second Metal Contact feature to define the drain.
Metal Contact 2
144
Thin Insulator Gate 1
On the Physics toolbar, click Boundaries and choose Thin Insulator Gate.
The Thin Insulator Gate feature is also a terminal, but in this instance it
is possible to fix the voltage or charge on the terminal, as well as to
connect it to a circuit. Note that the charge setting determines the
charge on the terminal and does not relate to trapped charge at the
interface.
The voltage applied to the gate is determined by the parameter
previously added. In the Thin Insulator Gate settings window, locate
the Terminal section.
In the V0 edit field, type Vg.
Locate the Gate Contact section. In the εins edit field, type 4.5.
In the dins edit field, type
20[nm]. Select Boundary 7
only.
Shockley-Read-Hall Recombination 1
145
MESH 1
The Physics-based mesh settings can be used for this model, but the default
element size needs refining slightly to properly resolve the region under the
gate.
146
STUDY 1
Before setting up the study, check that the doping was set up correctly. To do
this, first get the initial value for the study.
RESULTS
2D Plot Group 1
On the Home toolbar, click Add Plot Group and choose 2D Plot Group.
In the Model Builder window, under Results right-click 2D Plot Group 1
and choose Surface.
Plot the signed dopant concentration (Nd-Na). This quantity is
positive for net donor doping and negative for net acceptor doping.
In the Surface settings window, click Replace Expression in the upper-
right corner of the Expression section. From the menu, choose
Semiconductor>Carrier concentrations>Signed dopant concentration
(semi.Ndoping).
147
RESISTOR
Every electrical device has some resistance. That is, when a
voltage difference is applied across any two terminals of the device,
there will be a directly proportional current flow. This model
demonstrates how to compute the resistance of a short section of copper
wire. The convergence of the solution with respect to the mesh size is
also studied.
PROCEDURE
NEW
MODEL WIZARD
GEOMETRY 1
Cylinder 1
149
On the Geometry toolbar, click Cylinder.
In the Cylinder settings window, locate the
Size and Shape section. In the Radius edit
field, type 0.5[mm].
In the Height edit
field, type 10[mm].
Click the Build All
button.
ELECTRIC CURRENTS
Set up the Electric Current physics. Specify the ground and terminal
boundaries.
Ground 1
150
On the Physics toolbar, click Boundaries and choose
Terminal. Select Boundary 4 only.
In the Terminal settings window, locate the
Terminal section. In the I0 edit field, type 1.
MATERIALS
In the Size settings window, locate the Element Size section. From
the Predefined list, choose Extra coarse.
STUDY 1
On the Home toolbar, click Compute.
151
PIEZOELECTRIC SHEAR-ACTUATED BEAM
This example performs a static analysis on a piezoelectric actuator based
on the movement of a cantilever beam, using the Piezoelectric Devices
predefined multiphysics interface. Inspired by work done by V. Piefort (Ref. 1)
and A. Benjeddou (Ref. 2), it models a sandwich beam using the shear mode of
the piezoelectric material to deflect the tip.
PROCEDURE:-
NEW
MODEL WIZARD
152
In the Depth edit field, type
0.03. In the Height edit field,
type 0.018. Click the Build
Selected button.
Block 2
On the Geometry toolbar, click Block.
In the Block settings window, locate the Size
section. In the Width edit field, type 0.1.
In the Depth edit field, type
0.03. In the Height edit field,
type 0.002.
153
Click the Transparency button on the Graphics
toolbar.
The geometry in the Graphics window should now look like that in
Figure 1. Click the Transparency button on the Graphics toolbar.
DEFINITIONS
Define a coordinate system whose third axis is aligned with the global x-
axis, that is, the polarization direction of the piezoceramic material. Choose
the second axis to be parallel to the global y-axis.
Base Vector System 2
Leave the other components at their default values. You will use this
coordinate system in the piezoelectric material settings.
MAT E R I A L S
For the aluminum layers, use a library material.
On the Home toolbar, click Add Material.
ADD MATERIAL
Go to the Add Material window.
In the tree, select MEMS>Metals>Al.
In the Add material window, click Add to Component.
154
MAT E R I A L S
Al
155
ADD MATERIAL
Go to the Add Material window.
In the tree, select Piezoelectric>Lead Zirconate Titanate
(PZT-5H). In the Add material window, click Add to
Component.
MATERIALS
Lead Zirconate Titanate (PZT-5H)
In the Model Builder window, under Component 1>Materials click
Lead Zirconate Titanate (PZT-5H).
Select Domain 4 only.
PIEZO ELECTRICDEVICES
On the Home toolbar, click Add Material.
Piezoelectric Material 1
Electric Potential 1
On the Physics toolbar, click Boundaries and choose
Electric Potential. Select Boundary 16 only.
156
In the Electric Potential settings window, locate the Electric Potential
section. In the V0 edit field, type 20.
Ground 1
RESULTS
Potential (pzd)
157
On the 3D Plot Group toolbar, click Plot.
Click the Zoom In button on the Graphics toolbar.
Displacement (pzd)
Follow the steps below to reproduce the plot shown in Figure 2.
In the Model Builder window, expand the Displacement (pzd) node, then
click Surface 1.
In the Surface settings window, click Replace Expression in the upper-
right corner of the Expression section. From the menu, choose
Piezoelectric Devices (Solid Mechanics)>Displacement>Displacement
field (Material)>Displacement field, Z Component (w).
Locate the Expression section. From the Unit list,
choose nm. On the 3D Plot Group toolbar, click
Plot.
Click the Zoom Extents button on the Graphics
toolbar. Click the Scene Light button on the
Graphics toolbar.
158