Tuesday, October 5, 2010

1.1 Introduction to Numbers & Coding Systems

Hello Readers:

I have started this blog to show you Embedded C programming for 8051 family microcontroller using KEIL compiler. The KISS philosophy is used to write this tutorial. What is KISS? Keep It Simple, Stupid!

1.1 Introduction to Numbers & Coding Systems


Note:
  • For detailed explanation of numbers and coding systems refer any Digital Communications book or google search the net.
  • For finding equivalent numbers or converting between decimal, binary and hexadecimal number systems, use Windows calculator.
Start Menu->All Programs->Accessories->calculator.



Decimal Number Systems:
Humans are having ten fingers, hence he uses decimal number system. This number system uses 10 as its base number, as it is having ten digits 0 to 9.


 

Fig 1.1.1 shows how four digit decimal numbers is formed with the help of their position value. The Left Most Digit [i.e., 4] is referred as Least Significant Bit, as it carries least weightage  [i.e., 100=1]. The Right Most Digit [i.e., 1] is referred as Most Significant Bit, as it carries highest weightage [i.e., 103=1000].

The Table 1.1.1 shows all the numbers present in the decimal number systems.




Binary Number Systems:
Computer or Microcontroller is made of electronic circuits and having only two states: ON and OFF. These two states are represented by numbers 1 and 0. Hence it is called as binary [bi-two] number systems and having 2 as its base number.

The two states of binary number systems are referred by many names, as shown in Fig 1.1.2a.



  In this number system single digit is called as BInary digiT or BIT. The Fig 1.1.2 shows the popular binary number sets.




  The Fig 1.1.3 shows widely used binary number multipliers.



  The Fig 1.1.4 shows each position weightage of a byte [length of 8-bit].



  The four digit binary numbers with their decimal counter-part are shown in



  Fig 1.1.5 shows how four digit binary numbers is formed with the help of their position value. The Left Most Digit [i.e., 0] is referred as Least Significant Bit, as it carries least weightage  [i.e., 20=1]. The Right Most Digit [i.e., 1] is referred as Most Significant Bit, as it carries highest weightage [i.e., 23=8].



 

Hexadecimal Number Systems:
Let us see memory map of on-chip ROM of three microcontrollers, as shown in Table 1.1.3.


 

In Table 1.1.3, the last column, is having address range in binary. Suppose you write that column values two-three times in each page can you figure-it out exactly what that number means, without any error?

Yes, it is hard for humans to read & manipulate multiple zero and ones arranged one after the other. And it takes lots of place and effort writing & decoding it. So we need an intermediate number system and thus hexadecimal numbers comes into picture.





The hexadecimal number system uses 16 as its base as it is having 16 numbers. It is shown in Table 1.1.4. Note that first 10 numbers are decimal only [0-9], but next 6 digits are alphabets [A-F]. Thus in hexadecimal number system nibble [4-bits] is represented by 16 single numbers/characters. Note that hexadecimal numbers are suffix with letter ‘h’, e.g., 0FFF h.

Now Table 1.1.3 is rewritten with equivalent hex number in last column and shown in Table 1.1.5.


The Fig 1.1.6 shows Number System Diagram.





Fig 1.1.7 shows how four digit hexadecimal numbers is formed with the help of their position value. The Left Most Digit [i.e., 2] is referred as Least Significant Bit, as it carries least weightage  [i.e., 160=1]. The Right Most Digit  [i.e., F] is referred as Most Significant Bit, as it carries highest weightage [i.e., 163=].



First Thing Last:
There is an apartment with 5 floors and each floor is having 10 flats. How you number them?



The Apartment Flat Numbering Diagram in deciaml method is shown in Fig 1.1.8. So now we can say that:

Apartment is having 50 flats and address range is 1 to 50.

Note that Floor I is numbered from 1 to 10, where first nine numbers are single digit and last number is two digits [i.e., 10]. The Floor II is numbered from 11 to 20, where first nine numbers are having 1 as their MSB and last number [i.e, 20] is having 2 as its MSB. Same thing can be observed for Floor III, IV & V also.

In digital electronics every bit is counted and it comes with cost. That means every bit-information is stored in its own memory cell, which is constructed by electronics components. So to store large amount of bit information, such as Apartment Flat Numbers there must be some logic and order is needed. So in digital electronics numbering is started from ZERO and not from ONE. The other reason for using Zero as first number is binary number system has ZERO as its one state.

The new Apartment Flat Numbering Diagram with binary method is shown in Fig 1.1.9. So now we can say that:

Apartment is having 50 flats and address range is 00 to 49 [50-1].






Now you understood, [refer Table 1.1.5] AT89S51 microcontroller’s on-chip ROM address range in hexadecimal is 0000 to 0FFF h [1000-1 h], where as total number of bytes is 1000 h.

<End of 1.1 Introduction to Number & Coding Systems>




...till next post bye-bye & take care.

No comments:

Post a Comment