Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3...

43
Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The S-R flip-flop 5.6 Examples

Transcript of Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3...

Page 1: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Lecture 5

5. Sequential functions and circuits 5.1 Introduction5.2 Feedback, memory, state5.3 Sequential functions and circuits5.4 Flip-flops5.5 The S-R flip-flop5.6 Examples

Page 2: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

5.1 Introduction

• In the preceding chapters we have discussed various types and aspects of combinational functions, whose outputs are determined completely by their inputs.

• An important property ot that functions and circuits, where these functions are implemented, is that there is no feedback from the output to the input

Page 3: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

5.2 Feedback, memory, state

• The moment we introduce this feedback, we get a new type of function or circuit with a new capability:

-The capability to store bits of information.

In other words the circuit also acquires memory.

Depending on the contents of its memory,

we say that the circuit is in a certain state

Page 4: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Feedback, memory, state - 2

• Therefore a change in the contents of the memory implies a change in the state of the circuit.

• The output of such a circuit with memory is not always the same for the same input, as is the case with a combinational circuit but also depends on its present state.

Page 5: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Feedback, memory, state - 3

• Note, that we have used the word „present“ in the last sentence.

• This means that the next state as well as the output depend not only on the present input but also the present state.

• Hence the element of time also comes in. • Such combinational functions (circuits) with

feedback , having memory of internal states, are called sequental functions (circuits).

Page 6: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

5.3 Sequential functions and circuits

• Such combinational functions (circuits) with feedback , having memory of internal states, are called sequental functions (circuits).

• A formal definition of sequential circuits or the more general term sequential machines (automatons) will be given later.

Page 7: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Sequential functions and circuits -1

• There are three special types of sequential machines:

Flip-flops

Counters

Shift registers

The building blocks of all these sequential circuits are the flip-flops, which we discuss

in this lecture.

Page 8: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

5.4 Flip-flops

• A flip-flop is the most elementary sequential machine having only two states.

• These are therefore bistable circuits.

• Although the flip-flops may differ in their electronic compositions, they exhibit certain definite logical properties.

Page 9: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Flip-flops - 2

• In fact, all flip-flops, irrespective of their internal circuit implementation, can be classsified into a few types according to their logical behavior.

• The R-S flip-flop

• The J-K flip-flop

• The D flip-flop

• The T flip-flop

Page 10: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Flip-flops - 3

• In subsequent sections we first discuss a few typical types of flip-flops and then we seehow theese flip-flops produce various types of conters and shift registers depending on their interconnections

Page 11: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Flip-flops - 4

• In PLC we usually have some of these flip-flops at disposal (mostly RS flip -flop and /or SR flip-flop) as co called „function blocks“ (SW function blocks).

• We only program these blocks, that means we connect them with other blocks in one of the programming languages for PLCs named „Function block diagram - FBD“ (see e.g. LOGO! )

Page 12: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

5.5 The S-R flip-flop

• Consider the circuit shown in the figure:

>=1

G1

>=1

G2

S

R

NQ

Q

Z2

Z1

Page 13: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop - 2

• It is a combinational circuit with feedback

>=1

G1

>=1

G2

S

R

NQ

Q

Z2

Z1It has only two NOR gates,G1 and G2, with the output of one gate being fed to the input of the other

Page 14: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop - 3

• Now let us study the outputs of the circuit Z1 and Z2 for the four different combinations 00,01,10,11 of the input lines S and R.

1.When S=0, Z1 becomes 1(0) depending on if Z2=0(1):

Z1=N(S+Z2)=NS.NZ2=1.NZ2=NZ2Z1=1.1…….Z2=0Z1=1.0…….Z2=1

Page 15: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop - 4

2. Similarly, when R=0, Z2=NZ1, sinceZ2=N(R+Z1)=NR.NZ1=1.NZ1=NZ1

3. Thus when SR=00, the values of Z1and Z2 depend only on them and it is always

Z1=NZ2.It can now be verified, that with SR=00, if

Z1Z2=01 or Z1Z2=10, they retain these output values.

• In other words, the outputs remain unchanged.

Page 16: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop - 5

4.However the situation changes if S=1 and R=0, then the 1 on the S-line will force the output Z1 to be 0, irrespective of the value of Z2. Therefore Z1 becomes 0. This forces Z2 to become 1, as both input lines of gate G2 become 0.

Hence when SR=10, the circuit has a stable state with Z1Z2=01.

Page 17: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop - 6

5. Similarly it can be found, that the circuit has another stable state with SR=01 and Z1Z2 becoming 10.

6. Now, let us investigate what happens, if SR=11. In this situation, the 1 on the S-line will force Z1 to be 0, and the 1 on the R-line will force Z2 to be 0. So under this conditions, when SR=11, the output will be Z1Z2=00 and this will also be a stable state.

Page 18: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop - 7

7. Now, let S and R both become 00 simultanously. Then both NOR gates, G1 and G2, will „see“ 00 at their inputs simultaneously, and their outputs will tend to become 11. Now let the output Z1 of gate G1 change to 1much earlier than Z2 of gate G2. Then the 1 at Z1 will prevent Z2 to become 1 and Z2 will continue to remain 0. Now it can be easily checked that the output Z1Z2=10 with SR=00 is also a stable state.

Page 19: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop - 8

8. However, when S and R become 00 simultaneously, if Z2 would have become 1 much earlier than Z1, the output will stabilize at the value of Z1Z2=01. Thus the outputs become unpredictable and depend on the operating delays of the gates G1 and G2.

Page 20: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop - 9

• Even if these two delays are identical, there is a serious problem.

• In that case it can beverified that the outputs will oscillate between the values 11 and 00.

• These are very undesirable operating conditions for the flip-flop.

Page 21: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop - 10

• Thus although SR=11 and Z1Z2=0 is a stable state, it may introduce serious anomalous situations in operation of the flip-flop.

• Hence to eliminate this possibility entirely, an aditional restriction, that the S- and R-lines should not be made 1 simultanously, is accepted in the definition of an S-R flip-flop.

Page 22: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

S-R flip-flop - 11

Definition:

An S-R flip-flop has two input lines, S and R. When S is 1, the flip flop is set to state 1. When R becomes 1, the flip –flop is reset to state 0. When both S and R are 0, the flip-flop continues to be in the same state. The S- and R-lines are never made 1 simultaneously. When the flip-flop is in state 0(1), the output of the flip-flop Q is also 0(1).

Page 23: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

S-R flip-flop - 12

• This definition yields the truth table,(next snap), where q denotes the present state and Q the next state of the flip-flop.

• The truth table defines Q as a function of the three variables S, R, and q:

• Q=f(S,R,q)

Page 24: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

S-R flip-flop - 13

• The truth table of S-R- flip-flop

S R q Q0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 11 0 1 11 1 0 x1 1 1 x

As a sum of minterms it can be expressed as:

Q=(S,R,q)=SUM(1,4,5)+

+x SUM(6,7)

=NS.NR.q+S.NR.Nq+S.NR.q+

???(assume, that x=1)…..+

+S.R.nq+S.R.q=S+NR.q

This function is known as the characteristic function of the RS flip-flop.

Page 25: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop – 14

• Theory says all this ….but what about praxis???• In practical applications, we must solve the

situation when S=1 and R=1 simultaneously• There are two types of SR flip-flops (both HW

and SW applications)• SR - with prior setting

(if SR=11, then Q=1)• RS - with prior reseting

(if SR=11, then Q=0)

Page 26: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R flip-flop - 15

• The truth table of S-R- flip-flop with prior setting (x=1)

S R q Q0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 11 0 1 11 1 0 11 1 1 1

As a sum of minterms it can be expressed as:

Q=(S,R,q)=SUM(1,4,5,6,7)==NS.NR.q+S.NR.Nq+S.NR.q+ +S.R.nq+S.R.q=NS.NR.q++S.(NR.Nq+NR.q+R.Nq+R.q)==NS.NR.q+S(NR+R)==NS.NR.q+S=NR.q+S==S+NR.q

Page 27: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The R-S Flip-flop - 16

• The truth table of R-S flip-flop with prior resetting (x=0)

S R q Q0 0 0 00 0 1 10 1 0 00 1 1 01 0 0 11 0 1 11 1 0 01 1 1 0

As a sum of minterms it can be expressed as:

Q=(S,R,q)=SUM(1,4,5)==NS.NR.q+S.NR.Nq+S.NR.q==NS.NR.q+S.NR==NR.(NS.q+S)==NR.(q+S)

Page 28: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R Flip-flops - 17

Practical summary of the RS-flip-flops function:• RS(SR) flip-flop (RS(SR) memory) has two

inputs:S input – for setting the output Q (Q=1)R input – for reseting the output Q (Q=0)

If both R and S inputs are 0, output remains on its last value.

If on both S and R inputs are 1 simultaneously, the value of output depends on the type of the flip flop (SR …Q=1,RS…Q=0)

Very often the R-S flip-flop blocks have the second output, negation of the output Q, NQ.

Page 29: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The S-R Flip-flop - 18

• Block diagram and function table

• (function table is not the same as the true table, it serves for the function description )

R

S Q

NQ

S R Q NQ

1 0 1 0

0 0 1 0

0 1 0 1

0 0 0 1

1 1 1 0

SR

Page 30: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

The R-S Flip-flop - 19

• Block diagram and function table

R

S Q

NQ

S R Q NQ

1 0 1 0

0 0 1 0

0 1 0 1

0 0 0 1

1 1 0 1

RS

Page 31: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

5.6 Examples

Example 1:

• If sensor B1 has a 1-signal, this indicates an error status in the system. A horn H1 is sounded. The horn can only be switched off by actuating push button S1. It is possible to switch off the horn, even if the B1-signal continues to be applied.

Page 32: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Example 1 - 2

• Block diagram of the system:

B1

S1

H1

The control system has two inputs, from B1,S1 one output to the H1

Page 33: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Example 1 - 3

Let’s try to solve the task intuitively:We use SR flip-flop in the control system first.Horn H1 will be connected to the output Q of the

flip-flop. This output should be switched on (set) by error

status (indicated by the sensor B1) …thus we connect sensor B1 to the S-input of the flip-flop.

This output should be switched off (reset) by push button S1…thus we connect push button S1 to the R-input of the flip-flop.

Page 34: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Example 1 - 4

• The first solution:

S1

H1B1

SR

S

R

Q

NQ

The basic function is OK, but the last sentence of the task definition cannot be fulfilled by this type of flip-flop. If the B1-signal continues to be applied, (this is Set signal for SR flip-flop), it is not possible to reset this flip-flop by its reset signal S1!

Page 35: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Example 1 - 5

• Let’s try the second type of the flip-flop, the RS-one.

Horn H1 will be connected to the output Q of the flip-flop.

This output should be switched on (set) by error status (indicated by the sensor B1) …thus we connect sensor B1 to the S-input of the flip-flop.

This output should be switched off (reset) by push button S1…thus we connect push button S1 to the R-input of the flip-flop.

Page 36: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Example 1 - 6• The second solution:

S1

H1B1

RS

S

R

Q

NQ

The basic function is OK. Also the last sentence of the task definition is fulfilled by this type of flip-flop. If the B1-signal continues to be applied, (this is Set signal for RS flip-flop), it is possible to reset this flip-flop by its reset signal S1 and thus switch off the horn. This solution is the right one.

Page 37: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Example 2

Example 2:Pressing of the start button S2 is to cause the

piston of a cylinder to advance (if it is in initial position, that is retracted) – signal Y1=1. This mechanism is to be used to clamp workpieces. When the piston has advanced fully, it is to remain in this position for 20 seconds. (Signal Time_out from the special „timer“ block is on).The cylinder then returns to its initial position signal Y1=0. Sensor B1 indicates, that cylinder is retracted, sensor B2 indicates, that cylinder is advanced.

Page 38: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Example 2 - 2

• Block diagram of the system:

S2

B1

Y1

B2

Time_out

Page 39: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Example 2 - 3We use SR flip-flop in the control system.

Signal for cylinder Y1 will be connected to the output Q of the SR flip-flop.

This output should be switched on (set) by pressing the start button S2 if the piston is in retracted position (indicated by the sensor B1) …

thus we connect conjunction of the signals S2 and B1 to the S-input of the SR flip-flop.

Page 40: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Example 2 - 4

This output should be switched off (reset) when the piston has advanced fully (indicated by sensor B2) and has remained there for 20 seconds (signal from timer Time_out)….

thus we connect conjunction of the signals S2 and Time_out to the R-input of the SR flip-flop.

Page 41: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Example 2 - 5

&B1

S2

&B2

Time_out

SR

Q

NQ

S

R

Y1

Page 42: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

Literature

• Nripendra N. Biswas: Logic Design Theory,Prentice Hall International,1993,ISBN 0-13-010695-X

Page 43: Lecture 5 5. Sequential functions and circuits 5.1 Introduction 5.2 Feedback, memory, state 5.3 Sequential functions and circuits 5.4 Flip-flops 5.5 The.

6. The smallest control systems (PLCs)–“Programmable modules“