Dr. Bk Singh's Mechatronics Chap-5

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 42

ADAMA SCIENCE AND TECHNOLOGY UNIVERSITY

SCHOOL OF MECHANICAL, CHEMICAL AND MATERIAL ENGINEERING


DEPARTMENT OF MECHANICAL ENGINEERING
Introduction to Mechatronics
CHAPTER-5
Processors for Automation and Languages

Prepared by: Proff B.K. Sing and Mr. Tatek


Tafesse

04/07/202
4
CHAPTER FIVE
Processors for Automation and Languages
• Artificial intelligence
• Microprocessors
• Assembly languages
• C – Language
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
• Objectives
The objectives of this chapter are that, after studying it, the students should be able to:

• Explain what is meant by an intelligent machine and the capabilities of such machines.

• Explain the meaning of neural networks and their relevance to pattern recognition.

• Explain the term fuzzy logic.

• Describe the basic structure of a microprocessor system.

• Describe the architecture of common microprocessors and how they can be incorporated in

microprocessor systems.

• Describe the basic structure of microcontrollers and how their registers can be set up to carry

out tasks.
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers

What is meant by artificial intelligence?

• What constitutes an intelligent machine?

• A dictionary definition of intelligent might be ‘endowed (brilliant) with the ability to reason’.

• The more intelligent we think a person is, the more we consider he or she is able to learn,
generalise from this acquired knowledge, be capable of reasoning and able to make
predictions by considering what is possible, learning from any mistakes.

• We can apply the same criteria to a machine: an intelligent machine is one endowed with the
ability to reason.
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers

What is meant by artificial intelligence?

• A central heating system makes decisions about its actions.

• For example, should the boiler switch on or off as a result of information from a thermostat?

• It is not, however, considered to be intelligent because it is not capable of reasoning and making
decisions under a wide range of conditions.

• For example, it cannot recognise a pattern in inputs from a thermostat and so make predictions about
whether to switch the boiler on or off.

• It just does what it is told to do.

• It does not ‘think for itself’


CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers

Self-regulation

• We can consider the closed-loop feedback systems discussed in earlier chapters as


being self-regulation systems in that they regulate the output of a system to a
required value.

• Thus a thermostatically controlled central heating system is used to maintain the


room temperature at the value set for the thermostat.

• Such systems cannot, however, be considered intelligent;

• they merely do what they were told to do.


CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers

Perception and cognition

 Perception with an intelligent system is the collecting of information using sensors and the
organising of the gathered information so that decisions can be made.

 For example, a control system used with a production line might have a video camera to
observe components on a conveyor belt.

 The signals received from the camera enable a computed representation of the components to
be made so that features can be identified.

 This will contain information about critical elements of the components.


CHAPTER FIVE
Processors for Automation and Languages
 Microprocessors and microcontrollers

Perception and cognition

 These can then be compared with representations of the components so that decisions can be
made by the control system as to whether the component is correctly assembled or perhaps
which component it is.

 Then action can be taken by the control system perhaps to reject faulty components or divert
particular components to particular boxes.

 Thus, with a mechatronics system, perception involves sensors gathering appropriate


information about a system and its environment, decoding it and processing it to give useful
information which can be used elsewhere in the system to make decisions
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
Cognition
• Once a machine has collected and organised information, it has to make decisions about what
to do as a consequence of the information gathered.

• This is termed cognition. Vital to this perception and cognition is pattern recognition.

• What are the patterns in the data gathered?


CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
Cognition
 Humans are very good at pattern recognition.

 Think of a security guard observing television monitors.

 He or she is able to look at the monitors and recognise unusual patterns, e.g. a person where
there should be no person, an object having been moved, etc.

 This is the facility required of intelligent machines.

 An autopilot system on an aircraft monitors a lot of information and, on the basis of the
patterns perceived in that data, makes decisions as to how to adjust the aircraft controls.
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
Cognition
 Machine pattern recognition can be achieved by the machine having a set of patterns in its
memory and gathered patterns are then compared with these and a match sought.

 The patterns in its memory may arise from models or a process of training in which data is
gathered for a range of objects or situations and these given identification codes.

 For example, for recognising coins, information may be gathered about diameter and colour.

 Thus a particular one-pound coin might be classified as having a diameter of 2.25 cm and a
colour which is a particular degree of redness (it is a bronze coin).

 However, an intelligent machine will need to take account of worn and dirty coins and still be
able to recognise the one-pound coin.
Neural networks
 In example of the coins, only two dimensions were considered, namely diameter and colour.

 In more complex situations there may be many more dimensions.

 The human brain is faced with sorting and classifying multidimensional information and does
this using neural networks.

 Artificial neural networks are now being used with intelligent machines.

 Such networks do not need to be programmed but can learn and generalize from examples
and training.

 A neural network (Figure 23.1) is composed of a large number of interconnected processing


units, the outputs from some units being inputs to others.

 Each processor in the network receives information at its inputs, and multiplies each by a
weighting factor.

 If operating as AND, it then sums these weighted inputs and gives an output of a 1 if the sum
exceeds a certain value or is positive.
 For example, we might have an input of 1 with a weighting factor of -1.5 to give -1.5,
another input of 1 with a weighting factor of 1.0 to give 1.0 and a third input of 1 with a
weighting factor of 1.0 to give 1.0.

 The sum of these weighted inputs is thus -1.5 + 1.0 + 1.0 = 0.5 and so an output of 1 if the
values are to be positive for an output.

 With these inputs as 1 x -1.5, 0 x 1.0 and 0 x 1.0, the weighted sum is -1.5 and so an output of
0.

 The network can be programmed by learning from examples and so be capable of learning.

Reasoning

 It is the process of going from what is known to what is not known.

 There are a number of mechanisms for carrying out reasoning.


What is Fuzzy Logic?
 The 'Fuzzy' word means the things that are not clear or are vague.
 Sometimes, we cannot decide in real life that the given problem or statement is either true or
false.
 At that time, this concept provides many values between the true and false and gives the
flexibility to find the best solution to that problem.
Example of Fuzzy Logic as comparing to Boolean Logic

 Fuzzy logic contains the multiple logical values and these values are the truth values of a
variable or problem between 0 and 1.
 This concept was introduced by Lofti Zadeh in 1965 based on the Fuzzy Set Theory.
 This concept provides the possibilities which are not given by computers, but similar to the
range of possibilities generated by humans.
Control

 If we take a simple control problem, e.g. the sequencing of the red, amber, green lights at a
traffic crossing, then it should be possible to solve it by an electronic control system involving
combinational and sequential logic integrated circuits.

 However, with a more complex situation there might be many more variables to control in a
more complex control sequence.

 The simplest solution now becomes not one of constructing a system based on hard-wired
connections of combinational and sequential logic integrated circuits but of using a
microprocessor and using software to make the ‘interconnections’.

 The microprocessor systems that we are concerned with in this course are for use as control
systems and are termed embedded microprocessors.

 This is because such a microprocessor is dedicated to controlling a specific function and is


self-starting, requiring no human intervention and completely self-contained with its own
operating program.
 For the human, it is not apparent that the system is a microprocessor one.

 Thus, a modern washing machine contains a microprocessor but all that the operator has to do
to operate it is to select the type of wash required by pressing the appropriate button or rotating
a switch and then press the button to start.

Microprocessor systems

 Systems using microprocessors basically have three parts:

 Central processing unit (CPU) to recognize and carry out program instructions (this is the part
which uses the microprocessor),

 Input and output interfaces to handle communications between the microprocessor and the
outside world (the term port is used for the interface), and

 Memory to hold the program instructions and data.

 Figure 10.1 illustrates the general arrangement of a microprocessor system.

 Microprocessors which have memory and various input/output arrangements all on the same
chip are called microcontrollers
Buses
 Digital signals move from one section to another along paths called buses.
 A bus, in the physical sense, is just a number of parallel conductors along which electrical
signals can be carried and are paths which can be shared by all the chips in the system.
 This is because if separate connections were used between the chips, there would be a very
large number of connecting conductors.
 Using shared connection buses does mean that when one chip puts data on the bus, the other
chips have to wait their turn until the data transfer is complete before one of them can put its
data on the bus.
 Typically a bus has 16 or 32 parallel connections so that each can carry 1 bit of a data word
simultaneously.
 This gives faster transmission than having a serial connection in which an entire word is sent
in a sequence of bits along a single conductor.
 There are three forms of bus in a microprocessor system
Data bus
 The data associated with the processing function of the CPU is carried by the data bus.

 it is used to transport a word to or from the CPU and the memory or the input/output
interfaces.

 Each wire in the bus carries a binary signal, i.e. a 0 or a 1.

 Thus with a four-wire bus we might have the word 1010 being carried, each bit being carried
by a separate wire in the bus, as:
• The more wires the data bus has, the longer the word length that can be used.

• The range of values which a single item of data can have is restricted to that which can be
represented by the word length.

• Thus with a word of length 4 bits the number of values is Thus if the data is to
represent, say, a temperature, then the range of possible temperatures must be divided into 16
segments if we are to represent that range by a 4-bit word.

Address bus

• The address bus carries signals which indicate where data is to be found and so the selection of
certain memory locations or input or output ports.

• Each storage location within a memory device has a unique identification, termed its address,
so that the system is able to select a particular instruction or data item in the memory.

• Each input/output interface also has an address.

• When a particular address is selected by its address being placed on the address bus, only that
location is open to the communications from the CPU.
 The CPU is thus able to communicate with just one location at a time.

 A computer with an 8-bit data bus has typically a 16-bit-wide address bus, i.e. 16 wires.

 This size of address bus enables ….. locations to be addressed; …. is 65536 locations and is
usually written as 64K, where K is equal to 1024.

 The more memory that can be addressed, the greater the volume of data that can be stored and
the larger and more sophisticated the programs that can be used.

Control Bus

 The signals relating to control actions are carried by the control bus.

 For example, it is necessary for the microprocessor to inform memory devices whether they
are to read data from an input device or write data to an output device.

 The term READ is used for receiving a signal and WRITE for sending a signal.

 The control bus is also used to carry the system clock signals;
 these are to synchronise all the actions of the microprocessor system.
 The clock is a crystal-controlled oscillator and produces pulses at regular intervals.
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
The microprocessor

 The microprocessor is generally referred to as the central processing unit (CPU).

 It is that part of the processor system which processes the data fetching instructions from
memory, decoding them and executing them.

 The internal structure – the term architecture is used – depends on the microprocessor
concerned.

 Figure 10.2 indicates, in a simplified manner, the general architecture of a microprocessor.


CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
The microprocessor

The following are the functions of the constituent parts of a microprocessor.

1 Arithmetic and logic unit (ALU)

• The arithmetic and logic unit is responsible for performing the data manipulation.

2 Registers

• Internal data that the CPU is currently using is temporarily held in a group of registers while
instructions are being executed.

• These are memory locations within the microprocessor and are used to store information
involved in program execution.

• A microprocessor will contain a group of registers, each type of register having a different
function.
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
The microprocessor
3. Control unit
 The control unit determines the timing and sequence of operations.

 It generates the timing signals used to fetch a program instruction from memory and
execute it.

 The Motorola 6800 uses a clock with a maximum frequency of 1 MHz, i.e. a clock
period of 1 μs, and instructions require between two and twelve clock cycles.

 Operations involving the microprocessor are reckoned in terms of the number of


cycles they take
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
The microprocessor
Memory
• The memory unit in a microprocessor system stores binary data and takes the form of one or
more integrated circuits.

• The data may be program instruction codes or numbers being operated on. The size of the
memory is determined by the number of wires in the address bus.

• The memory elements in a unit consist essentially of large numbers of storage cells with each
cell capable of storing either a 0 or a 1 bit.

• The storage cells are grouped in locations with each location capable of storing one word.
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
The microprocessor
Memory
• In order to access the stored word, each location is identified by a
unique address.
• Thus with a 4-bit address bus we can have 16 different addresses with
each, perhaps, capable of storing 1 byte, i.e. a group of 8 bits (Figure
10.5).
• The size of a memory unit is specified in terms of the number of
storage locations available; 1K is locations and thus a 4K
memory has 4096 locations.
Input/output

 The input/output operation is defined as the transfer of data between the microprocessor and
the external world.

 The term peripheral devices is used for pieces of equipment that exchange data with a
microprocessor system.

 Because the speeds and characteristics of peripheral devices can differ significantly from
those of the microprocessor, they are connected via interface chips.

 A major function of an interface chip is thus to synchronise data transfers between the
microprocessor and peripheral device.

 In input operations the input device places the data in the data register of the interface chip;
this holds the data until it is read by the microprocessor.

 In output operations the microprocessor places the data in the register until it is read by the
peripheral.
Microcontrollers
For a microprocessor to give a system which can be used for control, additional chips are
necessary, e.g.

 memory devices for program and data storage and

 input/output ports to allow it to communicate with the external world and receive signals
from it.

 The microcontroller is the integration of a microprocessor with memory and input/output


interfaces, and other peripherals such as timers, on a single chip.

 Figure 10.9 shows the general block diagram of a microcontroller.

 The general microcontroller has pins for external connections of inputs and outputs,
power, clock and control signals.
 The pins for the inputs and outputs are grouped into units called input/output ports.

 Usually such ports have eight lines in order to be able to transfer an 8-bit word of data.

 Two ports may be used for a 16-bit word, one to transmit the lower 8 bits and other the upper 8 bits.

 The ports can be input only, output only or programmable to be either input or output.
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
The microprocessor
Programming
A commonly used method for the development of programs follows the following steps.

1 Define the problem, stating quite clearly what function the program is to perform, the inputs and outputs required, any
constraints regarding speed of operation, accuracy, memory size, etc.

2 Define the algorithm to be used. An algorithm is the sequence of steps which define a method of solving the problem.

3 For systems with fewer than thousands of instructions a useful aid is to represent the algorithm by means of a flow
chart.

Figure 10.39(a) shows the standard symbols used in the preparation of flow charts. Each step of an algorithm is
represented by one or more of these symbols and linked together by lines to represent the program flow.

Figure 10.39(b) shows part of a flow chart where, following the program start, there is operation A, followed by a
branch to either operation B or operation C depending on whether the decision to the query is yes or no.
Programming
 Another useful design tool is pseudocode.
 Pseudocode is a way of describing the steps in an algorithm in an informal way which can
later be translated into a program.
4 Translate the flow chart/algorithm into instructions which the microprocessor can execute.
 This can be done by writing the instructions in some language, e.g. assembly language or
perhaps C, and then converting these, either manually or by means of an assembler computer
program, into a code which is acceptable to the microprocessor, i.e. machine code.
5. Test and debug the program.
 Errors in programs are referred to as bugs and the process of tracking them down and
eliminating them as debugging.
Pseudocode
 Pseudocode is rather like drawing a flow chart and involves writing a program as a sequence
of functions or operations with the decision element IF–THEN–ELSE and the repetition
element WHILE–DO.
 A sequence (Figure 10.40(a)) would be written as:
Figure 10.40(b) shows such a decision in a flow chart. A
repetition is written as:
Figure 10.40(c) shows the WHILE–DO as a flow chart. A
program written in this way might then appear as:
CHAPTER FIVE
Processors for Automation and Languages
Microprocessors and microcontrollers
The microprocessor
Summary

• Basically, systems involving microprocessors have three parts:

• a central processing unit (CPU),

• input and output interfaces and

• memory.

• With in a microprocessor, digital signals move along buses, these being parallel tracks for transmission of parallel
rather than serial data.

• Microcontrollers are the integration on a single chip of a microprocessor with memory, input/output interfaces and
other peripherals such as timers.

• An algorithm is the sequence of steps which define a method of solving a problem.

• Flow charts and pseudocode are two methods of describing such steps
i o n ! !
t t e n t
ou r a
f or y
n k y ou
Th a

You might also like