Embedded Systems

Assignment 1

Jan Hendrik Dithmar

2031259

Pascal Gwosdek

2505221

Assignment 1  Dithmar (2031259), Gwosdek (2505221)

1.1 A Vending Machine

a. • Initially, the automata are in states 0 and A.

• The user inserts a coin, the environment generates the event coin in, A_{1} moves to state 1 and the event ok is generated.

• A_{2} consumes the event ok and moves to state B.

• The user requests a tea, the environment generates the event req tea, A_{2} moves to state D and the event start tea is generated.

• The event drink ready is generated by the environment, A_{2} moves to state A and the event done is generated.

• A_{1} consumes the event done and moves to state 0.

b. Imagine that the user presses the cancel-button while the coffee or tea is prepared, then the user can get the drink and the money out of the machine, because there is no lock on the cancel-button while the drink is being prepared.

c.

0A  1A  1B  1C 1D  0C 0D^{coin in}  ^{ok}^{cancel}  ^{req coffee}^{req tea}  ^{cancel}^{cancel}^{drink ready}^{drink ready}^{drink ready}^{drink ready}

d.

A_{1} 0  1  2 A_{2} A  B  C D^{coin in/ok}^{cancel/coin out, reset}  ^{req/}^{done/}^{ok/}^{reset/}  ^{req coffee/start coffee, req}^{req tea/start tea, req}^{drink ready/done}^{drink ready/done}^{coin in}  ^{cancel}  ^{coin out}^{ok}  ^{reset}  ^{done}  ^{req}^{req coffee, req tea}  ^{drink ready}  ^{start coffee, start tea}

e.

A_{1}  0  1 A_{2} A  B  C D 50 20 10 5  ^{(*)}  ^{req/}^{[x ⩾ 50]/x:=x-50, coin out 50}^{[x < 50]/}^{[x ⩾ 20]/x:=x-20,}^{coin out 20}^{[x < 20]/}^{[x ⩾ 10]/x:=x-10, coin out 10}^{[x < 10]/}^{[x ⩾ 5]/x:=x-5,coin out 5} ^{x=0/}  ^{done/}^{cancel/reset}^{[x > 0]/}^{reset/}  ^{req coffee [x ⩾ 75]/}^{start coffee, req, x:=x-75}^{req tea [x ⩾ 50]/}^{start tea, req, x:=x-50}^{drink ready/done}^{drink ready/done}^{coin in 5} ^{...} ^{coin in 50}  ^{cancel}  ^{coin out 5} ^{...} ^{coin out 50}^{reset}  ^{done}  ^{req}^{req coffee, req tea}  ^{drink ready}  ^{start coffee, start tea}

For the sake of readability, the loops – marked with (*) – for state 0 are left out. The loops are:

• coin in 5/x:=x+5 • coin in 10/x:=x+10 • coin in 20/x:=x+20 • coin in 50/x:=x+50

1.2 Statecharts

AC  BC BD^{/x:=1; y:=0}_{AC/x:=0}_{BC/y:=1}_{BD/y:=0}  ^{AC/x:=x+1}^{BC/x:=x+1}

1.3 Statecharts

D1 E1  A B C  D2 E2^{u} ^{v}  ^{s}^{t}  ^{w} ^{x}^{y}^{x}  ^{u} ^{v}^{s} ^{t}^{t}