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.

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 

Metal Detector DIY


                           Metal Detector D.I.Y schematic diagram









The heart of this DIY metal detector circuit is CS209A. The metal detector is build with one 100µH coil. CS209A has one oscillator which forms a LC circuit, the inductance of the coil will change when it is near metal objects.
LED 1 will light and the buzzer turns on when the coil is changing inductance. The setup is easy, VR1 is adjusted (away from any metal objects) so that LED 1 will light and the buzzer sounds on, and then VR1 will be trimmed until led and buzzer are off.

METAL DETECTOR Circuit


                                    METAL DETECTOR Circuit

This circuit detects metal and also magnets. When a magnet is brought close to the 10mH choke, the output frequency changes. 



Saturday 2 March 2013

Rain Alarm


                                      Rain Alarm


                       GIVES BEEP WHEN WATER IS IN CONTACT WITH THE WIRE


      Water is a conductor of electricity. When water is in contact with the probe then there is a flow of current which reaches to the base of Q1. Transistor Q1 is a NPN transistor which conducts. With the conduction of Q1 electron reaches to Q2 which is a PNP transistor .Q2 also conducts and current flows through the speaker. In a speaker there is inductive coil which causes motion in one direction and also produce induce current which is in opposite direction to the flow of current this induce current in the form of pulse flows through a capacitor, resistance and switches off Q1 and relax .this process repeats again and again till probe is in contact with water or we can say there is a oscillation in the circuit thus speaker diaphragm vibrates and gives a tone. Frequency of the circuit depends on the value of Speaker Coil impendence, Capacitor and Resistance Value.




Traffic Light Project


                 Traffic Light Project





This project operates red, amber and green LEDs in the correct sequence for a single UK traffic light. The time taken for the complete red - red & amber - green - amber sequence can be varied from about 7s to about 2½ minutes by adjusting the 1M preset. Some amber LEDs emit light that is almost red so you may prefer to use a yellow LED.



The 555 astable circuit provides clock pulses for the 4017 counter which has ten outputs (Q0 to Q9). Each output becomes high in turn as the clock pulses are received. Appropriate outputs are combined with diodes to supply the amber and green LEDs. The red LED is connected to the ÷10 output which is high for the first 5 counts (Q0-Q4 high), this saves using 5 diodes for red and simplifies the circuit.

Parts Required

  • resistors: 470 ×3, 22k, 100k
  • capacitors: 0.1µF, 1µF 16V radial, 10µF 16V radial
  • diodes: 1N4148 ×6
  • LEDs: red, amber (or yellow), green
  • 1M preset, horizontal
  • 555 timer IC, such as NE555
  • 4017 counter IC
  • DIL sockets for ICs: 8-pin, 16-pin
  • on/off switch
  • battery clip for 9V PP3
  • stripboard: 20 rows × 21 holes

PCB LAY OUT :



CIRCUIT DIAGRAM :