Vending machine A design-example by Ingo Sander William Sandqvist - - PowerPoint PPT Presentation

vending machine
SMART_READER_LITE
LIVE PREVIEW

Vending machine A design-example by Ingo Sander William Sandqvist - - PowerPoint PPT Presentation

Vending machine A design-example by Ingo Sander William Sandqvist william@kth.se System Control We will design the block System Control COIN_PRESENT DROP COIN DROP BOTTLE RECEIVER GT_1_EURO DROP_READY SYSTEM EQ_1_EURO CONTROL


slide-1
SLIDE 1

Vending machine

William Sandqvist william@kth.se

A design-example by Ingo Sander

slide-2
SLIDE 2

System Control

COIN RECEIVER

COIN_PRESENT GT_1_EURO EQ_1_EURO LT_1_EURO DEC_ACC CLR_ACC

SYSTEM CONTROL

DROP DROP_READY CHANGER_READY RETURN_10_CENT

DROP BOTTLE COIN RETURN

William Sandqvist william@kth.se

ACCUMU- LATOR

We will design the block System Control Return only 10 cents coin.

slide-3
SLIDE 3

Coin Reciever

COIN RECEIVER

COIN_PRESENT GT_1_EURO EQ_1_EURO LT_1_EURO DEC_ACC CLR_ACC

SYSTEM CONTROL

William Sandqvist william@kth.se

The System Control unit controls a number of subsystems from other suppliers. Coin Reciever. Drop Bottle. Coin Return.

ACCUMU- LATOR

A ACCUMULATOR counts up the amount of paid coins.

  • Signal COIN_PRESENT indicates that there are coins and the ”amount” is

indicated by the signals GT_1_EURO, EQ_1_EURO, LT_1_EURO.

  • With the signals DEC_ACC and CLR_ACC the systemcontrol unit can

reduce the amount by 10 cents, or reset the ACCUMULATOR.

slide-4
SLIDE 4

Coin Return

William Sandqvist william@kth.se

SYSTEM CONTROL

CHANGER_READY RETURN_10_CENT

COIN RETURN

With a pulse on RETURN_10_CENT the coin return unit will eject 10 cent, and signal CHANGER_READY when this is done and the unit is ready for the next command.

slide-5
SLIDE 5

Drop Bottle

William Sandqvist william@kth.se

With a pulse on DROP the drop bottle unit will eject a bottle, and signals DROP_READY when this is done and the unit is ready for the next command.

SYSTEM CONTROL

DROP DROP_READY

DROP BOTTLE

slide-6
SLIDE 6

Block diagram

COIN RECEIVER

COIN_PRESENT GT_1_EURO EQ_1_EURO LT_1_EURO DEC_ACC CLR_ACC

SYSTEM CONTROL

DROP DROP_READY CHANGER_READY RETURN_10_CENT

DROP BOTTLE COIN RETURN

  • Signal properties
  • DROP_READY is active for a clockperiod after the bottle is ejected
  • CHANGER_READY is active for a clockperiod after a 10 Cent coin is ejected
  • Because of the mechanical properties the following signals are active and inactive

for several clock periods:

 COIN_PRESENT ( active for several clockperiods after the coin is inserted )  DROP_READY ( active for several clockperiods at bottle ejection )  CHANGER_READY ( inactive for several clockperiods at coin ejection )

slide-7
SLIDE 7

Use a Moore-machine

William Sandqvist william@kth.se NEXT STATE DECODER STATE REGISTER OUTPUT DECODER State

Clk

Input- signals Output- signals

  • Construction of a state machine for the controller of a

vending machine

  • Assumptions
  • Moore-machine
  • Stateregister implemented with D-flip-flops
slide-8
SLIDE 8

Function diagram for vending machine

William Sandqvist william@kth.se

Reset Myntinkast registrerat? Summa? Mata ut flaskan Nollställ summan Retur 10 Cent Nej Ja Sum < 1€ Sum= 1€ Sum > 1€ Minska summan

  • Coin input

– 10 Cent, 50 Cent, 1 Euro

  • Coin return

– 10 Cent

  • Price of one bottle

– 1 Euro

no yes

slide-9
SLIDE 9

State diagram

We draw a state diagram from the functional diagram :

(a) (b) (c) (d) (e) (f) (g) READY CHANGER _ CENT RETURN _ 10 _ READY CHANGER _ EURO GT _ 1 _ PRESENT COIN _ PRESENT COIN _ PRESENT COIN _ PRESENT COIN _ EURO LT _ 1 _ EURO EQ _ 1 _ READY DROP _ DROP READY DROP _ ACC CLR _ ACC DEC _

slide-10
SLIDE 10

State diagram

(a) Wait for coin input (b) Register coin? (c) Coin is registered (3 cases) (d) Eject bottle (e) Reset sum (f) Return 10 Cent (g) Decrease sum 10 Cent

William Sandqvist william@kth.se

slide-11
SLIDE 11

Block schematic

William Sandqvist william@kth.se

D D D Next State Decoder

COIN_PRESENT LT_I_EURO EQ_I_EURO GT_I_EURO DROP_READY CHANGER_READY A B C DA DB DC A B C

Output Decoder

DROP CLR_ACC DEC_ACC Clk Clk Clk RETURN_I0_CENT

Insignals Outsignals State register

slide-12
SLIDE 12

State encoding

William Sandqvist william@kth.se

Idea: Let the states that are close together in the state diagram have codes with unit distance. (b) next to (c) (d) next to (e) (a) next to (b) (f) next to (g)

AB 00 01 11 10 C a Ø d f 1 b c e g

7 states 3 state variables A, B, C are needed The number of inputs is large, 6, total there may be nine variables in Karnaugh maps ???

(Ø = don’t care)

slide-13
SLIDE 13

State encoding

(a) (b) (c) (d) (e) (f) (g) READY CHANGER _ CENT RETURN _ 10 _ READY CHANGER _ EURO GT _ 1 _ PRESENT COIN _ PRESENT COIN _ PRESENT COIN _ PRESENT COIN _ EURO LT _ 1 _ EURO EQ _ 1 _ READY DROP _ DROP READY DROP _ ACC CLR _ ACC DEC _ 000

001

011 100 110 111 101 State variable ABC, eg. in state (c) is A = 0, B = 1 and C = 1 C B A

AB 00 01 11 10 C a Ø d f 1 b c e g (Ø = don’t care)

slide-14
SLIDE 14

Coded state table?

William Sandqvist william@kth.se

From the state diagram, you can set up the following coded state table. How do we avoid the complexity of nine variables?

slide-15
SLIDE 15

Variable-Entered Mapping (VEM)

William Sandqvist william@kth.se

A+ DA AB 00 01 11 10 C Ø 1 1 1 EQ + GT

Variable-Entered Mapping can be helpful when you need Karnaugh diagrams with many

  • variables. You write functional expression of Karnaugh diagrams.

Variables

slide-16
SLIDE 16

Next state - DA

William Sandqvist william@kth.se

A+ DA AB 00 01 11 10 C Ø 1 1 1 EQ + GT

EQ : EQ_1_EURO GT : GT_1_EURO C A GT B A EQ B A D A

A

⋅ + ⋅ ⋅ + ⋅ ⋅ = =

+

slide-17
SLIDE 17

Next state - DB

William Sandqvist william@kth.se

B+ DB AB 00 01 11 10 C Ø 1 1 CP EQ 1

EQ : EQ_1_EURO CP : COIN_PRESENT C B A CP C B C B EQ B A D B

B

⋅ ⋅ + ⋅ ⋅ + ⋅ + ⋅ ⋅ = =

+

Easy to miss!

slide-18
SLIDE 18

Next state - DC

William Sandqvist william@kth.se

C+ DC AB 00 01 11 10 C CP Ø DR CR 1 1 1

CP : COIN_PRESENT DR: DROP_READY CR: CHANGER_READY C B CR B A DR C B CP C A D C

C

⋅ + ⋅ ⋅ + ⋅ ⋅ + ⋅ ⋅ = =

+

slide-19
SLIDE 19

Output signals

William Sandqvist william@kth.se

C B A ACC DEC C B A CENT RETURN ABC ACC CLR C AB DROP = = = = _ _ 10 _ _

The output signals are the "pulses" which are generated when passing through the states d, f, e, g.

slide-20
SLIDE 20

Implementation of the vending machine

William Sandqvist william@kth.se

When they call from CocaCola, it's just for you all”Digital Designers” to adopt the mission ... ” students must master the the design of simple combinational and sequential digital systems” You do that now!

slide-21
SLIDE 21

William Sandqvist william@kth.se

slide-22
SLIDE 22

What will happen in state Φ?

William Sandqvist william@kth.se

AB 00 01 11 10 C a Ø d f 1 b c e g

ABC

) 010 ( = Φ

GT EQ GT EQ A C A GT B A EQ B A A

ABC

+ = ⋅ + ⋅ ⋅ + ⋅ ⋅ = ⇒ ⋅ + ⋅ ⋅ + ⋅ ⋅ =

+ +

1 1 1 1 1 ) 010 ( e c d C B A , , , 111 , 011 , 110 , 010 1 Φ → = − − =

+ + +

Φ

1 ... 1 1 1 1 ) 010 ( = + ⋅ + ⋅ ⋅ = ⇒ ⋅ ⋅ + ⋅ ⋅ + ⋅ + ⋅ ⋅ =

+ +

EQ B C B A CP C B C B EQ B A B

ABC

DR CP CR DR CP C C B CR B A DR C B CP C A C

ABC

+ = ⋅ + ⋅ ⋅ + ⋅ ⋅ + ⋅ ⋅ = ⇒ ⋅ + ⋅ ⋅ + ⋅ ⋅ + ⋅ ⋅ =

+ +

1 1 1 1 ) 010 (

slide-23
SLIDE 23

What will happen in state Φ?

William Sandqvist william@kth.se

e c d C B A , , , 111 , 011 , 110 , 010 1 Φ → = − − =

+ + +

Φ

In Φ-state we are stuck, or we go to (c) and then on. Or we go to (d) and offers soft drinks, or we go to (e) and resets any previous payment. Obviously, we need to purchase a reset circuit that ensures that the machine always starts in (a) 000! Otherwise we will have legitimate complaints from the customers!

RESET-generator

slide-24
SLIDE 24

William Sandqvist william@kth.se