Earth quake


  • Just felt a Earthquake of 6.5 intensity. Some days ago I read that Pakistan is in the most active quake zone. 

          http://www.dawn.com/news/1215636
  • A website for monitoring earthquake is as follows....


  • And here are some precautionary measures....

Kron Reduction using Matlab Code

Kron Reduction
In power system anylasis, kron reduction is a way of reducing buses in Y bus matrix of the power system. It usually used for two reasons
  1.             To remove a bus where current injection is zero to reduce size of matrix thereby effectively making computation easy. Buses with no load or source don't inject currents.
  2.            To use only some buses specific buses instead of whole system to know required voltages only. This way we can get voltages of our interest with less computational power of our computer.

If Y j ,k  is our matrix to be kron reduced and p is number of row and coloum to be reduced then this formula is used to find kron reduced elements.

Matlab Code:
%Author: Muhammad Awais fb/awais12506
%Kron Reduction
%p is row and colum to be removed
%Y is array to be kron reduced

clear all
clc
p=2;
Y=[-16.75i 11.75i 2.5i 2.5i
    11.75i -19.25i 2.5i 5i
    2.5i 2.5i -5.8i 0
    2.5i 5i 0 8.3i];
[row,col]=size(Y);   
Y_new=zeros(row,col);  %Produces 4 by 4 matrixes of zeros

%In this loop all p colum and row is replaced by 0 and other by respective
%value
for k=1 :row
    for l=1 : col
        if k==p || l==p
            Y_new(k,l)=0;
        else 
           Y_new(k,l)=Y(k,l)-((Y(k,p)*Y(p,l))/(Y(p,p)));
           
        end
    end
end
% To remove p row and colum
Y_new(:, p) = [];
Y_new(p, :) = [];
Y_new




Example:

Kron Reduction by calculation

Kron Reduction by our Program:
Y_new =
        0 - 9.5779i        0 + 4.0260i        0 + 5.5519i
        0 + 4.0260i        0 - 5.4753i        0 + 0.6494i
        0 + 5.5519i        0 + 0.6494i        0 + 9.5987i

There was a mistake while entering data so answer was a bit wrong. Mistake is corrected and now also I have written the code in function form ....

MATLAB Code:
%Author: Muhammad Awais fb/awais12506
%Descrption: Function uses Kron Reduction to reomove a column
%Input:Y==> Matrix to be reduced, p==> Row and Colum to be removed
%OutPut: Reduced Matrix
function Y_Reduced=KronReduction(Y,p)
[row,col]=size(Y);
Y_new=zeros(row,col);  %Produces 4 by 4 matrixes of zeros

%In this loop all p colum and row is replaced by 0 and other by respective
%value
for k=1 :row
    for l=1 : col
        if k==p || l==p
            Y_new(k,l)=0;
        else
           Y_new(k,l)=Y(k,l)-((Y(k,p)*Y(p,l))/(Y(p,p)));

        end
    end
end
% To remove p row and colum
Y_new(:, p) = [];
Y_new(p, :) = [];
Y_Reduced=Y_new;
end

Output:


In Search of Water

Imagine you are on a place with no water. What would you do? Obviously, try to find water with all resources possible 'cause its the only way for us to live. The very same principle applies for life. If you want to find life, you will always look for water. In fact water is only trace of life. Life is always present alongside water in one form or other. Why? Actually life may have never begun with out water as scientists think it was water that give essential medium for mixing of organic compounds that results in very simple, uni cellular organisms. And not only this, water also played and important role in evolution of simple life in complex multi cellular life and survival of this life.

Now if we want to discover life outside our planet, we have to stick with this basic principle of water. Mean instead of finding life directly, we search for water. That's what NASA do all the time. They are trying to find life outside the planet earth and they were trying to find water. They sent a lot of non-human missions to mars in order to find life, Yes, the little red planet.




 Recently they sent a well equipped mission named curiosity rover. A non-human, automatic rover full of chemical analytical equipment to study martian surface. And it was not the first of its kind. Actually this was second.

Selfie taken by rover on barren martian surface.
Earlier today, NASA has confirmed that a imaging spectrometer on MRO detected signature of hydrated minerals which is considered most strong evidence of flowing water yet. It was found in different location with temperature of -23 degree Celsius or less and it disappeared in cold times.



recurring slope lineae
These dark, narrow, 100 meter-long streaks called recurring slope lineae flowing downhill on Mars are inferred to have been formed by contemporary flowing water. Recently, planetary scientists detected hydrated salts on these slopes at Hale crater, corroborating their original hypothesis that the streaks are indeed formed by liquid water. The blue color seen upslope of the dark streaks are thought not to be related to their formation, but instead are from the presence of the mineral pyroxene. The image is produced by draping an orthorectified (Infrared-Red-Blue/Green(IRB)) false color image (ESP_030570_1440) on a Digital Terrain Model (DTM) of the same site produced by High Resolution Imaging Science Experiment (University of Arizona). Vertical exaggeration is 1.5.
Credits: NASA/JPL/University of Arizona



“Our quest on Mars has been to ‘follow the water,’ in our search for life in the universe, and now we have convincing science that validates what we’ve long suspected,” said John Grunsfeld, astronaut and associate administrator of NASA’s Science Mission Directorate in Washington. “This is a significant development, as it appears to confirm that water -- albeit briny -- is flowing today on the surface of Mars.”
Although it is strongest evidence but it is not first of its sort. It also found calcium perchlorate, a salt in soil which suggests water presence on Mars. This salt actually lowers temperature of water freezing and water can be found in liquid form at even -125 degree Celsius.

And also in December  last year, Curiosity found burps of methane which might show bacterial action on surface as most of methane on earth is produced by living organisms with waste.

By the way don't think it as marketing scheme for coming science fiction o mars as some people might think ;). 



Although neither water nor any kind on life is yet confirmed on mars but one thing we can say for sure is that mars is not as barren and dried as we 

Sources:

Some basic codes for TM4C123 lauchboard using Energia

A basic blinky code:


ARM Cortex M3, Programming

I am studying a course in university name Microprocessor system. We are using ARM Cortex M3 and evaluation board is TM4C123. This is nice board that can be programmed like Arduino using a software named Energia or as any other common ARM code editor like keil code composer. Here I'll share all the codes and other we will cover. Here is list of some materials.

 Books:

      REQUIRED:
  1.     J. Valvano, Introduction to Embedded Systems: Introduction to ARM CORTEX-M  Microcontrollers, 3rd ed., December 2012.

     References:
  1. 1. J. Yiu, The Definitive Guide to the ARM® Cortex-M3, 2nd edition, 2010.
  2. 2. ARM®v7-M Architecture Reference Manual
    http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.ddi0403c/index.html

Board:

Tiva™ C Series LaunchPad Evaluation Kit
(ACTIVE) EK-TM4C123GXL


What is PATH in environment variables and how to change it

[Windows]

Every process need to do some tasks like to create temporary files, execute some files, store some data etc. Environment variables are set of values that defines default location for these tasks. So whenever a process requires to create a temp file, it looks to environment variable and see the location given by it. 
Environment variables are a set of dynamic named values that can affect the way running processes will behave on a computer. They are part of the environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.[1]

Anroid phone Buttons Dilema

I have a anroid phone, HTC X one. Its very nice mobile and working nice for me. It have 3 physical buttons on the bottom.

Visit of Saritow Spinning Mills Ltd's Power Plant


Visit of Saritow Textile Mills Ltd Power Plant 
Pakistan is facing worst blackouts of the history due to a large difference of production and consumption of power. They are becoming more and more worse with time. These blackouts are specially affecting industries so a lot of industries are installing their own small scale gas or oil fired power plants to meet their energy needs. Although this adds extra cost to purchase and maintain their own plants but still severe black outs encourages and even small industrialists are making their own power plants.
Saritow Spinning Mills Ltd Lahore also has their own 10 MW power plant. Last day I visited this power plant and observe synchronization of plant with WAPDA supply. Here I going to write whatever I have seen.

Arduino UNO as in circuit programmer for AVR

How to use Arduino as AVR programmer
Atmega series Micro controllers  have several benefits like its open source, easy to use, available in a large different types, cheap and most important one, it is easy to begin. It have wide variety of boards available called arduino which are easy to start things. Specially if you are programmer and know a little about electrical then it is a blessing for you. Although it can help you to begin but these are not appropriate for Electrical engineers as they have a lot of essential things skipped or being done under the hood. But still it is of great help if you start with Arduino, so I come with a "cost effective" solution. Yeah! I find out a way to use Arduino programmer to program Atmega Micro controllers. So start with Arduino and slowly switch down to atmega. You don't need a stand alone programmer. So in short, 2 in 1 package.



>> Pre Requisites: Installed WinAVR and compiled hex file of the code
Step 1:
See board configuration. Note Com port number and Programmer.




Step 2:
Choose ArduinoISP from examples and burn it on Arduino.

Step 3:
Connect circuit like this
pin name:    not-mega:         mega(1280 and 2560)
slave reset: 10:               53
MOSI:        11:               51
MISO:        12:               50
SCK:         13:               52


Step 4:
Open command prompt and write AVRdude (It will be already installed if you have installed WinAVR ) otherwise install it and open command prompt and write following command…
avrdude -p m8 -P com11 -c avrisp -b 19200
>> Here after –p is name  of Microcontroller.

Following are atmegas and their name for avrdude command
Valid parts are:
  t10  = ATtiny10        [C:\WinAVR-20100110\bin\avrdude.conf:15443]
  t8   = ATtiny9         [C:\WinAVR-20100110\bin\avrdude.conf:15403]
  t5   = ATtiny5         [C:\WinAVR-20100110\bin\avrdude.conf:15363]
  t4   = ATtiny4         [C:\WinAVR-20100110\bin\avrdude.conf:15323]
  ucr2 = 32UC3A0512      [C:\WinAVR-20100110\bin\avrdude.conf:15302]
  x128a4 = ATXMEGA128A4    [C:\WinAVR-20100110\bin\avrdude.conf:15204]
  x64a4 = ATXMEGA64A4     [C:\WinAVR-20100110\bin\avrdude.conf:15107]
  x32a4 = ATXMEGA32A4     [C:\WinAVR-20100110\bin\avrdude.conf:15010]
  x16a4 = ATXMEGA16A4     [C:\WinAVR-20100110\bin\avrdude.conf:14913]
  x256a3b = ATXMEGA256A3B   [C:\WinAVR-20100110\bin\avrdude.conf:14816]
  x256a3 = ATXMEGA256A3    [C:\WinAVR-20100110\bin\avrdude.conf:14719]
  x192a3 = ATXMEGA192A3    [C:\WinAVR-20100110\bin\avrdude.conf:14622]
  x128a3 = ATXMEGA128A3    [C:\WinAVR-20100110\bin\avrdude.conf:14525]
  x64a3 = ATXMEGA64A3     [C:\WinAVR-20100110\bin\avrdude.conf:14428]
  x256a1 = ATXMEGA256A1    [C:\WinAVR-20100110\bin\avrdude.conf:14331]
  x192a1 = ATXMEGA192A1    [C:\WinAVR-20100110\bin\avrdude.conf:14234]
  x128a1d = ATXMEGA128A1REVD [C:\WinAVR-20100110\bin\avrdude.conf:14137]
  x128a1 = ATXMEGA128A1    [C:\WinAVR-20100110\bin\avrdude.conf:14040]
  x64a1 = ATXMEGA64A1     [C:\WinAVR-20100110\bin\avrdude.conf:13943]
  m6450 = ATMEGA6450      [C:\WinAVR-20100110\bin\avrdude.conf:13754]
  m3250 = ATMEGA3250      [C:\WinAVR-20100110\bin\avrdude.conf:13565]
  m645 = ATMEGA645       [C:\WinAVR-20100110\bin\avrdude.conf:13376]
  m325 = ATMEGA325       [C:\WinAVR-20100110\bin\avrdude.conf:13187]
  usb82 = AT90USB82       [C:\WinAVR-20100110\bin\avrdude.conf:13007]
  usb162 = AT90USB162      [C:\WinAVR-20100110\bin\avrdude.conf:12823]
  usb1287 = AT90USB1287     [C:\WinAVR-20100110\bin\avrdude.conf:12634]
  usb1286 = AT90USB1286     [C:\WinAVR-20100110\bin\avrdude.conf:12445]
  usb647 = AT90USB647      [C:\WinAVR-20100110\bin\avrdude.conf:12257]
  usb646 = AT90USB646      [C:\WinAVR-20100110\bin\avrdude.conf:12068]
  m32u4 = ATmega32U4      [C:\WinAVR-20100110\bin\avrdude.conf:11880]
  t84  = ATtiny84        [C:\WinAVR-20100110\bin\avrdude.conf:11697]
  t44  = ATtiny44        [C:\WinAVR-20100110\bin\avrdude.conf:11515]
  t24  = ATtiny24        [C:\WinAVR-20100110\bin\avrdude.conf:11333]
  m128rfa1 = ATMEGA128RFA1   [C:\WinAVR-20100110\bin\avrdude.conf:11145]
  m2561 = ATMEGA2561      [C:\WinAVR-20100110\bin\avrdude.conf:10951]
  m2560 = ATMEGA2560      [C:\WinAVR-20100110\bin\avrdude.conf:10758]
  m1281 = ATMEGA1281      [C:\WinAVR-20100110\bin\avrdude.conf:10570]
  m1280 = ATMEGA1280      [C:\WinAVR-20100110\bin\avrdude.conf:10381]
  m640 = ATMEGA640       [C:\WinAVR-20100110\bin\avrdude.conf:10193]
  t85  = ATtiny85        [C:\WinAVR-20100110\bin\avrdude.conf:10012]
  t45  = ATtiny45        [C:\WinAVR-20100110\bin\avrdude.conf:9833]
  t25  = ATtiny25        [C:\WinAVR-20100110\bin\avrdude.conf:9653]
  pwm3b = AT90PWM3B       [C:\WinAVR-20100110\bin\avrdude.conf:9472]
  pwm2b = AT90PWM2B       [C:\WinAVR-20100110\bin\avrdude.conf:9289]
  pwm3 = AT90PWM3        [C:\WinAVR-20100110\bin\avrdude.conf:9106]
  pwm2 = AT90PWM2        [C:\WinAVR-20100110\bin\avrdude.conf:8922]
  t2313 = ATtiny2313      [C:\WinAVR-20100110\bin\avrdude.conf:8735]
  m328p = ATMEGA328P      [C:\WinAVR-20100110\bin\avrdude.conf:8547]
  t88  = attiny88        [C:\WinAVR-20100110\bin\avrdude.conf:8361]
  m168 = ATMEGA168       [C:\WinAVR-20100110\bin\avrdude.conf:8173]
  m88  = ATMEGA88        [C:\WinAVR-20100110\bin\avrdude.conf:7987]
  m48  = ATMEGA48        [C:\WinAVR-20100110\bin\avrdude.conf:7800]
  t861 = ATTINY861       [C:\WinAVR-20100110\bin\avrdude.conf:7612]
  t461 = ATTINY461       [C:\WinAVR-20100110\bin\avrdude.conf:7423]
  t261 = ATTINY261       [C:\WinAVR-20100110\bin\avrdude.conf:7234]
  t26  = ATTINY26        [C:\WinAVR-20100110\bin\avrdude.conf:7077]
  m8535 = ATMEGA8535      [C:\WinAVR-20100110\bin\avrdude.conf:6919]
  m8515 = ATMEGA8515      [C:\WinAVR-20100110\bin\avrdude.conf:6761]
  m8   = ATMEGA8         [C:\WinAVR-20100110\bin\avrdude.conf:6600]
  m161 = ATMEGA161       [C:\WinAVR-20100110\bin\avrdude.conf:6460]
  m32  = ATMEGA32        [C:\WinAVR-20100110\bin\avrdude.conf:6285]
  m6490 = ATMEGA6490      [C:\WinAVR-20100110\bin\avrdude.conf:6092]
  m649 = ATMEGA649       [C:\WinAVR-20100110\bin\avrdude.conf:5907]
  m3290p = ATMEGA3290P     [C:\WinAVR-20100110\bin\avrdude.conf:5724]
  m3290 = ATMEGA3290      [C:\WinAVR-20100110\bin\avrdude.conf:5539]
  m329p = ATMEGA329P      [C:\WinAVR-20100110\bin\avrdude.conf:5354]
  m329 = ATMEGA329       [C:\WinAVR-20100110\bin\avrdude.conf:5170]
  m169 = ATMEGA169       [C:\WinAVR-20100110\bin\avrdude.conf:4990]
  m163 = ATMEGA163       [C:\WinAVR-20100110\bin\avrdude.conf:4832]
  m162 = ATMEGA162       [C:\WinAVR-20100110\bin\avrdude.conf:4636]
  m1284p = ATMEGA1284P     [C:\WinAVR-20100110\bin\avrdude.conf:4446]
  m644p = ATMEGA644P      [C:\WinAVR-20100110\bin\avrdude.conf:4254]
  m644 = ATMEGA644       [C:\WinAVR-20100110\bin\avrdude.conf:4064]
  m324p = ATMEGA324P      [C:\WinAVR-20100110\bin\avrdude.conf:3873]
  m164p = ATMEGA164P      [C:\WinAVR-20100110\bin\avrdude.conf:3682]
  m16  = ATMEGA16        [C:\WinAVR-20100110\bin\avrdude.conf:3504]
  c32  = AT90CAN32       [C:\WinAVR-20100110\bin\avrdude.conf:3313]
  c64  = AT90CAN64       [C:\WinAVR-20100110\bin\avrdude.conf:3123]
  c128 = AT90CAN128      [C:\WinAVR-20100110\bin\avrdude.conf:2933]
  m128 = ATMEGA128       [C:\WinAVR-20100110\bin\avrdude.conf:2755]
  m64  = ATMEGA64        [C:\WinAVR-20100110\bin\avrdude.conf:2574]
  m103 = ATMEGA103       [C:\WinAVR-20100110\bin\avrdude.conf:2434]
  8535 = AT90S8535       [C:\WinAVR-20100110\bin\avrdude.conf:2313]
  8515 = AT90S8515       [C:\WinAVR-20100110\bin\avrdude.conf:2199]
  4434 = AT90S4434       [C:\WinAVR-20100110\bin\avrdude.conf:2116]
  4433 = AT90S4433       [C:\WinAVR-20100110\bin\avrdude.conf:1992]
  2343 = AT90S2343       [C:\WinAVR-20100110\bin\avrdude.conf:1868]
  2333 = AT90S2333       [C:\WinAVR-20100110\bin\avrdude.conf:1740]
  2313 = AT90S2313       [C:\WinAVR-20100110\bin\avrdude.conf:1627]
  4414 = AT90S4414       [C:\WinAVR-20100110\bin\avrdude.conf:1514]
  1200 = AT90S1200       [C:\WinAVR-20100110\bin\avrdude.conf:1399]
  t15  = ATtiny15        [C:\WinAVR-20100110\bin\avrdude.conf:1266]
  t13  = ATtiny13        [C:\WinAVR-20100110\bin\avrdude.conf:1093]
  t12  = ATtiny12        [C:\WinAVR-20100110\bin\avrdude.conf:960]
  t11  = ATtiny11        [C:\WinAVR-20100110\bin\avrdude.conf:896]

>> Then after –P  are name of com port on which your Arduino is connected.
>>After –c  is name of compiler which in this case is avrisp or you can also Arduino 

If screen like following appears then it means your Arduino is ready to use like programmer..


Now you can burn your code using following command
$ avrdude -p m8 -P com11 -c avrisp -b 19200 -U flash:w:main.hex


Possible errors:

1)Device signature not found. Once it was 0 ×ffffff which is possibly due to dead chip and another time it was 0 ×00000 possibly due to external or internal oscillator 

A simple Digital CRO (exaggeration)

A simple Digital CRO using Arduino
Idea behind this simple concept is to use Arduino’s serial communication and MATLAB’s serial port function to draw a signal on your computer.  So for generation of signal, I simply use a photo resistor that will vary input voltage according to light incident on it. Arduino code is as below..
Arduino code:
//This code is used to generate a signal and then signal in converted into digital using sampling...
/* Simple Digital CRO using MARTLAB to draw signals. This signal will be sent on com11 pot where MATLAB will read it and plot it..
----------------------------------------------------

           PhotoR     10K
 +5    o---/\/\/--.--/\/\/---o GND
                  |
 Pin 0 o-----------

----------------------------------------------------
*/

int SensorPin = 0;  //define a pin for Photo resistor


void setup()
{
    Serial.begin(9600);  //Begin serial communcation
   
}

void loop()
{
    Serial.println(analogRead(SensorPin)); //Write the value of the photoresistor to the serial monitor.
  
}

MATLAB code:
clear all
clc

arduino=serial('COM11','BaudRate',9600);

fopen(arduino);

x=linspace(1,100);
  
for i=1:length(x)
    y(i)=fscanf(arduino,'%d');
end
   
fclose(arduino);
disp('making plot..')
plot(x,y);

Results:

Some other results:

A servo motor input from controller mapped in simple DCRO
Pulse train


Limitations: 
This is not very precise 'cause we are just using digital pins of ARDUINO, if we use analog pins, and sampling with baud rate of 9600 can give us even more precise output. 

These results were tested when input is no more than 5 volt (Maximum Voltage arduino can bear), if we wanna make it to test for any voltage we need some circuitry to limit current and voltages just as we use in Multi meter. 

Possible errors:


Solution:
Don’t use any device that uses serial pin on which arduino is connected. Like don’t open serial monitor of  ARDUINO IDE like this..
Also take care of  baud rate and  also select correct port both in Arduino IDE and MATLAB code. You  can check port number where arduino is connected using device manger.




Average Monthly energy from solar Insolation for Gujranwala


Estimated Energy Delivered by a 1-kW (dc, STC) PV Array in Gujranwala, Using Average Maximum Monthly Temperatures to Compute Performance Degradation.

Monthly Temperature for Gujranwala:




It was considered that with every increase in 1C temp, dc power decreases by .5%
Month
Insolation
(kWh/m^2-day)
Avg Max
Temp(◦C)
Cell Temp .(◦C)
Array dc
Power
(kW)
Array ac
Power
(kW)
Energy
(kWh/mo)
January
2.6
19.1
52.85
0.86075
0.721377
684.58711
February
3.76
22.1
55.85
0.84575
0.708806
972.76557
March
5.05
27.4
61.15
0.81925
0.686597
1265.57
April
6.01
33.7
67.45
0.78775
0.660198
1448.2423
May
7.13
39
72.75
0.76125
0.637988
1660.3329
June
6.99
40.8
74.55
0.75225
0.630446
1608.4876
July
6.47
36.1
69.85
0.77575
0.650141
1535.3394
August
5.88
34.6
68.35
0.78325
0.656426
1408.8218
September
5.57
35
68.75
0.78125
0.65475
1331.1395
October
4.75
33
66.75
0.79125
0.663131
1149.703
November
3.65
27
60.75
0.82125
0.688273
916.95197
December
2.9
21.2
54.95
0.85025
0.712578
754.2633











Refrences:

Temperature:  http://en.wikipedia.org/wiki/Gujranwala