Tuesday, October 16, 2012

How Bikes work



The understanding of the different Bike mechanism is an important aspect for a rider to be more familiar with the bike and get adjusting to the different aspect of the Bike.

Lets Look at the different mechanism of a Bike :
1. Working of Engine and Valve :

The are two types of engine commonly used in Motorbikes. They are Two Stroke Engine and Four stroke Engine.

Both the Engines comes under the banner of “Internal Combustion (IC) Engine”. In the two stroke engine, the working cycle is completed in two strokes of tyhe piston or one revolution of the crankshaft. This is achieved by carrying out the suction and compression processes in one stroke (or more precisely in inward stroke), expansion and exhaust prrocess in the second stroke (or more precisely in outward stroke).

In a four stroke engine, the working cycle is completed in four strokes of the piston or two revolutions of the crankshaft. This is achieved by carrying out suction, compression, expansion and exhaust processes in each stroke. The four stroke Petrol Engine Cycle also known as Otto Cycle requires four strokes of operation in the engine cylinder. The four strokes of a petrol engine sucking fuel-air mixture (petrol mixed with proportionate quantity of air in the carburettor known as charge) are described below.

    * Suction or Charge Stroke : In this stroke, the inlet valve opens and pure air is sucked into the cylinder as piston moves downwards from the Top dead centre (TDC). It continues till the piston reaches its Bottom dead centre (BDC).
    * Compression Stroke : In this stroke, both the valves are closed and the air is compressed as the piston moves upwards from the BDC to TDC. As a result of compression, pressure and temperature of the air increases considerably. This compleytes one revolution of the crank shaft.
    * Expansion or Working Stroke : Shortly after the piston reaches the TDC (during the compression stroke), fuel oil is injected in the form of very fine spray into the engine cylinder, through the nozzle, known as fuel injection valve. At this moment, temperature of the compressed air is sufficiently high to ignite the fuel. It suddenly increases the pressure and temperature of the products of combustion. The fuel oil continuously injected for a fraction of the revolution. The fuel oil is assumed to be burnt at constant pressure. Due to increased pressure, the piston is pushed down with a great force. The hot burnt gases expand due to high speed of the piston. During this expansion, some of the heat energy is transformed into mechanical work. It may be noted that during this working stroke, both the valves are closed and the piston moves from TDC to BDC.
    * Exhaust Stroke : In this stroke, the exhaust valve is open as the piston moves from BDC to TDC. This movement of the piston pushes out the products of the combustion from the engine cylinder through the exhaust valve into the atmosphere. Thjis completes the cycle and the engine cylinder is ready to suck the fresh air again.

It will be interesting to know that from the thermodynamic point of view, there is no difference between two-stroke and four-stroke cycle engine. The difference is purely mechanical.

Today all the major IC Engines of the world are running on the four stroke cycle.
2. The Transmission :
The engine converts the explosive energy to mechanical energy, through the reciprocating motion to rotary motion. The power developed from rotary motion is controlled by various systems in a bike. This system is known as the Transmission.The Transmission consists of the clutch, gear-box & final-drive chain all the way upto the to driving wheel.

The clutch is a very important “Link” in the transmission of the bike. Its primary use is to allow the rider to engage and disengage the engine from the wheels. It also takes up most of the load and vibrations from the engine and does not allow it to pass onto the rest of the transmission.

After the clutch comes the gear-box. As the name suggests, a box having set of gears. It allows the rider to use the optimum amount of power from the engine as and how required. The main function of the gear-box is to reduce strain on the engine by supplying efficient power at required time. For Instance, the first gear is lowest and most sensitive gear, which helps in moving of a stationary bike without putting excessive load on the engine. On the other hand use of second gear requires relatively more acceleration and gives more strain on the engine and clutch. A lower gear serves two purposes. They serve as brake and also improve acceleration when required. For instance, while going downhill on a lower gear provides “Braking Power” and during uphill provides extra power.

The power transmission is by means of two chains. The primary chain is enclosed in the clutch case on the L.H.S. of the bike and runs in an oil-bath. The final or drive chain connects the gear-box to the drive-sprocket of the rear wheel. The drive-sprocket is coupled with the brake drum, which in turn is fit into the rear hub. There are 4 rubber blocks fitted between the drive-sprocket/brake-drum and the hub of the rear wheel, which act as efficient dampers, absorbing practically all the shocks of power and transmission units and have a very favorable influence on the life of chain as well as vital engine parts.

3. The Electricals :
The main components of an electrical system in the bike are the Battery, Alternator/Dynamo/ Generator/Magneto and Ignition/High-Tension Coil(s). The main function of the system is to provide ignition in the form of a spark to the compressed air+fuel mixture in the cylinder. A battery provides either 6 volts or 12 volts current. But a voltage thousands times higher is needed to create a spark from the spark plug, which can ignite the air+fuel mixture. It’s the high tension coil (Ignition coil) which boosts low voltage current of the battery and provides upto 30,000 volts to the spark plug. A small spark is generated at the distributor, which is converted to a high voltage current, which flows to the spark plug and finally ignites the air+fuel mixture. A contact breaker and rotor, inside the distributor, ensure correct sequence of current to the plug while a condenser attached to the contact breaker serves as a capacitor that minimizes the damage to the contact breaker.Another part, which is at the heart of the electrical system is the Alternator/Dynamo/Generator/ Magneto. This provides a charge to the battery by generating a current. As the generator output increases with the engine speed a control unit (Cut-out/Regulator) is provided to regulate the output. This unit prevents the damage to the generator unit and protects the battery from over charging/discharging. The stored energy of battery is used for different purposes such as: ignition, horn, lights etc….

To retain the standard energy of the battery it needs periodical maintenance like check up of specific gravity, cleaning of terminals, applying a thin film of petroleum jelly or pure Vaseline (not grease) to keep terminals and connections from corrosion and sulphation etc…
4. Brakes :
There are two different types of brakes used in bikes, namely: Drum Brakes & Disk Brakes.The Drum Brake has an aluminum/steel/iron drum to which the wheel is attached. The drum and wheel rotate together. The brake shoe plate is bolted on to the chassis and inside the drum lie the brake shoes, which have brake liners on them. The brake liners are either riveted or moulded onto the brake shoes.

When the brake pedal is depressed, a cam (placed between the brake shoes) rotates such that the brake shoes move towards the drum. When the brake shoes grip the rotating drum, the rotating wheel locks/stops.

The Disk Brake has a metal disk instead of a drum fitted to the wheel and the calipers are bolted on to the chassis/shock-absorber pipe. The calipers have pistons and brake pads. The disk brake has to be operated hydraulically. The brake fluid and the actuating cylinder (brake-oil sump) are fitted on the handle bar of the bike. When the brake lever is pressed a non return brake valve operates and sends the brake fluids to the caliper and the piston, the caliper operates thereby forcing the brake pads to move towards the disk and produce the friction which allows you to slow down or stop.

The usual arrangement on a good bike is front disk brake and rear drum brake.


5. Suspension System :
The Front suspension consists of a telescopic fork with hydraulic dampers. It is the straight slider type with two cylindrical coil springs. Steel cover tubes protect the suspension elements.The rear suspension operates on a circular path. The pivoted rear swing arm is sprung by two cylindrical coil springs and fitted with hydraulic dampers. The suspension dampers are protected by chromium plated steel covers.

6. The Wheels and Tyres :
The Tyres have two functions. First, they are air-filled cushions that absorb most of the shocks caused by riding on bad roads. Therefore they reduce the effect of the shocks. Second, the tyres grip the road to provide good traction; Good traction enables the bike to accelerate, brake and make turns without skidding.There are two types of tyres available, the inner tube type and the tubeless type.

In the inner tube type tyre, both the tube and tyre are mounted on the rim. The tube is like a hollow rubber doughnut. It is inflated with air after it is installed inside the tyre and the tyre is put on the wheel rim. The inflation causes the tyre to resist any change of shape.

The tubeless type tyre does not have an inner tube. Instead, the tubeless tire is directly mounted on the wheel rim so that the air is retained between the rim and the tyre.

Wednesday, October 10, 2012

LINQ



What is LINQ?
Basically LINQ address the current database development model in the context of Object Oriented Programming Model. If someone wants to develop database application on .Net platform the very simple approach he uses ADO.Net. ADO.Net is serving as middle ware in application and provides complete object oriented wrapper around the database SQL. Developing application in C# and VB.Net so developer must have good knowledge of object oriented concept as well as SQL, so it means developer must be familiar with both technologies to develop an application. If here I can say SQL statements are become part of the C# and VB.Net code so it’s not mistaken in form of LINQ. According to Anders Hejlsberg the chief architect of C#.

             “Microsoft original motivation behind LINQ was to address the impedance mismatch between programming languages and database.”

LINQ has a great power of querying on any source of data, data source could be the collections of objects, database or XML files. We can easily retrieve data from any object that implements the IEnumerable<T> interface. Microsoft basically divides LINQ into three areas and that are give below.

  • LINQ to Object {Queries performed against the in-memory data}
  • LINQ to ADO.Net
    • LINQ to SQL (formerly DLinq) {Queries performed against the relation database only Microsoft SQL Server Supported}
    • LINQ to DataSet {Supports queries by using ADO.NET data sets and data tables}
    • LINQ to Entities {Microsoft ORM solution}
  • LINQ to XML (formerly XLinq) { Queries performed against the XML source}

I hope few above lines increase your concrete knowledge about Microsoft LINQ and now we write some code snippet of LINQ.

1. Code Snippet
int[] nums = new int[] {0,1,2};
var res = from a in nums
             where a < 3
             orderby a
             select a;
foreach(int i in res)
    Console.WriteLine(i);
Output:
0
1
2


All SQL Operates are available in LINQ to Object like Sum Operator in the following code.

2. Code Snippet
int[] nums = new int[] {2,4,6,2};
int result = nums.Sum();
Console.WriteLine(result);

Output:
1
2

One thing that I want to share with you guys is LINQ to Object support querying against any object that inherits from IEnumerable (all .Net collection inherits from IEnumerable interface). LINQ to Object provided main types of Operator Type that are give below.


Operator Types
Operator Name
Aggregation
  • Aggregate
  • Average
  • Count
  • LongCount,
  • Max,
  • Min,
  • Sum
Conversion
  • Cast,
  • OfType,
  • ToArray,
  • ToDictionary,
  • ToList,
  • ToLookup,
  • ToSequence
Element
  • DefaultIfEmpty,
  • ElementAt,
  • ElementAtOrDefault,
  • First,
  • FirstOrDefault,
  • Last,
  • LastOrDefault,
  • Single,
  • SingleOrDefault
Equality
  • EqualAll
Generation
  • Empty,
  • Range,
  • Repeat
Grouping
  • GroupBy
Joining
  • GroupJoin,
  • Join
Ordering
  • OrderBy,
  • ThenBy,
  • OrderByDescending,
  • ThenByDescending,
  • Reverse
Partitioning
  • Skip,
  • SkipWhile,
  •  Take,
  •  TakeWhile
Quantifiers
  • All,
  • Any,
  • Contains
Restriction
  • Where
Selection
  • Select,
  • SelectMany
Set
  • Concat,
  • Distinct,
  • Except,
  • Intersect,
  • Union

To the good use of above operator types I need samle patient class so here it
using System;

public class Patient
{
    // Fields
    private string _name;
    private int _age;
    private string _gender;
    private string _area;
    // Properties
    public string PatientName
    {
        get { return _name; }
        set { _name = value; }
    }

    public string Area
    {
        get { return _area; }
        set { _area = value; }
    }
    public String Gender
    {
        get { return _gender; }
        set { _gender = value; }
    }
    public int Age
    {
        get { return _age; }
        set { _age = value; }
    }
}

Here is my code that intiliaze patients object with following data.

List<Patient> patients = new List<Patient> {
           new Patient { PatientName="Ali Khan", Age=20, Gender="Male" , Area = "Gulshan"},
           new Patient { PatientName="Ahmed Siddiqui", Age=25 ,Gender="Male", Area = "NorthKarachi" },
           new Patient { PatientName="Nida Ali", Age=20, Gender="Female", Area = "NorthNazimabad"},
           new Patient { PatientName="Sana Khan", Age=18, Gender="Female", Area = "NorthNazimabad"},
           new Patient { PatientName="Shahbaz Khan", Age=19, Gender="Male", Area = "Gulshan"},
           new Patient { PatientName="Noman Altaf", Age=19, Gender="Male", Area = "Gulshan"},
           new Patient { PatientName="Uzma Shah", Age=23, Gender="Female", Area = "NorthKarachi"}};

Patient p = new Patient();
        p.Age =33; p.Gender = "male";
        p.PatientName = "Hammad Ali"
        p.Area = "Defence";         
        patients.Add(p);


This code snippet fetch those records whose gender is equal to “Male”. 
   gdView.DataSource = from pa in patients
                        where pa.Gender == "Male"
                        orderby pa.PatientName, pa.Gender, pa.Age
                        select pa;
   gdView.DataBind();

The following code snippet uses the selection operator type, which brings all those records whose age is more than 20 years.
 var mypatient = from pa in patients
                  where pa.Age > 20
                  orderby pa.PatientName, pa.Gender, pa.Age
                  select pa;
       
        foreach(var pp in mypatient)
        {
        Debug.WriteLine(pp.PatientName + " "+ pp.Age + " " +          pp.Gender);
        }
 The following code snippet uses the grouping operator type that group patient data on the bases area. 
var op = from pa in patients
group pa by pa.Area into g
select new {area = g.Key, count = g.Count(), allpatient = g};

 foreach(var g in op)
 {
    Debug.WriteLine(g.count+ "," + g.area);
    foreach(var l in g.allpatient)
     {
       Debug.WriteLine("\t"+l.PatientName);
     }
 }
This code snippet determine the count of those records, which lay in above 20 years. 
int patientCount = (from pa in patients
                    where pa.Age > 20
                    orderby pa.PatientName, pa.Gender, pa.Age
                    select pa).Count();

All the above codes are few example of LINQ to Object technique of LINQ.

Mixed Content: The page at xxx was loaded over HTTPS, but requested an insecure

 Mixed Content: The page at ' https ://www.test.com/signup.aspx' was loaded over HTTPS, but requested an insecure script ' http ...