finite state machines exercises. software embebido para la insustria automotriz 2 / david robles /...

5
Finite State Machines Exercises

Upload: lily-farmer

Post on 22-Dec-2015

217 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: Finite State Machines Exercises. Software Embebido para la Insustria Automotriz 2 / David Robles / 10/25/2012 © Continental AG Debounce

Finite State MachinesExercises

Page 2: Finite State Machines Exercises. Software Embebido para la Insustria Automotriz 2 / David Robles / 10/25/2012 © Continental AG Debounce

Software Embebido para la Insustria Automotriz

2 / David Robles / 10/25/2012 © Continental AG

Debounce

1 DISABLE

4 COUNT_DIS

3 ENABLE

2 COUNT_EN

Reset /counter = 0output = DISABLE

[input = HIGH] /counter = 0output = DISABLE

[input = LOW] /counter = 0output = DISABLE

[(input = LOW) AND(counter >= 3)] /output = DISABLE

[(input = HIGH) AND(counter >= 4)] /output = ENABLE

[input = LOW] /counter = 0output = ENABLE

[input = HIGH] /counter = 0output = ENABLE

[input = HIGH] /counter = counter + 1output = DISABLE

[input = LOW] /counter = counter + 1output = ENABLE

Page 3: Finite State Machines Exercises. Software Embebido para la Insustria Automotriz 2 / David Robles / 10/25/2012 © Continental AG Debounce

Software Embebido para la Insustria Automotriz

3 / David Robles / 10/25/2012 © Continental AG

Debounce

Fill the table according the FSM for debounce

input cycle counter output state

LOW 1 0 DISABLE 1 DISABLE

HIGH 2 0 DISABLE 2 COUNT_EN

HIGH 3 1 DISABLE 2 COUNT_EN

HIGH 4

LOW 5

HIGH 6

HIGH 7

HIGH 8

HIGH 9

HIGH 10

HIGH 11

LOW 12

LOW 13

Page 4: Finite State Machines Exercises. Software Embebido para la Insustria Automotriz 2 / David Robles / 10/25/2012 © Continental AG Debounce

Software Embebido para la Insustria Automotriz

4 / David Robles / 10/25/2012 © Continental AG

Lock - Unlock

Codify the next SM in C:

1 IDLE

2 UNLOCK_DRIVER 3 UNLOCK_ALL

<1>[UnlockRqst = TRUE] /UnlockRqst = FALSEUnlock_Driver() <1>[LockRqst = TRUE] /

LockRqst = FALSE

<2>[UnlockRqst = TRUE] /UnlockRqst = FALSEUnlock_All()

<1>[LockRqst = TRUE] /LockRqst = FALSE

<2>[LockRqst = TRUE] /LockRqst = FALSE

<2>[UnlockRqst = TRUE] /UnlockRqst = FALSE

Reset /LockRqst = FALSEUnlockRqst = FALSE

Page 5: Finite State Machines Exercises. Software Embebido para la Insustria Automotriz 2 / David Robles / 10/25/2012 © Continental AG Debounce

Software Embebido para la Insustria Automotriz

5 / David Robles / 10/25/2012 © Continental AG

Cabin temperature

Make the state machine for the next feature:

The feature controls temperature in the cabin of a vehicle. There are three LEDs which indicate the control state of the temperature system: a LED green, a LED red and a LED blue. At Reset, all the LEDs, the heating system and the air conditioner system are turned off. When the temperature is great than TempHigh, the air conditioner system and only the LED red are turned on. If the temperature is less than TempLow the heating system and only the LED blue are turned on. If the temperature is less than TempNormalHigh and great than TempNormalLow, heating system or air conditioner system are turned off and only the LED green is turned on.

Take in count that:

TempHigh > TempNormalHigh > TempNormalLow > TempLow