Manupulator Kinematics PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 98

AUTOMATION: A ROBOTIC ARM

Presented By:

ARSALAN ALLAHYAR (EngTech – MIMechE)

Bachelor of Technology (Hons) in Mechanical

Preston Institute of Management Sciences &

Technology (PIMSAT)

Karachi, Sindh, Pakistan

© 2013 Submitted to the Faculty of the Applied Technology 
of The Preston Institute of Management Sciences & 
Technology 
in partial fulfillment of the requirements for the Degree of 
Bachelors of Technology (Hons) 
May, 2014 
 

ACKNOWLEDGEMENTS

Foremost, I would like to express my sincere gratitude to my advisor Mr. Obaidullah


Quraishi for the continuous support of my Bachelor`s study, industrial training and final
year project, for his patience, motivation, enthusiasm, and immense knowledge. His
guidance helped me in all the time of research and writing of this thesis. I could not have
imagined having a better advisor and mentor for my bachelor`s study.

Besides my advisor, I would like to thank the rest of my thesis advisor: Mr. Anwar Butt,
Mr. Qaisar and Mr. Shahid Rasheed for their encouragement, insightful comments, and
support at every step.

My sincere thanks also goes to Mr. Nadeem Shaukat, Mr. Mohammad Saleem, Mr.
Anwar Chohan, Mr. Abdul Hai and Mr. Atique-ure-rehman and all my workshop mates
who helped me in this project.

Last but not the least, I would like to thank my family: my parents Mr. Allahyar Hayat
Mohammad and Mrs. Allahyar, for giving birth to me at the first place and supporting me
spiritually throughout my life. Also my brother Mr. Farhan Allahyar and Mr. Rizwan
Allahyar for their encouragement and support and lastly, my sister.

iii 
Acknowledgements reflect the views of the author and are not endorsed by committee 
members or Preston Institute of Management Sciences & Technology (PIMSAT). 
 

This thesis is submitted to the fulfillment of final year project of bachelors of technology
(Hons) in Mechanical Engineering. This project is submitted by the group of three
members:

Thesis written by:


Name: Arsalan Allahyar
ID No: A1QW - 312001

Supported by:
Name: Kaleemullah Wazir
ID No: A1QW - 312009

Name: Tajdaar Azeem


ID No: A1QW - 312013

Date of Degree: 18th of MAY, 2014

Title of Study: BACHELORS OF TECHNOLOGY (HONS)

Major Field: MECHANICAL

Abstract:

 A robotic arm is design and manufactured in this project, the project


involved the understanding of Mechanical system, Electronics system and
Computer Programing.

 The main purpose of this project is to demonstrate the automation


technology and how we can achieve a certain mechanical task by
combining other technologies.

 A simple 3 axis robotic arm is designed and driven by a microcontroller


which programed through a computer software.

 A robotic arm successfully achieved the task of lifting an object from one
location to another as per programed sequence.

 The project gives the understanding of combined technologies and their


importance in the industries.

iv 
 
 

TABLE OF CONTENTS

Chapter Page

I. INTRODUCTION ......................................................................................................2

Overview ..................................................................................................................2
Problem Statement ...................................................................................................4

II. REVIEW OF LITERATURE....................................................................................5

Machine Design .......................................................................................................5


Robotics ...................................................................................................................6
Microcontroller ......................................................................................................13
Programing Language ............................................................................................33

III. METHODOLOGY ................................................................................................73

Robotic Arm Design ..............................................................................................73


Electronic Circuit Design & Hardware Selection ..................................................78
Computer Programing ............................................................................................85
Testing....................................................................................................................90

IV. FINDINGS.............................................................................................................91

Importance of Automation .....................................................................................91


Consumer Usage ....................................................................................................92

CONCLUSION ............................................................................................................93

REFERENCES ............................................................................................................94


 
 

CHAPTER I

INTRODUCTION

OVERVIEW

The term mechanization is often used to refer to the simple replacement of human labour by

machines, automation generally implies the integration of machines into a self-governing system.

Automation has revolutionized those areas in which it has been introduced, and there is scarcely

an aspect of modern life that has been unaffected by it.

The term automation was coined in the automobile industry about 1946 to describe the increased

use of automatic devices and controls in mechanized production lines. The origin of the word is

attributed to D.S. Harder, an engineering manager at the Ford Motor Company at the time. The

term is used widely in a manufacturing context, but it is also applied outside manufacturing in

connection with a variety of systems in which there is a significant substitution of mechanical,

electrical, or computerized action for human effort and intelligence.

“Industrial automation is a vast and diverse discipline that encompasses machinery, electronics,

software, and information systems working together toward a common set of goals—increased

production, improved quality, lower costs, and maximum flexibility.” (Hwaiyu Geng, 2004)


 
 

“Automation is the independent accomplishment of a function by a device or system that was

formerly carried out by a human.” (National Research Council (NRC), 1998; Parasuraman &

Riley, 1997)

In general usage, automation can be defined as a technology concerned with performing a process

by means of programmed commands combined with automatic feedback control to ensure proper

execution of the instructions. The resulting system is capable of operating without human

intervention. The development of this technology has become increasingly dependent on the use

of computers and computer-related technologies. Consequently, automated systems have become

increasingly sophisticated and complex. Advanced systems represent a level of capability and

performance that surpass in many ways the abilities of humans to accomplish the same activities.

Automation technology has matured to a point where a number of other technologies have

developed from it and have achieved a recognition and status of their own. Robotics is one of

these technologies; it is a specialized branch of automation in which the automated machine

possesses certain anthropomorphic, or humanlike, characteristics. The most typical humanlike

characteristic of a modern industrial robot is its powered mechanical arm. The robot’s arm can be

programmed to move through a sequence of motions to perform useful tasks, such as loading and

unloading parts at a production machine or making a sequence of spot-welds on the sheet-metal

parts of an automobile body during assembly. As these examples suggest, industrial robots are

typically used to replace human workers in factory operations.


 
 

PROBLEM STATEMENT

Crescent Steel & Allied Products Ltd is a private organization location in Nooraibad. The

Company manufactures large diameter spiral submerged arc welded steel line pipes and a pipe

coating facility capable of applying multi and single layer, high density polyethylene internal and

external coatings.

The coating plant has an extruder which extrudes the polyethylene material through the die. The

extruder uses the suction system to take in the raw material - which is in grain size - located in the

bin nearby. The bin has to be filled by a person time to time by emptying the nearby sack,

therefore this process occupies one man permanently to achieve this simple job.

I took the liberty to design and implement an effective automation system to achieve this specific

task without any workforce in order to demonstrate the importance of automation technology.

However, the design must be a simple and cost effective system. Therefore I decided to design a

simple 3 axis robotic arm to achieve the task.


 
 

CHAPTER II

REVIEW OF LITERATURE

MACHINE DESIGN

The subject Machine Design is the creation of new and better machines and improving the

existing ones. A new or better machine is one which is more economical in the overall cost of

production and operation. The process of design is a long and time consuming one. From the

study of existing ideas, a new idea has to be conceived. The idea is then studies keeping in mind

its commercial success and given shape and form in the form of drawings. In the preparation of

these drawings, care must be taken of the availability of resources in money, in men and in

materials required for the successful completion of the new idea into an actual reality. In

designing a machine component, it is necessary to have a good knowledge of many subjects such

as Mathematics, Engineering Mechanics, and Strength of materials, Theory of Machines,

Workshop process and Engineering Drawing. ( R.S KHURMI, J.K GUPTA, 14th Edition)

In order to understand the basic concept of machines, one must study the machine design subject.

Machines are always the same, they have combination of linkages, gears, belts and other

mechanics and by which we make a complete mechanism to achieve a certain task.


 
 

ROBOTIC ARM

The term robot comes from the Czech word robota, meaning work, and has been applied to a

wide variety of computer-controlled electromechanical systems, from autonomous landrovers to

underwater vehicles to teleoperated arms in industrial manipulators. The Robot Institute of

America (RIA) defines a robot as a reprogrammable multifunctional manipulator designed to

move material, parts, tools, or specialized devices through variable programmed motions for the

performance of a variety of tasks. Many industrial manipulators bear a strong resemblance in

their conceptual design to that of a human arm. However, this is not always true and is not

essential; the key to the above definition is that a robot has flexibility through its programming,

and its motion can be adapted to fit a variety of tasks. (John J. Uicker, Jr., Gordon R. Pennock

and Joseph E. Shigley, 2003)

To understand automation, I chose to design an

articulated robotic arm. Articulated robotic arms

have motions similar to those of a human arm.

These machines comprise both a “shoulder” and

“elbow” joint along with a “wrist” axis and vertical

motion (Fig. 1.1). Articulated robots are ideal for

general-purpose applications requiring fast,

repeatable, and articulate point-to-point movements

such as palletizing, machine loading/unloading, and Figure 1.1: ARTICULATED ROBOTIC ARM

assembly. Other tasks that are ideal include spray

painting, welding, and sealing applications. Articulates are rigid, but less so than Cartesians

because all joints are at the end of the arm, resulting in unsupported mass and in more deflection.


 
 

BACKGROUND

The history of industrial automation is characterized by periods of rapid change in popular

methods. Either as a cause or, perhaps, an effect, such periods of change in automation techniques

seem closely tied to world economics. Use of the industrial robot, which became identifiable as a

unique device in the 1960s, along with computer-aided design (CAD) systems and computer-

aided manufacturing (CAM) systems, characterizes the latest trends in the automation of the

manufacturing process. These technologies are leading industrial automation through another

transition, the scope of which is stifi unknown.

In North America, there was much adoption of robotic equipment in the early 1980s, followed by

a brief pull-back in the late 1980s. Since that time, the market has been growing (Fig. a), although

it is subject to economic swings, as are all markets. Figure b shows the number of robots being

installed per year in the major industrial regions of the world. Note that Japan reports numbers

somewhat differently from the way that other regions do: they count some machines as robots

that in other parts of the world are not considered robots (rather, they would be simply considered

"factory machines"). Hence, the numbers reported for Japanare somewhat inflated. A major

reason for the growth in the use of industrial robots is their declining cost. Figure c indicates that,

through the decade of the 1990s, robot prices dropped while human labor costs increased. Also,

robots are not just getting cheaper, they are becoming more effective—faster,


 
 

Figure a

more accurate, more flexible. If we factor these quality adjustments into the numbers, the cost of

using robots is dropping even faster than their price tag is. As robots become more cost effective

at their jobs, and as human labor continues to become more expensive, more and more industrial

jobs become candidates for robotic automation. This is the single most important trend propelling

growth of the industrial robot market. A secondary trend is that, economics aside, as robots

become more capable they become able to do more and more tasks that might be dangerous or

impossible for human workers to perform.

 

 
 

Figure b

Figure c

The applications that industrial robots perform are gradually getting more sophisticated, but it is

stifi the case that, in the year 2000, approximately 78% of the robots installed in the US were

welding or material-handling robots.

THE MECHANICS AND CONTROL OF MECHANICAL MANIPULATORS

The following sections introduce some terminology and briefly preview each of the topics that

will be covered in the text. Description of position and orientation In the study of robotics, we are

constantly concerned with the location of objects in three-dimensional space. These objects are

the links of the manipulator, the parts and tools with which it deals, and other objects in the

manipulator's environment.


 
 

At a crude but important level, these objects are described by just two attributes: position and

orientation. Naturally, one topic of immediate interest is the manner in which we represent these

quantities and manipulate them mathematically. In order to describe the position and orientation

of a body in space, we wifi always attach a coordinate system, or frame, rigidly to the object. We

then proceed to describe the position and orientation of this frame with respect to some reference

coordinate system. Any frame can serve as a reference system within which to express the

position and orientation of a body, so we often think of transforming or changing

the description of these attributes of a body from one frame to another. This Chapter discusses

conventions and methodologies for dealing with the description of position and orientation and

the mathematics of manipulating these quantities with respect to various coordinate systems.

Developing good skifis concerning the description of position and rotation of rigid bodies is

highly useful even in fields outside of robotics.

Forward kinematics of manipulators

Kinematics is the science of motion that treats motion without regard to the forces which cause it.

Within the science of kinematics, one studies position, velocity, acceleration, and all higher order

derivatives of the position variables (with respect to time or any other variable(s)). Hence, the

study of the kinematics of manipulators refers to all the geometrical and time-based properties of

the motion. Manipulators consist of nearly rigid links, which are connected by joints that allow

relative motion of neighboring links. These joints are usually instrumented with position sensors,

which allow the relative position of neighboring links to be measured. In the case of rotary or

revolute joints, these displacements are called joint angles. Some manipulators contain sliding (or

10 
 
 

prismatic) joints, in which the relative displacement between links is a translation, sometimes

called the joint offset.

The number of degrees of freedom that a manipulator possesses is the number of independent

position variables that would have to be specified in order to locate all parts of the mechanism.

This is a general term used for any mechanism. For example, a four-bar linkage has only one

degree of freedom (even though there are three moving members). In the case of typical industrial

robots, because a manipulator is usually an open kinematic chain, and because each joint position

is usually defined with a single variable, the number of joints equals the number of degrees of

freedom.

11 
 
 

At the free end of the chain of links that make up the manipulator is the endeffector. Depending

on the intended application of the robot, the end-effector could be a gripper, a welding torch, an

electromagnet, or another device. We generally describe the position of the manipulator by giving

a description of the tool frame, which is attached to the end-effector, relative to the base frame,

which is attached to the nonmoving base of the manipulator. A very basic problem in the study of

mechanical manipulation is called forward kinematics. This is the static geometrical problem of

computing the position and orientation of the end-effector of the manipulator. Specifically, given

a set of joint angles, the forward kinematic problem is to compute the position and orientation of

the tool frame relative to the base frame. Sometimes, we think of this as changing the

representation of manipulator position from a joint space description into a Cartesian space

description.

12 
 
 

MICROCONTROLLER

Microcontroller is a compact microcomputer designed to govern the operation of embedded

systems in motor vehicles, robots, office machines, complex medical devices, mobile radio

transceivers, vending machines, home appliances, and various other devices. A typical

microcontroller includes a processor, memory, and peripherals.

The simplest microcontrollers facilitate the operation of the electromechanical systems found in

everyday convenience items. Originally, such use was confined to large machines such as

furnaces and automobile engines to optimize efficiency and performance. In recent years,

microcontrollers have found their way into common items such as ovens, refrigerators, toasters,

clock radios, and lawn watering systems. Microcomputers are also common in office machines

such as photocopiers, scanners, fax machines, and printers.

The most sophisticated microcontrollers perform critical functions in aircraft, spacecraft, ocean-

going vessels, life-support systems, and robots of all kinds. Medical technology offers especially

promising future roles. For example, a microcontroller might regulate the operation of an

artificial heart, artificial kidney, or other artificial body organ. Microcomputers can also function

with prosthetic devices (artificial limbs). A few medical-science futurists have suggested that

mute patients might someday be able, in effect, to speak out loud by thinking of the words they

want to utter, while a microcontroller governs the production of audio signals to drive an

amplifier and loudspeaker. (Source: Reference 1)

13 
 
 

Microcontroller is the base of all automation technology, without microcontroller automation

would not have been possible. I decided to design a simple microcontroller circuit and simple

hardware of electronics to understand the basic concepts of automation. Figure 1.2 shows the

architecture of Atmel 8051 family microcontroller.

Figure 1.2: BLOCK DIAGRAM OF AN INTEL 8051 MCU ARCHITECTURE

Microcontrollers have only been with us for a few decades but their impact (direct or indirect) on

our lives is profound. Usually these are supposed to be just data processors performing exhaustive

numeric operations. But their presence is unnoticed at most of the places like At supermarkets in

Cash Registers, Weighing Scales, etc.

• At home in Ovens, Washing Machines, Alarm Clocks, etc.

• At play in Toys, VCRs, Stereo Equipment, etc.

• At office in Typewriters, Photocopiers, Elevators, etc.

• In industry in Industrial Automation, safety systems, etc.

14 
 
 

• On roads in Cars, Traffic Signals, etc.

What inside them makes these machines smart? The answer is microcontroller.

Creating applications for the microcontrollers is different than any other development job in

electronics and computing. Before selecting a particular device for an application, it is important

to understand what the different options and features are and what they can mean with regard to

developing the application.

The purpose of this chapter is to introduce the concept of a microcontrollers, how it differ from

microprocessors, different type of commercial microcontrollers available as well as their

applications. The reminder of the book will go through and present different types of

microcontrollers and also programming and interfacing techniques of microcontroller, mainly

8051, in detail.

EMBEDDED CONTROLLER

Simply an embedded controller is a controller that is embedded in a greater system. One can

define an embedded controller as a controller (or computer) that is embedded into some device

for some purpose other than to provide general purpose computing.

Is an embedded controller is the same as a microcontroller? The answer is definitely no. One can

state devices such as 68000, 32032, x86, Z80, and so on that are used as embedded controllers but

they aren’t microcontrollers.

15 
 
 

We might be correct by stating that an embedded controller controls something (for example

controlling a device such as a microwave oven, car braking system or a cruise missile). An

embedded controller may also embed the on-chip resources like a microcontroller.

Microcontrollers and microprocessors are widely used in embedded systems. Though

microcontrollers are preferred over microprocessors for embedded systems due to low power

consumption.

MICROCONTROLLERS AND MICROPROCESSORS

A controller is used to control some process. At one time, controllers were built exclusively from

logic components, and were usually large, heavy boxes. Later on, microprocessors were used and

the entire controller could fit on a small circuit board. This is still common– one can find many

controllers powered by one of the many common microprocessors (including Zilog Z80, Intel

8088, Motorola 6809, and others).

As the process of miniaturization continued, all of the components needed for a controller were

built right onto one chip. A one chip computer, or microcontroller was born. A CPU built into a

single VLSI chip is called microprocessor. The simplified block diagram of the CPU is shown in

the Fig. a. It contains arithmetic and logic unit (ALU), Instruction decode and control unit,

Instruction register, Program counter (PC), clock circuit (internal or external), reset circuit

(internal or external) and registers. For example, Intel 8085 is 8-bit microprocessor and Intel

8086/ 8088 is 16-bit microprocessor.

16 
 
 

Microprocessor is general-purpose digital computer central processing unit (CPU). The

microprocessor is general-purpose device and additional external circuitry are added to make it

microcomputer.

Figure a General block diagram of CPU (Microprocessor)

A digital computer having microprocessor as the CPU along with I/ O devices and memory is

known as microcomputer. The block diagram in the Fig. b shows a microcomputer.

17 
 
 

Figure b Microcomputer block diagram

A microcontroller is a highly integrated chip, which includes on single chip, all or most of the

parts needed for a controller. The microcontroller typically includes: CPU (Central Processing

Unit), RAM (Random Access Memory), EPROM/ PROM/ ROM (Erasable Programmable Read

Only Memory), I/ O (input/ output) – serial and parallel, timers, interrupt controller. For example,

Intel 8051 is 8-bit microcontroller and Intel 8096 is 16-bit microcontroller.

By only including the features specific to the task (control), cost is relatively low. A typical

microcontroller has bit manipulation instructions, easy and direct access to I/ O (input/ output),

and quick and efficient interrupt processing

COMPARING MICROPROCESSORS AND MICROCONTROLLERS

• Microprocessor is a single chip CPU, microcontroller contains, a CPU and much of the

remaining circuitry of a complete microcomputer system in a single chip.

18 
 
 

• Microcontroller includes RAM, ROM, serial and parallel interface, timer, interrupt

schedule circuitry (in addition to CPU) in a single chip.

–RAM is smaller than that of even an ordinary microcomputer, but enough for its

applications.

–Interrupt system is an important feature, as microcontrollers have to respond to control

oriented devices in real time. E.g., opening of microwave oven’s door cause an interrupt to

stop the operation. (Most microprocessors can also implement powerful interrupt schemes,

but external components are usually needed).

• Microprocessors are most commonly used as the CPU in microcomputer systems.

Microcontrollers are used in small, minimum component designs performing control-

oriented activities.

• Microprocessor instruction sets are processing intensive, implying powerful addressing

modes with instructions catering to large volumes of data. Their instructions operate on

nibbles, bytes, etc. Microcontrollers have instruction sets catering to the control of inputs

and outputs. Their instructions operate also on a single bit. E.g., a motor may be turned ON

and OFF by a 1-bit output port.

Before going in to details of microcontrollers it will be beneficial to go through common and

frequently used terminology encountered in the description of microcontrollers.

19 
 
 

CENTRAL PROCESSING UNIT (CPU)

CPU is the brain of the computer system, administers all activity in the system and performs all

operations on data. It continuously performs two operations: fetching and executing instructions.

It understand and execute instructions based on a set of binary codes called the instruction set.

Machine Cycle

To execute an instruction–the processor must:

1. Fetch the instruction from memory

2. Decode the instruction

3. Execute the instruction

4. Store the result back in the memory. These four steps refer to Machine Cycle.

Generally one machine cycle = X clock cycles (X depends on the particular instruction being

executed). Shorter the clock cycle, lesser the time it takes to complete one machine cycle, so

instructions are executed faster. Hence, faster the processor.

FETCHING AND EXECUTING AN INSTRUCTION

Fetching involves the following steps:

(a) Contents of PC are placed on address bus.

(b) READ signal is activated.

(c) Data (instruction opcode) are read from RAM and placed on data bus.

20 
 
 

(d) Opcode is latched into the CPU’s internal instruction register.

(e) PC is incremented to prepare for the next fetch from memory.

While execution involves decoding the opcode and generating control signals to gate internal

registers in and out of the ALU and to signal the ALU to perform the specified operation.

THE BUSES: ADDRESS, DATA, AND CONTROL

A BUS is a collection of wires carrying information with a common purpose. For each read or

write operation, the CPU specifies the location of the data or instruction by placing an address on

the address bus, then activates a signal on the control bus indicating whether the operation is read

or write.

–READ OPERATIONS retrieve a byte of data from memory at the location specified and place it

on the data bus. CPU reads the data and places it in one of its internal registers.

–WRITE OPERATIONS put data from CPU on the data bus and store it in the location specified.

ADDRESS BUS carries the address of a specified location. For n address lines, 2n locations can

be accessed. E.g., A 16-bit address bus can access 216 = 65,536 locations or 64K locations (210 =

1024 = 1K, 26 = 64).

DATA BUS carries information between the CPU and memory or between the CPU and I/ O

devices.

CONTROL BUS carries control signals supplied by the CPU to synchronize the movement of

information on the address and data bus.

21 
 
 

CONTROL/MONITOR (INPUT/OUTPUT) DEVICES

CONTROL DEVICES are outputs, or actuators, that can affect the world around them when

supplied with a voltage or current.

MONITORING DEVICES are inputs, or sensors, that are stimulated by temperature, pressure,

light, motion, etc. and convert this to voltage or current read by the computer. Note: The interface

circuitry converts the voltage or current to binary data, or vice versa.

TYPES OF MICROCONTROLLERS

Microcontrollers can be classified on the basis of internal bus width, architecture, memory and

instruction set. Figure 1.4 shows the various types of microcontrollers.

THE 8,16 AND 32-BIT MICROCONTROLLERS

THE 8-BIT MICROCONTROLLER

When the ALU performs arithmetic and logical operations on a byte (8-bits) at an instruction, the

microcontroller is an 8-bit microcontroller. The internal bus width of 8-bit microcontroller is of 8-

bit. Examples of 8-bit microcontrollers are Intel 8051 family and Motorola MC68HC11 family.

22 
 
 

THE 16-BIT MICROCONTROLLER

When the ALU performs arithmetic and logical operations on a word (16-bits) at an instruction,

the microcontroller is an 16-bit microcontroller. The internal bus width of 16-bit microcontroller

is of 16-bit. Examples of 16-bit microcontrollers are Intel 8096 family and Motorola MC68HC12

and MC68332 families. The performance and computing capability of 16 bit microcontrollers are

enhanced with greater precision as compared to the 8-bit microcontrollers.

THE 32-BIT MICROCONTROLLER

When the ALU performs arithmetic and logical operations on a double word (32bits) at an

instruction, the microcontroller is an 32-bit microcontroller. The internal bus width of 32-bit

microcontroller is of 32-bit. Examples of 32-bit microcontrollers are Intel 80960 family and

Motorola M683xx and Intel/ Atmel 251 family. The performance and computing capability of 32

bit microcontrollers are enhanced with greater precision as compared to the 16-bit

microcontrollers.

Types of micrcontroller

23 
 
 

EMBEDDED AND EXTERNAL MEMORY MICROCONTROLLERS

EMBEDDED MICROCONTROLLERS

When an embedded system has a microcontroller unit that has all the functional blocks (including

program as well as data memory) available on a chip is called an embedded microcontroller. For

example, 8051 having Program & Data Memory, I/ O Ports, Serial Communication, Counters and

Timers and Interrupt Control logic on the chip is an embedded microcontroller.

EXTERNAL MEMORY MICROCONTROLLERS

When an embedded system has a microcontroller unit that has not all the functional blocks

available on a chip is called an external memory microcontroller. In external memory

microcontroller, all or part of the memory units are externally interfaced using an interfacing

circuit called the glue circuit. For example, 8031 has no program memory on the chip is an

external memory microcontroller.

MICROCONTROLLER ARCHITECTURAL FEATURES

There are mainly two categories of processors, namely, Von-Neuman (or Princeton) architecture

and Harvard Architecture. These two architecture differ in the way data and programs are stored

and accessed.

24 
 
 

VON-NEUMAN ARCHITECTURE

Microcontrollers based on the Von-Neuman architecture have a single data bus that is used to

fetch both instructions and data. Program instructions and data are stored in a common main

memory. When such a controller addresses main memory, it first fetches an instruction, and then

it fetches the data to support the instruction. The two separate fetches slows up the controller’s

operation. Figure d shows the Von-Neuman Architecture. The Von-Neuman architecture’s main

advantage is that it simplifies the microcontroller design because only one memory is accessed. In

microcontrollers, the contents of RAM can be used for data storage and program instruction

storage. For example, the Motorola 68HC11 microcontroller VonNeuman architecture.

Example : An Instruction “Read a byte from memory and store it in the accumulator” as follows:

Cycle 1 :- Read instrution

Cycle 2 - Read data out of RAM and put into Accumulator

Figure d Von-neuman architecture block diagram

25 
 
 

HARVARD ARCHITECTURE

Microcontrollers based on the Harvard Architecture have separate data bus and an instruction bus.

This allows execution to occur in parallel. As an instruction is being “pre-fetched”, the current

instruction is executing on the data bus. Once the current instruction is complete, the next

instruction is ready to go. This pre-fetch theoretically allows for much faster execution than Von-

Neuman architecture, on the expense of complexity. Figure e shows the Harvard Architecture.The

Harvard Architecture executes instructions in fewer instruction cycles than the Von-Neuman

architecture. For example, the intel MCS-51 family of microcontrollers and PIC microcontrollers

uses Harvard Architecture.

The same instruction (as shown under Von-Newman architecture) would be executed as follows:

Cycle 1: - Complete previous instruction

- Read the “Move Data to Accumulator” instruction

Cycle 2: - Execute “Move Data to Accumulator” instruction

- Read next instruction

Hence each instruction is effectively executed in one instruction cycle.

26 
 
 

Figure e Harvard architecture block diagram

CISC (COMPLEX INSTRUCTION SET COMPUTER) ARCHITECTURE

MICROCONTROLLERS

Almost all of today’s microcontrollers are based on the CISC (Complex Instruction Set

Computer) concept. When an microcontroller has an instruction set that supports many

addressing modes for the arithmetic and logical instructions, data transfer and memory accesses

instructions, the microcontroller is said to be of CISC architecture.

The typical CISC microcontroller has well over 80 instructions, many of them very powerful and

very specialized for specific control tasks. It is quite common for the instructions to all behave

quite differently. Some might only operate on certain address spaces or registers, and others

might only recognize certain addressing modes.

27 
 
 

The advantages of the CISC architecture are that many of the instructions are macrolike, allowing

the programmer to use one instruction in place of many simpler instructions.

An example of CISC architecture microcontroller is Intel 8096 family.

RISC (REDUCED INSTRUCTION SET COMPUTER) ARCHITECTURE

MICROCONTROLLERS

The industry trend for microprocessor design is for Reduced Instruction Set Computers (RISC)

designs. When a microcontroller has an instruction set that supports fewer addressing modes for

the arithmetic and logical instructions and for data transfer instructions, the microcontroller is

said to be of RISC architecture.

The benefits of RISC design simplicity are a smaller chip, smaller pin count, and very low power

consumption.

Some of the typical features of a RISC processor- Harvard architecture are

1. Allows simultaneous access of program and data.

2. Overlapping of some operations for increased processing performance.

3. Instruction pipelining increases execution speed.

4. Orthogonal (symmetrical) instruction set for programming simplicity.

5. Allows each instruction to operate on any register or use any addressing mode.

28 
 
 

SISC (SPECIFIC INSTRUCTION SET COMPUTER)

Actually, a microcontroller is by definition a Reduced Instruction Set Computer. It could really be

called a Specific Instruction Set Computer (SISC). The basic idea behind the microcontroller was

to limit the capabilities of the CPU itself, allowing a complete computer (memory, I/ O,

interrupts, etc) to fit on the single chip. At the expense of the more general purpose instructions

that make the standard microprocessors (8088, 68000, 32032) so easy to use, the instruction set

was designed for the specific purpose of control (powerful bit manipulation, easy and efficient I/

O, and so on).

MICROCONTROLLER APPLICATIONS

In addition to control applications such as the home monitoring system, microcontrollers are

frequently found in embedded applications. Among the many uses that you can find one or more

microcontrollers: automotive applications, appliances (microwave oven, refrigerators, television

and VCRs, stereos), automobiles (engine control, diagnostics, climate control), environmental

control (greenhouse, factory, home), instrumentation, aerospace, and thousands of other uses.

Microcontrollers are used extensively in robotics. In this application, many specific tasks might

be distributed among a large number of microcontrollers in one system. Communications

between each microcontroller and a central, more powerful microcontroller (or microcomputer, or

even large computer) would enable information to be processed by the central computer, or to be

passed around to other microcontrollers in the system.

29 
 
 

A special application that microcontrollers are well suited for is data logging. By stick one of

these chips out in the middle of a corn field or up in a balloon, one can monitor and record

environmental parameters (temperature, humidity, rain, etc). Small size, low power consumption,

and flexibility make these devices ideal for unattended data monitoring and recording.

COMMERCIAL MICROCONTROLLER DEVICES

Microcontrollers come in many varieties. Depending on the power and features that are needed,

one might choose a 4 bit, 8 bit, 16 bit, or 32 bit microcontroller. In addition, some specialized

versions are available which include features specific for communications, keyboard handling,

signal processing, video processing, and other tasks. The examples of different types of

commercial microcontroller devices are given in the following tables.

Table 1.1 4 Bit Microcontrollers

Model
I/ O Pins RAM (bytes) ROM (bytes) Counters Extra Features
(Manufacturer)

COP400 23 28 64 1K 1 Serial bit I/O

Family

(National)

HMCS40 10 28 32 512 - 10-bit ROM

(Hitachi)

30 
 
 

TMS 1000 23 28 64 1K - LED display

(Texas

Instruments)

Table 1.2 8 Bit Microcontrollers

Model I/ O Pins RAM ROM Counters Extra Features

(Manufacturer) (bytes) (bytes)

8048 (Intel) 27 40 64 1K 1 8k External memory

8051 (Intel) 32 40 128 4K 2 128k External memory,

Boolean processing,

serial port

COP800 Family 24 28 64 1K 1 Serial bit I/O, 8- channel

A/ D converter
(National)

6805 (Motorola) 20 28 64 1K 1 PLL frequency

synthesizer,

68hc11(Motorola) 40 52 256 8K 2 A/ D, PWM generator,

pulse accumulator

31 
 
 

TMS370 (Texas) 55 68 256 4K 2 watchdog timer,

Instruments) Serial

ports,

A/ D (8 bit, 8 channel)

PIC (Micro Chip) 12 18 25 1K 0 small pin count, very

low power consumption

Table 1.3. 16 Bit Microcontrollers

Model I/ O Pins RAM (bytes) ROM (bytes) Counters Extra Features

(Manufacturer)

80c196 (Intel) 40 68 232 8K 2 PWM generator,

watchdog timer

HPC Family 52 68 512 16K 4 PWM generator,

(National) watchdog timer, 8-

channel A/ D,

serial port

32 
 
 

PROGRAMMING LANGUAGE

Computer does not understand any language and numbers like humans do, they only understand

yes or no, on and off or simply 0 for off and 1 for on. Computer programming language, any of

various languages for expressing a set of detailed instructions for a digital computer. Such

instructions can be executed directly when they are in the computer manufacturer-specific

numerical form known as machine language, after a simple substitution process when expressed

in a corresponding assembly language, or after translation from some “higher-level” language.

Although there are over 2,000 computer languages, relatively few are widely used, such as Java,

Python, C, C++, and Fortran etc…

Machine and assembly languages are “low-level,” requiring a programmer to manage explicitly

all of a computer’s idiosyncratic features of data storage and operation. In contrast, high-level

languages shield a programmer from worrying about such considerations and provide a notation

that is more easily written and read by programmers.

Automation technology uses in depth low level language in order to get the job done by specific

instruction. However, these low languages are still very hard to use, therefore, programmers

developed another language close to assembly language and named it C and also C++. Further, to

make it easier some companies have developed their own integrated languages which is normally

called integrated development environment (IDE).\

Given the general nature of that question, and the fact that programming is seen as a hideously

complex subject, you're probably expecting a highly convoluted and technical answer. But you're
33 
 
 

not going to get one (sorry about that). In truth, it's quite easy to say what programming is, so I

will:

• Programming is breaking a task down into small steps.

That's just about the most honest and accurate answer I can give. It also has the added benefit of

being concise, and sounding very much like something you'd read in an official book on the topic,

thus adding to my credibility.

You're perhaps wondering what exactly I mean by breaking a task down into small steps, so I'll

explain the point in more detail. Let me start by giving you a fact about programmers that you'll

find very easy to believe:

• Programmers think in an unnatural way.

This refers just to the fact that programming is breaking a task into small steps, and that's not the

usual way that your mind works. An example will help you to understand what I mean. Here's a

task for you to do:

Put these words in alphabetical order: apple, zebra, abacus

I'm going to assume that you managed to put them in alphabetical order, and ended up with

abacus, then apple, then zebra. If you didn't manage that, reading this article may soon become

one of the worst experiences of your life so far.

Now think about exactly how you performed that task; what steps you took to put the words in

alphabetical order, and what you required to know in order to do so. The most obvious thing you

needed to know was the alphabet; the desired order of the letters. Then, if you're like me, you

probably did something like this:


34 
 
 

1. Look through the words for one beginning with "A".

2. If you found a word beginning with "A", put that word at the beginning of the list

(in your mind).

3. Look for another word beginning with "A".

4. If there's another word beginning with "A", compare its second letter with the

second letter of our first "A" word.

5. If the second letters are different, put the two words in alphabetical order by their

second letter. If the second letters are the same, proceed to the third letter, and so on.

6. Repeat this whole process for "B" and each other letter in alphabetical order,

until all the words have been moved to the appropriate place.

Your method may differ slightly, but probably not by much. The thing to notice (which I noticed

particularly, since I'm having to type all this) is how much time it took to explain a process which

happens without any real conscious thought. When you saw that you had to put some words in

alphabetical order, you certainly didn't first sit down and draw up a plan of what you were going

to do, detailing all the steps I listed above. Your mind doesn't need to; you learned to do it once

when you were a child, and now it just happens. You have a kind of built-in shortcut to that

sequence of steps.

Now let's try another simple example:

Count the number of words in this sentence: "Programming really can be fun."

35 
 
 

Hopefully you decided that there were five words. But how did you come to that decision? First

you had to decide what a word is, naturally. Let's assume for the moment that a word is a

sequence of letters which is separated from other words by a space. Using that rule, you do

indeed get five words when looking at the sentence above. But what about this sentence:

"Sir Cecil Hetherington-Smythe would make an excellent treasurer,minister."

Notice my deliberate mistake: I didn't leave a space after the comma. You might also feel it's a

mistake to name anyone Cecil Hetherington-Smythe, but that's a debate for another time. Using

our rule about sequences of letters which are separated from other sequences by spaces, you

would decide that there were eight words in the new sentence. However, I think we can agree that

there are in fact ten words, so our rule clearly isn't working. Perhaps if we revised our rule to say

that words can be separated by spaces, commas or dashes, instead of just spaces. Using that new

rule, you'd indeed find ten words. Now let's try another sentence:

"Some people just love to type really short lines, instead of using the full width of the page."

Although it might not be obvious, there is no space after "really", nor is there a space after "full".

Instead, I took a new line by pressing the return key. So, using our newest rule, how many words

would you find in that last sentence? I'll tell you: you'd get sixteen, when in fact there are

eighteen. This means that we need to revise our rule yet again, to include returns as valid word-

separators. And so on, until another sentence trips up our rule, and we need to revise it yet again.

You might wonder why we're doing this at all, because after all, we all know what we mean

when we say "count the number of words". You can do it properly without thinking about any

rules or valid word-separators or any such thing. So can I. So can just about anyone. What this

example has shown us is that we take for granted something which is actually a pretty

36 
 
 

sophisticated "program" in our minds. In fact, our own built-in word counting "program" is so

sophisticated that you'd probably have a lot of trouble describing all the actual little rules it uses.

So why bother?

The answer comes in the form of an exceptionally important truth which you must learn. It's to do

with computers (even your own computer that you're using to read this). Here it is:

• Computers are very, very stupid.

To some people, that statement is almost sacrilegious. You can understand that, because

computers are really expensive. If you've just bought a Ferrari, you probably don't want your

neighbour to come along and say that it's ugly and slow. If you're a Mac user (as I am, so don't

send abusive email about this - I'm typing this article on my beloved PowerBook), you might

actually kill a person who said your computer was stupid.

Nevertheless, it's true - computers are desperately stupid. Your computer will sit there and do

whatever mindless task you tell it to, for days, weeks, months or years on end, without any

complaints or any slacking-off. That's not the typical behaviour of something that's even slightly

clever. It will also happily erase it's own hard disk (which is a bit like you deleting all your

memories then pulling parts of your brain out), so we're clearly not dealing with an intimidatingly

intelligent item.

In fact, computers are so painfully stupid that they require to be told, in minute detail, how to do

even the most laughably simple of tasks. It's quite pathetic, when you think about it (or perhaps

37 
 
 

we're pathetic, since we're willing to pay ridiculous amounts of money to own them). In fact, just

about the only positive thing about computers is that they're completely obedient. No matter how

crazed your instructions might be, your computer will carry them out precisely.

By now, hopefully you can see how this is all tying together. Programmers tell computers what to

do. Computers require these instructions to be precise and complete in every way. Humans aren't

usually good at giving precise and complete instructions since we have this incredible brain

which lets us give vague commands and still get the correct answer. Thus, programmers have to

learn to think in an unnatural way: they have to learn to take a description of a task (like "count

the number of words in a sentence"), and break it down into the fundamental steps which a

computer needs to know in order to perform that task.

You may be feeling slightly uneasy at this point. I've admitted that programming is, in a way,

unnatural. I've warned you about the spectacular stupidity of computers, so you're probably

getting a small idea of the amount of task-description you'd need to do in order to make your

computer do anything even vaguely impressive. But don't worry; there are some excellent reasons

to become a programmer:

• Programmers make lots of money.

• Programming really is fun.

• Programming is very intellectually rewarding.

• Programming makes you feel superior to other people.

38 
 
 

• Programming gives you complete control over an innocent, vulnerable machine,

which will do your evil bidding with a loyalty not even your pet dog can rival.

At least some if not all of these points will instantly appeal to you as a human being, and it's none

of my business which ones you find most attractive. Additionally, people have been programming

for many years, and so have already written many task-descriptions ("programs") for a lot of

common tasks, so you can use all their hard work to save yourself some trouble. Which is also a

very attractive prospect, I'm sure.

If you're still not sure whether programming is for you, perhaps the next section will help you

decide.

Who can be a programmer?

You might be wondering just who can become a programmer (probably because you've read the

title of this section, and it got you thinking). The clichéd thing to do would be to say "anyone!",

but I won't do that, because it's just not true. There are a few traits which might indicate that the

person would be a good programmer:

• Logical

• Patient

• Perceptive

• At least moderately intelligent

• Enjoys an intellectual challenge

39 
 
 

• Star Trek fan

• Female *

* Actually, males and females make equally good programmers. I just said that to address the

gender disparity which exists in the programming world; it's true that there are currently more

male programmers than female, which is strange given that one of the first ever programmers

(Ada Lovelace) was female. Besides, male programmers are especially eager to encourage more

females to take up the profession, since they (the male programmers) traditionally have no social

lives whatsoever. Or perhaps that's an unfair generalisation, and it's just me who has no social

life.

As you can see, it does take a certain type of person to be a successful programmer (in my

humble opinion). If you're not logical, you'll have trouble organising and constructing complex

programs. If you're not fairly intelligent, you won't be able to break a task down into the

necessary individual steps. If you're not patient, you'll deliberately destroy your computer long

before you manage to finish all but the most simple programs. If you don't enjoy intellectual

challenges, you'll hate every minute of programming. If you're not a Star Trek fan, you'll miss out

on a large percentage of the conversation your fellow programmers will have (I'm not saying

that's a bad thing). Finally, if you're not perceptive, you won't notice that the twenty consecutive

hours you've spent in front of your computer have depleted your body's energy resources to a

near-fatal level, and you'll die whilst designing an icon for your new application program (tip:

experienced programmers avoid this problem by designing the icon before writing the program).

40 
 
 

In other words, if you get annoyed waiting for the five beeps after your microwave finishes

cooking a Pot Noodle, and you fly into a rage trying to solve the "coffee break" crossword in the

tabloid newspapers, you may want to consider another line of work. That's not to say that you

can't be a programmer; you just might find it more difficult than it needs to be.

By now you should at least have an inkling of whether or not programming could be a serious

proposition for you. If you're interested in finding out what's actually involved in programming

(the actual process of writing programs), read on. If not, then it's clear that you should instead

leave the programming to others, and then buy their excellent software (hint hint).

What's actually involved in programming?

In this section I'm going to introduce some technical terms. It's unavoidable. The jargon will

always get you in the end (if you choose to become a programmer, soon you'll actually be talking

in jargon). However, I'll explain each term as we come to it, and there's a list of jargon in the

following section (with explanations, of course).

So, what's actually involved in programming - the actual process of writing programs? I'll answer

that myself even though I asked the question, since I'm assuming that you don't know yet. Here's

a quick overview of the process:

1. Write a program.

2. Compile the program.

41 
 
 

3. Run the program.

4. Debug the program.

5. Repeat the whole process until the program is finished.

Let's discuss those steps one by one, shall we? Yes, we shall. And here goes.

1. Write a program.

I have a small amount of bad news for you: you can't write programs in English. It would be nice

indeed to be able to type "count the number of words in a sentence" into your computer and have

it actually understand, but that's not going to happen for a while (unless someone writes a

program to make a computer do that, of course). Instead, you have to learn a programming

language.

You're now probably having nightmarish flashbacks to French class in high school, sweating over

which nouns took the verb "avoir" and which didn't. Thankfully, learning a programming

language is nothing like that - for one thing, much of a programming language is indeed in

English. Programming languages commonly use words like "if", "repeat", "end" and such. Also,

they use the familiar mathematical operators like "+" and "=". It's just a matter of learning the

"grammar" of the language; how to say things properly. Since there are many possible languages

you could choose to learn (see the jargon section for a bit more on some of the languages), I won't

go into any specific one here. I just wanted to make you aware of the fact that you won't be typing

your programs in English.

42 
 
 

So, we said "Write a program". This means: write the steps needed to perform the task, using the

programming language you know. You'll do the typing in a programming environment (an

application program which lets you write programs, which is an interesting thought in itself). A

common programming environment is CodeWarrior, and another common one is InterDev, but

you don't need to worry about those just yet. Some programming environments are free, and some

you have to buy just like any other application program. Commercial (non-free) programming

environments cost anything from $50 to $500+, and you'll almost always get a huge discount if

you're a student or teacher of some kind. Again, see the jargon section for where to find some

programming environments.

Incidentally, the stuff you type to create a program is usually called source code, or just code.

Programmers also sometimes call programming coding. We think it sounds slightly more cool.

2. Compile the program.

In order to use a program, you usually have to compile it first. When you write a program (in a

programming language, using a programming environment, as we mentioned a moment ago), it's

not yet in a form that the computer can use. This isn't hard to understand, given that computers

actually only understand lots of 1s and 0s in long streams. You can't very well write programs

using only vast amounts of 1s and 0s, so you write it in a more easily-understood form (a

programming language), then you convert it to a form that the computer can actually use. This

conversion process is called compiling, or compilation. Not surprisingly, a program called a

compiler does the compiling (that's why it's called a compiler and not, for example, a banana).

43 
 
 

It's worth mentioning that if your program has problems which the compiler can't deal with, it

won't be able to compile your program (in this situation, some programmers say that the compiler

puked or barfed - which I'm sure you'll agree is just delightful).

You'll be pleased to hear that your programming environment will include a suitable compiler (or

maybe more than one compiler: each different programming language your programming

environment allows you to use requires its own compiler). Compilers are just fancy programs, so

they too are written by programmers. Programmers who write compilers are a bit like gods; they

make it possible for everyone else to program. So if anyone ever tells you that they're a compiler

programmer, be sure to buy them a cup of coffee (they will definitely like coffee, you can be

sure).

3. Run the program.

Now that you've compiled the program into a form that the computer can use, you want to see if it

works: you want to make the computer perform the steps that you specified. This is called

running the program, or sometimes executing it (I'm aware of the potential irony of that term).

Just the same as how a car isn't much use if you don't drive it, a program isn't much use if you

don't run it. Your programming environment will allow you to run your program too (as you can

see, programming environments do rather a lot for you).

4. Debug the program.

You've probably heard the term "debug" before (it's pronounced just as you might expect: "dee-

bug"). It refers to fixing errors and problems with your program. As I'm sure you know, the term

came about because the earliest computers were huge building-sized contraptions, and actual real-

life insects sometimes flew into the machinery and caused havoc with the circuits and valves.
44 
 
 

Hence, those first computer engineers had to physically "debug" the computers - they had to

scrape the toasted remains of various kinds of flying insect out of the inner workings of their

machines. The term became used to describe any kind of problem-solving process in relation to

computers, and we use it today to refer purely to fixing errors in our code. I've never had an insect

fly inside my computer (though I hear that cats love to lie on top of them, so be sure to de-cat

your computer before debugging your programs).

You may also have heard the phrase "it's not a bug, it's a feature". Programmers sometimes say

this when someone points out a problem with their programs; they're saying that it's not a bug, but

rather a deliberate design choice (which is almost always a lie). This is rather like accidentally

spilling coffee all over yourself whilst simultaneously falling down some stairs, then getting up

and saying "I meant to do that".

Once again, your programming environment will help you to debug your programs (indeed, you'll

often find the picture of an insect shown in your programming environment to indicate

debugging). You usually debug your program by stepping through it. This means just what it

sounds like: you go through your program one step at a time, watching how things are going and

what's happening. Sooner or later (usually later), you'll see what's going wrong, and slap yourself

upside the head at the ridiculously obvious error you've made. Ahem.

5. Repeat the whole process until the program is finished.

And then you repeat the whole process until you're happy with the program. This is more tricky

than it might sound, since programmers are never happy with their programs. You see,

programmers are perfectionists - never satisfied until absolutely everything is complete and

45 
 
 

elegant and powerful and just gorgeous (though this pursuit of perfection doesn't always extend to

their choice of girlfriends/boyfriends, by necessity). Programmers will commonly release a new

version of their program every day for a couple of weeks after the initial release (just ask my

friends about this).

As you can imagine, enjoying an intellectual challenge is an important trait to have when you're

going back to correct and enhance your code many times over. You'll actually find that you can't

wait to get back into your program and fix the bugs, make improvements, and refine the existing

code. No, really you will!

And that's the basic process of programming. Note that most programming environments will

make a lot of it much easier for you, by doing such things as:

• Warning you about common errors

• Taking you to the specific bit of code which is causing the compiler to puke

• Letting you quickly look up documentation on the programming language you're

using

• Letting you just choose to run the program, and compiling it automatically first

• Colouring parts of your code to make it easier to read (for example, making

numbers a different colour from other text)

• And many other things

46 
 
 

So, don't worry too much about the specifics of compiling then running then debugging or

whatever. The purpose of this section was mostly to make you aware of the cyclical nature of

programming: you write code, test it, fix it, write more, test it, fix, and so on.

Now, we digress for a moment (or however long it takes you read the next section), to talk briefly

about something called scripting.

A brief word about scripting

You've perhaps heard about something called scripting, or maybe you've heard of languages like

JavaScript, AppleScript, Tcl and others (those languages are called scripting languages). You

may thus be wondering if scripting is the same as programming, and/or what the differences are,

and so on.

People get quite passionate about this question, so I'm just going to cover it briefly and

technically. Here are some facts:

• Scripting is essentially a type of programming

• Scripting languages have a few minor technical differences which aren't

important to discuss at this point

• Scripting languages tend to be interpreted rather than compiled, which means

that you don't need to compile them - they're compiled "on the fly" (i.e. when necessary,

right before they're run). This can make it faster to program in them (since you always

have the source code, and don't need to take the deliberate extra step of compiling)

47 
 
 

• The fact that scripting languages are interpreted generally makes them slower

than programming languages for intensive operations (like complex calculations)

• Scripting languages are often easier to learn than programming languages, but

usually aren't as powerful or flexible

• For programming things like applications for personal computers, you'll need to

use a programming language rather than a scripting language

Scripting languages can be excellent for beginners: they tend to be easier to learn, and they

insulate you from some of the technical aspects of programming (compiling, for one). However,

if you're serious about programming, you won't be able to stay with a scripting language forever -

you will move on to a programming language at some point. I'd say that it's good to know a

scripting language or two, and even to start with a scripting language rather than a programming

language. However, there's a point of view which says that, by protecting and "hand-holding" too

much, scripting languages don't properly prepare you for "serious" programming, and set you up

for a bit of a learning curve when you move on to a programming language. I can't really tell you

whether that's true one way or the other; all I can say is that I started with scripting languages like

JavaScript and AppleScript, and moved on to programming languages. I'd advise that you try a

programming language, and if you find it really hard going, try a scripting language to ease you

into thinking like a programmer.

We now move on to the "where to start" section, which is funny considering how much we've

talked about already. Such is life.

48 
 
 

Where to start

The question of exactly where to start learning to program is a big one, and it's something that

everyone has an opinion about (even your postman may have a strongly-held opinion on this

subject). I'm going to try to be as practical as possible about answering this, but just be aware that

personal preferences (in terms of programming languages, books, programming environments,

and so on) will always creep in somewhere. I do however promise to be as impartial as possible

(which isn't too difficult when you're as unquestionably great as I am).

You may think that the obvious first step would be to choose a programming language, probably

by weighing up the various pros and cons of each major language. However, when someone

begins a sentence with "you may think that", there's a fair chance that they're going to tell you

that you were wrong to think whatever it was. I'm not exactly going to do that; instead I'm going

to point out something that you must realise before going any further:

• Programming is programming

You're probably thinking "you don't say" (or something less kind), but there really is a valid point

in there. You see, there are fundamental similarities between all programming languages, so as a

beginner it's really not so important which language you begin with; the important thing is to just

get some experience with programming. So, you're really free to choose a language, up to a point.

Just be aware that there's no "wrong" language to start with.

Having said that, there are of course some other considerations you might want to take into

account, for example these:

• Do you want to pay for a programming environment, or use a free one?

49 
 
 

• Do you want to learn with a language you'll still be able to use professionally?

You see, each programming environment will only support certain languages. If you're going to

use a free programming environment and compiler at first, you may have a limited choice of

languages. Also, you may (understandably) want to learn with a language which you'll still be

able to use professionally. That's a normal feeling, and it's probably a good idea too, but just don't

feel that you have to learn with a "commercially viable" language - that's nonsense. As I said, just

get started programming, whatever the language may be - your skills will be entirely transferrable

to other languages, and you'll find each new language much (much) easier after learning your

first one.

Let's assume that you want to use a commercial language (meaning one which is used by

professional programmers in the current mainstream software industry), and you're willing to pay

for a programming environment if need be. The main choices basically boil down to these, in no

particular order:

• C

• C++ • Java

(Remember that you can find out more about these languages in the jargon section, later in this

article). For now, let's talk about each language very briefly.

• C

This is probably the most widely-used, and definitely the oldest, of the three languages I

mentioned. It's been in use since the 70s, and is a very compact (i.e. not much "vocabulary" to

learn), powerful and well-understood language (by "well understood", I mean that there's a huge

50 
 
 

body of literature and example source code related to C). It would be an excellent choice. I'd

recommend it to you as a starting language if you asked me for my own opinion (but you didn't

ask me, so I won't say anything).

• C++

This language is a superset of C (that just means that it's C with more stuff added; it's more than

C, and includes pretty much all of C). Its main benefit over C is that it's object oriented. Don't

worry about what that means right now, but feel free to check the jargon section for more about it.

The key point is that object oriented languages are more modern, and using object oriented

languages is the way things are done now in the programming world.

However, don't take that the wrong way. You'll notice that I said C++ included pretty much all of

C (in case you're wondering; there was no "C+"). This means that C is at the core of C++, and

you need to know C in order to use C++. I also said that C++ is essentially an object oriented

version of C, but it's not the only enhanced version of C which is object oriented. You've got

basic C, and you've got a few languages which are object oriented, enhanced versions of C, and

C++ is only one of those. What I'm trying to convey by saying this is that it's a better idea to learn

C, then you can move to whatever object oriented version of C you want to. If you dive in and

learn C++ first, you may find it harder to switch to other C-based object oriented languages since

you'll have to "forget" parts of C++. I hope that makes sense.

Let me just balance that (which was my own opinion) by saying that C++ is most definitely the

second-most used language after C, and may soon become the most used language. I'd say that it's

certainly the language of choice for most commercial application software development on

Windows and Macintosh, which says a lot. I just feel that you can learn C and not suffer (you can

51 
 
 

still go on to C++ afterwards, very quickly indeed since you'll already know the vast majority of

C++ by virtue of knowing C), and still also leave your options open.

• Java

You've almost certainly heard of Java; it's been hyped all the way to the moon and back. Java has

a benefit which other programming languages lack: it's cross-platform. So what exactly does that

mean? Well, it means that it runs on more than one platform without needing to be recompiled.

A platform is just a particular type of computer system, like Windows or Mac OS or Linux.

Normally, if you wanted to use the same program on a different platform from the one it was

written on, you'd have to recompile it - you'd have to compile a different version for each

different platform.

Sometimes, you'd also need to change some of your code to suit the new platform. This probably

isn't surprising, since the different platforms work differently, and look different (an alert window

on Windows looks different than an alert window on Mac OS, for example, and they both use

different code).

Anyway, Java can run on more than one platform without needing to be recompiled. You can

understand why that would be a serious advantage. However, Java also has a disadvantage which

is almost as serious: it's slow. Java achieves its cross-platform trick by putting what is essentially

a big program on your computer which pretends to be a little computer all of its own. The Java

runs inside this "virtual machine", which runs on whatever platform you're using (like Windows

or Mac OS). Because of this extra layer between the program and the computer's processor chip,

Java is slower than a program written and compiled natively for the same platform. Hopefully

52 
 
 

you can roughly understand why that might be. It's for the same reason that it's quicker to speak

French to a French person directly than to speak English to an interpreter, and have the interpreter

repeat what you said in French to the French person. It's exactly like that with Java and its Virtual

Machine. In fact, I'm rather proud of that analogy (so don't steal it).

Having said all that, remember that I also mentioned how much Java has been marketed and

hyped. Because of this, Java has become very popular. Another reason for its popularity is that it

runs inside web browsers, letting programmers create little applications which can run on web

sites. This is obviously a big attraction, given the explosion of the internet over the past several

years. Due to this popularity, there are a lot of jobs out there for Java programmers at the

moment. I'm just making you aware of this fact as it's naturally going to be one of your

considerations. I wouldn't say that there's more demand for Java programmers than for C or C++

programmers, but there will probably be more demand for Java programmers than for

programmers who use languages I've not yet mentioned.

Now let's talk about books, and more generally about reading material, help and tutorials. One of

the first things you should do after thinking about a language is to research it a bit. Do a web

search, and you'll doubtless find many thousands of relevant web sites. Take a quick look around

a few of them, and you'll notice that there are plenty of mailing lists (email lists which you can

send mail to, and everyone who's on the list receives it and can reply to it) about programming

languages, so those are an excellent place to get help (but do learn at least some of your

programming language first). You'll quickly see how popular a language is by how much material

you find about it on the internet. You'll also be able to find programming environments, both free

53 
 
 

and commercial, in the same way. When you're comfortable that you've chosen the right language

for you, it's time to get a book.

Don't let anyone tell you otherwise: there's no substitute for being able to hold a book. I'm not

claiming that they'll never be replaced with Star Trek-like electronic pads; I'm just saying that

they won't be replaced until the pads offer the same light weight, sharpness of text, and

portability. At the moment, you can only get that in a good old-fashioned book (and don't say that

laptops offer all that; they don't, and I know because I'm typing this article on a very nice one,

which is nevertheless not as enjoyable to read as a printed book). But I digress.

You'll want to find a suitable beginner's book on your chosen programming language, and you'll

be pleased to know that there will be plenty to choose from (particularly so if you chose one of

the three languages I mentioned earlier). Generally speaking, go by the opinions of others, not the

blurb on the books themselves. An excellent way to do this is to read the customer reviews at

places like amazon.com (and amazon.co.uk, of course). Some of the comments are inevitably

semi-literate nonsense, but you'll get an excellent general impression of the book's quality and

relevance. Just one tip about that: when weighing up the reviews, discard the top and bottom 5-

10% (in terms of ratings). There will always be overly negative people, and there will most

certainly always be those who lavish excessive praise on anything they lay hands upon (perhaps

surprisingly, you'll always find more of them than of the overly negative people). But that's just

common sense.

54 
 
 

I can't give a specific suggestion regarding Java since I haven't read many Java books (though I

will say that the book I have here now is Beginning Java 2 by Ivor Horton, published by Wrox).

Regarding the other two languages, I would suggest titles as follows:

• C

The C Programming Language by Brian W Kernighan and Dennis M Ritchie, published by

Prentice Hall. Make sure you get the 2nd Edition. Let me just say that this was written by the

people who created the C language, and is seen as the classic programming text. It's commonly

referred to as "K&R", after its authors. However, it's quite challenging, and I wouldn't tend to

recommend it for beginners. For beginners I would tend to recommend you also get:

The Absolute Beginner's Guide to C by Greg Perry, published by Sams. This is great because it

gives a good introduction to programming in general as well as giving you a good grounding in

C. It also talks about how to use various popular programming environments, which will be

useful if you've never used one before.

• C++

The C++ Programming Language by Bjarne Stroustrup, published by Addison-Wesley. This was

written by the programmer who created C++, so it's certainly authoritative. I don't have this one

myself, but I would presume it will be similar (in terms of its target audience) to The C

Programming Language, detailed above. Make sure you look for a suitable beginner's C++ book

also.

You might feel that this section is a bit dismissive, but you really will benefit hugely from getting

hold of an appropriate book and working through it. Let me just finish this section with two tips

for when you're going through your new books:

55 
 
 

1. Take your time, and don't expect to go too fast.

It may take you an hour to go through a single page and really understand everything (you may

particularly find this with The C Programming Language, which is focused almost to the point of

terseness), but that's fine. The point isn't to get through the book; it's to understand the subject. A

programming textbook is like any other textbook; you don't read it, you work through it (and you

keep going back to it). It will be an extremely enjoyable and enlightening experience, so enjoy

every moment of it.

2. Do the exercises.

That sounds like a really obvious thing to say, but you'd be amazed how many people don't do the

exercises - they don't type in the code they see in the book, they don't run it, and then they come

away from the book when they're only about a third of the way through, having found that they

suddenly ran up against an impossible-to-understand section after they thought they'd been doing

so well. It's an old story indeed (I know, because I have first-hand experience - I never used to do

the exercises, and only when I finally tried doing it "by the book" did I suddenly realise how

important they were).

Just do it to humour me, or as thanks for writing this huge article. I'll go so far as to say this: if

you don't do the exercises, you may still understand every bit of the book, and get through it all,

but you won't have learned even half of what you might have. Also, you won't be as good a

programmer - I guarantee it. There are so many things you miss by not doing the exercises:

• You miss typing in the code and making typing errors which make the compiler

puke

• You miss having to debug your program because you mistyped something in it

56 
 
 

• You miss the immersion you get from editing the code yourself

• You miss the feeling of control you get from typing the code in yourself

• You deprive your brain of the chance to assimilate the code line by line

Really, it's that much of a loss. You might think that the first two points are reasons not to do the

exercises, but you'd be wrong - we learn much more from those kinds of mistakes than from

reading some code in a book. If you learn nothing else from this article, just learn that you should

always do the exercises. I promise you'll thank me later (or at least you would if you remembered

to).

Now, at last, it's time to move on to the dreaded jargon section, where grown men and women

have been known to go completely insane after only moments of exposure (though that might just

be hearsay). It's not required reading, but it might really help to give you a leg up on some of the

terms which you will definitely run into at some point. You can also be fairly sure that nowhere

else will you find them explained as sensibly and clearly as they are here (you'd be shocked at the

bizarre and convoluted definitions and explanations some people come up with for programming

jargon - those people often go on to write documentation for major application programs).

Programming jargon

This section lists various terms related to programming (and computers in general, but only those

which are in some way relevant to programming), in alphabetical order. The terms aren't split into

categories or topics, because it's presumed that in most cases you wouldn't be sure which category

57 
 
 

to look at in the first place (people really do categorise glossaries; those people should probably

be forced to take part in Star Trek trivia competitions with expert programmers).

Note that terms in bold are defined in this section, so if you see a bold term you're not familiar

with, just look in this section for an explanation. Now, without further ado, here we go.

• Ada

A programming language, sometimes with a number after the name (e.g. Ada95). Used

commonly for defense applications (particularly in the UK). A fairly common choice as a first

language in university computer science courses (again, particularly in the UK). Named after Ada

Lovelace, a very clever lady who was one of the first ever programmers (I told you that gender

had nothing to do with programming ability).

• API

An Application Programming Interface. An API is a kind of predefined standard for how you

should write certain types of programs, and commonly refers to a standard for how to write

programs which interact with and extend other programs. For example, you probably know that

your web browser can use plug-ins to allow it to display more kinds of content. You might have a

plug-in that lets you view PDF files, or a plug-in that lets you view Quicktime movies. The

reason people can write these plugins is because the browser has a "plug-in API" - a predefined

set of rules that programmers should follow if they want their plug-ins to work with the web

browser.

APIs are everywhere. The reason all Windows applications look much the same (the same style

of buttons and checkboxes and menus) is that there's a Windows programming API. Any time

58 
 
 

you're defining a standard way of writing code to work with something, you're creating an API. If

someone asks about the API for something, they're asking for information on how to properly

write programs which work with whatever the thing is.

• Apple Computer

A computer software and hardware company based in Cupertino, California. Apple are the

creators of the Macintosh (sometimes just called Mac) line of computers, and of the Mac OS

operating system. Apple invented many of the technologies which all computers use today.

People who own Macs are typically intensely fond of their computers, and passionately

evangelise them. Many surveys have found that Mac users are amongst the most loyal computer

users in the whole computer industry.

• application

A program designed to let you accomplish a specific task. For example, a word processor (like

Microsoft Word, or WordPerfect) is an application. So is a graphics program like Photoshop or

Paint.

• application framework

A sort of template to help you make applications. With some programming languages, there's

quite a lot of work involved in creating a full application for a GUI operating system, so it helps

to have the basics already done for you. A popular application framework is PowerPlant, which is

included with the programming environment called CodeWarrior.

• ASCII

American Standard Code for Information Interchange. A way of specifying alphabetical letters,

digits, punctuation marks and so on as numbers. Computers deal with numbers by design, so it's
59 
 
 

easier and more efficient for them to represent things as numbers rather than as anything else. The

ASCII system lets you represent letters and other characters as numbers; for example, a capital

"A" is represented by the number 65. Sometimes, people use the term "plain text" to refer to text

which is encoded as ASCII (notably in email programs).

• barf

Also sometimes puke. To run into a programming error; usually used to refer to a compiler, in

this form: "I'd left out a semicolon, and the compiler just barfed."

• BASIC

A programming language, or more accurately a family of programming languages since there

are many versions of BASIC. The term stands for Beginner's All-purpose Symbolic Instruction

Code, which sounds technical but really isn't: it's for beginners, it's all-purpose rather than being

designed for a specific type of programming (quite a few languages are designed for just one type

of programming, like business programming or scientific programming), and it's a "symbolic

instruction code" which just essentially means that it's a programming language.

As its name implies, any version of BASIC tends to be good for those who are just starting to

program. For that same reason, BASIC tends to have a bad reputation amongst "serious"

programmers, for being "too simple" or inflexible. Of course, the real reason they're annoyed is

that BASIC makes it even easier for people to take up programming, so there's more competition

for all the fabulous software products programmers create.

• binary

60 
 
 

A way of counting which involves just two digits: 0 and 1. Our normal way of counting (with ten

digits) is called decimal. Computers use binary since processors really have millions of little

switches, and switches can only be in one of two states: on or off. So, it was sensible to use

binary since you can represent off with 0 and on with 1.

Sometimes you'll also hear programmers referring to "a binary". This means the same as object

code; it's the compiled version of a program.

• Borland

A software company which makes programming environments, notably for C++ and Java

programmers.

•C

A very popular programming language, created by Dennis M. Ritchie. C is a very compact and

quite easy to learn language, and is an excellent choice for those intending to make a career out of

programming. It is an especially good first language, since you can then move on to any of

various object oriented versions of C, or other fairly C-like languages such as Java.

• C++

A programming langauge which is an object oriented version of C, and which was created by

Bjarne Stroustrup. The modern language of choice for Windows and Mac OS application

development.

• Carbon

An API for the operating system called Mac OS X, which also can be used with Mac OS

versions 89. Carbon is an updated version of the Macintosh Toolbox.

61 
 
 

• COBOL

COmmon Business-Oriented Language; a programming language. As its name implies,

COBOL was designed to be used for writing business programs. It was very popular during the

1960s and 70s, but is now seen as an essentially dead language.

• Cocoa

A very tasty hot drink. In computing, it also refers to an API for the operating system called

Mac OS X, which runs on Macintosh computers. Cocoa is a very advanced object oriented

API. Cocoa used to be called NEXTSTEP, back when it was owned by Next Computer Inc.

• code

The actual text of the programs you write, before you compile them. Sometimes called source

code, or just source.

• CodeWarrior

A programming environment, including an editor, compiler, linker, debugger, application

frameworks and RAD tools. It's called CodeWarrior because some programmers like to call

themselves "code warriors", because it's a better title than "pasty-faced geeks". CodeWarrior is

available in a full version and a starter version, and both have academic discounts available. You

can get versions of CodeWarrior for Mac OS, Windows, Linux and any number of other

platforms.

• compile

62 
 
 

To convert source code into object code. Sometimes also used as a noun; you might refer to your

compiled program as "a compile", or you might say you "did a compile" when you've compiled

your program.

• compile

A special kind of program which compiles (converts) source code (which is easy for humans to

read and write) into object code (which is what computers need). Compilers are almost always

included with your programming environment.

• cross-platform

Able to run on multiple different types of computers and operating systems without needing to

be recompiled first. Java is cross-platform.

• debug

To find and correct errors and problems in your programs. You will probably use a debugger to

help you debug. The term comes from the fact that the earliest computers were huge mechanical

devices, and sometimes insects would fly into them and cause damage, thus the computer

engineers had to physically remove dead bugs from the internal workings of the computers.

• debugger

A special program which lets you run your programs one line at a time, and keep track of

everything that's going on in them, to help you identify and correct errors and problems.

Debugging is an integral, if sometimes unpleasant, part of programming.

• editor

63 
 
 

A program (much like a simple word processor) which you use to write your programs. It can be

any text editor, or part of a programming environment.

• FOLDOC

The Free OnLine Dictionary Of Computing. A web site at http://www.foldoc.org/ where you can

find definitions of pretty much any computing term. Use as a next step after reading this list of

common jargon.

• FORTRAN

Also "Fortran" (not all in capital letters). FORmula TRANslation; a programming language.

FORTRAN is a programming language designed to be used for writing scientific and numerical

programs. Still in use, although not really a mainstream language.

• GUI

A Graphical User Interface. The idea of having little pictures (icons) of things instead of just text.

You'll be familiar with a GUI, since you're almost certainly using one right now. The concept of

having a mouse pointer, menubars, buttons, checkboxes, windows, folders, document icons and

so on is all part of a GUI.

• hack

A program which was written very quickly and/or carelessly, or a program which does something

unconventional or frivolous. Can also be used as a verb, meaning simply to write computer

programs.

• hacker

64 
 
 

Traditionally, simply a computer programmer - and this meaning is still in use. More recently, the

term also refers to a person who maliciously compromises or damages computer systems (often

over the internet).

• hardware

Any physical piece of machinery or electronics. A computer is hardware, as is a mouse or

keyboard or printer. A tangible, physical piece of equipment. Compare with software.

• InterDev

A programming environment from Microsoft. It allows you to program in various different

programming languages.

• Interface Builder

A RAD and object oriented programming tool included with Mac OS X. Used in conjunction

with Project Builder to create applications for Carbon, Cocoa and Java.

• Java

A programming language which is object oriented and can run on many different computers

without needing to be re-compiled for each one. Very popular at the moment, but can be slow in

comparison to other languages.

• JavaScript

A scripting language used within web pages to add basic interactivity and so on. A completely

different language from Java, despite the similar name. Often confused with Java by those who

don't know the difference.

• linker
65 
 
 

Usually included with a compiler. A special program which links together all the bits of object

code produced by a compiler. You'll rarely, if ever, have to explicitly use a linker; it's always

automatically taken care of by your programming environment after your program is compiled.

• Linux

An open source, Unix-like operating system. Created by a person called Linus Torvalds, hence

it's "Linus' Unix", or Linux.

• Macintosh

Also called Mac. A line of computers created by Apple Computer. The first mainstream GUI

computers (though the first ever GUI computer was created by Xerox Corporation).

• Macintosh Toolbox

The API for Macintosh computers running the Mac OS operating system up to version 9. Now

updated for Mac OS X and called Carbon.

• Mac OS

The operating system which runs on Macintosh computers. Used to refer to versions up to and

including 9 (not including Mac OS X).

• Mac OS X

A radically new operating system for recent Macintosh computers. It combines the power of

Unix with the friendliness of the Macintosh GUI.

• object code

66 
 
 

A program which has been compiled into a form suitable for the computer to use. Also

sometimes called a binary.

• object orientation

Also called OO. A modern programming concept where the programmer creates "objects" like

reallife objects, with both properties and abilities. In traditional programming, the program was

very separate from the information it acted upon. That's not very much like real life; objects in

real life have both properties (like the colour of your hair, or your height) and abilities (like your

ability to read this article, or your ability to tie your shoelaces). Object oriented programming

essentially tries to allow programmers to think (and program) in a more natural and familiar way.

Popular modern object oriented programming languages include Java and C++ (and my own

favourite, Objective-C).

• Objective-C

Sometimes also Obj-C or ObjC. A programming language which is an object oriented version

of C. Used as the language of choice for developing programs to run in the Cocoa environment

on Mac OS X. A very easy to learn and powerful language. My own language of choice.

• OO

Another way of saying object orientation (or object oriented).

• open source

The idea that the source code of a program should be available to everyone, as well as the

compiled version. This allows any programmer to modify and enhance the program as they see

fit, and it allows new programmers to see exactly how the program was written. Programs which

are open source are free, since anyone can get the source and compile it themselves.

67 
 
 

• operating system

The special and very important program which makes your computer work. It takes care of things

like talking to the screen, printer, keyboard and all the other hardware. Without an operating

system, your computer would just sit there staring blankly into the distance, like you do after

you've had a few beers.

• Pascal

A programming language designed for teaching programming; made to be as simple as

possible. However, this simplicity is also a weakness, and has lead to Pascal being denounced as

a "toy" language, just for hobbyists and rudimentary teaching purposes. There are many

variations of Pascal available.

• Perl

A programming language originally created for Unix computers. Very powerful for

manipulating text, and very popular for writing programs to help run web sites.

• programming

The art of writing computer programs (and it is indeed an art). What this article is all about, so

you shouldn't need this definition.

• programming language

Any of countless special languages used to write programs. Usually not difficult to learn, and

including several English words like "end" and "repeat" and "if".

• programming environment

68 
 
 

A special program (or set of programs) which help people to write other programs. Just like you

use a word processor program to write letters to your Aunt Mary, you use a programming

environment to write programs. Commonly includes a compiler, linker, debugger and

sometimes other things too.

• Project Builder

An excellent programming environment included with Mac OS X. Used in conjunction with

Interface Builder to create programs for Carbon, Cocoa and Java.

• PROLOG

PROgramming in LOGic; a programming language. PROLOG was the first of many languages

designed to use so-called "logical programming" techniques. The basic idea is that you define a

set of facts, then define a goal, and the computer tries to get to the goal using the facts you've

defined.

• puke

Another way of saying barf.

• RAD

Rapid Application Development. A concept where you create application programs very quickly

by visually dragging controls (like buttons and checkboxes and so forth) into windows, to create

the user interface for your application. Many programming environments now include RAD

tools.

• REALbasic

69 
 
 

Sometimes also called RB. An object oriented version of BASIC which includes a

programming environment with an editor, compiler, linker, debugger, and RAD tools.

REALbasic's programming environment runs on Mac OS computers, but can compile

applications for Windows and Carbon too. Probably a very good choice for Macintosh users

who are just starting into programming.

• run

To make a computer perform the steps you've written in your program; to make the program do

whatever it does. Sometimes also called "executing" a program.

• SDK

A Software Development Kit. Typically a package of sample code, documentation and other

items to help you create certain kinds of programs. For example, if you wanted to create a plug-in

for Adobe Photoshop (that's a program which lets you edit pictures), you'd probably want to get

hold of the Photoshop plug-ins SDK. Sort of like a toolkit for programmers.

• scripting

A type of programming using a scripting language.

• scripting language

A special kind of programming language which isn't compiled before you run it; it is compiled

automatically as needed, right before it's run. Often easier than traditional programming for a few

very technical reasons which we won't go into. Might be a good place to start if you find normal

programming languages too difficult.

• software

70 
 
 

Any computer program. It's called software because it's not tangible; not "hard". Compare with

hardware.

• source

Another name for code.

• source code

Another name for code.

• string

Any piece of text. Computers refer to any amount of alphabetical letters or digits or punctuation

marks etc as a "string".

• Unix

A very general group of operating systems, known for their power, stability and reliability, but

also acknowledged to be more difficult to learn and master than a GUI operating system.

Extremely popular operating systems for running web servers.

• user interface

The appearance of your program to the person using it. The windows, menus, buttons and so on

are all collectively called the user interface. Sometimes just called UI.

• virtual machine

A program which emulates (pretends to be) an entire little computer all of its own. Java uses a

virtual machine, which allows Java code itself to be cross-platform, at the expensive of some

speed.

71 
 
 

• virtual memory

A technique whereby a computer uses part of its hard disk as temporary memory for a program. A

way to use more memory than your computer actually has, but at the expense of considerable

speed.

• VM

Either virtual machine or virtual memory.

• wetware

What programmers sometimes humorously call the human brain; the ultimate computing device.

See also hardware and software.

• Windows

One of several operating systems from the company called Microsoft. Collectively they are the

most commonly used operating systems in the world. Each version of Windows tends to have a

year after it instead of a version number (for example, Windows 98). Windows is a graphical

operating system (or GUI operating system).

This brings us to the end of the list of jargon (you can wake up now). For a much more extensive

list of computer related terms, be sure to look at the FOLDOC definition, in the list above - it

will give you the address of a web site you can visit to find the meaning of any computer term

ever used by anyone, anywhere (probably).

72 
 
 

CHAPTER III

METHODOLOGY

Designing an automation system is a very complex task and it requires highly skilled workforce

with different field of specialization. My major is in Mechanical, but automation involves more

than one field. Therefore this project has been planned in three major different stages in order to

understand each stage carefully and to complete the project in time.

Mechanical  Electronic  Computer 


Design circuit design Programming

ROBOTIC ARM DESIGN

In modern era of technology, we can now design and simulate any product in virtual

environment, thus reducing time, effort and cost of overall project. Computer aided design was

first introduced in 1980s and now being used in wide range of industries. The first task in

mechanical design is to create a computer aided product. To achieve this task I have selected a

software called SolidWorks by Dassault Systems. An initial design was built with the help of

SolidWorks 2012, giving the shape of a robotic arm in a virtual environment. (The drawings are

attached)

An articulated robot is a perfect solution for the problem stated in this project earlier. I have

decided to design a 3 Axis articulated robot covering the range of 180 degree with a gripper to
73 
 
 

pick the sack of polyethylene (20kg) and placing it to another location. The arm which needs to

be design can lift and tolerate up to 20kg of weight, therefore following are the parameters

required to begin the design.

PROBLEM

There is a robotic arm required to lift 20kg of sack of polyethylene and placing it from one point

to another within 180 degree range, assuming other parameters, how much force is required to lift

the object?

Applying Newton`s second law of motion, we get;

F = m.g

F = 20*9.8

F = 196 N

Considering that the robot has an

articulated arm which moves in an

angle driven by a servo motor, the

motor requires a certain torque to

lift that object. Hence we have

applied force = 196 N, assuming

other parameters, Lever arm = 6m,

angle of rotation = 45 degree. A

formula is given as torque = rFsin ϴ

Where, r is Radius.
74 
 
 

Applying the formula we get;

τ = rFsin θ

τ = 6*196*sin (45)

τ = 692 N.m

To demonstrate the system I have designed a prototype similar to the actual robot arm, this arm

will demonstrate you by lifting an object from point A to point B.

75 
 
 

UNLESS OTHERWISE SPECIFIED: FINISH:     DEBUR AND


 
DO NOT SCALE DRAWING
DIMENSIONS ARE IN MILLIMETERS   BREAK SHARP REVISION
SURFACE FINISH:   EDGES
TOLERANCES:  
LINEAR:  
ANGULAR:  
NAME   SIGNATURE DATE   TITLE:
   
PIMSAT 
DRAWN A Allahyar
CHK'D  
APPV'D  
MFG  
Q.A   
Robotic Arm  A4
MATERIAL: DWG NO.

WEIGHT:   SCALE:1:10  
SHEET 1 OF 1

76 
 
 

77 
 
 

ELECTRONIC CIRCUIT DESIGN & HARDWARE SELECTION

The second major and complex part is design an electronic circuit to control a robot arm. To

understand the automation technology I have chosen a simple circuit of microcontroller to create

the simple electronic circuit. Creating a microcontroller from scratch is tidy task but fortunately,

the technological advancement helped me to choose better hardware in order to create a simple

system. Arduino development environment is used for this purpose.

Arduino is a tool for making computers that can sense and control more of the physical world

than your desktop computer. It's an open-source physical computing platform based on a simple

microcontroller board, and a development environment for writing software for the board,

Arduino can be used to develop interactive objects, taking inputs from a variety of switches or

sensors, and controlling a variety of lights, motors, and other physical outputs. (Reference: 2)

The figure 1.3 is the selected development board for this

project. The Arduino Uno is a microcontroller board

based on the ATmega328 (datasheet, Atmel). It has 14

digital input/output pins (of which 6 can be used as PWM

outputs), 6 analog inputs, a 16 MHz ceramic resonator, a


Figure 1.3: ARDUINO UNO R3
USB connection, a power jack, an ICSP header, and a

reset button. It contains everything needed to support the microcontroller; simply connect it to a

computer with a USB cable or power it with an AC-to-DC adapter or battery to get started.

SUMMARY
78 
 
 

Microcontroller ATmega328

Operating Voltage 5V

Input Voltage (recommended) 7-12V

Input Voltage (limits) 6-20V

Digital I/O Pins 14 (of which 6 provide PWM output)

Analog Input Pins 6

DC Current per I/O Pin 40 mA

DC Current for 3.3V Pin 50 mA

Flash Memory 32 KB (ATmega328) of which 0.5 KB used by bootloader

SRAM 2 KB (ATmega328)

EEPROM 1 KB (ATmega328)

Clock Speed 16 MHz

79 
 
 

Arduino UNO R3 Schematics (Reference 3)

80 
 
 

The next hardware which is a drive system of a robotic arm is a servomotor. Servo motors have

been around for a long time and are utilized in many applications. They are small in size but pack

a big punch and are very energy-efficient. Because of these features, they can be used to operate

remote-controlled or radio-controlled toy cars, robots and airplanes. Servo motors are also used in

industrial applications, robotics, in-line manufacturing, pharmaceutics and food services. To

demonstrate the task I have selected a small size servo named Futaba s303. It is a standard servo

used in many small scale applications, the detailed information is give below:

Control System: +Pulse Width Control 1520usec Neutral

Required Pulse: 3-5 Volt Peak to Peak Square Wave

Operating Voltage: 4.8-6.0 Volts

Operating Temperature Range: -20 to +60 Degree C

Operating Speed (4.8V): 0.23sec/60 degrees at no load

Operating Speed (6.0V): 0.19sec/60 degrees at no load

Stall Torque (4.8V): 44 oz/in. (3.2kg.cm)

Stall Torque (6.0V): 56.8 oz/in. (4.1kg.cm)

Operating Angle: 45 Deg. one side pulse traveling 400usec

Continuous Rotation Modifiable: Yes

Direction: Counter Clockwise/Pulse Traveling 1520-1900usec

81 
 
 

Current Drain (4.8V): 7.2mA/idle

Current Drain (6.0V): 8mA/idle

Motor Type: 3 Pole Ferrite

Potentiometer Drive: Indirect Drive

Bearing Type: Plastic Bearing

Gear Type: All Nylon Gears

Connector Wire Length: 12"

Dimensions: 1.6" x 0.8"x 1.4" (41 x 20 x 36mm)

Weight: 1.3oz. (37.2g)

Further, basic electronics items were used to as per the requirement and design to control this

servo and to communicate with Arduino UNO R3. The schematic diagram given below is the

final design of this project.

82 
 
 

83 
 
 

84 
 
 

COMPUTER PROGRAMMING

Automation system requires a specific set of instruction to achieve a given task, those instruction

are compiled in computer based programe. In modern technology we have around 2000 computer

language but some of them used widely. In sight of automation, in depth and low level

programing is required in order to give the step by step instruction. C and C++ are two most

popular languages widely used in automation technology and these languages updated to the

integerated development environment by some companies. The Arduino has its own development

environment which contains a text editor for writing code, a message area, a text console, a

toolbar with buttons for common

functions, and a series of menus. It

connects to the Arduino hardware

to upload programs and

communicate with them.

Software written using Arduino are

called sketches. These sketches are

written in the text editor. Sketches

are saved with the file extension

.ino. It has features for

cutting/pasting and for searching/replacing text. The message area gives feedback while saving

and exporting and also displays errors. The console displays text output by the Arduino

environment including complete error messages and other information. The bottom righthand

85 
 
 

corner of the window displays the current board and serial port. The toolbar buttons allow you to

verify and upload programs, create, open, and save sketches, and open the serial monitor.

After completing the design of a robotic arm and its electronic circuit, I programmed it using

arduino software. The micrcontroller cam be programmed and reprogrammed as per required by

task. I programmed a microntroller in a such a way that it lift object from locatio A to location B.

The code I wrote is given below;

//Copyright 2014, Final Year project submitted by Arsalan to Presont Institute of Management
Sciences & Technology.

#include <Servo.h>

int relay2 = 2;
Servo servo8;

int relay3 = 3;
Servo servo9;

int relay4 = 4;
Servo servo10;

int relay5 = 5;
Servo servo11;

int relay6 = 6;
Servo servo12;

int pos = 0; // variable to store the servo position

void setup()
{
pinMode(relay2, OUTPUT);
servo8.attach(8);

pinMode(relay3, OUTPUT);
servo9.attach(9);

86 
 
 

pinMode(relay4, OUTPUT);
servo10.attach(10);

pinMode(relay5, OUTPUT);
servo11.attach(11);

pinMode(relay6, OUTPUT);
servo12.attach(12);

void loop()
{
// 1 - ONE START
//Axis A - base movement from point A to B

digitalWrite(relay4, HIGH);
delay(2000);

for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees

{ // in steps of 1 degree
servo10.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}

//Axis A - base movement from point A to B Complete


// 1 - ONE END

delay(2000);

// 2 - TWO START
//Axis B - for arm movement from point A to B

digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay5, HIGH);
delay(500);

for(pos = 0; pos < 80; pos += 1) //Axis B - Arm movement DOWN


{ // in steps of 1 degree
servo8.write(pos); // tell servo to go to position in variable 'pos'
servo9.write(80-pos);
servo11.write(pos);
delay(15); // waits 15ms for the servo to reach the position
}

//Axis B - for arm movement from point A to B complete - END


//2 - TWO END
87 
 
 

delay(2000);

// 3 - THREE START
//Axis C - Gripper close

digitalWrite(relay6, HIGH);
delay(500);

for(pos = 0; pos < 60; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
servo12.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
//Axis C - Gripper closed - END
//3 - THREE END

delay(2000);

//4 - FOUR START


//Axis B - arm movement from point B to A

for(pos = 80; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees


{
servo8.write(pos); // tell servo to go to position in variable 'pos'
servo9.write(80-pos);
servo11.write(pos);
delay(15); // waits 15ms for the servo to reach the position
}

//Axis B - arm movement from point B to A - END


//4 - FOUR END

delay(2000);

//5 - FIVE START


//Axis A - base movement from point B to A

for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees


{
servo10.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}

//Axis A - base movement from point B to A


//5 - FIVE END

delay(2000);
88 
 
 

// 6 - SIX START
//Axis B - for arm movement

for(pos = 0; pos < 100; pos += 1) //Axis B - Arm movement DOWN


{ // in steps of 1 degree
servo8.write(pos); // tell servo to go to position in variable 'pos'
servo9.write(100-pos);
servo11.write(pos);
delay(15); // waits 15ms for the servo to reach the position
}

//Axis B - for arm movement complete - END


//6 - SIX END

delay(2000);

//7 - SEVEN START


//Axis C - Gripper Open

for(pos = 60; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees


{
servo12.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}

digitalWrite(relay6, LOW);
delay(500);

//Axis C - Gripper Open


//7 - SEVEN END

delay(2000);

//8 - EIGHT START


//Axis B - arm movement from point B to A

for(pos = 100; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees


{
servo8.write(pos); // tell servo to go to position in variable 'pos'
servo9.write(100-pos);
servo11.write(pos);
delay(15); // waits 15ms for the servo to reach the position
}

//Axis B - arm movement from point B to A - END


//8 - EIGHT END
89 
 
 

//9 - NINE START


//All relays Closed

digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, LOW);
digitalWrite(relay5, LOW);
delay(500);

//ALL relays Closed


//9 - NINE END
}

TESTING

After completing all the design process

and reviewing, the final test is on its

place. The robotic arm is assembled and

programmed in different sequence to

check the result of the system. The robot

sucessfully lifted an object weighing about 200 grams and moving it to another location. The

object was lifted from Point A to Point B exactly at 180 degree. Below are the two pictures

showing the result of the test.

90 
 
 

CHAPTER IV

FINDINGS

IMPORTANCE OF AUTOMATION

This outcome of this project indicates a clear understanding towards automation system and its

importance. A simple 3 axis robot arm demonstrate how we can utilize combined technologies to

achieve a certain task. Moreover, this is just one example, if discuss a little more about

automation, we can see industrial automation, process control, and numerical control is the use of

control systems such as computers to control industrial machinery and processes.

Some advantages are repeatability, tighter quality control, and waste reduction, integration with

business systems, increased productivity and reduction of labour. Some disadvantages are high

initial costs and increased dependence on maintenance.

Industrial automation and process control greatly reduces the need for human sensory and mental

requirements as well. Most complex industrial automation processes and systems can be

automated. A major advantage of industrial automation and process control is the increased

emphasis on flexibility and convertibility in the manufacturing process. Manufacturers are

increasingly demanding the ability to easily switch from manufacturing a wide range of products

without having to completely rebuild the production lines.

91 
 
 

CONSUMER USAGE

The use of automation technology in industry is just one aspect. If we even look around, we can

find thousands of home appliances using automation technology without your knowledge. A

simple example is your home washing machine, it turns off after the job is done. All that process

is controlled by a tiny microcontroller system. But this is not it.

Recently, a new technology is emerging in market which is bringing industries to your home, so

everyone can make whatever they want with just a click of a button. Additive manufacturing or

3D printing is the most developing technology in recent times. “A 3D printer is a limited type of

industrial robot that is capable of carrying out an additive process under computer control.”

(Wikipedia)

While 3D printing technology has been around since the 1980s, it was not until the early 2010s

that the printers became widely available commercially and for consumer use because of the low

cost and easy to use integrated development environment.

CHAPTER V
92 
 
 

CONCLUSION

Several technological advances have always tried the minds of men. But one thing is for sure,

technology has always been there to help us in our everyday situations. Just think of how you

could get food to stay fresh without a fridge. In fact, technology has given us the power to support

our rapidly growing needs in order to survive.

Just like with manufacturing industry, most of the companies today that have reach success have

upgraded their machine in to something automated. Productions have increased since they have

improved the machines that they use in producing their products. If you are using 30 years old

machine and it does not provide the certain number of products required you will definitely lose a

lot on your income, this is true especially on bottling and packaging department. If your workers

and machines are too old to handle big orders you might torture your equipment and cost a lot to

the damage that it will incur if you force it to work continuously.

A simple robotic arm in this demonstrated a vision of how an automated system can ease your

life. From industry to your home automation can help you build better system. Technology has

always been a gift to our lives. It is just us use it well. If we can do things faster and better, then it

must be a gift from the God.

93 
 
 

REFERENCES

Bibliography:

Hwaiyu Geng, 2004, Manufacturing Engineering Handbook, McGraw-Hill


Engineering, Chapter 11, Pg 11.1.

National Research Council. (1998). The future of air traffic control: Human
operators and automation. C. D. Wickens, A. S. Mavor, R. Parasuraman,
& J. P. McGee (Eds.). Washington, DC: National Academy Press.

R.S KHURMI, J.K GUPTA, 14th Edition, Machine Design

John J. Uicker, Jr., Gordon R. Pennock and Joseph E. Shigley, 2003, Theory of
Machines and Mechanisms, Third Edition, Oxford University Press

Parasuraman, R., & Riley, V. (1997). Humans and automation: Use, misuse,
disuse, abuse. Human Factors, 39(2), 230-253

Reference 1: http://whatis.techtarget.com/definition/microcontroller

Reference 2: http://arduino.cc/en/Guide/Introduction

Reference 3: http://arduino.cc/en/uploads/Main/Arduino_Uno_Rev3-
schematic.pdf

Figure 1.2: http://www.mikroe.com/chapters/view/65/

Hwaiyu Geng, 2004, Manufacturing Engineering Handbook, McGraw-Hill


Engineering, Chapter 45, Figure No. 45.3.

Datasheet, Atmel:
http://www.atmel.com/dyn/resources/prod_documents/doc8161.pdf

Wikipedia: http://en.wikipedia.org/wiki/3D_printing

94 
 
 

VITA

Arsalan Allahyar (EngTech – MIMechE)

Candidate for the Degree of

Bachelors of Technology (Hons)

Thesis: AUTOMATION: A ROBOTIC ARM

Major Field: Mechanical

95 
 

You might also like