User Tools

Site Tools


old_lab_3

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

old_lab_3 [2014/09/04 15:13] (current)
hutch created
Line 1: Line 1:
 +====== Lab 3: Lock State Machine ======
 +===== Overview =====
 +In this lab you shall implement two "​lock"​ programs. The first lock program has the combination hard-coded into the software and cannot be changed. For the second program, you must write a program that allows the combination to be entered via the slide switches so that it can be changed.
  
 +===== Objective =====
 +Write and debug your first state-machine-based program based upon the concepts taught in Chapter 3 of the text.
 +
 +===== Specifications for Lock Program 1 =====
 +The state machine for your lock program will be different than the one in the book. It shall have four states:
 +  * INIT: Initializes any global variable you decided to use with your state machine. Then transitions to WAIT.
 +  * WAIT: Waits for a new switch value. Transitions to CHECK when there is a new value.
 +  * CHECK: ??? You will have to figure out what to put in this state.
 +  * UNLOCK: Lights up all the LEDs to show the user has successfully entered the entire sequence. Then goes back to INIT to reset the lock.
 +
 +To open the lock the user must enter the correct sequence of values on the switches. Use switches (SW0 - SW2) on the Zedboard. The sequence should be four values long. For example, 010 -> 110 -> 111 -> 101. When the user enters the first correct value illuminate LED0, then LED1 after the second value, and LED2 for the third value. The fourth correct value will unlock it and the UNLOCK state will light up all the LEDs.
 +
 +===== Notes =====
 +
 +Be careful when choosing a sequence. Only one switch can change at a time so some sequences are impossible such as 000 -> 111 -> 000 -> 111.
 +
 +Initialize the GPIOs before you initialize your state machine and start running it. Your state machine should be inside an infite loop like so:
 +
 +<​code>​
 +while(1)
 +{
 +    next_state();​
 +}
 +</​code>​
 +
 +The INIT and WAIT states should not change the LEDs. If they do then you probably won't see all the LEDs light up when you reach the UNLOCK state because the LEDs' value will quickly get overwritten.
 +
 +Tera Term is not needed for this lab but if you get stuck it is helpful to put in some print statements and see what you get in Tera Term.
 +
 +===== Specifications for Lock Program 2 =====
 +You must write the specification for Lock Program 2. Lock Program 2 should function just as Lock Program 1 except for the following:
 +  - The lock code is initially set to 000 -> 001 -> 011 -> 111
 +  - Changing the lock code is initiated somehow. You can use an unused slide switch, etc., but determining how to do this is up to you.
 +  - Once the lock code has been changed, the lock program should return to the state where it is waiting for the user to start sliding switches to unlock the lock. Pass off of your code can only be achieved if the TA can reliably change the lock code and then open the lock.
 +
 +  - **You must implement this lab using the state-machine techniques taught in Chapter 3. Labs that are implemented without using these techniques will receive 0 credit.**
 +  - Your specification must contain a description of the state machine and its states and anything else that documents the behavior of your program.
 +  - It is important that the code used to change the lock code is very reliable and easy to use. Otherwise, you may end up with a lock that you cannot open. 
 +
 +===== Grading =====
 +Pass off your lock with the TA when it meets the specifications. Turn in your well commented code. Also turn in the specification for Lock Program 2.
 +
 +In addition, hand in feedback for this lab. Were there confusing or ambiguous parts of the lab specs? What major bugs did you have? This doesn'​t need to be long, a few highlights are sufficient. Also report how many hours the lab took you.
old_lab_3.txt ยท Last modified: 2014/09/04 15:13 by hutch