1.1 Introduction to the world of microcontrollers

MikroElektronika

Novices in electronics usually think that the microcontroller is the same as the microprocessor. That’s not true. They differ from each other in many ways. The first and most important difference in favour of the microcontroller is its functionality. In order that the microprocessor may be used, other components, memory comes first, must be added to it. Even though it is considered a powerful computing machine, it is not adjusted to communicating to peripheral environment. In order to enable the microprocessor to communicate with peripheral environment, special circuits must be used. This is how it was in the beginning and remains the same today.

pic-microcontrollers-programming-in-c-chapter-01-image-01

On the other hand, the microcontroller is designed to be all of that in one. No other specialized external components are needed for its application because all necessary circuits which otherwise belong to peripherals are already built in it. It saves time and space needed to design a device.

ALL THE MICROCONTROLLER CAN DO

In order to make it easier for you to understand the reasons for such a great success of microcontrollers, we will call your attention for a few minutes to the following example.

About ten years ago, designing of an electronic device controlling the elevator in a multistory building was enormously difficult, even for a team of experts. Have you ever thought about what requirements an ordinary elevator must meet? How to deal with the situation when two or more people call the elevator at the same time? Which call has priority? How to handle security question? Loss of electricity? Failure? Misuse?…What comes after solving these basic questions is a painstaking process of designing appropriate electronics using a large number of specialized chips. Depending on device complexity, this process can take weeks or months. When finished, its time to design a printed circuit board and assemble device. A huge device! It is another long-lasting and trying work. Finally, when everything is finished and tested for many times, the crucial moment comes when you concentrate, take a deep breath and switch the power supply on.

This is usually the point at which the party turns into a real work since electronic devices almost never starts to operate immediately. Get ready for many sleepless nights, corrections, improvements… and don’t forget, we are still talking about running an ordinary elevator.

When your device finally starts to operate perfectly and everybody is satisfied and you finally get paid for the work you have done, many constructing companies will become interested in your work. Of course, if you are lucky, another day will bring you a locking offer from a new investor. However, a new building has four stories more. You know what it is about? You think you can control destiny? You are going to make a universal device which can be used in buildings of 4 to 40 stories, a masterpiece of electronics? All right, even if you manage to make such an electronic jewel, your investor will wait in front of your door asking for a camera in elevator. Or for relaxing music in the event of the failure of elevator. Or for two-door elevator. Anyway, Murphy’s law is inexorable and you will certainly not be able to make an advantage of all the effort you have made. Unfortunately, everything that has been said now is true. This is what ‘handling electronics’ really means. No, wait, let us correct ourself, that is how it was until the first microcontrollers were designed – small, powerful and cheap microcontrollers. Since the moment their programming stopped being a science, everything took another direction…

Electronics capable of controlling a small submarine, a crane or the above mentioned elevator is now built in one single chip. Microcontrollers offer a wide range of applications and only some of them are normally used. It’s up to you to decide what you want the microcontroller to do and dump a program containing appropriate instructions into it. Prior to turning on the device, its operation should be tested by a simulator. If everything works fine, build the microcontroller into your device. If you ever need to change, improve or upgrade the program, just do it. Until when? Until you feel satisfied. That’s all.

pic-microcontrollers-programming-in-c-chapter-01-image-cartoon

Do you know that all people can be classified into one out of 10 groups- those who are familiar with binary number system and those who are not familiar with it. You don’t understand? It means that you still belong to the latter group. If you want to change your status read the following text describing briefly some of the basic concepts used further in this book (just to be sure we are on the same page).