In this tutorial, we will use Android Studio to show notifications

We start by creating a new Android studio project

Then you can copy and paste this xml to your layout

This code is a simple linear layout with two buttons, one for showing toast and the other for showing notification in the notification bar.

Now let's look at the java code
This code is simple too.
We are identifying the buttons with their id, then we are adding onClickListner to them.
The toast button just is easy, you are using Toast class, calling makeText method, passing to it the context, the string you want to show and the time of it to stay, there is two options for the time Toast.LENGTH_SHORT for short period and Toast.LENGTH_LONG for long periods

The other buttons makes a notification with a notification builder, Notification Builder takes a context, then you call setSmallIcon, setTitleText and setContentText to form the shape of the notification.
Last thing to do is adding intent to it, this must be pending intent, so you can just make an intent to pass it to a pending intent which you have to pass to the method setContentIntent.
The notification Builder is ready so we are making a reference to the notification manager then calling it to notify with our notification after it is built.

Good luck with coding.
Demos App [Link to be Added] have a show of some working Android examples Implemented with Android Studio (You can see This[Link] video to see how to download and install it)

This is List of lessons describing how to implement them

Microprocessor is an IC which has only the CPU inside them i.e. only the processing powers such as Intel’s Pentium 1,2,3,4, core 2 duo, i3, i5 etc. These microprocessors don’t have RAM, ROM, and other peripheral on the chip. A system designer has to add them externally to make them functional. Application of microprocessor includes Desktop PC’s, Laptops, notepads etc.
But this is not the case with Microcontrollers. Microcontroller has a CPU, in addition with a fixed amount of RAM, ROM and other peripherals all embedded on a single chip. At times it is also termed as a mini computer or a computer on a single chip. Today different manufacturers produce microcontrollers with a wide range of features available in different versions. Some manufacturers are ATMEL, Microchip, TI, Freescale, Philips, Motorola etc.

Microcontrollers are designed to perform specific tasks. Specific means applications where the relationship of input and output is defined. Depending on the input, some processing needs to be done and output is delivered. For example, keyboards, mouse, washing machine, digicam, pendrive, remote, microwave, cars, bikes, telephone, mobiles, watches, etc. Since the applications are very specific, they need small resources like RAM, ROM, I/O ports etc and hence can be embedded on a single chip. This in turn reduces the size and the cost.
If you finished lesson1 Here[link], You have the tools you need to start.
This lesson we will start coding.

## Create Project

Open Eclipse, Then go to File>New>JavaProject

You will find a window asking you for some information to create the project
Enter the project name, Edit the path if you need and press finish

Close the welcome screen if it is still there, here we are done.
You have two folders in the project folder
JRE System Library that contains all libraries needed (check the past lesson), anyway we are not going to touch this folder.
src is the folder contains all the code files we are going to create.
Let's go next.

## Hello World

Right-click on the src folder, then choose New>Class
In the window appears you have to set the name of the package and the name of the class.
The package is a unique name identifies a group of classes, Interfaces(we will know that thing soon) and more.
Classes can easily treat with other classed in the same package, Packages can be treated as libraries later so think in as good friends now.
Because the program will start running from this class we will check the box of public static void main.
Let us discuss what was that and go on.

## Basic Rules

In Java, each application has an entry point, or a starting point, which is a method called main.
If you are c/c++ programmer so you know the syntax, it's the same.
• In Java, every line of code that can actually run needs to be inside a class.
• Every line ends with(;) (semicolon) - Never forget it.
• Anything outside the {} will not run unless we told the program to run it.
• Any line starts with // will not be compiled or executed.
Don't be confused, we will run some code it's okay.

## Hello World Runs

Inside the public static void main(string[] args){} write this line:
System.out.println("Hello World");
Press run (green small icon with white arrow) and see the console in the bottom prints what we wrote inside the "".

## Main method

To run our program, the main method must be identical to this signature:
public static void main(string[] args)
public: anyone can access it
static: method can be run without creating an instance of the class containing the main method
void: method doesn't return any value
main: the name of the method.

## Input and Output

System.out is used to produce an output (usually to the console), system.in is used to get input for the program.

## Code of this tutorial

The code in this lesson is in tutorial001 folder.
All codes of tutorial should be available here[link]

See you next time.
I'm going to produce a serious of articles to give a clear and good introduction to java and android.
This is the first one of the Java for Android serious where we are going to know what is java and explore the tools we will need to learn it.

## What is Java?

 Cup of Java

The word java is a noun, In dictionary can be defined as Coffee, for example, "I'm dying for a cup of java".
But when we say JAVA we mean a general-purpose computer programming language designed to produce programs that will run on any computer system.

## The JAVA Language

Like any programming language, the Java language has its own structure, syntax rules, and programming paradigm. The Java language's programming paradigm is based on the concept of OOP, which the language's features support.
The Java language is a C-language derivative, so its syntax rules look much like C's. For example, code blocks are modularized into methods and delimited by braces ({ and }), and variables are declared before they are used.
Structurally, the Java language starts with packages. A package is the Java language's namespace mechanism. Within packages are classes, and within classes are methods, variables, constants, and more.
You don't understand what that means? It's okay only C/C++ programmers can, That won't affect your understanding through the tutorials here or any other place.

## The Java Compiler

When you program for the Java platform, you write source code in .java files and then compile them. The compiler checks your code against the language's syntax rules, then writes out bytecode in .class files. Bytecode is a set of instructions targeted to run on a Java virtual machine (JVM). In adding this level of abstraction, the Java compiler differs from other language compilers, which write out instructions suitable for the CPU chipset the program will run on.

## The JVM

At runtime, the JVM reads and interprets .class files and executes the program's instructions on the native hardware platform for which the JVM was written. The JVM interprets the bytecode just as a CPU would interpret assembly-language instructions. The difference is that the JVM is a piece of software written specifically for a particular platform. The JVM is the heart of the Java language's "write once, run anywhere" principle. Your code can run on any chipset for which a suitable JVM implementation is available. JVMs are available for major platforms like Linux and Windows, and subsets of the Java language have been implemented in JVMs for mobile phones and hobbyist chips.

## The JAVA Development Kit (JDK)

When you download a Java Development Kit (JDK), you get — in addition to the compiler and other tools — a complete class library of prebuilt utilities that help you accomplish most common application development tasks.

Enough Talking, We need Just to run it.
Okay Sorry, We are about to start now, Ready? I know you are excited.

## Install JDK

We will show you how to install it for Windows, If you are using different Operating System things are different.
2. Agree to the license terms.
You can just follow this video

## Install Eclipse

We have the tools java need it to run on our device, but we don't have the IDE (Integrated Development Environment) we need to write the code and use for debugging and optimising our programs.
Throw this tutorial we are going to use Eclipse but, You are free to use any other IDE if you want.
2. Click Eclipse IDE for Java Developers.
4. Click the mirror you want to download from; then, save the file to your hard drive.
5. Extract the contents of the .zip file to a location on your hard drive that you'll be able to remember easily
This video shows you how I did it

## Setup Eclipse

The Eclipse IDE sits atop the JDK as a useful abstraction, but it still needs to access the JDK and its various tools. Before you can use Eclipse to write Java code, you must tell it where the JDK is located.
To set up your Eclipse development environment:

1. Launch Eclipse by double-clicking eclipse.exe
2. The Workspace Launcher opens, allowing you to choose a root folder for your Eclipse projects. Use a folder you can easily remember, such as C:\home\workspace.
3. Close the Welcome to Eclipse window.
4. Click Window > Preferences > Java > Installed JREs.
5. Eclipse points to an installed JRE. You must use the JRE that you downloaded with the JDK. If Eclipse does not automatically detect the JDK you installed, click Add..., and in the next dialogue box, clickStandard VM and then click Next.
6. Specify the JDK's home directory (such as C:\home\jdk1.8.0_60 on Windows), and then click Finish.
7. Confirm that the JDK that you want to use is selected and click OK.

You also can see this small video

Okay now everything is ready, you need to explore the IDE? go and play with it a little.
Are you afraid you make something wrong? Don't be for two reasons:

• You don't have to be very careful when you explore something, We learn from problems so go and make some problems and I'm sure you can solve them.
• You can easily restore the view of the IDE by clicking Window > Perspective > Reset Perspective.
Next, we will make our first java project - get it here[link].
I usually Suggest my followers on social media accounts to learn some techniques to improve their code readability.

One day I found a lot of students think that git or any version control software is not useful, what a surprise for me!!

## What is version control?

According to Wikipedia,
A component of software configuration management, version control, also known as revision control or source control, is the management of changes to documents, computer programs, large web sites, and other collections of information.

So normally version control is the process of keeping track of code changes along the time.

## What is git?

According to Wikipedia,
Git (/ɡɪt/) is a version control system (VCS) that is used for software development and other version control tasks. As a distributed revision control system it is aimed at speed, data integrity, and support for distributed, non-linear workflows.

Okay, git is just a software and we can't judge it as anything more than this.

## Why Github not just sharing with the cloud?

Let us make something clear here, I'm not saying that Github or any git hosting website is better than any other one.
So sharing using any cloud like Drive, Dropbox or 4shared ... etc.
You really have many many options here, I use Github and Bitbucket but, I don't recommend a specific one, use just what you want.
But, using git hosting website allows you to easily push and pop your edits immediately.

Using git software itself is the purpose, That gives you many benefits and power to track code changes and bugs sources, It's hard at the beginning but once you spend time with it, you have full control on your project code.

## How to learn it?

You can go here [link] for reading introduction tutorial Or try this 3 weeks only free course produced by Udacity here [here]

Good luck
Second Order System

# Introduction

Second order equations has the formula g(s)=wn2s(s+2wn), where wn and ζare the parameters of the system.
There is also two other important parameters that we have to consider, the good news they are functions of the above two parameters.
wd = wn1-2, =wn
In this report we will discuss the effect of changing these parameters on step response of the system, Bode diagram and margin of the system.

## Changing

In order to study the effect of changing sigma we will use matlab script to do all the mathematical work.
When using wd=1and =0.5, 1, 5.
The graph for step response is following
Also the bode diagram is as following
And the margins ….
And of-course the code written to obtain these rsults …..
% Get the start and end time from the user and the number of points in time
tg = input('Enter the initial and final times(eg. [1 10]):_');
nt = input('Enter the number of time points nt(eg. 100):_');

% Making time vector
tt = linspace(tg(1), tg(2), nt);

% Repeat above for frequency(w)
wg = input('Enter the frequency range(eg. [0.01 100]):_');
nw = input('Enter the number of frequency points nt(eg. 100):_');
w = logspace(log10(wg(1)), log10(wg(2)), nw); % w vector

%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
%                                                                         %
%      Step Response and bode diagrame for fixed wd and variable sigma    %
%                                                                         %
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%

% Read the wd and number of segments
wd = input('Enter the fixed value of wd rad/sec (eg. 1):_');
nseg = input('Enter the number of segments (eg. 3):_');

% Open and clear (if opened) 3 figure windows
figure(1); clf reset; figure(2); clf reset; figure(3); clf reset;

% Loop number of segments
for jnseg=1:nseg
% Get segma from the user
str = sprintf('Please Enter the Value number %g of segma(eg. 0.5, 1, 5):_', jnseg);
seg = input(str);

% Calculate wn and theta
wn = sqrt(seg^2 + wd^2);
theta = seg/wn;

% Store values in vectors
wns(jnseg)=wn; wds(jnseg)=wd; thetas(jnseg)=theta; segs(jnseg)=seg;

% Create the system open and closed loop
numinator = wn^2; dominator = [1 2*seg 0];
olSys = tf(numinator, dominator);
clSys = minreal(olSys/(1+olSys));

% Relative stability (gain margin, phase margin, gain crossover, phase crossover)
[gm, pm, wgc, wpc] = margin(olSys);
pc = rlocus(olSys);

% Step response and Bode
yt = step(clSys, tt);
[mag, phase] = bode(clSys, w);

% Extract needed part of mag and phase
for jj=1:nw
m(jj) = mag(:,:,jj);
p(jj) = phase(:,:,jj);
end
mag = m'; phase = p';

% Draw the step response
figure(1);
plot(tt, yt);
hold on;
title(sprintf('Step response for closed loop system with fixed wd=%g', wd));
xlabel('time(sec)'); ylabel('amplitude'); shg; % Pring graph on the top of the screen
gtext(sprintf('-->segma=%g', seg));

% Draw bode diagram
figure(2); subplot(211); semilogx(w, 20*log10(mag)); hold on;
title(sprintf('the magnitude for C.L. analog system with fixed wd=%g', wd));
xlabel('log w'); ylabel('Magnitude db'); shg;
gtext(sprintf('-->segma=%g', seg));

figure(2); subplot(212); semilogx(w, phase); hold on;
title(sprintf('the phase for C.L. analog system with fixed wd=%g', wd));
xlabel('log w'); ylabel('phase deg'); shg;
gtext(sprintf('-->segma=%g', seg));

% Draw the margins
figure(3); margin(olSys); hold on;
end

## After editing the code so that =1, and wd= 0.5, 1, 1.5we now have the following results.

Effect on step response …
Bode diagram …
And margins ….
Finally … the code we were using (it not that big different code).
% Get the start and end time from the user and the number of points in time
tg = input('Enter the initial and final times(eg. [1 10]):_');
nt = input('Enter the number of time points nt(eg. 100):_');

% Making time vector
tt = linspace(tg(1), tg(2), nt);

% Repeat above for frequency(w)
wg = input('Enter the frequency range(eg. [0.01 100]):_');
nw = input('Enter the number of frequency points nt(eg. 100):_');
w = logspace(log10(wg(1)), log10(wg(2)), nw); % w vector

%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
%                                                                         %
%      Step Response and bode diagrame for fixed sigma and variable wd    %
%                                                                         %
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%

% Read the segma and number of wds
seg = input('Enter the fixed value of sigma  (eg. 1):_');
nwd = input('Enter the number of wds (eg. 3):_');

% Open and clear (if opened) 3 figure windows
figure(1); clf reset; figure(2); clf reset; figure(3); clf reset;

% Loop number of wds
for jnwd=1:nwd
% Get wd from the user
str = sprintf('Please Enter the Value number %g of wd rad/sec(eg. 0.5, 1, 5):_', jnwd);
wd = input(str);

% Calculate wn and theta
wn = sqrt(seg^2 + wd^2);
theta = seg/wn;

% Store values in vectors
wns(jnwd)=wn; wds(jnwd)=wd; thetas(jnwd)=theta; segs(jnwd)=seg;

% Create the system open and closed loop
numinator = wn^2; dominator = [1 2*seg 0];
olSys = tf(numinator, dominator);
clSys = minreal(olSys/(1+olSys));

% Relative stability (gain margin, phase margin, gain crossover, phase crossover)
[gm, pm, wgc, wpc] = margin(olSys);
pc = rlocus(olSys);

% Step response and Bode
yt = step(clSys, tt);
[mag, phase] = bode(clSys, w);

% Extract needed part of mag and phase
for jj=1:nw
m(jj) = mag(:,:,jj);
p(jj) = phase(:,:,jj);
end
mag = m'; phase = p';

% Draw the step response
figure(1);
plot(tt, yt);
hold on;
title(sprintf('Step response for closed loop system with fixed segma=%g', seg));
xlabel('time(sec)'); ylabel('amplitude'); shg; % Pring graph on the top of the screen
gtext(sprintf('-->wd=%g', wd));

% Draw bode diagram
figure(2); subplot(211); semilogx(w, 20*log10(mag)); hold on;
title(sprintf('the magnitude for C.L. analog system with fixed segma=%g', seg));
xlabel('log w'); ylabel('Magnitude db'); shg;
gtext(sprintf('-->wd=%g', wd));

figure(2); subplot(212); semilogx(w, phase); hold on;
title(sprintf('the phase for C.L. analog system with fixed segma=%g', seg));
xlabel('log w'); ylabel('phase deg'); shg;
gtext(sprintf('-->wd=%g', wd));

% Draw the margins
figure(3); margin(olSys); hold on;
end

## Now we will see what changing wncauses, we consider =0.707 and wn=0.707, 1.4, 7.07.

The step response is ….
The Bode plot is ….
And the margins are …
And our pretty code …
% Get the start and end time from the user and the number of points in time
tg = input('Enter the initial and final times(eg. [1 10]):_');
nt = input('Enter the number of time points nt(eg. 100):_');

% Making time vector
tt = linspace(tg(1), tg(2), nt);

% Repeat above for frequency(w)
wg = input('Enter the frequency range(eg. [0.01 100]):_');
nw = input('Enter the number of frequency points nt(eg. 100):_');
w = logspace(log10(wg(1)), log10(wg(2)), nw); % w vector

%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
%                                                                         %
%      Step Response and bode diagrame for fixed theta and variable wn    %
%                                                                         %
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%

theta = input('Enter the value of theta (eg. 0.707):_');
nwn = input('Enter the number of wns (eg. 3):_');

% Open and clear (if opened) 3 figure windows
figure(1); clf reset; figure(2); clf reset; figure(3); clf reset;

% Loop number of wns
for jnwn=1:nwn
% Get wn from the user
str = sprintf('Please Enter the Value number %g of wn rad/sec(eg. 0.707, 1.4, 7.07):_', jnwn);
wn = input(str);

% Store values in vectors
wns(jnwn)=wn; thetas(jnwn)=theta;

% Create the system open and closed loop
numinator = wn^2; dominator = [1 2*theta*wn 0];
olSys = tf(numinator, dominator);
clSys = minreal(olSys/(1+olSys));

% Relative stability (gain margin, phase margin, gain crossover, phase crossover)
[gm, pm, wgc, wpc] = margin(olSys);
pc = rlocus(olSys);

% Step response and Bode
yt = step(clSys, tt);
[mag, phase] = bode(clSys, w);

% Extract needed part of mag and phase
for jj=1:nw
m(jj) = mag(:,:,jj);
p(jj) = phase(:,:,jj);
end
mag = m'; phase = p';

% Draw the step response
figure(1);
plot(tt, yt);
hold on;
title(sprintf('Step response for closed loop system with fixed theta=%g', theta));
xlabel('time(sec)'); ylabel('amplitude'); shg; % Pring graph on the top of the screen
gtext(sprintf('-->wn=%g', wn));

% Draw bode diagram
figure(2); subplot(211); semilogx(w, 20*log10(mag)); hold on;
title(sprintf('the magnitude for C.L. analog system with fixed theta=%g', theta));
xlabel('log w'); ylabel('Magnitude db'); shg;
gtext(sprintf('-->wn=%g', wn));

figure(2); subplot(212); semilogx(w, phase); hold on;
title(sprintf('the phase for C.L. analog system with fixed theta=%g', theta));
xlabel('log w'); ylabel('phase deg'); shg;
gtext(sprintf('-->wn=%g', wn));

% Draw the margins
figure(3); margin(olSys); hold on;
end

## Changing

Finally we will see the effect of changing , considering wn=1.414 and =0.866, 0.707, 0.5.
The step response is like following ….
The Bode plot ….
And the margins for sure ….
Finally the code used to obtain results (pattern must be very clear now)...
% Get the start and end time from the user and the number of points in time
tg = input('Enter the initial and final times(eg. [1 10]):_');
nt = input('Enter the number of time points nt(eg. 100):_');

% Making time vector
tt = linspace(tg(1), tg(2), nt);

% Repeat above for frequency(w)
wg = input('Enter the frequency range(eg. [0.01 100]):_');
nw = input('Enter the number of frequency points nt(eg. 100):_');
w = logspace(log10(wg(1)), log10(wg(2)), nw); % w vector

%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%
%                                                                         %
%      Step Response and bode diagrame for fixed wn and variable theta    %
%                                                                         %
%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++%

wn = input('Enter the value of wn (eg. 1.414):_');
ntheta = input('Enter the number of thetas (eg. 3):_');

% Open and clear (if opened) 3 figure windows
figure(1); clf reset; figure(2); clf reset; figure(3); clf reset;

% Loop number of thetas
for jntheta=1:ntheta
% Get theta from the user
str = sprintf('Please Enter the Value number %g of theta (eg. 0.866, 0.707, 0.5):_', jntheta);
theta = input(str);

% Store values in vectors
wns(jntheta)=wn; thetas(jntheta)=theta;

% Create the system open and closed loop
numinator = wn^2; dominator = [1 2*theta*wn 0];
olSys = tf(numinator, dominator);
clSys = minreal(olSys/(1+olSys));

% Relative stability (gain margin, phase margin, gain crossover, phase crossover)
[gm, pm, wgc, wpc] = margin(olSys);
pc = rlocus(olSys);

% Step response and Bode
yt = step(clSys, tt);
[mag, phase] = bode(clSys, w);

% Extract needed part of mag and phase
for jj=1:nw
m(jj) = mag(:,:,jj);
p(jj) = phase(:,:,jj);
end
mag = m'; phase = p';

% Draw the step response
figure(1);
plot(tt, yt);
hold on;
title(sprintf('Step response for closed loop system with fixed wn=%g', wn));
xlabel('time(sec)'); ylabel('amplitude'); shg; % Pring graph on the top of the screen
gtext(sprintf('-->theta=%g', theta));

% Draw bode diagram
figure(2); subplot(211); semilogx(w, 20*log10(mag)); hold on;
title(sprintf('the magnitude for C.L. analog system with fixed wn=%g', wn));
xlabel('log w'); ylabel('Magnitude db'); shg;
gtext(sprintf('-->theta=%g', theta));

figure(2); subplot(212); semilogx(w, phase); hold on;
title(sprintf('the phase for C.L. analog system with fixed wn=%g', wn));
xlabel('log w'); ylabel('phase deg'); shg;
gtext(sprintf('-->theta=%g', theta));

% Draw the margins
figure(3); margin(olSys); hold on;
end

### Conclusion

It looks like resonance peak is inverse proportional to , as well as POS, so Mr POS.
It also looks like BW 1Tr, Actually  BW = 0.35 / Tr

Where wnis inverse proportional to rise time so, wnTr.