Lab 2 Introduction

Finite state machines often model embedded software applications, where a series of actions are performed by the system depending on the system inputs and system mode. The FSM model can be used to implement the same application using different hardware, such as when power or size are important design parameters.

FSM Design

Draw the finite state machine for a washing machine. The machine has 5 sensors:

  1. Load size setting knob (small and large loads)
  2. Bottom water-level sensor (senses whether laundry tub is empty)
  3. Middle water-level sensor (senses whether tub is half-full)
  4. Top water-level sensor (senses whether tub is full)
  5. Door sensor (senses if door is open or closed)

and controls 3 output devies:

  1. Water supply valve (opens to allow water to flow into tub, closes to suppress flow)
  2. Agitation motor (agitates soap and clothes in tub)
  3. Water drain valve (opens to allow water to drain from tub, closes to keep water in tub)

Implement FSM in C

Using a while loop and if-then-else or switch-case statements, implement your FSM in C. You can use stdin and stdout for I/O. But write sendstring routine that uses printf(), getonechar routine that uses scanf() for a single character, and getstring routine that uses scanf() for a string.

In this way, your group's program should send prompts such as "Is door open or closed" and get responses such as 0 for open 1 for closed. (By abstracting the actual means by which the program gets and sends, you can later switch between debugging and operation - like using the VDSP++ IDDE rather than a digital I/O device.)

Implementing the Controller on BF561

In the examples folder located at C:\Program Files\Analog Devices\VisualDSP 4.0\Blackfin\EZ-KITs\ADSP-BF561\Examples\ there is a project called UART RS-232 HyperTerminal session. This is an example of using the UART controller to communicate to RS232 devices.

In Lab #3 we will discuss more about the communication protocol, but for this lab we will just use the code to send and get characters and strings via RS232.

Edit your send, getonechar, and getstring rountes to use the appropriate UART_[getc,gets,putc,puts] function calls. Using an RS-232 cable, confirm that your group's program can communicate to the PC via Hyper Terminal.

For more information contact Michael Benjamin or David Kaeli
Last Modified: 08/22/17