Showing posts with label Projectideas.. Show all posts
Showing posts with label Projectideas.. Show all posts
Friday, 17 June 2016
Sunday, 15 May 2016
3D - OBJECT DETECTION USING OPENCV-PYTHON
The following Code will detect the object present in the image ,whether it is a Cube or a Cylinder or Sphere based on Contour Approximation.The below Code is written Using the Python API for OpenCV Library.
Script:
import cv2
# Importing the Opencv Library
import numpy as np
# Importing NumPy,which is the fundamental package for scientific computing with #Python
# Reading Image
img = cv2.imread("/home/whoami/Pictures/cylinder1.jpg")
cv2.namedWindow("Original Image",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Original Image",img)
# Display image
# RGB to Gray scale conversion
img_gray = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
cv2.namedWindow("Gray Converted Image",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Gray Converted Image",img_gray)
# Display Image
# Noise removal with iterative bilateral filter(removes noise while preserving edges)
noise_removal = cv2.bilateralFilter(img_gray,9,75,75)
cv2.namedWindow("Noise Removed Image",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Noise Removed Image",noise_removal)
# Display Image
# Thresholding the image
ret,thresh_image = cv2.threshold(noise_removal,0,255,cv2.THRESH_OTSU)
cv2.namedWindow("Image after Thresholding",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Image after Thresholding",thresh_image)
# Display Image
# Applying Canny Edge detection
canny_image = cv2.Canny(thresh_image,250,255)
cv2.namedWindow("Image after applying Canny",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Image after applying Canny",canny_image)
# Display Image
canny_image = cv2.convertScaleAbs(canny_image)
# dilation to strengthen the edges
kernel = np.ones((3,3), np.uint8)
# Creating the kernel for dilation
dilated_image = cv2.dilate(canny_image,kernel,iterations=1)
cv2.namedWindow("Dilation", cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Dilation", dilated_image)
# Displaying Image
contours, h = cv2.findContours(dilated_image, 1, 2)
contours= sorted(contours, key = cv2.contourArea, reverse = True)[:1]
pt = (180, 3 * img.shape[0] // 4)
for cnt in contours:
approx = cv2.approxPolyDP(cnt,0.01*cv2.arcLength(cnt,True),True)
# print len(cnt)
print len(approx)
if len(approx) ==6 :
print "Cube"
cv2.drawContours(img,[cnt],-1,(255,0,0),3)
cv2.putText(img,'Cube', pt ,cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, 2, [0,255, 255], 2)
elif len(approx) == 7:
print "Cube"
cv2.drawContours(img,[cnt],-1,(255,0,0),3)
cv2.putText(img,'Cube', pt ,cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, 2, [0, 255, 255], 2)
elif len(approx) == 8:
print "Cylinder"
cv2.drawContours(img,[cnt],-1,(255,0,0),3)
cv2.putText(img,'Cylinder', pt ,cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, 2, [0, 255, 255], 2)
elif len(approx) > 10:
print "Sphere"
cv2.drawContours(img,[cnt],-1,(255,0,0),3)
cv2.putText(img,'Sphere', pt ,cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, 2, [255, 0, 0], 2)
cv2.namedWindow("Shape", cv2.WINDOW_NORMAL)
cv2.imshow('Shape',img)
corners = cv2.goodFeaturesToTrack(thresh_image,6,0.06,25)
corners = np.float32(corners)
for item in corners:
x,y = item[0]
cv2.circle(img,(x,y),10,255,-1)
cv2.namedWindow("Corners", cv2.WINDOW_NORMAL)
cv2.imshow("Corners",img)
cv2.waitKey()
Script:
import cv2
# Importing the Opencv Library
import numpy as np
# Importing NumPy,which is the fundamental package for scientific computing with #Python
# Reading Image
img = cv2.imread("/home/whoami/Pictures/cylinder1.jpg")
cv2.namedWindow("Original Image",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Original Image",img)
# Display image
# RGB to Gray scale conversion
img_gray = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)
cv2.namedWindow("Gray Converted Image",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Gray Converted Image",img_gray)
# Display Image
# Noise removal with iterative bilateral filter(removes noise while preserving edges)
noise_removal = cv2.bilateralFilter(img_gray,9,75,75)
cv2.namedWindow("Noise Removed Image",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Noise Removed Image",noise_removal)
# Display Image
# Thresholding the image
ret,thresh_image = cv2.threshold(noise_removal,0,255,cv2.THRESH_OTSU)
cv2.namedWindow("Image after Thresholding",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Image after Thresholding",thresh_image)
# Display Image
# Applying Canny Edge detection
canny_image = cv2.Canny(thresh_image,250,255)
cv2.namedWindow("Image after applying Canny",cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Image after applying Canny",canny_image)
# Display Image
canny_image = cv2.convertScaleAbs(canny_image)
# dilation to strengthen the edges
kernel = np.ones((3,3), np.uint8)
# Creating the kernel for dilation
dilated_image = cv2.dilate(canny_image,kernel,iterations=1)
cv2.namedWindow("Dilation", cv2.WINDOW_NORMAL)
# Creating a Named window to display image
cv2.imshow("Dilation", dilated_image)
# Displaying Image
contours, h = cv2.findContours(dilated_image, 1, 2)
contours= sorted(contours, key = cv2.contourArea, reverse = True)[:1]
pt = (180, 3 * img.shape[0] // 4)
for cnt in contours:
approx = cv2.approxPolyDP(cnt,0.01*cv2.arcLength(cnt,True),True)
# print len(cnt)
print len(approx)
if len(approx) ==6 :
print "Cube"
cv2.drawContours(img,[cnt],-1,(255,0,0),3)
cv2.putText(img,'Cube', pt ,cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, 2, [0,255, 255], 2)
elif len(approx) == 7:
print "Cube"
cv2.drawContours(img,[cnt],-1,(255,0,0),3)
cv2.putText(img,'Cube', pt ,cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, 2, [0, 255, 255], 2)
elif len(approx) == 8:
print "Cylinder"
cv2.drawContours(img,[cnt],-1,(255,0,0),3)
cv2.putText(img,'Cylinder', pt ,cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, 2, [0, 255, 255], 2)
elif len(approx) > 10:
print "Sphere"
cv2.drawContours(img,[cnt],-1,(255,0,0),3)
cv2.putText(img,'Sphere', pt ,cv2.FONT_HERSHEY_SCRIPT_SIMPLEX, 2, [255, 0, 0], 2)
cv2.namedWindow("Shape", cv2.WINDOW_NORMAL)
cv2.imshow('Shape',img)
corners = cv2.goodFeaturesToTrack(thresh_image,6,0.06,25)
corners = np.float32(corners)
for item in corners:
x,y = item[0]
cv2.circle(img,(x,y),10,255,-1)
cv2.namedWindow("Corners", cv2.WINDOW_NORMAL)
cv2.imshow("Corners",img)
cv2.waitKey()
Sunday, 3 April 2016
Transparent Wood Could Potentially Help Light Up Homes
Scientists from the KTH, School of Chemical Science and engineering have
recently published a paper which is capable of featuring the perfect
blend between interior decoration and bio composites. The team has
designed a material that can come forward as the next generation home
décor, namely transparent wood. People invest a huge amount of money in
artificial lights to create a suitable presence inside the room. However
with this new material, an automatic transparent ambience can be
created and it also has great use as a potential material for solar cell
windows.
Lars Berglund and his subordinates have taken the initiative to gift design enthusiasts an artificial wood which is transparent, reflective and refractive in nature. Contemporary work regarding extracting transparent paper from transparent wood guided the team to frame an abstract related to a similar, but stronger material.
Lars Berglund and his subordinates have taken the initiative to gift design enthusiasts an artificial wood which is transparent, reflective and refractive in nature. Contemporary work regarding extracting transparent paper from transparent wood guided the team to frame an abstract related to a similar, but stronger material.
The method of preparation includes several steps, among which the first step made the team remove lignin from samples of commercial balsa wood. The polymer is held responsible for absorbing 80 to 95 percent light and preventing it from passing through. Although the team successfully removed the polymer, they were still unable to produce a complete see-through material due to scattering. To overcome the glitch, scientists added acrylic, colloquially known as Plexiglass. Finally a customized, optically transparent wood was developed, having transmittance of 85% and haze of 71%. Additionally, the hazing property could even boost the manufacturing of solar cells.
The research was supported by the Knut and Alice Wallenberg Foundation, and was published in the Biomacromolecules journal of the American Chemical Society.
Source: Biomacromolecules
Friday, 26 February 2016
Segmentation Using Canny+Watershed in Opencv-python
import cv2
# Importing opencv libraryimport numpy as np
# Importing NumPy,which is the fundamental package for scientific computing with Python
img = cv2.imread('C:\\Users\Ram\Pictures\\humans\\368078.jpg')
# Read the image from disk
cv2.imshow("Original image", img) # Display image
img_float = np.float32(img) # Convert image from unsigned 8 bit to 32 bit float
criteria = (cv2.TERM_CRITERIA_EPS+cv2.TERM_CRITERIA_MAX_ITER, 10, 1)
# Defining the criteria ( type, max_iter, epsilon )
# cv2.TERM_CRITERIA_EPS - stop the algorithm iteration if specified accuracy, epsilon, is reached.
# cv2.TERM_CRITERIA_MAX_ITER - stop the algorithm after the specified number of iterations, max_iter.
# cv2.TERM_CRITERIA_EPS + cv2.TERM_CRITERIA_MAX_ITER - stop the iteration when any of the above condition is met.
# max_iter - An integer specifying maximum number of iterations.In this case it is 10
# epsilon - Required accuracy.In this case it is 1
k = 50 # Number of clusters
ret, label, centers = cv2.kmeans(img_float, k, None, criteria, 50, cv2.KMEANS_RANDOM_CENTERS)
# apply kmeans algorithm with random centers approach
center = np.uint8(centers)
# Convert the image from float to unsigned integer
res = center[label.flatten()]
# This will flatten the label
res2 = res.reshape(img.shape)
# Reshape the image
cv2.imshow("K Means", res2) # Display image
cv2.imwrite("1.jpg", res2) # Write image onto disk
meanshift = cv2.pyrMeanShiftFiltering(img, sp=8, sr=16, maxLevel=1, termcrit=(cv2.TERM_CRITERIA_EPS+cv2.TERM_CRITERIA_MAX_ITER, 5, 1))
# Apply meanshift algorithm on to image
cv2.imshow("Output of meanshift", meanshift)
# Display image
cv2.imwrite("2.jpg", meanshift)
# Write image onto disk
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# Convert image from RGB to GRAY
ret, thresh = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
# apply thresholding to convert the image to binary
fg = cv2.erode(thresh, None, iterations=1)
# erode the image
bgt = cv2.dilate(thresh, None, iterations=1)
# Dilate the image
ret, bg = cv2.threshold(bgt, 1, 128, 1)
# Apply thresholding
marker = cv2.add(fg, bg)
# Add foreground and background
canny = cv2.Canny(marker, 110, 150)
# Apply canny edge detector
new, contours, hierarchy = cv2.findContours(canny, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
# Finding the contors in the image using chain approximation
marker32 = np.int32(marker)
# converting the marker to float 32 bit
cv2.watershed(img,marker32)
# Apply watershed algorithm
m = cv2.convertScaleAbs(marker32)
ret, thresh = cv2.threshold(m, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
# Apply thresholding on the image to convert to binary image
thresh_inv = cv2.bitwise_not(thresh)
# Invert the thresh
res = cv2.bitwise_and(img, img, mask=thresh)
# Bitwise and with the image mask thresh
res3 = cv2.bitwise_and(img, img, mask=thresh_inv)
# Bitwise and the image with mask as threshold invert
res4 = cv2.addWeighted(res, 1, res3, 1, 0)
# Take the weighted average
final = cv2.drawContours(res4, contours, -1, (0, 255, 0), 1)
# Draw the contours on the image with green color and pixel width is 1
cv2.imshow("Watershed", final) # Display the image
cv2.imwrite("3.jpg", final) # Write the image
cv2.waitKey() # Wait for key stroke
The result of the above script is given in the pdf below (2nd Answer):
Thursday, 17 December 2015
C Code to Perform Sampling Rate Convertion
Sampling Rate Conversion in Real Time(Using a C language)
Upsampling and DownSampling using Reconstruction
(Using sinc Function):
Code:
#include<stdio.h>#include<math.h>
#define PI 3.14
void main()
{
int m,n,samplingrate,chunksize,subchunk2size,newchunksize,newsamplingrate,newsubchunk2size;
float i;
//int noofsamples;
int factor;
unsigned char a,b,c,d,e;
FILE *fp,*fp2;
void writeheaderfile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size,FILE *fp2);
void writedatafile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size,float i,int subchunk2size,FILE *fp2);
printf("Original Song is in : song1.wav\nResult is stored in : Createdsong.wav\n");
fp=fopen("song1.wav","r");
fp2=fopen("Createdsong.wav","w+");
fseek(fp,24,SEEK_SET);
fread(&samplingrate,4,1,fp);
printf("Sampling Rate is : %d\n",samplingrate);
fseek(fp,4,SEEK_SET);
fread(&chunksize,4,1,fp);
printf("chunksize is : %d\n",chunksize);
fseek(fp,40,SEEK_SET);
fread(&subchunk2size,4,1,fp);
printf("subchunk2size is : %d\n",subchunk2size);
printf("Enter the New Sampling Rate : ");scanf("%d",&newsamplingrate);
i=(float)samplingrate/newsamplingrate;
//printf("I value is : %f\n",i);
//noofsamples=readnoofsamples(fp);
printf("No of Samples in Given File : %d\n",subchunk2size/4);
newsubchunk2size=subchunk2size/i;
newchunksize=newsubchunk2size+36;
//noofsamples=newsubchunk2size/4;
writeheaderfile(fp,newsamplingrate,newchunksize,newsubchunk2size,fp2);
//fclose(fp2);
// fp2=fopen("Createdsong.wav","w+");
writedatafile(fp,newsamplingrate,newchunksize,newsubchunk2size,i,subchunk2size,fp2);
}
/*int readnoofsamples(FILE *fp)
{
int count=1;
unsigned char c;
fp=fopen("song1.wav","r");
fseek(fp,44,SEEK_SET);
while(1)
{
if(feof(fp)) break;
fscanf(fp,"%c",&c);
count++;
//printf("%d\n",count);
}
//count=count/4;
return count;
}*/
void writedatafile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size,float i,int subchunk2size,FILE *fp2)
{
//FILE *fp2;
int count=0,samco=1,center,samp=0,previous=0,x,temp;
short int e,r;
long int m,n,sumfr,sumfl;
float suml=0,sumr=0;
unsigned char z,s,v,w,c;
float sinc(int m,float i,int n);
printf("Writing the Samples in File....Please Wait....\n");
//fp=fopen("song1.wav","r");
fseek(fp,40,SEEK_SET);
fread(&subchunk2size,4,1,fp);
//printf("subchunk2size is : %d\n",subchunk2size);
//fclose(fp);
//fp=fopen("song1.wav","r");
//fp2=fopen("Createdsong.wav","a");
fseek(fp,44,SEEK_SET);
fseek(fp2,44,SEEK_SET);
//printf("%d\n",subchunk2size);
for(m=0;m<=subchunk2size;m++)
{
//if(feof(fp)) break;
sumfl=0;
sumr=0;
suml=0;
sumfr=0;
center=rint(m*i);
if(previous==center)
{
}
else
{
for(temp=0;temp<(center-previous);temp++)
{
count++;
}
}
previous=center;
fseek(fp,44+(4*count),SEEK_SET);
for(n=count-10;n<count+10;n++)
{
//printf("m value : %d\n",m);
if(n<0)
{
e=0;
r=0;
}
else
{
fread(&e,2,1,fp);
fread(&r,2,1,fp);
}
sumr=sumr+(e*sinc(m,i,n));
suml=suml+(r*sinc(m,i,n));
sumfl=suml;
sumfr=sumr;
//if(sumfl==0) printf("m=%d\t n=%d\n",m,n);
//printf("m*I=%d\t n=%d\t e=%d\n",m*i,n,e);
//printf("suml=%lf\t sumr=%lf\t n=%d\t count=%d\t e=%d\t r=%d\n",suml,sumr,n,count,e,r);
}
fwrite(&sumfr,2,1,fp2);
fwrite(&sumfl,2,1,fp2);
/*fscanf(fp,"%c",&t);
fscanf(fp,"%c",&s);
fscanf(fp,"%c",&v);
fscanf(fp,"%c",&w);
printf("%d %d %d %d\n",t,s,v,w);*/
//if(sumfr==0) printf("m=%d\t and n=%d\n",m,n);
//printf("m=%d\t and sumfl=%d\t sumfr=%d\n",m,sumfl,sumfr);
//getchar();
}
printf("Process Completed...Result is in Createdsong.wav\n");
fclose(fp);
fclose(fp2);
}
float sinc(int m,float i,int n)
{
float temp;
if(rint(m*i)==n)
{
//printf("sinc value is : %f\n",1.00);
return 1.00;
}
else
{
temp=PI*(m*i-n);
//printf("sinc value is : %f\n",(sin(temp)/temp));
return (sin(temp)/temp);
}
}
void writeheaderfile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size,FILE *fp2)
{long int count=1;
unsigned char header;
//FILE *fp2;
//fp=fopen("song1.wav","r");
//fp2=fopen("Createdsong.wav","w+");
fseek(fp,0,SEEK_SET);
while(1)
{
fread(&header,4,1,fp);
fwrite(&header,4,1,fp2);
if(ftell(fp)==44) break;
}
fseek(fp2,4,SEEK_SET);
fwrite(&newchunksize,4,1,fp2);
fseek(fp2,24,SEEK_SET);
fwrite(&newsamplingrate,4,1,fp2);
fseek(fp2,40,SEEK_SET);
fwrite(&newsubchunk2size,4,1,fp2);
//fclose(fp2);
//fclose(fp);
//printf("Suc\n");
}
Down Sampling using Decimation(Without Using Sinc Function):
Code:#include<stdio.h>
void main()
{
FILE *fp,*fp2;
unsigned char down;
int samplingrate,ratio,i=4,chunksize,subchunk2size,newchunksize,newsubchunk2size;
int newsamplingrate;
long int count=1;
//Getting the Sampling Rate from the File
// while(1)
// {
fp=fopen("mono.wav","r");
fseek(fp,24,SEEK_SET);
fread(&samplingrate,4,1,fp);
rewind;
fseek(fp,4,SEEK_SET);
fread(&chunksize,4,1,fp);
rewind;
fseek(fp,40,SEEK_SET);
fread(&subchunk2size,4,1,fp);
//fscanf(fp,"%d",&sample);
//**fprintf(stdout,"samplingrate is %u\n chunksize is : %u\nsubchunk2size is : %u\n",samplingrate,chunksize,subchunk2size);
//count++;
//if(count>44) break;
//}
//printf("The count value is : %ld\n",count-1);
fclose(fp);
//printf("Enter the New Sampling Rate : ");scanf("%d",&newsamplingrate);
newsamplingrate=5000;
if(newsamplingrate<samplingrate)
{
ratio=samplingrate/newsamplingrate;
fp=fopen("song1.wav","r");
fseek(fp,44,SEEK_SET);
while(1)
{
fscanf(fp,"%c",&down);
//fprintf(stdout,"%d\t",down);
count++;
i--;
if(feof(fp)) break;
if(i<1)
{
i=4;
fseek(fp,SEEK_CUR+4*(ratio-1)-1,SEEK_CUR);
}
}
fclose(fp);
count=count/4;
// printf("Count is : %ld\n",count);
newsubchunk2size=chunksize/3;
newchunksize=newsubchunk2size+36;
writeheaderfile(fp,newsamplingrate,newchunksize,newsubchunk2size);
writedatafile(fp,newsamplingrate,newchunksize,newsubchunk2size,ratio);
}
/*if(newsamplingrate>samplingrate)
{
ratio=newsamplingrate/samplingrate;
fp=fopen("song1.wav","r");
fseek(fp,44,SEEK_SET);
newsubchunk2size=chunksize*3;
newchunksize=newsubchunk2size+36;
writeheaderfile(fp,newsamplingrate,newchunksize,newsubchunk2size);
writedataupfile(fp,newsamplingrate,newchunksize,newsubchunk2size,ratio);
}*/
}
//Writing the Header Section
void writeheaderfile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size)
{long int count=1;
unsigned char header;
FILE *fp2;
fp=fopen("mono.wav","r");
fp2=fopen("song2.wav","w+");
//rewind;
while(1)
{
fread(&header,4,1,fp);
//if(ftell(fp)==5) fprintf(fp2,"%c",newchunksize);
//else if(ftell(fp)==17) fprintf(fp2,"%c",newsubchunk2size);
//else if(ftell(fp)==25) fprintf(fp2,"%c",newsamplingrate);
//else fprintf(fp2,"%c",header);
fwrite(&header,4,1,fp2);
if(ftell(fp)==44) {fclose(fp);break;}
}
//fp=fopen("song1.wav","r");
//fp2=fopen("song2.wav","w+");
//rewind(fp2);
fseek(fp2,4,SEEK_SET);
fwrite(&newchunksize,4,1,fp2);//fprintf(fp2,"%c",&newchunksize);
//rewind(fp2);
fseek(fp2,40,SEEK_SET);
fwrite(&newsubchunk2size,4,1,fp2);
//rewind(fp2);
fseek(fp2,24,SEEK_SET);
fwrite(&newsamplingrate,4,1,fp2);
//fclose(fp);
fclose(fp2);
}
//Write data to file
void writedatafile(FILE *fp,int newsamplingrate,int newchunksize,int newsubchunk2size,int ratio)
{unsigned char down;
long int count=1;
int i=4;
FILE *fp2;
fp=fopen("mono.wav","r");
fp2=fopen("song2.wav","a+");
fseek(fp,44,SEEK_SET);
while(1)
{
fscanf(fp,"%c",&down);
fprintf(fp2,"%c",down);
count++;
i--;
if(feof(fp)) break;
if(i<1)
{
i=4;
fseek(fp,SEEK_CUR+4*(ratio-1)-1,SEEK_CUR);
}
}
fclose(fp);
fclose(fp2);
}
Monday, 14 December 2015
Transient Analysis of CMOS NAND gate
Transient analysis if a 2-input CMOS Nand gate is derived in the below pdf have a look at it .
Powered by PdfSR.com
Download DocumentCMOS Buffer Using Two transistors
How to Analyse the Cmos Buffer With Two transistors
- This is one of the most prominent questions that is often asked in technical interviews of any electronics company.
- This circuit seems like it is very simple,but it if you start solving it it will lead to hell.
- In this post I will analyse this circuit and plot the VOUT vs VIN characteristics same as like the CMOS inverter.
- step1:
- Step2:
- Step3:
- Step4:
These Values will give you the input and output values that are being satisfyied by the circuit.
As it is very tuff to say intutively that which transistor will On and which will off for which values of input because those conditions will include the output voltage,I use MATLAB to get these graphs and intersections.
The Matlab Code is given Below:
clc;
clear all;
close all; vdd=5; up=500; un=1500; cox=3.28e-6; wbyl=2; wbylp=6; vtn=0.5;
vtp=-0.5;
vin=0:0.1:5;
vout=0:0.01:5;
lengthofvin=length(vin);
lengthofvout=length(vout);
for j=1:lengthofvin
for i=1:lengthofvout
if (vin(j)-vout(i)) < vtn currentn(j,i)=0;
end
if (vdd-vout(i))>(vin(j)-vout(i)-vtn)&& (vin(j)-vout(i))>=vtn
currentn(j,i)=0.5*un*cox*wbyl*((vin(j)-vout(i)-vtn).^2);
end
if (vdd-vout(i))<=(vin(j)-vout(i)-vtn )&& (vin(j)-vout(i))>=vtn
currentn(j,i)=un*cox*wbyl*(vin(j)-vout(i)-vtn-(vdd-vout(i))./2).*(vdd-vout(i));
end
end
end
for j=1:lengthofvin
for i=1:lengthofvout
if (vout(i)-vin(j)) < abs(vtp)
currentp(j,i)=0;
end
if (vout(i))>(vout(i)-vin(j)-abs(vtp))&& (vout(i)-vin(j))>=abs(vtp)
currentp(j,i)=0.5*up*cox*wbylp*((vout(i)-vin(j)-abs(vtp)).^2);
end
if (vout(i))<=(vout(i)-vin(j)-abs(vtp)) && (vout(i)-vin(j))>=abs(vtp)
currentp(j,i)=up*cox*wbylp*(vout(i)-vin(j)-abs(vtp)-((vout(i))./2))*(vout(i));
end
end
end
hold on; plot(vout,currentp','b');
xlabel('--------->vds');
ylabel('--------->ids');
title('Ids Vs Vds'); plot(vout,currentn','r'); hold off;
for j=1:lengthofvin
count=0;
for i=1:lengthofvout
if currentn(j,i)==currentp(j,i)
newinput(1,j)=vin(j);
if(vout(i)<=abs(vtp))
newoutput(1,j)=abs(vtp);
else if(vout(i)>=vdd-vtn)
newoutput(1,j)=vdd-vtn;
end newoutput(1,j)=vout(i); count=count+1;
if count==1 break;
end
end
end
end
end
for j=1:lengthofvin count=0;
for i=lengthofvout:-1:1
if currentn(j,i)==currentp(j,i)
newoutput1(j,1)=vout(i);
if(vout(i)>=vdd-vtn)
newoutput1(j,1)=vdd-vtn;
end
count=count+1;
if count==1
break;
end
end
end
end
figure; hold on;
plot(newinput,newoutput,'b',newinput,newoutput1,'b');
axis([0 5 0 5]);
xlabel('--------------->vin');
ylabel('--------------->vout');
title('Transfer Characteristics');
- The plot of the above MATLAB code will look something like give below:
So in the graph you can see that the intersection of the PMOS and NMOS curves for a particular value of VGS are the input and output voltages that will satisfy this circuit conditions.And from the above plot it is clear that we can see a lot of intersections between the PMOS and NMOS curves .So let us consider the average value of voltage between the first point of intersection and the last point of intersection between the two PMOS and NMOS curves for a particular value of VGS. Then we will get the input versus output characteristics as shown below.But still we have a confusion because we took an average intersection point .
If we take the first intersection point ,then we will get the characteristics like shown below:
Monday, 23 November 2015
WaterFlow Model of CommonSource Amplifier
How Common Source Amplifier Works??
Have a look at the below video
Water Flow Model:
========================
1. Analogies used in the water flow model are as indicated
Valve 1 as Vg1
Valve 2 as Vg2
Source Width as Width
2.For the existing waterflow system as shown the two valve's are used for controlling the water flow, similar to the biasing voltages of an Amplifier.
Valve 1 is used for setting up the maximum distance the water can travel,which is similar to biasing the P MOS using VG1 with which Upper limit in output voltage is set.
3.Valve 2 is used to apply pressure on the waterflow which increases the distance with which water can travel.
Here the maximum distance is analogous to Overdrive voltage which is biased by making use Vg2 of N MOS.
4.Valve 2 is used to release pressure on the waterflow which decreases the distance with which water can travel.
Here the minimum distance is analogous to Overdrive voltage which is biased by making use Vg2 of N MOS.
5.Based on Minimum/Maximum distance travelled we can decide the Distance swing which is similar to the voltage swing.
6. Based on the source width variation we will have the water flow variation , which is analogous to the variation in width ,which varies current ,which varies the Gm and inturn varies the gain of the amplifier.
There at the Input pipe we can see the water flow with its pressure variation which is anologous to the applying a varying input voltage
The output is interms of travel distance variation of water ,which is analogous to the output voltage variations.
========================
1. Analogies used in the water flow model are as indicated
Valve 1 as Vg1
Valve 2 as Vg2
Source Width as Width
2.For the existing waterflow system as shown the two valve's are used for controlling the water flow, similar to the biasing voltages of an Amplifier.
Valve 1 is used for setting up the maximum distance the water can travel,which is similar to biasing the P MOS using VG1 with which Upper limit in output voltage is set.
3.Valve 2 is used to apply pressure on the waterflow which increases the distance with which water can travel.
Here the maximum distance is analogous to Overdrive voltage which is biased by making use Vg2 of N MOS.
4.Valve 2 is used to release pressure on the waterflow which decreases the distance with which water can travel.
Here the minimum distance is analogous to Overdrive voltage which is biased by making use Vg2 of N MOS.
5.Based on Minimum/Maximum distance travelled we can decide the Distance swing which is similar to the voltage swing.
6. Based on the source width variation we will have the water flow variation , which is analogous to the variation in width ,which varies current ,which varies the Gm and inturn varies the gain of the amplifier.
There at the Input pipe we can see the water flow with its pressure variation which is anologous to the applying a varying input voltage
The output is interms of travel distance variation of water ,which is analogous to the output voltage variations.
Total Pageviews
Labels
animation
ARM
ARM programming
Assembly programming
augmentedreality
authentication
Bag of Words
build module
CMOS
Companyprofile
computer vision
Cortex M4
CreaticeAssignment
cross build
Cross Compile
culture
embeddedsystems
Exponential Series
Facts
Fibonacci Series
five stage Pipeline
Floating Point
FPU
graphics
Hacking
Hazards
health
HowStuff
iiitb
imageClassifiaction
india
Innovation
Innovators
interview prep
interviewtips
kernel.img
Kmeans
KNN
LDAP
LDAPS
memory
Motivation
native compilation
natural
opencv
os
Pendrivefix
pipeline
pipelined processor
Projectideas.
protocols
python
raspberry pi
RealtimeCoding
Robotics
security
SIFT
Skill
soc
SURF
Technology
techstuff
tls
tutorials
vlsi
Watershed algorithm
writeback
Copyright ©
Learn Delta X | Powered by Blogger
Design by ManojKiran Eda | Blogger Theme by learndeltax