You are on page 1of 13

MECHATRONICS

(Course Code: 15ME54T)

LECTURE NOTES

For Fifth Semester Diploma in Mechanical Engineering


According to Revised Curriculum – 2015

Prepared by:
PAVITHRA KUMAR M
LECTURER
DEPARTMENT OF MECHANICAL ENGINEERING

GOVERNMENT POLYTECHNIC, BANTWAL – 574211


DAKSHINA KANNADA
Mechatronics Digital Logic and Data Presentation

UNIT 2: DIGITAL LOGIC AND DATA PRESENTATION

2.1 Digital Signals

The output from most sensors tends to be in analogue form, the size of the output being related to the
size of the input. Where a microprocessor is used as part of the measurement or control system, the
analogue output from the sensor has to be converted into a digital form before it can be used as an
input to the microprocessor. Likewise, most actuators operate with analogue inputs and so the digital
output from a microprocessor has to be converted into an analogue form before it can be used as an
input by the actuator.

2.1.1 Binary Number System

The binary system is based on just the two symbols or states 0 and 1, these possibly being 0 V and 5
V signals. These are termed binary digits or bits .When a number is represented by this system, the
digit position in the number indicates the weight attached to each digit, the weight increasing by a
factor of 2 as we proceed from right to left:

... 23 22 21 20
bit 3 bit 2 bit 1 bit 0

For example, the decimal number 15 is 20 + 21 + 22 + 23 = 1111 in the binary system. In a binary
number the bit 0 is termed the least significant bit (LSB) and the highest bit the most significant bit
(MSB). The combination of bits to represent a number is termed a word. Thus 1111 is a 4-bit word.
Such a word could be used to represent the size of a signal. The term byte is used for a group of 8
bits.

2.1.2 Binary Coded Decimal System

The Binary Coded Decimal system (BCD system) is a widely used system with computers. Each
decimal digit is coded separately in binary. For example, the decimal number 15 in BCD is
0001 0101. This code is useful for outputs from microprocessor-based systems where the output has
to drive decimal displays, each decimal digit in the display being supplied by the microprocessor
with its own binary code.

By: Pavithra Kumar M Page 1


Mechatronics Digital Logic and Data Presentation

2.2 Analogue and Digital Signals


Analogue-to-digital conversion involves converting analogue signals into binary words.
Figure 2.1(a) shows the basic elements of analogue-to-digital conversion.

Figure 2.1
(a) Analogue-to digital
conversion,
(b) analogue input,
(c) clock signal,
(d) sampled signal,
(e) sampled and held signal

The procedure used is that a clock supplies regular time signal pulses to the analogue-to-digital
converter (ADC) and every time it receives a pulse it samples the analogue signal. Figure 2.1
illustrates this analogue-to-digital conversion by showing the types of signals involved at the various
stages. Figure 2.1(b) shows the analogue signal and Figure 2.1(c) the clock signal which supplies the
time signals at which the sampling occurs. The result of the sampling is a series of narrow pulses
(Figure 2.1(d)). A sample and hold unit is then used to hold each sampled value until the next pulse
occurs, with the result shown in Figure 2.1(e). The sample and hold unit is necessary because the
ADC requires a finite amount of time, termed the conversion time, to convert the analogue signal
into a digital one.

The relationship between the sampled and held input and the output for an ADC is illustrated by the
graph shown in Figure 2.2 for a digital output which is restricted to 3 bits. With 3 bits there are 23 = 8
possible output levels. Thus, since the output of the ADC to represent the analogue input can be only
one of these eight possible levels, there is a range of inputs for which the output does not change.

By: Pavithra Kumar M Page 2


Mechatronics Digital Logic and Data Presentation

The eight possible output levels are termed


quantisation levels and the difference in
analogue voltage between two adjacent levels is
termed the quantisation interval. Thus for the
ADC given in Figure 2.2, the quantisation
interval is 1 V. Because of the step-like nature
of the relationship, the digital output is not
always proportional to the analogue input and
thus there will be error, this being termed the
quantisation error. When the input is centred
over the interval, the quantisation error is zero,
the maximum error being equal to one-half of Figure 2.2 Input/output for an ADC
the interval or ±1/2 bit.

2.2.1 Digital to Analogue Conversion

The input to a digital-to-analogue converter


(DAC) is a binary word; the output is an
analogue signal that represents the weighted
sum of the non-zero bits represented by the
word. Thus, for example, an input of 0010 must
give an analogue output which is twice that
given by an input of 0001. Figure 2.3 illustrates
this for an input to a DAC with a resolution of 1
V for unsigned binary words. Each additional
bit increases the output voltage by 1 V.
Consider the situation where a microprocessor
gives an output of an 8-bit word. This is fed
through an 8-bit DAC to a control valve. The Figure 2.3 Input/output for a DAC
control valve requires 6.0 V to be fully open.

The full-scale output voltage of 6.0 V will be divided into 28 intervals. A change of 1 bit is thus a
change in the output voltage of 6.0/28 = 0.023 V.

2.3 Digital to Analogue and Analogue to Digital Converters


The following are commonly encountered forms of DACs and ADCs.

By: Pavithra Kumar M Page 3


Mechatronics Digital Logic and Data Presentation

2.3.1 Digital to Analogue Converters

Figure 2.4 Weighted-resistor DAC

A simple form of DAC uses a summing amplifier to form the weighted sum of all the non-zero bits
in the input word (Figure 2.4). The reference voltage is connected to the resistors by means of
electronic switches which respond to binary 1. The values of the input resistances depend on which
bit in the word a switch is responding to, the value of the resistor for successive bits from the LSB
being halved. Hence the sum of the voltages is a weighted sum of the digits in the word. Such a
system is referred to as a weighted-resistor network. The function of the op-amp circuit is to act as a
buffer to ensure that the current out of the resistor network is not affected by the output load and also
so that the gain can be adjusted to give an output range of voltages appropriate to a particular
application.

2.3.2 Analogue to Digital Converters

Figure 2.5 Successive Approximations ADC

By: Pavithra Kumar M Page 4


Mechatronics Digital Logic and Data Presentation

The input to an ADC is an analogue signal and the output is a binary word that represents the level of
the input signal. There are a number of forms of ADC, the commonest being successive
approximations, ramp, dual ramp and flash. Successive approximation is probably the most
commonly used method. Figure 2.5 illustrates the subsystems involved. A voltage is generated by a
clock emitting a regular sequence of pulses which are counted, in a binary manner, and the resulting
binary word converted into an analogue voltage by a DAC. This voltage rises in steps and is
compared with the analogue input voltage from the sensor. When the clock-generated voltage passes
the input analogue voltage, the pulses from the clock are stopped from being counted by a gate being
closed. The output from the counter at that time is then a digital representation of the analogue
voltage.

2.4 Logic Gates

With digital control we might, for example, have the water input to the domestic washing machine
switched on if we have both the door to the machine closed and a particular time in the operating
cycle has been reached. There are two input signals which are either yes or no signals and an output
signal which is a yes or no signal. The controller is here programmed to only give a yes output if
both the input signals are yes, i.e. if input A and input B are both 1 then there is an output of 1.
Such an operation is said to be controlled by a logic gate, in this example an AND gate. There are
many machines and processes which are controlled in this way. The term combinational logic is used
for the combining of two or more basic logic gates to form a required function.

2.5 Applications of Logic Gates

The following are some examples of the uses of logic gates for a number of simple applications.

2.5.1 Coder
Figure 2.6 shows a simple system by which a
controller can send a coded digital signal to a
set of traffic lights so that the code determines
which light, red, amber or green, will be turned
on. To illuminate the red light we might use the
transmitted signal A = 0, B = 0, for the amber
light A = 0, B = 1 and for the green light A = 1,
B = 0. We can switch on the lights using these
codes by using three AND gates and two NOT
Figure 2.6 Traffic Lights
gates.

By: Pavithra Kumar M Page 5


Mechatronics Digital Logic and Data Presentation
2.5.2 Code Converter

In many applications there is a need to change data from


one type of code to another. For example, the output from a
microprocessor system might be BCD (binary-coded
decimal) and need to be transformed into a suitable code to
drive a seven-segment display. A decoder has n binary input
lines for the coded input of an n-bit word and gives m
output lines such that only one line is activated for one
possible combination of inputs, i.e. only one output line
gives an output for a particular word input code. For
example, a BCD-to-decimal decoder has a 4-bit input code
and 10 output lines so that a particular BCD input will give
rise to just one of the output lines being activated and so
indicate a particular decimal number with each output line
Figure 2.7 Decoder corresponding to a decimal number.

Thus, in general, a decoder is a logic circuit


that looks at its inputs, determines which
number is there, and activates the one output
that corresponds to that number. Decoders are
widely used in microprocessor circuits.

A decoder is widely used for taking a 4-bit BCD


input and giving an output to drive the seven
segments of a display. Often the output from the
driver is not in the normal binary form but in
Binary-Coded Decimal (BCD). With BCD, each
decimal digit is coded separately in binary. For
example, the decimal number 15 has the 1
coded as 0001 and the 5 as 0101 to give the
BCD code of 0001 0101. The driver output has
then to be decoded into the required format for Figure 2.8 Decoder with Seven
the LED display. The 7447 is a commonly used Segment Display
decoder for driving displays (Figure 2.8)

By: Pavithra Kumar M Page 6


Mechatronics Digital Logic and Data Presentation
2.6 Displays
Many display systems use light indicators to indicate on/off status or give alphanumeric displays.
The term alphanumeric is a contraction of the terms alphabetic and numeric and describes displays of
the letters of the alphabet and numbers 0 to 9 with decimal points. One form of such a display
involves seven ‘light’ segments to generate the alphabetic and numeric characters. The light
indicators for such displays might be neon lamps, incandescent lamps, light-emitting diodes (LEDs)
or liquid crystal displays (LCDs).

2.6.1 Liquid Crystal Displays


Liquid crystal displays do not produce any light of their own but rely on reflected light or transmitted
light. The liquid crystal material is a compound with long rod-shaped molecules which is
sandwiched between two sheets of polymer containing microscopic grooves. The upper and lower
sheets are grooved in directions at 90° to each other. The molecules of the liquid crystal material
align with the grooves in the polymer and adopt a smooth 90° twist between them (Figure 2.9).

When plane polarised light is incident on the liquid crystal material its plane of polarisation is rotated
as it passes through the material. Thus if it is sandwiched between two sheets of polariser with their
transmission directions at right angles, the rotation allows the light to be transmitted and so the
material appears light.

Figure 2.9 Liquid crystal: (a) no electric field, (b) with electric field

However, if an electric field is applied across the material, the molecules become aligned with the
field and the light passing through the top polariser is not rotated and cannot pass through the lower
polariser but becomes absorbed. The material then appears dark.

By: Pavithra Kumar M Page 7


Mechatronics Digital Logic and Data Presentation
2.7 Sequential Logic
With combinational logic systems the output is determined by the combination of the input variables
at a particular instant of time. The output does not depend on what the inputs previously were. Where
a system requires an output which depends on earlier values of the inputs, a sequential logic system
is required. The main difference between a combinational logic system and a sequential logic system
is that the sequential logic system must have some form of memory.

Figure 2.10 shows the basic form of a sequential


logic system. The combinational part of the
system accepts logic signals from external
inputs and from outputs from the memory. The
combinational system then operates on these
inputs to produce its outputs. The outputs are
thus a function of both its external inputs and
the information stored in its memory. Figure 2.10 Sequential logic system

2.7.1 The Flip-flop


The flip-flop is a basic memory element which is made up of an assembly of logic gates and is a
sequential logic device. There are a number of forms of flip-flops.

SR Flip-flop

Figure 2.11(a) shows one form, the SR


(set–reset) flip-flop, involving NOR gates. If
initially we have both outputs 0 and S = 0 and
R = 0, then when we set and have S change
from 0 to 1, the output from NOR gate 2 will
become 0. This will then result in both the
inputs to NOR gate 1 becoming 0 and so its
output becomes 1. This feedback acts as an
input to NOR gate 2 which then has both its
inputs at 1 and results in no further change.

Now if S changes from 1 to 0, the output from


NOR gate 1 remains at 1 and the output from
NOR gate 2 remains at 0. There is no change in
the outputs when the input S changes from 1 to
0. It ‘remembers’ the state it was set to. Figure 2.11 (a) SR flip-flop, (b) Logic symbol

By: Pavithra Kumar M Page 8


Mechatronics Digital Logic and Data Presentation
If we change R from 0 to 1 when S is 0, the output from NOR gate 1 changes to 0 and hence the
output from NOR gate 2 changes to 1. The flip-flop has been reset. A change then of R to 0 will have
no effect on these outputs.

Note that if S and R are simultaneously made equal to 1, no stable state can occur and so this input
condition is not allowed. Figure 2.11(b) shows the simplified block symbol used for the SR flip-flop.
The output Q that occurs at a particular time will depend on the inputs S and R and also the last value
of the output. The following state table illustrates this.

JK Flip-flop

For many applications the indeterminate state that occurs with the SR flip-flop when S = 1 and R = 1
is not acceptable and another form of flip-flop is used, the JK flip-flop (Figure 2.12). This has
become a very widely used flip-flop device.

Figure 2.12 JK flip-flop with its truth table

The following is the truth table for this flip-flop; note that the only changes from the state table for
the SR flip-flop are the entries when both inputs are 1. But when both J=1 and K=1 the outputs are
toggled.

By: Pavithra Kumar M Page 9


Mechatronics Digital Logic and Data Presentation
D Flip-flop

The data or D flip-flop is basically a clocked SR flip-flop or a JK flip-flop with the D input being
connected directly to the S or J inputs and via a NOT gate to the R or K inputs (Figure 2.13(a)); in
the symbol for the D flip-flop this joined R and K input is labelled D. This arrangement means that a
0 or a 1 input will then switch the outputs to follow the input when the clock pulse is 1. A particular
use of the D flip-flop is to ensure that the output will only take on the value of the D input at
precisely defined times.

Figure 2.13 (a) D flip-flop using JK flip-flop, (b) Symbol of D flip-flop

2.8 Registers
A register is a set of memory elements
and is used to hold information until it is
needed. It can be implemented by a set of
flip-flops. Each flip-flop stores a binary
signal, i.e. a 0 or a 1. Figure 2.14 shows
the form a 4-bit register can take when
using D flip-flops. When the load signal is
0, no clock input occurs to the D flip-flops
and so no change occurs to the states of
the flip-flops. When the load signal is 1,
then the inputs can change the states of
the flip-flops. As long as the load signal is
0, the flip-flops will hold their old state
values.
Figure 2.14 Register

2.8 Printers
Printers provide a record of data on paper. There are a number of versions of such printers: the dot
matrix printer, the ink/bubble jet printer and the laser printer.

By: Pavithra Kumar M Page 10


Mechatronics Digital Logic and Data Presentation
2.8.1 Dot Matrix Printer
The dot matrix printer has a print head (Figure 2.15) which consists of either 9 or 24 pins in a
vertical line. Each pin is controlled by an electromagnet which when turned on propels the pin onto
the inking ribbon. This transfers a small blob of ink onto the paper behind the ribbon. A character is
formed by moving the print head in horizontal lines back and forth across the paper and firing the
appropriate pins.

Figure 2.15 Dot matrix print head mechanism

2.8.2 Laser Printer

The laser printer has a photosensitive drum which is coated with a selenium-based light-sensitive
material (Figure 2.16). In the dark the selenium has a high resistance and consequently becomes
charged as it passes close to the charging wire; this is a wire at a high voltage and off which charge
leaks.

Figure 2.16 Basic elements of a laser printer

A light beam is made to scan along the length of the drum by a small rotating eight-sided mirror.
When light strikes the selenium its resistance drops and it can no longer remain charged. By
controlling the brightness of the beam of light, so points on the drum can be discharged or left

By: Pavithra Kumar M Page 11


Mechatronics Digital Logic and Data Presentation
charged. As the drum passes the toner reservoir, the charged areas attract particles of toner, which
thus stick to the areas that have not been exposed to light and do not stick on the areas that have been
exposed to light. The paper is given a charge as it passes another charging wire, the so-called corona
wire, so that as it passes close to the drum, it attracts the toner off the drum. A hot fusing roller is
then used to melt the toner particles so that, after passing between rollers, they firmly adhere to the
paper. General-use laser printers are currently able to produce 1200 dots per inch.

2.9 Data Acquisition Systems


The term data acquisition (DAQ) tends to be frequently used for systems in which inputs from
sensors are converted into a digital form for processing, analysis and display by a computer. The
systems thus contain: sensors, wiring to connect the sensors to signal conditioning to carry out
perhaps filtering and amplification, DAQ hardware to carry out such functions as conversion of input
to digital format and conversion of output signals to analogue format for control systems, the
computer and DAQ software. The software carries out analysis of the digital input signals. Such
systems are also often designed to exercise control functions as well.

Figure 2.17 Data acquisition system

Figure 2.17 shows the basic elements of a DAQ system using plug-in boards with a computer for the
DAQ hardware. The signal conditioning prior to the inputs to the board depends on the sensors
concerned.

In selecting the DAQ board to be used the following criteria have to be considered:

1. What type of computer software system is being used, e.g. Windows, MacOS?
2. What type of connector is the board to be plugged into, e.g. PCMCIA for laptops, NuBus for
MacOS, PCI?
3. How many analogue inputs will be required and what are their ranges?
4. How many digital inputs will be required?
5. What resolution will be required?
6. What is the minimum sampling rate required?
7. Are any timing or counting signals required?

By: Pavithra Kumar M Page 12

You might also like