Saturday, April 28, 2012

How data is stored in CD (Compact Disc) and read back from it?


©2012 Ganti Sree Rajiv

You can’t imagine the world if there are no storage medium like CD/DVD. You put a CD into the CD drive, open some software in your computer, select the files to be stored, and finally click on ‘Burn’. Within minutes, all the data gets copied in CD and you are happy.

But what’s happening behind the scene???

Before knowing about it, it would be better to know the difference between ‘Analog recording’ and ‘Digital recording’ and the way they work, as you will most often encounter these words.

An analog signal continuously varies with time. The most common and best example is an ECG machine. The ECG machine has a sharp pointed pen which is very sensitive and vibrates according to the sound waves coming from your heart. A graph paper is made to move using a small motor, and this sharp pointed pen draws some pattern on this graph as it vibrates which resembles the way your heart beats (with time). This is an analog storage and that wave is called analog wave.



On the other hand, a Digital signal represents ‘Bits’ (in case of binary, these bits are stored as sequence of ‘0’s and ‘1’s) and not a continuous wave. The CD/DVD stores such Digital data.

Digital recording first converts the Analog wave into stream of bits(Digital) and then records these bits. The analog wave can be converted to Digital by using ‘Analog to Digital converter (ADC)’. In order to play back the recorded music, these stored Digital bits are to be converted back to Analog wave. This is done by ‘Digital to Analog converter (DAC)’.

However there are lot of issues practically that, along with the original (intended) signal lot of noise due to surroundings also add up to the wave, which leads to errors in case of digital data. However, we are not discussing about this issue in detail.

How the analog wave is converted to Digital bits?
Let us look at this process in brief.

Let the ‘Red’ colored wave represent the part of the original Analog wave (to show you as example). Now, the first step in converting this analog wave into digital is that it is to be ‘SAMPLED’. In simple terms, the time period(time axis) of analog wave is equally divided (you can see 0-8 in above figure). After dividing the time period(time axis) equally, vertical lines (‘Green’ in color) are drawn from those points, and these vertical lines meets the original analog wave at some points (‘Yellow’ in color).
Now all these YELLOW colored points are connected (you can see a ‘Black’ line connecting these ‘Yellow’ points).

The wave representing these sampled points (we call it here as ‘Representing wave’) looks like this:
As the next step, you can see from the above figure that the whole amplitude of this 'representing wave' is divided equally into what is called as ‘Decision thresholds’. Each of these decision thresholds is given a unique code in binary (0000,0001,0010,0011,0100….). If the representing wave falls in that particular decision threshold region (follow ‘Yellow’ points), then that part of the representing wave is assigned with that code as its equivalent Digital representation. 


(Please note that the binary codes assigned to Decision threshold doesn't necessarily follow a particular fashion. It may be assigned in any way depending on coding mechanism.)

For the above 'representing wave', the equivalent digital representation is therefore: 
0001 0001 0101 0011 0010 0110 0110 0010 0111

So, this is the final digital equivalent binary data of that particular Analog wave which is finally stored in storage medium. 

The ‘Digital to Analog converter (DAC)’ uses the reverse mechanism to reproduce the analog wave back from these digital codes using the same code words of the threshold assigned to ADC.
Looking at this, here comes the definition of one common term, “Sampling rate” defined as Number of samples taken per second.

Note: It is very important that the Analog wave which is reproduced back from Digital codes, must match the original analog wave. If there is lot of difference, then there is no point using this wave anymore. So for the purpose of the analog wave which is reproduced back from the digital codes to accurately/closely represent the original analog wave, it is observed that the sampling rate must be 44,100 samples/second, and the number of decision thresholds is 65,536.

 I’m not going to confuse you anymore about this. This is just the basics showing how an analog wave is converted into Digital (Binary) representation.


What is the Capacity of a CD?
You might have observed mentioned on label of a CD as “74min/700MB”. What does it mean? 
It means that the CD can store a maximum 74 minutes of continuous sound. And in terms of digital data it can store 700MB of data.

But, did you ever think of how this number ‘700MB’ is determined by the CD manufacturer???

Before calculating the CD capacity, let us make a note of some points used in this calculation.
1.       1MB = 1024KB = 1024Bytes = 1024 Bits
2.       As I mentioned above that number of decision thresholds = 65,536 is preferred for the reproduced signal to accurately represent the original analog signal. These 65536 levels are actually represented by 2 Bytes.
3.       Also I mentioned that a sampling rate of 44,100 samples/sec is preferred for the reproduced signal to accurately represent the original analog signal. These 44,100 samples/sec is for 1 Channel. But a CD stores for 2 channels(one for each of the speaker in a speaker system).

Now, we arrive at the calculation of CD capacity:

44100 samples/sec/channel * 2 channels * 2 Bytes (per sample) * 74 minutes * 60 seconds (per minute) = 783,216, 000 bytes which ‘approximately’ equals a number ‘700 MB’. This is how the CD capacity is determined.



Now, coming to our main topic, How data is stored in a CD?

We calculated above that a CD can store approximately 700MB of data.
But looking at a CD, it is just a piece of plastic, and looking at cross-section of CD, it is just 1.2mm thick and 12cm in diameter. So how these 700MB of data stored in such a small device?

As I discussed above, the CD stores digital data (binary 1’s and 0’s). Well, theoretically it is Ok and everyone knows it. But how exactly are these 1’s and 0’s stored in a disc????

As the answer to this question, let us look at the different layers with which the Disc is made.


This image shows the layers of CD-R (CD-R means CD-Recordable, i.e., it is only one time recordable disc). The base is a plastic substrate (injection-molded piece of clear polycarbonate plastic). The layer above it is filled with an organic dye material, and over it a metal layer (usually Aluminum) which is used for reflection. 
When you ask your computer to save your data on disc, it will convert your data into digital bits, and signals the CD-ROM drive to write data accordingly. The CD drive has a laser unit (components of CD drive are discussed below). During recording, the laser present in the CD-ROM drive heats the organic dye layer, which makes a hole (called as ‘pit’). These pits are made according to the Digital binary data sequence which the computer sends. (For example, if binary ‘1’ is received, the laser makes a pit(hole) on the dye layer of the disc, and for binary ‘0’ it doesn’t).


Note: that we sometimes refer the words ‘pits’ and ‘bumps’. This is a very common fact that if you make a hole (pit) on one side of a surface, it means that on the other side of the same surface it resembles a lump (bump).


If you look deep inside the disc at the surface of dye after recording the data, you can find bumps.
The bump is usually 0.5 micron wide, and varies in length depending on the sequence of digital data. (As per the example discussed above, if series of 1’s are sent, then longer will be the length of the bump).

This is in case of a CD-R (only one time recording). But, how this happens in CD-RW (re-writable CD)???
In case of a CD-RW (re-writable) disc, instead of using organic dye layer as in CD-R, a special alloy (containing silver, indium, antimony, tellurium) is used. The CD-RW drive has laser that works with 2 different temperatures (instead of only one temperature as in the case of CD-R drive). These two temperatures are usually 200 degree and 600 degree.
When CD-RW drive has to record data on the CD-RW disc, it sets temperature to 200 degree, and the laser makes pits (bumps) on this alloy, same like before. In case, it has to erase the previous stored data and re-write the data on a disc, then the CD-RW drive first sets the temperature to 600 degrees at which temperature the entire alloy ‘liquefies’ and again upon solidification it loses its previous pattern, which resembles that data is erased. Now, once the data is erased, the CD-RW drive sets the temperature to 200 degree, and the laser again starts making pits on the disc to store new data.



Now comes the question,

How data is read back from CD?
The CD has a single track which is spiral in shape. The bumps (discussed above) are also made along this spiral track

The circling starts from centre (inside) of the disc to the outside.

Before understanding further, let us first look at the components of a CD drive.

The 'disc drive motor' rotates the disc usually at 200-500 revolutions/minute (the speed varies from 200-500 depending on other factors discussed later).
The 'laser unit' focuses on the bumps (working is explained later).
The 'tracking drive and motor' moves this laser unit so that laser unit follows the desired spiral path to read the bumps.

How the CD drive reads data back from Disc??
This mechanism is very interesting. In simple words, you can say the laser searches for presence of bumps along the spiral. This is correct, but let us see in detail how this works:
The laser unit sends a laser light onto the disc. This beam passes through the polycarbonate layer, and suppose if there is a bump(that means some data is stored there), the laser reflects back from that bump and falls exactly on the opto-electronic device, which then gives a logical high voltage (indicating presence of data).






If there is no bump present, then the laser light passes through and falls on the Aluminium layer where it gets reflected.

This time, due to difference in the reflection angle, the reflected laser doesn’t fall anymore on the opto-electronic device, and hence this device gives a logical low voltage (indicating no presence of data).
In this way, the data which is stored in CD is read back as binary (digital form). Now the DAC (Digital to analog converter) converts this back to analog (refer top).


The 'tracking motor' moves the lens unit from centre of the disc to the outer, and the 'disc drive motor' meanwhile rotates the disc, so that laser covers the entire spiral. Don’t get confused. See this illustration video…

As you can see, when the laser unit is at the centre of the CD, the disc motor is rotating the CD fast at high speed of 500 revolutions/minute. When the laser unit comes to outer part of CD, then the disc motor is rotating the CD slowly at around 350 revolutions/minute so as to read all the bumps without missing them.
(Please note that this mechanism is due to the fact that the radius of disc at centre and outer part is not the same).


Some more Information:
1.       Suppose you have stored several songs in a disc and you wish to listen to a particular song. Instead of listening to all songs on the disc until you get the desired one, you would prefer to first display the list of all the songs present, and then you would like to play the desired song. How the CD player does this for you??
For this purpose, in order the laser to be able to move between songs, data indicating the detail of song needs to be encoded into the music telling the drive “where it is” on the disc. This data is called as ‘sub-code data’.
2.       Sometimes there is possibility that a laser may misread the bump, which may change completely the sequence and the output analog wave. In order to make sure this doesn’t happen even if the laser misreads the presence of bump, 'error-correcting codes' are used.
3.       Suppose there is a very large file stored onto disc. The whole data is not stored sequentially. It is stored non-sequentially around one of the disc’s circuits. This is because even if a small error occurs while searching for presence of bump(data), it should not lead to big error as sequence gets disturbed.




©2012 Ganti Sree Rajiv

Monday, April 23, 2012

How the Mobile(Cellular) Communication takes place, and overview of different Generations of technologies


©2012 Ganti Sree Rajiv

These days cell phone has become integral part of daily life. You dial a number, within seconds it connects to the person who is hundreds/thousands of miles away. But within these few seconds, lot of things happen wirelessly to connect you to the destination.

The very first observation: You simply press the mobile number of your friend in your phone and click on the ‘green’ call button. Did you ever think what actually happens inside your mobile phone when you press some buttons (which the cell phone doesn’t actually understand that you pressed digits from 0…9) but connects you to that number?

Here is the answer:

Generally the keypad of the mobile phone is standardized with DTMF (Dual-Tone Multi Frequency) system. It is a standard 4*3 grid (4 rows and 3 columns) of buttons. As you can see from the above diagram, each row and each column in the grid has set to a particular frequency. So when you press telephone number of your friend on this keypad, every single key pressed will produce a pitch(music/sound) consisting of sinusoidal frequencies.

For example the mobile number you pressed starts something like this: 98*******6. The first digit here is 9. So when you press the button 9 on your phone keypad, according to the table above, 2 frequencies are generated by the mobile circuit. 1477 Hz representing the higher frequency and 852 Hz representing the lower frequency. So pressing 9 will result in a pitch (sound) composed of 2 frequencies, the 1477 Hz(higher frequency) and 852 Hz (lower frequency). So, in this way, the mobile transmits signal when you actually press the mobile number of your friend.

This is the case of old landline telephones. But in present day cell phones, you dial the entire phone number, and only when you press the ‘green’ call button, the number gets dialed. So for this, the circuit remembers the pattern that you pressed, and once you accept by pressing the ‘green’ button, the mobile then transmits signals with same principle as above. 

Try this:
(When you press buttons on your keypad, try to hear the sound produced by keeping your mobile near your ear. You can clearly observe the difference in sounds produced when you press different numbers). This is due to the above mentioned principle.

A brief History:
Radio was invented in 1920. During invention of radio only AM (Amplitude Modulation) was used. Later Edwin Armstrong invented FM (Frequency Modulation). Quality of signal is good in FM compared to AM (however there are also many other reasons to go for FM).
The first mobile network available for commercial use is by ‘ANetz’ in Germany in 1958 which used 160 MHz frequency. Then in 1987 came the cordless telephone.
The mobile phone transmits signals in all directions. If the receiver/antenna is in the coverage area then it receives this signal (irrespective of direction).

There are 3 most famous systems: AMPS (introduced in 1983 in chicago), GSM (introduced in Europe), and CDMA (commissioned in America).

For the purpose of study/research to be convenient, the coverage area of a cellular tower was assumed to be Circular, and then divided into small circular areas.

But as you can see, there are lots of gaps left which are not covered with these circular area (blue color) and also there are overlaps in several areas(brown).
So, this was then not used, and currently hexagonal representation is used.

You can now observe that the problem with the circular coverage is now resolved with hexagonal coverage area.

Uplink and Downlink:
These are the 2 common terms that you come across whenever you hear about wireless communication. In simple terms, uplink (uploading) is sending information from mobile to antenna/tower. Downlink (download) is the opposite, which connects antenna/tower to mobile. Seems to be confusing? See the illustration:


Why is the 2nd generation(2G) most successful and is in existence for a long time??
Before knowing about this, it would be better to know the disadvantages of 1st generation(1G) that made us to move to 2G.
1.       Quality of signal(speech) is poor as it is analog.
2.       Coverage area is limited due to FM (which would not have been sufficient for current generation).
3.       Illegal tapping is very easy. (Just take a receiver and keep it in the path of signal source, and you can hear the conversation).
4.       Most importantly, there is no authentication and security.
5.       No Inter operability to other network
6.       No Roaming
7.       Idea to increase Bandwidth, Channels
8.       To bill customers in different ways (outgoing tariff, roaming tariff, SMS tariff, etc).
    
    With all these requirements, then came the most successful 2G systems:  GSM and CDMA.

   GSM (Global System for Mobile):
   GSM is the most successful and is in existence for a long time. 

     This architecture illustrates GSM. When you call a person from your mobile (MS), It transmits signals. These signals are received by the nearest antenna/cellular tower in your coverage area. This antenna/tower is technically called BTS (Base Transceiver Station). Several of such towers (BTS) - all may be from one area or many areas together, are connected to a BSC ( Base station Controller). The number of towers connected to single BSC depends on several factors like geographical area(plain land or hills etc), population in that area etc.

      Several of such BSC’s are then connected to a MSC (Main station controller) and we call it ‘exchange’ as our daily life term. 
      
      The MSC (Main station) is the main centre. It’s main function Is Radio resource allocation (i.e., Frequency allocation). Apart from this, It provides several integrated functions to customers. As you can see from above figure, several functions like HLR, VLC, OMC etc are connected to MSC. Knowing these in detail is not necessary, but I would like to describe in short what they offer.
HLR (Home Location register):  stores the profile of every customer.


VLC (Visiting Location Register): Suppose if you are from some location. You are roaming to another location and you are connected via some other operator. So, in this case, the Main station of your roaming area gets your information via the VLC of your home town Main station.
Ex: When a Aircel customer is in coverage of Airtel when he is in roaming.

OMC (Operator Maintenance Centre), as the name describes it is to handle faults in the network.

Main Station also plays important role in receiving text messages apart from voice call, and sends it to destination customer database. Suppose if the destination person phone is switched off, even then the text message is stored in his database for some amount of time. Within this time if he turns on the mobile, he will receive the message. (Everyone might have experienced this).

GSM uses 890-915 MHz frequency range for Uplink, and 935-960 MHz range for Downlink.



CDMA (Code Division Multiple Access):
CDMA is also one of the most successful 2G system.
The main features of it are: Unlike GSM, same Bandwidth/ channel is used by all customers, and the data is coded in different way and sent through same channel. So in this way, CDMA saves lot of bandwidth. It assigns unique code for every customer. No frequency planning is required for CDMA.
It uses 824-849 MHz for uplink, and 869-894 MHz for downlink.
Even though CDMA seems to be more advantageous, the biggest disadvantage is that as all the information is coded and sent through same channel, there are more chances of getting Jammed. 

     

(Interesting Additional information):

1. 

When you look at cellular tower, you can find that every tower has antennas (whatever might be the shape of antenna) and also very thick wires flowing from top of the tower to bottom. The existence of these antenna means that the cellular tower (BTS) is connected to its BSC by Microwave (wireless) transmission link. The thick wires are also another way of connecting to BSC by optical fiber link (through the ground/earth).

2. Do you know one fact that, every mobile phone searches for signal from the tower for every 46 milli-seconds ???

3. One of the most commonly used methods to enhance coverage area with the currently available small bandwidth is the technique of “Frequency Re-Use”.

The same frequency used in one cluster/coverage area can be also given to another area (black colored in the figure), provided that there is a safe distance between these areas in order not to cause any interference.

4.  Suppose you have both DTH Tv (Direct to Home-satellite Television) and Cable Tv at your home and try watching cricket match. You can see that there will be a small delay and both of them don’t show at same time, even though you are watching the same cricket match. The reason behind that is: even though both DTH operator and Cable operator receive the signal from satellite at same time, after receiving it, the cable tv operator sends this information to you via cable(physical medium) where as DTH operator sends it again via satellite. So DTH signal is delayed compared to Cable Tv as the signal has to travel more distance and hence delayed propagation.

5. Practically the mobile is never in ‘line of sight’ directly with tower. There are several obstacles like huge buildings, reflectors etc which delay the propagation of signal, which is technically termed as ‘Fading’.


Overview about 3G:
Currently we are in the 3G (high speed internet, voice with video, mobile TV, etc) age however 3G is still not widespread in all areas like 2G. The following standards are typically branded as 3G:
1.       EDGE:  same like GPRS (which is used in 2G), but more efficient modulation schemes are used. EDGE is also called as ‘EGPRS’ which is not completely 3G, but often termed as 2.5G which allows data peak rates of 200kbit/sec. 

2. W-CDMA: commonly operated on the 2100 MHz band.

3.   HSPA: is an amalgamation of several upgrades to the original W-CDMA standard and offers speeds of 14.4Mbit/s downlink and 5.76MBit/s uplink.

4. HSDPA+ along with MIMO can provide theoretical peak data rates up to 168 Mbit/s in the downlink and 22 Mbit/s in the uplink.


©2012 Ganti Sree Rajiv












Saturday, April 21, 2012

How music is stored in memory chip and How the Earphones work???

© 2012 Ganti Sree Rajiv

Everyone these days has a pair of earphones plugged into their music player and enjoys the music. When you press ‘Play’ button you start hearing song in your earphones. Did you ever wonder how it actually happens??


The song is actually stored in a tiny memory card. The memory card is a tiny chip which is built with thousands of transistors and capacitors. The transistor and Capacitor is paired to make a ‘memory cell’, which represents a single bit of data. So when the whole memory is considered, there will be array of these memory cells. When the capacitor is charged, it means capacitor has stored binary ‘1’, and if the capacitor is discharged it means capacitor has stored binary ‘0’. The transistor acts as a switch that lets the control circuitry on the memory chip read the capacitor or change its state. However there are different types of memory (Flash Memory http://en.wikipedia.org/wiki/Flash_memory is usually used for music players). The song you store in memory is ‘encoded’ http://en.wikipedia.org/wiki/Code using a specific format (for example, the most common encoding format for audio/songs is MP3 ) and this encoded data bits are then stored in memory.


When you ‘Play’ the music, the encoded data from particular memory location is read, and decoded back and electrical signals are sent out through the earphones Jack (there are different connecting Jack’s depending on the device built, one of them is the 3.5mm Jack).

The earphone/Headphone has 2 speakers which you fit them in your ear. These 2 speakers are independent and are connected to signal wire. These two signal wires come down and are joined below at one point to make one sound cable, that connects to the audio jack. 













This Jack is connected to signal source such as Music player.


The song(actually in form of varying electric signals) flow from the signal source via the Jack to the housing of the earphone. Now this housing has several parts that actually convert these electrical signals into sound waves. The brain then translates these sound waves and so we experience it as Sound/Music.



Working Mechanism: ‘Inside the Earphone
The principle behind it is very simple. Consider you are striking a drum.













When you strike a drum, the outer skin/diaphragm vibrates thereby creating sound waves. The same is the principle of speakers. But it uses something called as ‘Electromagnetism’.

As you can see from the diagram, one end of the speaker has a Diaphragm (a very thin material made of fibre or plastic) which is firmly fixed at top and bottom, which is similar to the outer skin of the Drum. The other smaller end of the speaker has a magnet and a coil placed right in front of the magnet and in between the magnet ends. The wires coming from the source (audio jack of player) are coiled around.
The electric signal comes from the audio jack rotates around this coil, and as this coil is put in a constant magnetic field, this constant magnetic field and changing electric current creates ‘Electromagnetism’. This electromagnetic force either attracts or repels the diaphragm. This force of attraction or repulsion depends on the varying current around the coil as the magnetic force is constant in that field.  The pitch of the sound depends on this vibration of diaphragm.
Thus, the movement of Diaphragm back and forth creates sound waves (just like in case of Drum), and these waves reach your ears.
In order to give the ear/head phones a good look, this speaker part is covered/finished with many other parts.


The mechanism explained above is just basic mechanism which gives clear idea of how it works inside earphones.
However with the advancement of technology, there are many developments in field of sound technology (acoustic technology) and today we can see lot of difference and improvement in quality of sound being produced.
One such famous development is the ‘Noise-Cancellation’.


How Noise Isolation and Noise Cancellation works??
The principle of noise cancellation is pretty simple. It is in principle of physics ‘destructive interference’ that suppose if you consider a periodic wave, and if you add to it another periodic wave equal in amplitude and opposite in phase, they cancel out each other, and result is Zero amplitude wave.


Please note that Noise isolation and Noise cancellation are different.

Noise Isolation is a passive way to isolate external noise. In this case, the earphone has a 'round the ear' pad and a high-density foam to block the sound waves from outside to reach ears.

However the Noise Cancellation uses active method. It uses the above mentioned destructive interference method to cancel noise.


A microphone is placed inside the earphone. When external noise reaches this microphone, the microphone picks up some of this noise randomly and sends it the noise-cancellation circuit. This circuit then analyzes the noise wave pattern, and sends back similar wave (equal in amplitude and opposite in phase). When this wave mixes with original noise wave, according to principle of destructive interference, both waves cancel out each other. So in this way, noise gets cancelled. 


©2012 Ganti Sree Rajiv