This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Sunday 9 June 2013

SPEED CONTROLLER FOR AC MOTORS






THIS circuit is used to control brightness of mains lights and the speed of AC motors. It
uses a triac, diac and has a radio-frequency interference
(RFI) noise suppression circuit built into it as well.

Caution: this Kit connects directly to mains power supply.
You must know what you are doing as mains voltages can
be lethal. The board must be put in a suitable enclosed box
before using.

The kit is constructed on a single-sided printed circuit
board (PCB). Protel Autotrax and Schematic were used to
design the board.

ASSEMBLY INSTRUCTIONS

It is generally best to add the lowest height components to
the board first; the resistors. Make sure to get the triac in
the correct way - the metal back of the triac goes in
above the bar marked on the overlay. The diac looks like
a glass diode but it has a mark around the centre, not at
one end. The choke (wire wound ferrite coil) can be
soldered in either way around.

CIRCUIT DESCRIPTION


This is a standard text-book circuit. A triac may be
considered as two SCR's (Silicon Controlled Rectifiers
connected in opposite directions. A diac is a gate trigger
device. Triacs, diacs & SCR's are different types of
Thyristors.
A triac is a 3 terminal ac semiconductor switch which is
triggered ON when a low energy signal is applied to its
Gate. Switching is fast. The low energy of switching
means that a wide range of low cost control circuits can
be used, for example, optically coupled switches. Since
the triac is bilateral (2 SCR's connected in opposite
directions) the terms anode and cathode have no meaning.
So the terms Main Terminal 1 and 2 (MT1, MT2) are
used. It is standard to use MT1 as a reference
point.
The circuit here controls the average power to a load
through the triac by phase control. The ac supply is
applied to the load for only a controlled fraction of each
cycle. The triac is held in an OFF condition for a portion
of its cycle then is triggered ON at a time determined by
the circuit. The main problem with this circuit is radio
frequency interference (RFI.)
RFI. Each time the triac is turned on the load current
changes very quickly - a few micro seconds - from zero to
a value determined by the lamp resistance and the value
of the mains voltage at that instant in time. This transition
generates RFI. It is greatest when the triac is triggered at
90o and least when it is triggered at close to zero or 180o
of the mains AC waveform.
Since there may be long lengths of mains wire between
the triac and the lamp load which will radiate this RFI an
L-C RFI suppression network is usually built into these
types of circuits. You may detect this RFI by bringing an
FM radio close to the dimmer circuit. Short out the choke
coil and notice that the RFI increases. The wire-wound
coil and C1 provide the RFI suppression network.

WHAT TO DO IF IT DOES NOT WORK


Poor soldering is the most likely reason that the circuit
does not work. Check all solder joints carefully under a
good light. Next check that all components are in their
correct position on the PCB.

WORKING OF THE CIRCUIT:


 In this circuit, the traic uses the property of phase control and thus controls the average


power supplied to a load. The ac power is supplied to the load for only a controlled time

frame of each AC cycle.

 Triac is actually a three terminal device, which is triggered on when a positive or negative

current passes through its gate terminal. The triac remains in an OFF condition for a portion

of AC cycle  then is turned ON (triggered on by diac) for a time period determined by

the circuit. The triac turns on when the diac starts conduction. The diac is turned on when the

voltage reaches the break over voltage i.e. VBO. Diode then starts conduction and allows

current toward the gate of triac. When the voltage changes to below VBO the diac is off, so it

turns off the triac too. Diac mostly operates at low voltages, its VBO is usually around 30 V.

                       There is also a problem with this circuit, which is Radio Frequency

Interference or RFI. This RFI generates in a way that when the triac is turned on, each time

in a cycle, the current to the load changes very quickly i.e. in a few microseconds it goes

from zero to a certain value determined by the resistance of load and the mains line voltage at

that time. This sudden change causes RFI to generate.

This interference is highest when the traic triggers at 90o of the AC wave, and is lowest when

it triggers at 0o or 180o of the AC wave cycle.

This RFI factor can be neglected if there are long lengths of wires between triac and the load

Saturday 16 March 2013

MATLAB PROJECT , DIGITAL FUEL STATION


                        Matlab Project 
                 
 Digital Fuel Station
 by students of HITEC University

DESCRIPTION : THIS PROJECT DESCRIBES WORKING OF A DIGITAL FUEL STATION , CONTAINING 3 TYPES OF FUELS (DIESEL, GASOLINE , C-N-G).
FIRST OF ALL THE SELLER FEEDS INTO THE SYSTEM, THE AMOUNT OF FUELS AND CURRENT PRICES OF THE FUELS. THE SELLER USES HIS OWN PASSWORD TO DO THIS
AFTER THAT IT TELLS SYSTEMATICALLY TO EVERY CUSTOMER, THAT HOW TO CHOOSE FUEL AND AMOUNT REQUIRED BY THEM . THE CUSTOMER CAN CHOOSE FUEL AND AFTER FILLING IT SHOWS TOTAL COST.
AT THE END OF SALE IT GIVES US DIFFERENT GRAPHS OF FUEL SALE COMPARISON, PROFIT COMPARISON , COMPARISON OF FUELS LEFT , QUANTITY OF FUELS SOLD , AMOUNT EARNED COMPARISON . ALL OF THEM ARE DISPLAYED BY THE SYSTEM IN THE FORM OF GRAPHS  , AS WELL AS DIGITALLY. 
THANKS AND BEST OF LUCK :)  

clear all
clc
a1=input('Total Weight Of CNG  in compressor = '); % TOTAL C-N-G IN COMPRESSOR
a2=input('Total liters Of petrol in storage tank = ');% TOTAL PETROL STORED IN TANK
a3=input('Total liters of Diesel in storage tank = ');% TOTAL DIESEL STORED IN TANK
 
b1=input('Purchase price of CNG='); % price for which fuel is purchased
b2=input('Purchase price of Petrol=');% price for which fuel is purchased
b3=input('purchase price of Diesel=');% price for which fuel is purchased
 
 
w=0; %  varibles saved for assigning values from line # 12 upto line # 63
w1=0;
w2=0;
q=0;
q1=0;
q2=0;
 
q4=0;
q5=0;
q6=0;
q7=0;
q8=0;
q9=0;
 
 
 
u=0;
c=0;
c1=0;
c2=0;
c3=0;
c4=0;
c5=0;
d1=0;
d2=0;
d3=0;
l=0;
s=0;
y=0;
x1=a1;
x2=a2;
x3=a3;
 
e1=0;
e2=0;
e3=0;
e=0;
f=0;
f1=0;
f2=0;
y=0;
y1=0;
y2=0;
l=0;
l1=0;
l2=0;
r=0;
r1=0;
r2=0;
s=0;
s1=0;
s2=0;
 
p=input('Please enter Password to change prices = '); % PASSWORD FOR STARTING FUEL STATION EVERY DAY
if p==123;
    disp('.........initializing syndrome..."PHANTOM PROTOCOL"')
a=input('Fixed price of CNG='); % price fixed by station for selling C-N-G
d=input('Fixed price of Petrol=');% price fixed by station for selling PETROL
i=input('Fixed price of Diesel=');% price fixed by station for selling DIESEL
 
 
while 1
o=input('Enter 1 for CNG , 2 for Petrol & 3 for Diesel='); % ENTER OPTIONS FOR DESIRED FUEL INPUT
 
if o==999;
    break
end
 
if o==1
    
       
    
    while 1
        if x1>=0&&x1<1||c>x1||r>x1;
            break
        end
        b=input('Options enter 1 for PRICE &  2 for WEIGHT ='); % select option whether to input the weight or input the price
    if isempty(b)
        break
    end
        if b==1;
            r=0;
            f=0;
          e=input('paid amount in PKR =');% AMOUNT PAID BY CUSTOMER TO PURCHASE C-N-G
          c=e/a;
          
          if c>a1
              disp('CNG not available')% CAPACITY IN COMPRESSOR IS LESSER THAN DEMAND
              c=0;
              break
          end
          if c>x1
               disp('CNG not available')% CAPACITY IN COMPRESSOR IS LESSER THAN DEMAND
               c=0;
              break
          end
          disp(['sold weight of C-N-G in KG= ',num2str(c)]) % C-N-G sold by station     
          
          a=a+0;
          disp(['Price of C-N-G/kg=',num2str(a)])% fixed price of C-N-G is displayed with each purchase
 
          y1=y1+1;
          
      else
         if b==2;
             c=0;
             e=0;
            r=input('Required weight of CNG in Kg =');% C-N-G required by customer in Kilograms
            if r>a1
                disp('CNG not available')% CAPACITY IN COMPRESSOR IS LESSER THAN DEMAND
                r=0;
                break
            end
                if r>x1
                    disp('CNG not available')% CAPACITY IN COMPRESSOR IS LESSER THAN DEMAND
                    r=0;
                    break
                end
 
            f=r.*a;
            disp([' Price of CNG in RS=',num2str(f)])% Amount to be paid by customer for purchasing C-N-G
            a=a+0;
            disp(['Price of CNG/kg=',num2str(a)])% fixed price of C-N-G is displayed with each purchase
            y2=y2+1; 
         else
             disp('program not installed')% DISPLAY FOR WRONG INPUT
         end
        end
        
        q7=e+f;
        w=w+q7;
    
    q4=c+r;
    q=q+q4;
    
    x1=a1-q;
    if x1>=0&&x1<1;
        break
    end
   
    
    y=y1+y2;
    disp(['Total Numbers of CNG customers= ',num2str(y)])% TOTAL CUSTOMERS CALCULATED FOR C-N-G FUEL
    end
end
if o==2;
    
        while 1
            if x2>=0&&x2<1||c1>x2||r1>x2
                break
            else
            b=input('Options enter 1 for PRICE &  2 for Liter ='); % select option whether to input in liters or input for price
            if isempty(b)
                break
            end
                if b==1;
                    r1=0;
                    f1=0;
                   e1=input('Paid amount in PKR =');% AMOUNT PAID BY CUSTOMER TO PURCHASE PETROL
                   c1=e1/d;
                   
                   if c1>a2
                       disp('Petrol not available')% CAPACITY IN STORAGE TANK IS LESSER THAN DEMAND
                       c1=0;
                       break
                   end
                   if c1>x2
                       disp('Petrol not available')% CAPACITY IN STORAGE TANK   IS LESSER THAN DEMAND
                       c1=0;
                       break
                   end
                   disp(['Sold petrol in liters=',num2str(c1)])% AMOUNT OF PETROL SOLD IN liters
                   d=d+0;
                   disp(['Price of Petrol/liter=',num2str(d)])% fixed price of PETROL is displayed with each purchase
                   l1=l1+1;
                end
                if b==2
                    e1=0;
                    c1=0;
                    r1=input('Required liters of Petrol=');% REQUIRED liters OF PETROL BY CUSTOMER
                    if r1>a2
                        disp('Petrol not available')% CAPACITY IN STORAGE TANK  IS LESSER THAN DEMAND
                        r1=0;
                        break
                    end
                    if r1>x2
                        disp('Petrol is not available')% CAPACITY IN STORAGE TANK  IS LESSER THAN DEMAND
                        r1=0;
                        break
                    end
                    f1=r1.*d;
                    disp(['Price of Petrol in RS=' ,num2str(f1)])% Amount to be paid by customer for purchasing PETROL
                    d=d+0;
                    disp(['Price of Petrol/Liter=' ,num2str(d)])% fixed price of PETROL is displayed with each purchase
                    l2=l2+1;
                end
        q8=e1+f1;
        w1=w1+q8;
        
        q5=c1+r1;
        q1=q1+q5;
        
         l=l1+l2;
        disp(['Total Numbers of Petrol Customers= ', num2str(l)])% TOTAL CUSTOMERS CALCULATED FOR  FUEL
        x2=a2-q1;
        
        if x2>=0&&x2<1
            break
        end
        
       
            end
        end
end
if o==3
    
        while 1
            if x3>=0&&x3<1||c2>x3||r2>x3
                break
            end
            b=input('Options enter 1 for PRICE &  2 for liters ='); % select option whether to input in liters or input for price
            if isempty(b)
                break
            end
                if b==1;
                    r2=0;
                    f2=0;
                   e2=input('Paid amount in PKR = ');% AMOUNT PAID BY CUSTOMER TO PURCHASE DIESEL
                   c2=e2/i;
                   
                   if c2>a3
                       disp('Diesel not available')% CAPACITY IN STORAGE TANK   IS LESSER THAN DEMAND
                       c2=0;
                   end
                   if c2>x3
                       disp('Diesel not available')% CAPACITY IN STORAGE TANK   IS LESSER THAN DEMAND
                       c2=0;
                       break
                   end
                   disp(['Sold diesel in liter = ',num2str(c2)])
                   i=i+0;
                   disp(['Price of diesel/Liter = ',num2str(a)])% fixed price of DIESEL is displayed with each purchase
                  s1=s1+1;
                end
                if b==2
                    e2=0;
                    c2=0;
                    r2=input('Required Liter of diesel = ');% REQUIRED liters OF DIESEL BY CUSTOMER
                    if r2>a3
                        r2=0;
                        disp('Diesel not available')% CAPACITY IN STORAGE TANK   IS LESSER THAN DEMAND
                        break
                    end
                    if r2>x3
                        disp('Diesel not availble')% CAPACITY IN STORAGE TANK   IS LESSER THAN DEMAND
                        r2=0;
                        break
                    end
                    f2=r2.*i;
                    disp(['Price of diesel in PKR = ' ,num2str(f2)])% AMOUNT OF DIESEL SOLD IN liters
                    i=i+0;
                    disp(['Price of diesel/Liter = ' ,num2str(i)])% fixed price of DIESEL is displayed with each purchase
                    s2=s2+1;
                end
        q9=e2+f2;
        w2=w2+q9;
        
        q6=c2+r2;
        q2=q2+q6;
        
        x3=a3-q2;
        if x3>=0&&x3<1
            break
        end
        
s=s1+s2;
disp(['Total Numbers of Diesel Customers= ', num2str(s)])% TOTAL CUSTOMERS OF DIESEL
        end
end
 
 
end
else
    disp(' WARNING.....suspected Insurgency......"SYSTEM SHUT DOWN"')% IN CASE OF ENTERING WRONG PASSWORD
end
 
w=w+0;
disp(['Total Amount of CNG sale in PKR = ',num2str(w)])%Amount of CNG sale in PKR
w1=w1+0;
disp(['Total Amount of Petrol sale in PKR = ',num2str(w1)])%Amount of Petrol sale in PKR 
w2=w2+0;
disp(['Total Amount of Diesel sale in PKR = ',num2str(w2)])%Amount of Diesel sale in PKR
 
q=q+0;
disp(['Total Weight of CNG sold = ',num2str(q)])%Total Weight of CNG sold
q1=q1+0;
disp(['Total liters of Petrol sold = ',num2str(q1)]) %Total liters of Petrol sold
q2=q2+0;
disp(['Total liters of Diesel sold = ',num2str(q2)])%Total liters of Diesel sold
 
x1=x1+0;
disp(['CNG left in kg= ',num2str(x1)])%C-N-G left in kg
x2=x2+0;
disp(['Petrol left in liters= ',num2str(x2)])%Petrol left in liters
x3=x3+0;
disp(['Diesel left in liters= ',num2str(x3)])%Diesel left in liters
 
u=l+s+y;
disp(['Total Customers of HD Pump  ', num2str(u)])%Total Customers of Station
 
c3=q.*b1;
d1=w-c3;
disp([' Profit earned On CNG= ',num2str(d1)])%Profit earned On C-N-G
 
c4=q1.*b2;
d2=w1-c4;
disp(['Profit earned On Petrol= ',num2str(d2)])%Profit earned On Petrol
 
c5=q2.*b3;
d3=w2-c5;
disp(['Profit earned On Diesel= ',num2str(d3)])%Profit earned On Diesel
 
figure(1);
hold on
title('Profits earned on C-N-G vs PETROL vs DIESEL')
xlabel('Profit earned on C-N-G (green), Petrol (red) , Diesel (black) ');
ylabel(' Profit earned on each FUEL ')
tango=2;
bar(tango,d1,'green');%GRAPH OF PROFIT EARNED ON C-N-G
axis auto
tango2=4;
bar(tango2,d2,'red');%GRAPH OF PROFIT EARNED ON PETROL
axis auto
tango3=6;
bar(tango3,d3,'black');%GRAPH OF PROFIT EARNED ON DIESEL
axis auto
hold off
 
figure(2);
hold on
title('COMPARISON OF EACH FUEL LEFT IN STATION')
xlabel('C-N-G left (blue), Petrol left (black) , Diesel left (yellow) ');
ylabel(' FUEL left in storage tanks ')
charlie=2;
bar(charlie,x1,'blue');%GRAPH OF LEFT WEIGHT OF C-N-G
axis auto
charlie2=4;
bar(charlie2,x2,'black');%GRAPH OF LEFT liters OF PETROL
axis auto
charlie3=6;
bar(charlie3,x3,'yellow');%GRAPH OF LEFT liters OF DIESEL
axis auto
hold off
 
figure(3);
hold on
title('COMPARISON OF AMOUNTS OF FUELS SOLD')
xlabel('C-N-G amount (black), Petrol amount (cyan) , Diesel amount (green) ');
ylabel(' Amount of fuels sale in PKR ')
delta=2;
bar(delta,w,'black');%GRAPH OF TOTAL AMOUNT OF C-N-G SALE
axis auto
delta2=4;
bar(delta2,w1,'cyan');%GRAPH OF TOTAL AMOUNT OF PETROL SALE
axis auto
delta3=6;
bar(delta3,w2,'green');%GRAPH OF TOTAL AMOUNT OF DIESEL SALE
axis auto
hold off
 
 
figure(4);
hold on
title('COMPARISON OF QUANTITIES OF FUELS SOLD')
xlabel('C-N-G in kg , Petrol in liters  , Diesel in liters ');
ylabel(' FUEL sale in liters ')
alpha=2;
bar(alpha,q,'blue');%GRAPH OF WEIGHT OF C-N-G SALE
axis auto
alpha2=4;
bar(alpha2,q1,'blue');%GRAPH OF liters OF PETROL SALE
axis auto
alpha3=6;
bar(alpha3,q2,'blue');%GRAPH OF liters OF DIESEL SALE
axis auto
hold off
 
figure(5);
hold on
title('COMPARISON OF CUSTOMERS OF EACH FUEL')
xlabel('C-N-G customers (black) , Petrol customers (red)  , Diesel customers (green) ');
ylabel(' COMPARISON OF CUSTOMERS ')
bravo=2;
bar(bravo,l,'black');%GRAPH OF TOTAL C-N-G CUSTOMERS
axis auto
bravo2=4;
bar(bravo2,s,'red');%GRAPH OF TOTAL PETROL CUSTOMERS
axis auto
bravo3=6;
bar(bravo3,y,'green');%GRAPH OF TOTAL DIESEL CUSTOMERS
axis auto
hold off

( ALL RIGHTS RESERVED WITH THE PUBLISHER)

 THIS PROJECT IS FOR SEMESTER 1 . YOU CAN ASK QUESTIONS ABOUT ANY DIFFICULTY OR PROBLEM YOU ARE FACING. 
ANY SUGGESTION AND COMMENTS WOULD BE WELCOMED :)
GROUP MEMBERS : MALIK HAMMAD UD DIN , MUHAMMAD DANIYAL , SYED ADNAN SHAH
 HITEC UNIVERSITY TAXILA CANTT .

Thursday 14 March 2013

SIMPLE DIGITAL CLOCK


                                 SIMPLE DIGITAL CLOCK   using 

                      8051 micro-controller AT-89-C-51



 A digital clock is one that displays time digitally. The circuit explained here displays time with two ‘minutes’ digits and two ‘seconds’ digits on four seven segment displays. The seven segment and switches are interfaced with 8051 micro controller AT89C51. This circuit can be used in cars, houses, offices etc.

DESCRIBTION:
 As soon as the Vcc supply is provided to this circuit, the clock starts from 00:00. The time is displayed on four seven segments (in common anode configuration) by using the concept of multiplexing. This is achieved by using timer interrupt (Timer0) of AT89C51 

which is configured to refresh seven segments. The segments are refreshed many times in a second for simultaneous display. The clock runs with a delay of exactly one second. Timer1 has been used to produce a time delay of one second. The data pins (a–h) of all the segments are interconnected and receive signal from port P2 of the micro controller. The control or enable pins (common anode) are connected to pins 1-4 of port P1 (P1^0 – P1^3).
The number on 4th segment (displaying the unit digit of second) is incremented once in a second as it goes from 0 to 9. The number on 3rd segment is incremented after every 10 seconds from 0 to 5. Thus seconds are displayed varying from 00 to 59. The digit on the 2nd segment changes after every 60 seconds (a minute) from 0 to 9 and so on. Thus the clock runs for an hour and after that it resets to zero again



 

 
CODE: 


// Program to demonstrate the principle of digital clock. this digital clock displays two minute digits and two second digits

#include<reg51.h>
sbit dig_ctrl_4=P1^0;        //Declaring control pins of the seven segments
sbit dig_ctrl_3=P1^1;
sbit dig_ctrl_2=P1^2;
sbit dig_ctrl_1=P1^3;
unsigned char dig_disp=0;
int min2;
int min1;
int sec2;
int sec1;
char digi_val[10]={0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10};

void delay()        //Function to provide a time delay of approx. 1 second. using Timer 1.
{
    int i;
    for(i=0;i<20;i++)
    {
        TL1=0xFD;
         TH1=0x4B;
         TR1=1;
         while(TF1==0);
         TR1=0;
         TF1=0;
    }
}

void display() interrupt 1        //Function to display the number using seven segmnet multiplexing. For more details refer seven segment multiplexing.
{
    TL0=0x36;        //Reloading Timer0
    TH0=0xf6;
    P2=0xFF;
    dig_ctrl_1 = dig_ctrl_3 = dig_ctrl_2 = dig_ctrl_4 = 0;
    dig_disp++;
    dig_disp=dig_disp%4;
    switch(dig_disp)
    {
        case 0:
        P2=digi_val[sec1];
        dig_ctrl_1 = 1;
        break;
  
        case 1:
        P2=    digi_val[sec2];
        dig_ctrl_2 = 1;
        break;
  
        case 2:
        P2=    digi_val[min1];
        dig_ctrl_3 = 1;
        break;
  
        case 3:
        P2=    digi_val[min2];
        dig_ctrl_4 = 1;
        break;
    }
}

void main()
{
    TMOD=0x11;        //Intialize Timer 0
    TL0=0x36;
    TH0=0xF6;
    IE=0x82;        // Enable Timer 0 interrupt
    TR0=1;        //Start Timer 0
    while(1)        //Start clock
    {
          min2=min1=sec2=sec1=0;
          for(min2=0;min2<6;min2++)
          {
               for(min1=0;min1<10;min1++)
               {
                for(sec2=0;sec2<6;sec2++)
                {
                     for(sec1=0;sec1<10;sec1++)
                     {
                        delay();
                    }
                }
               }
          }
     }


   components:
Transistor BC547 
AT89C51 Microcontroller 
Seven Segment Display