Presentation is loading. Please wait.

Presentation is loading. Please wait.

Department of Electronic & Electrical Engineering Program design. USE CASES. Flow charts. Decisions. Program state.

Similar presentations


Presentation on theme: "Department of Electronic & Electrical Engineering Program design. USE CASES. Flow charts. Decisions. Program state."— Presentation transcript:

1 Department of Electronic & Electrical Engineering Program design. USE CASES. Flow charts. Decisions. Program state.

2 Department of Electronic & Electrical Engineering USE CASES. Useful for defining the interaction of the device with the user. Description of an interaction with the user.

3 Department of Electronic & Electrical Engineering INCREMENTAL DESIGN Start with simple use cases and then introduce more complexity. Your program evolves! Initial attempts are useful to learn about the problem. USE CASE

4 Department of Electronic & Electrical Engineering USE CASE 1: basic clock What should it do? Turn on CLOCK starts at 0. Displays 0 1 2.. 9 0 1 2 3... (rate is 1 per second) Only need a COUNTER to store value of the clock. SOME DID NOTE EVEN USE A COUNTER (see discussion on state later in this lecture)

5 Department of Electronic & Electrical Engineering FLOW CHARTS / PSUEDO CODE Use flow charts and/or pseudo code. In the design stage. To document how your code works.

6 Department of Electronic & Electrical Engineering FLOW CHART FOR BASIC CLOCK I should be able to understand how your program works by looking at your flow chart Simplify by encapsulation ( if not needed to understand high level working.) Document the lower level. DISPLAY COUNT

7 Department of Electronic & Electrical Engineering USE CASE 2: up/down button Use routines to simplify high level code

8 Department of Electronic & Electrical Engineering countdown subroutine

9 Department of Electronic & Electrical Engineering USE CASE 3: Up/Down/Stop Program now has 3 modes. 1.count up 0 1 2...9 0 1 2.count down 0 9 8... 0 9 3.stop. Hold current value We can use a register to store the MODE.

10 Department of Electronic & Electrical Engineering up/down/stop flow chart. We can reuse our existing count up/down/delay code

11 Department of Electronic & Electrical Engineering CASE 3 code Switch / if block

12 Department of Electronic & Electrical Engineering State of a computer program. "The state of a computer program is a technical term for all the stored information, at a given instant in time, to which program has access.computer program The output of a computer program at any time is completely determined by its current inputs and its state.outputinputs

13 Department of Electronic & Electrical Engineering State of a PIC Contents of the registers User DATA (file registers) Inputs (PORTA,PORTB) Working register Program counter (where we are in code) STATUS register... more Program in memory (hmmm).

14 Department of Electronic & Electrical Engineering CLOCK EXAMPLE user defined state COUNTER (value of the clock) MODE (up/down... etc)... more ? QUESTION: Some students did not use a COUNTER. How was the state of the clock stored in this case?


Download ppt "Department of Electronic & Electrical Engineering Program design. USE CASES. Flow charts. Decisions. Program state."

Similar presentations


Ads by Google