Archive

Archive for the ‘Computers’ Category

Let’s Build An iPod

July 13th, 2010 Rishabh Dev No comments

(Image Credit)

For a basic idea on whats inside the iPod, how it works and how it is build, let’s try to design our own iPod. Think of the iPod as a computer that is exclusively used to play music. It can further be equipped to add more features like video playback and games.

A Summary

Hardware Needed

  • Microprocessor
  • Hard Drive/Flash Memory
  • Audio Chip
  • Added features like Video Chip(if needed)
  • LCD Display device
  • Rechargeable Li Battery

Software Needed

  • Pixo OS 2.1
  • iTunes
  • iOS(for iPod Touch)

Interface

  • LCD/Touch Screen
  • Click Wheel

A computer works when its got two things-Hardware & Software. The hardware is the CPU-which we would refer to as a microprocessor. A microprocessor performs all the functions of the CPU on a single IC unit. It has a memory-We need RAM to run the various processes and we also need memory to store the data(music files and stuff).

Consider the RAM already chipped on to the microprocessor as microprocessor memory. We got the microprocessor, now we need memory for data storage. (Note-we can also have RAM and flash memory on our microprocessor) We now got two options for memory-

  • A Hard Drive(a highly sensitive one with lots of space)
  • Flash Memory(EEPROM using NAND sequential logic)

We can use flash memory if we need about 1-8 GB memory and for all other purposes, we would go for a hard drive. The iPod Classic & Mini use drives while Nano, Shuffle & Touch use Flash Memory.

So, we now got the microprocessor & memory for data storage. We now need an audio chip that can perform the decoding and encoding of the digital stream of data(we are dealing with digital audio here.) This could also be chipped on to the microprocessor like in iPod Shuffle which uses a SigmaTel chip. So, we now have the following-

  • A Microprocessor-the heart of the iPod
  • An Audio Chip that encodes/decodes audio.
  • Either a hard drive or flash memory for data storage

The other hardware we would require is a display device and a controlling device. For display, we use LCD(Liquid Crystal Display) for most of our purposes except when we need a touch screen. For the controls, we use the Click Wheel.

The click wheel is an interesting part of the iPod. It’s plastic when we look at it. But inside it is a metal channel in the form of a grid. The grid hold charge and acts as a capacitance equivalent. Our fingers act as conductors that vary this capacitance. These capacitance variations are interpreted by a control chip that translates the variations into instructions for the microprocessor.

(Image Credit)

We now add a rechargeable lithium ion battery to supply power to our iPod. Well, we are done with the iPod hardware but to make sense of the hardware, we need a platform or software or host-the Operating System is the host-a bridge between the user and the hardware.

The iPod uses the Pixo OS 2.1(found by Paul Mercer after he left Apple to create his own company-Pixo!). The Pixo OS framework uses C++(if you care).  And as everyone would agree,  iTunes would be our desired jukebox/media player software. Now, we all know about iTunes, don’t we?

7 people like this post.

Popularity: 11% [?]

C++ Tutorial 4 – More on Namespaces

July 10th, 2010 Rishabh Dev No comments

To see an introduction to what namespaces are, go back to tutorial 3. Now, cout is a function in the namespace “std”. Now, there’s another way of using cout without specifying the namespace before hand.

#include<iostream>
int main(
{

a
std::cout<<"Hello Jolly!";
system("pause");
return 0;
}

Here, std::cout means the cout that comes from the std namespace. However, since we would eventually use a large number of output and input statements(ie cout’s and cin’s), we would usually declare the namespace beforehand.

Creating our own namespaces

We can also create our own namespaces. These may contain a number of variables and functions to be used for the particular namespace. We here create a namespace called “my” with a variable of integer type called x.

We will be going into variables and data types in a few tutorials, but here’s ow you create an integer variable called x-

int x;   //creates a variable called x
           //which takes integral values

So, here’s our own namespace-

namespace my{   //creating a namespace
int x;
}
int main()
{
my::x;         //using the namespace variable
}

If we intend to use our variable x a number of times, we could specify our namespace in the program.

using namespace my;  //declare namespace beforehand

3 people like this post.

Popularity: 5% [?]

C++ Tutorial 3 – Basic Program Structure

July 10th, 2010 Rishabh Dev No comments

So here’s our very first program in C++. We’re gonna take a look at it and then see what each line of code means.

#include<iostream>
using namespace std;

int main(
{
cout<<"Hello Jolly!";
system("pause");
return 0;
}

#include<iostream>

Here, we’re using the code already there in the file iostream in own program. So the compiler is told to get the code from iostream and compile it before moving on to compile the rest of the code. The “<” and “>” are used when the file is located in the default compiler bin and not in an external location. You can try making your own iostream file. Copy all code from iostream to any file, say phoenix.txt and use #include<phoenix.txt> and it’ll work.

using namespace std;

Before anything else, you need to know that all statements end with a semi-colon. So, this is your first C++ statement. This just means that you’re using a namespace called the standard library. Now, this is done to avoid name collisions. For instance, consider a university which has a student with roll number 70. Another university may also have a student with the same roll number. Now, these are two namespaces, and by specifying  which namespace we’re using, we can differentiate between the two students.

int main(){…}

All he shit that we do before this statement is just getting things ready and set for the main function. Did i say function? Yes, this is your first C++ function. Like any function, it must return some data. We use “int” here to show that the returned data would be an integer. Every function has pretty much the same format.

It goes like this-> return-type func-name (parameters){statements}

cout<<”Hello Jolly!”;

Now this is another C++ statement. If you have seen the output of the program using your compiler-which is what you should have done. You’ll only see Hello Jolly! printed on a stupid blank black screen. Well, there you go-the cout is your standard output function. Anything in the double inverts with the output operator “<<” goes as output to the screen. This function, along with the standard input function(cin) is stored in the “std” file which we talked about in the namespace statement.

system(”pause”);

A program like this one would usually run in a matter of nanoseconds and the window would close in a flash, unless mi friend-you use the above to simply, pause the system-causing it to wait until you exit.

return 0;

Did I say the main function in C++ would return an integer? So, here we return 0-nada-nothing-goose egg.

Again, the most important thing is to go and try it out for yourself.

[Go to Tutorial 4]

1 people like this post.

Popularity: 5% [?]

C++ Tutorial 1 – The Basics

July 10th, 2010 Rishabh Dev No comments

Hello world! I just thought maybe a bunch of C++ tutorial could help. So here they are. To start with, a program is a simply, a set of instructions for the computer to do. The programmer is he who makes the instructions. And the language in which they are written is the programming language.

Low-Level VS High-Level Language

Now, just like you, your computer has its own languages-called the low-level languages(these are the ones your computer knows but they’re hard for you to understand). Then there are the ones which resemble your language including words like if, else, while, for called the high-level languages(these are the ones you know but your computer does not).

THE COMPILER

Now, a compiler is just another program which makes your high-level languages understandable to your computer. It is a translator that translates the code written in a high-level language into assembly language(low-level). So, the first thing you need is the compiler. I use Dev C++. You can use whichever you like. (The most popular being Visual C++).

Programming PARADIGM

This is more theoretical and would not much really affect your coding skills, but anyhow-a paradigm is a style of programming. For instance, a procedural paradigm would concentrate on the sequence of the program, a generic paradigm would concentrate on generalization concepts like templates, etc. C++ is a multi-paradigm language.

[Go to Tutorial 2]

2 people like this post.

Popularity: 5% [?]

An Introduction to Pointers in C++ Programming

July 1st, 2010 Rishabh Dev No comments

A pointer, formally called a “derived data type” defines where to get the value of a data variable. It itself, does not store the data but the memory location of the variable.

So, in short, it is a (derived)data type which points to the data of the variable but stores only the memory location of the variable.

The pointer uses the deference(*) operator & the reference/address(&) operator. Some of the stuff we can do using pointers is shown down there.. ;)

int *p1;          /* all of these can be used
int* p2;                  to declare pointers */
int*p3;

int *ptr, a;      //declared pointer and variable
ptr=&a;           //pointer now contains the address of a

cout<<ptr;        //gives the memory location of a
cout<<*ptr;       //gives the value stored at a

It’s very important not to get confused between the &variable, pointer, and *pointer.

&variable is used to assign the pointer an address of the variable, pointer gives the memory location of the variable and *pointer gives the value of the variable.

3 people like this post.

Popularity: 4% [?]

Content Protected Using Blog Protector By: PcDrome.