Tuesday 31 December 2019

Happy New Year 2020

Happy New Year 2020!






Sending you my warm wishes
from home to home and 
from heart to heart

Have a very very
Happy New Year 2020 !



  Share on Whatsapp  

Friday 27 December 2019

Formation of Y Bus Matrix


FORMATION OF Y BUS MATRIX

PROGRAM:

clc;
n=input('Enter the no. of buses:')
for i=1:n
for j=1:n
if(i==j)
y(i,j)=0;
a(i,j)=0;
else
i
j
z(i,j)=input('Enter the self impedance:');
if(z(i,j)==0)
y(i,j)=z(i,j);
else
y(i,j)=1/z(i,j);
end
a(i,j)=input('Enter the line changing admittance:');
end
end
end
for i=1:n
for j=1:n
if(i==j)
r(i,j)=0;
for k=1:n
                r(i,j)=y(i,k)+a(i,k)+r(i,j);
end
else
r(i,j)=-y(i,j);
end
end
end
disp('The resultant Y-bus is:');
r

C++ Program

#include<iostream.h>
#include<conio.h>
void swap(int *,int * );
void main()
{
int x,y;
clrscr();
cout<<"\n Enter the values of X & Y";
cin>>x>>y;
cout<<"\n Before swapping:";
cout<<"\n Values x="<<x<<"and Y="<<y;
swap(&x,&y);
getch();
}
void swap(int *x,int *y)
{
int m;
m=*x;
*x=*y;
*y=m;
cout<<"\n After swapping:";
cout<<"\n Values x="<<*x<<" and Y="<<*y;
}

Thursday 26 December 2019

DIY Vending Machine Correct Program

DIY VENDING MACHINE


Circuit Diagram:-


Program:-


#include <LiquidCrystal.h> 
#include <Servo.h>
LiquidCrystal lcd(27, 26, 25, 24, 23, 22); 
Servo servo1, servo2, servo3, servo4;   
#define dirPinVertical 0
#define stepPinVertical 1
#define dirPinHorizontal 2
#define stepPinHorizontal 3
#define coinDetector 9
#define button1 13
#define button2 12
#define button3 11
#define button4 10
#define microSwitchV 15
#define microSwitchH 14
int buttonPressed;
void setup() {
  lcd.begin(16, 2);
  servo1.attach(4);
  servo2.attach(5);
  servo3.attach(6);
  servo4.attach(7);
  pinMode(dirPinVertical, OUTPUT);
  pinMode(stepPinVertical, OUTPUT);
  pinMode(dirPinHorizontal, OUTPUT);
  pinMode(stepPinHorizontal, OUTPUT);
  pinMode(coinDetector, INPUT);
  pinMode(button1, INPUT_PULLUP);
  pinMode(button2, INPUT_PULLUP);
  pinMode(button3, INPUT_PULLUP);
  pinMode(button4, INPUT_PULLUP);
  pinMode(microSwitchV, INPUT_PULLUP);
  pinMode(microSwitchH, INPUT_PULLUP);
  digitalWrite(dirPinVertical, HIGH); 
  while (true) {
    if (digitalRead(microSwitchV) == LOW) { 
      moveUp(70);
      break;
    }
    digitalWrite(stepPinVertical, HIGH);
    delayMicroseconds(300);
    digitalWrite(stepPinVertical, LOW);
    delayMicroseconds(300);
  }
  digitalWrite(dirPinHorizontal, LOW);
  while (true) {
    if (digitalRead(microSwitchH) == LOW) {
      moveLeft(350);
      break;
    }
    digitalWrite(stepPinHorizontal, HIGH);
    delayMicroseconds(300);
    digitalWrite(stepPinHorizontal, LOW);
    delayMicroseconds(300);
  }
}
void loop() {
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Insert the coin!");
  while (true) {
    if (digitalRead(coinDetector) == LOW) { 
      break;
    }
  }
  delay(10);
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Select the item you want");
  lcd.setCursor(0, 1);
  lcd.print(" 1, 2, 3 or 4?");
  while (true) {
    if (digitalRead(button1) == LOW) {
      buttonPressed = 1;
      break;
    }
    if (digitalRead(button2) == LOW) {
      buttonPressed = 2;
      break;
    }
    if (digitalRead(button3) == LOW) {
      buttonPressed = 3;
      break;
    }
    if (digitalRead(button4) == LOW) {
      buttonPressed = 4;
      break;
    }
  }
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Please wait");
  switch (buttonPressed) {
    case 1:
      moveUp(4900); 
      delay(200);
      moveLeft(1700); 
      delay(300);
      servo1.writeMicroseconds(2000); 
      delay(950);
      servo1.writeMicroseconds(1500); 
      delay(500);
      moveRight(1700);
      delay(200);
      moveDown(4900);
      break;
    case 2:
      moveUp(4900);
      delay(200);
      servo2.writeMicroseconds(2000); 
      delay(950);
      servo2.writeMicroseconds(1500); 
      delay(500);
      moveDown(4900);
      break;
    case 3:
      moveUp(2200); 
      delay(200);
      moveLeft(1700);
      delay(300);
      servo3.writeMicroseconds(2000); 
      delay(950);
      servo3.writeMicroseconds(1500); 
      delay(500);
      moveRight(1700);
      delay(200);
      moveDown(2200);
      break;
    case 4:
      moveUp(2200); 
      delay(200);
      servo4.writeMicroseconds(2000); 
      delay(950);
      servo4.writeMicroseconds(1500);  
      delay(500);
      moveDown(2200);
      break;
  }
  
  lcd.clear(); 
  lcd.setCursor(0, 0);
  lcd.print("Delivered Sucessfully"); 
  delay(2000);
}
void moveUp (int steps) {
  digitalWrite(dirPinVertical, LOW);
  for (int x = 0; x < steps; x++) {
    digitalWrite(stepPinVertical, HIGH);
    delayMicroseconds(300);
    digitalWrite(stepPinVertical, LOW);
    delayMicroseconds(300);
  }
}
void moveDown (int steps) {
  digitalWrite(dirPinVertical, HIGH);
  for (int x = 0; x < steps; x++) {
    digitalWrite(stepPinVertical, HIGH);
    delayMicroseconds(300);
    digitalWrite(stepPinVertical, LOW);
    delayMicroseconds(300);
  }
}
void moveLeft (int steps) {
  digitalWrite(dirPinHorizontal, HIGH);
  for (int x = 0; x < steps; x++) {
    digitalWrite(stepPinHorizontal, HIGH);
    delayMicroseconds(300);
    digitalWrite(stepPinHorizontal, LOW);
    delayMicroseconds(300);
  }
}
void moveRight (int steps) {
  digitalWrite(dirPinHorizontal, LOW);
  for (int x = 0; x < steps; x++) {
    digitalWrite(stepPinHorizontal, HIGH);
    delayMicroseconds(300);
    digitalWrite(stepPinHorizontal, LOW);
    delayMicroseconds(300);
  }
}

Thursday 19 December 2019

Economic Load Dispatch In Power System Without Considering Losses Using Direct Method


ECONOMIC LOAD DISPATCH IN POWER SYSTEM WITHOUT CONSIDERING LOSSES USING DIRECT METHOD 

PROGRAM:

clc;
clear all;
warning off;
a=[.001562;.00194;.00482];
b=[7.92;7.85;7.97];
c=[561;310;78];
pd=850;
pgmin=[150;100;50];
pgmax=[600;400;200];
noofunits=length(a);
delp=10;
lambda=(pd+sum(b./(2*a)))/sum(ones(length(a),1)./(2*a));
lambda;
p=(lambda-b)./(2*a);
for i=1:noofunits
if p(i)>pgmax(i)
if lambda>((2*a(i)*pgmax(i))+b(i))
p(i)=pgmax(i);
end
else if p(i)<pgmin(i)
if lambda<((2*a(i)*pgmax(i))+b(i))
p(i)=pgmin(i);
end
end
end
end
p


Economic Load Dispatch In Power System With Considering Losses Using Direct Method

ECONOMIC LOAD DISPATCH IN POWER SYSTEM WITH CONSIDERING LOSSES USING DIRECT METHOD

PROGRAM:

clc;
clear all;
warning off;
a=[.658;.586;.789];
b=[5.3;5.5;5.8];
c=[500;400;200];
pd=800;
delp=10;
noofunits=length(a)
lambda=input('enter estimated value of lam=');
fprintf('\n')
disp(['lambda p1 p2 p3 delta data lambda'])
iter=0;
while abs(delp)>=0.001
iter=iter+1;
    p=(lambda-b)./(2*a);
delp=pd-sum(p);
    j=sum(ones(length(a),1)./(2*a));
delambda=delp/j;
disp([lambda,p(1),p(2),p(3),delp,delambda])
lambda=lambda+delambda;
end
lambda
p
totalcost=sum(c+b.*p+a.*p.^2)







Electromagnetic Transients in Power System


ELECTRO MAGNETIC TRANSIENTS IN POWER SYSTEM


PROGRAM:
clc;
clear all;
l=1.58e-3;
irms=7000;
c=.0028e-6;
x1=2*3.14*50*l;
v1=irms*x1*1.414*1e-3;
slc=sqrt(1*c);
t1=0e-6:.1e-6:10e-6
v2=v1*(1-cos(t1/slc))
plot(t1,v2,'r-')
xlabel('time(sec)');
ylabel('voltage(v)');
title('etps');
k1=sqrt(3);
k2=1.5;
k3=1;
ary=k1*k2*k3*v1
rv=1
mrv=v1*2
t=3.14*slc;
rrrv=mrv/t




Transient and Small Signal Stability Analysis


TRANSIENT AND SMALL SIGNAL STABILITY ANALYSIS
PROGRAM:

clear all
clc
E=1.2056;V=1.1;H=4.5;X=0.65;
pm=1.7;D=0.138;fo=50;
pmax=E*V/X
do=asin(pm/pmax)
ps=pmax*cos(do)
Wn=sqrt(pi*60/(H*ps))
Z=D/2*sqrt(pi*60/(H*ps))
Wd=Wn*sqrt(1-Z^2)
Fd=Wd/(2*pi)
Tau=1/(Z*Wn)
Th=acos(Z)
Ddo=10*pi/180
t=0:.01:3;
Dd=Ddo/sqrt(1-Z^2)*exp(-Z*Wn*t).*sin(Wd*t+Th);
d=(do+Dd)*180*pi;
DW=-Wn*Ddo/sqrt(1-Z^2)*exp(-Z*Wn*t).*sin(Wd*t);
f=fo+DW/(2*pi);
subplot(2,1,1),plot(t,d),grid
xlabel('tsec'),ylabel('delta deg')
subplot(2,1,2),plot(t,f),grid
xlabel('tsec'),ylabel('freqhz')
subplot(111)


Transient Stability Analysis of Single Machine Power System


TRANSIENT STABILITY ANALYSIS OF SINGLE MACHINE POWER SYSTEM

PROGRAM:

clc;
clear all;
t=0;
tf=0;
tfinal=0.5;
tc=0.625;
tstep=0.05;
m=2.52/(180*50);
i=2;
delta=21.64*pi/180;
ddelta=0;
time(1)=0;
angle(1)=21.64;
pm=0.9;
pmaxbf=2.44;
pmaxdf=0.88;
pmaxaf=2.00;
while t<tfinal
if(t==tf)
paminus=0.9-pmaxbf*sin(delta);
paplus=0.9-pmaxdf*sin(delta);
paav=(paminus+paplus)/2;
pa=paav;
end
if(t==tc)
paminus=0.9-pmaxdf*sin(delta);
paplus=0.9-pmaxaf*sin(delta);
paav=(paminus+paplus)/2;
pa=paav;
end
if(t>tf&t<tc)
pa-pm-pmaxdf*sin(delta);
end
if(t>tc)
end
t,pa
ddelta=ddelta+(tstep*tstep*pa/m);
delta=(delta*180/pi+ddelta)*pi/180;
deltadeg=delta*180/pi;
    t=t+tstep;
time(i)=t;
ang(i)=deltadeg;
ang(i)=deltadeg;
    i=i+1;
end
axis([0 0.6 0 160])
plot(time,ang,'ko-')








google-site-verification: google18ae80885fc3d876.html