Role of Embedded System in Robotics
Author: Taru Jindal
What is robotics?
It is a branch of technology which is used for building robots for some specific applications. Robots are now widely used to perform some high-precision jobs and also in some special situations that would be dangerous for humans like working in some toxic environment, diffusing bombs, in nuclear reactors etc.
Robot consists of three main components:
1. A mechanical device that can interact with surroundings.
2. Sensors that provide feedback from environment.
3. A system to communicate between a mechanical device and sensory data known as embedded system.
It is also important to know the three laws of robotics known as Asimov's Three Laws of Robotics which are
1. Robots must never harm human beings.
2. Robots must follow commands from humans without violating rule 1.
3. Robots must protect themselves without violating the other rules.
So robots need some intelligence to work and make decisions without breaking the above rules. This is also done with the help of embedded systems. Now the questions which come in our mind are “how this embedded system operates?”, “how it looks like?” As we all are familiar with the computers and its components which are used to perform different tasks, so it’s not difficult to understand the answers.
What is Embedded System?
It is also a computer that has been built to solve a specific problem. The term “Embedded” refers that this intelligent system is an integral part of some large system with hardware and mechanical parts, to perform some specific job. Since the embedded system is dedicated to specific tasks, design engineers can optimize it to reduce the size and cost of the product and increase the reliability and performance. Today embedded system is found in almost each and every electronic device we are using in day to day life. Some examples are video games, mobiles, washing machines, microwaves and so on. Any device that measures, stores, controls, calculates, or displays information must have an embedded system inside.
The most important part of embedded system is microprocessors and microcontrollers. These are multipurpose, programmable device that accepts digital data as input, processes it according to instructions stored in its memory, and provides results as output. Modern embedded systems are often based on microcontrollers but ordinary microprocessors are also common, especially in more-complex systems. The only difference between microprocessor and microcontroller is that microprocessor chip does not have memory, peripheral interface circuits and other components and thus we need to connect them externally. On the other hand, microcontroller has all the components i.e. CPU, memory (RAM, ROM), input/output ports and timers embedded on a single chip. Thus, a microcontroller has reduced power consumption, size and cost as compared to microprocessors. Fig 1(a) and 1(b) shows the basic difference between the two. MICROPROCESSOR MEMORY Fig 1(a): Architecture of Microprocessor MICROCONTROLLER Fig 1(b) : A Basic microcontroller
Let’s discuss in brief, the main parts of these devices i.e. ALU, Registers and Memory.
Arithmetic and Logic Unit: This unit performs basic arithmetic and logic functions like add, subtract, AND, OR etc, on operands stored in memory or registers.
Register: A register is a collection of flip-flops, used to store limited amount of data( a flip-flop stores one bit) such as status information, pointers etc. The majority of the registers in a processor are usually word sized and the largest piece of data that can be transferred to and from the working memory in a single operation is a word in many (not all) architectures.
Also the size of microprocessors or microcontrollers is defined by the maximum number of bits handled by them at a time and usually they have a word size of 8, 16, 24, 32, or 64 bits.
Program and Data Memory: Program memory is that part of the memory where code written by the user is stored. It also stores constants. This memory is usually the ROM and has to be programmed using special hardware( although it can also be programmed in system). Some popular types of ROM are EPROM, EEPROM and more recently Flash. Data memory is that part of the memory hierarchy which is used to store variables defined by the user and values generated during program execution. This memory is the RAM.
How to program a microcontroller?
Programming a microcontroller means to transfer the coded program to the flash memory of the microcontroller so that it works according to the given instruction and program. To achieve this, the steps are:
1. Write the code/program: The code instructing the microcontroller to carry out various operations known as firmware can either be written in assembly language or C. C is much more convenient to use, mainly because of the lesser amount code that needs to be written. Each microcontroller or a particular series has its own assembly level instruction set. On the other hand a C code remains basically the same across the whole range of microcontrollers, only, different C compilers are required.
2. Compile and link the program to get its Hex file. Its nothing but the machine level equivalent of our code in hexadecimal format, i.e. in bytes.
3. Burn the code into the microcontroller’s memory. This is done through a special device called a Programmer. This downloads the hex (.ihx ) file into the microcontroller’s Flash memory.
The microcontroller has been embedded in a large variety of projects from robotics. Microcontroller 8051 is the most common microcontroller designed especially for robots. Let’s take an example of a line follower robot to understand the role of microcontroller in robotics. It consists of three units i.e. input, control, and output unit. The function of all the units is given below:
Input unit consist of the sensors that detect the white path on black surface or the black path on white surface and depending on the color sensed, a signal logic 0 or logic 1will be send to the microcontroller. For a line follower robot two dc geared motors are used. The control unit is the microcontroller part of the robot and is essentially what makes a robot work.
As shown in the diagram above, in Line Follower, the microcontroller takes the input signals from the sensors, use them in its program and make decision of the next movement of the line follower robot to follow the path by sending the output signals to the motor driver unit of robot.