A design-example by Ingo Sander - Amazon Web...

24
Vending machine William Sandqvist [email protected] A design-example by Ingo Sander

Transcript of A design-example by Ingo Sander - Amazon Web...

Page 1: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Vending machine

William Sandqvist [email protected]

A design-example by Ingo Sander

Page 2: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

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 [email protected]

ACCUMU-LATOR

We will design the block System Control

Return only 10 cents coin.

Page 3: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Coin Reciever

COIN RECEIVER

COIN_PRESENT

GT_1_EURO

EQ_1_EURO

LT_1_EURO

DEC_ACC

CLR_ACC

SYSTEM CONTROL

William Sandqvist [email protected]

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.

Page 4: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Coin Return

William Sandqvist [email protected]

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.

Page 5: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Drop Bottle

William Sandqvist [email protected]

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

Page 6: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

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 )

Page 7: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Use a Moore-machine

William Sandqvist [email protected]

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

Page 8: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Function diagram for vending machine

William Sandqvist [email protected]

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

Page 9: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

State diagram

We draw a state diagram from the functional diagram :

(a)

(b)

(c)

(d)

(e)

(f)

(g)

READYCHANGER _

CENTRETURN _10_

READYCHANGER _

EUROGT _1_

PRESENTCOIN _

PRESENTCOIN _

PRESENTCOIN _

PRESENTCOIN _

EUROLT _1_

EUROEQ _1_

READYDROP _

DROP

READYDROP _

ACCCLR _ACCDEC _

Page 10: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

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 [email protected]

Page 11: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Block schematic

William Sandqvist [email protected]

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

Page 12: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

State encoding

William Sandqvist [email protected]

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

0 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)

Page 13: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

State encoding (a)

(b)

(c)

(d)

(e)

(f)

(g)

READYCHANGER _

CENTRETURN _10_

READYCHANGER _

EUROGT _1_

PRESENTCOIN _

PRESENTCOIN _

PRESENTCOIN _

PRESENTCOIN _

EUROLT _1_

EUROEQ _1_

READYDROP _

DROP

READYDROP _

ACCCLR _ACCDEC _

000

001

011

100110

111 101

State variable ABC, eg. in state (c) is A = 0, B = 1 and C = 1

CBAAB

00 01 11 10

C

0 a Ø d f

1 b c e g (Ø = don’t care)

Page 14: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Coded state table?

William Sandqvist [email protected]

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

Page 15: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Variable-Entered Mapping (VEM)

William Sandqvist [email protected]

A+ DA AB

00 01 11 10

C

0 0 Ø 1 1

1 0 EQ + GT 0 0

Variable-Entered Mapping can be helpful when you need Karnaugh diagrams with many variables. You write functional expression of Karnaugh diagrams.

Variables

Page 16: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Next state - DA

William Sandqvist [email protected]

A+ DA AB

00 01 11 10

C

0 0 Ø 1 1

1 0 EQ + GT 0 0

EQ : EQ_1_EURO GT : GT_1_EURO

CAGTBAEQBADA A ⋅+⋅⋅+⋅⋅==+

Page 17: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Next state - DB

William Sandqvist [email protected]

B+ DB AB

00 01 11 10

C

0 0 Ø 1 0

1 CP EQ 0 1

EQ : EQ_1_EURO CP : COIN_PRESENT

CBACPCBCBEQBADB B ⋅⋅+⋅⋅+⋅+⋅⋅==+

Easy to miss!

Page 18: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Next state - DC

William Sandqvist [email protected]

C+ DC AB

00 01 11 10

C

0 CP Ø DR CR

1 1 0 0 1

CP : COIN_PRESENT DR: DROP_READY CR: CHANGER_READY

CBCRBA

DRCBCPCADC C

⋅+⋅⋅+

⋅⋅+⋅⋅==+

Page 19: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Output signals

William Sandqvist [email protected]

CBAACCDEC

CBACENTRETURN

ABCACCCLRCABDROP

=

=

==

_

_10_

_

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

Page 20: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

Implementation of the vending machine

William Sandqvist [email protected]

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!

Page 21: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

William Sandqvist [email protected]

Page 22: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

What will happen in state Φ?

William Sandqvist [email protected]

AB

00 01 11 10

C

0 a Ø d f

1 b c e g

ABC)010(=Φ

GTEQGTEQACAGTBAEQBAA ABC +=⋅+⋅⋅+⋅⋅=⇒⋅+⋅⋅+⋅⋅= ++ 101111)010(

ecdCBA ,,,111,011,110,0101 Φ→=−−=+++

Φ

1...1111)010( =+⋅+⋅⋅=⇒⋅⋅+⋅⋅+⋅+⋅⋅= ++ EQBCBACPCBCBEQBAB ABC

DRCPCRDRCPCCBCRBADRCBCPCAC

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

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

+

00001111)010(

Page 23: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

What will happen in state Φ?

William Sandqvist [email protected]

ecdCBA ,,,111,011,110,0101 Φ→=−−=+++

Φ

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

Page 24: A design-example by Ingo Sander - Amazon Web Serviceskth.s3-website-eu-west-1.amazonaws.com/ie1204_5/slides/eng/flaskautomat_eng.pdfA design-example by Ingo Sander . System Control

William Sandqvist [email protected]