Presentation is loading. Please wait.

Presentation is loading. Please wait.

Slide 1 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Task 2 Briefing The Design of a Computer.

Similar presentations


Presentation on theme: "Slide 1 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Task 2 Briefing The Design of a Computer."— Presentation transcript:

1 slide 1 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Task 2 Briefing The Design of a Computer Controlled Stop Watch

2 slide 2 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking The Technology Used  Based on the Microcontroller card you have built  Controlled by a C program compiled on PC to run on the Microcontroller card.  ASCII characters are used to transfer data between PC and microcontroller  You can use a terminal emulator on the PC, there is no special program for the PC

3 slide 3 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Sample Program  The project worksheet contains a sample program  This is the same program used to test the serial port of your microcontroller card in the lab  Action - every second, the microcontroller sends the time to the PC as a text string over the serial interface.  The time can be displayed on a PC using any terminal program (9600bps, 8 bit, no parity)

4 slide 4 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking First Task  You first job is to understand the program and produce documentation for it.  To do this you should: o Compile and run the program o Add comments to the program o Produce Pseudocode for the program  Copies of the commented program and Pseudocode must be submitted to your Supervisor

5 slide 5 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Compiling the Program  The C program on the worksheet is to run on the microcontroller.  This processor uses different machine instructions to the PC  Visual C++ produces machine instructions for the PC - it won’t run on the microcontroller.  CC51 is a C compiler which produces machine instructions which run on the microcontroller

6 slide 6 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking The Process of Compiling To compile a program for the microcontroller:  Produce the text C code using any text editor  Use CC51 to compile the program o Make sure there are no errors  Transfer the file produced into the microcontroller (use EPROM programmer) o Compiler produces a HEX format file  Insert the microcontroller in your card and test.

7 slide 7 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Documenting the Program  Before starting to write a new program, you will gain some practice at documenting programs  You should : 1. Understand what the program does (run it if necessary) 2. Add comments to the program 3. Write a Pseudocode description of the program (this should be done before writing a program)

8 slide 8 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Sample Documentation  Consider the program on the microcontroller used with the dice as an example.  Problem : Send a ‘Y’ when the button is pressed and send a ‘N’ when the button is released. At the same time, display any received character on the LEDs.  The following shows 3 ways to describe the problem.

9 slide 9 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking State Diagram action trigger

10 slide 10 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Flow Chart

11 slide 11 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Pseudo Code Do forever[while ( true is true )] { while ( key not pressed ) { if (character received) { get character display pattern } } send ‘ Y ’ while ( key pressed ) {if (character received) { get character display pattern } } send ‘ N ’ }

12 slide 12 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Comments on Techniques  State Diagram – good graphical technique for describing a process. Doesn’t help much in writing program. Can be used to clarify design before writing pseudocode  Flow Chart – good at describing sequential processes. Doesn’t help much in writing high level programs, but good for machine level coding.  Pseudocode – good at describing complex processes. Helps to write high level code.

13 slide 13 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Creating a Stop Watch Function  You now understand the program ! ! !  You must modify the program to make it work as a stop watch.  Stop watch control is via the serial interface  Characters entered on the PC keyboard will control the Stop watch hitting the space bar will toggle the Stop watch on and off R resets the display to zero

14 slide 14 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking System Diagram Type to turn on Type to turn off Send ASCII characters of time to display 00:01:45

15 slide 15 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking What You Must Do  Firstly, make sure you understand what the Stop watch does – ask if you don’t understand  Modify the Pseudocode for the clock program to make it act as a stop watch  Code this in C  Produce a text file of the program  Compile using CC51  Load the code into the microcontroller  Test the functionality and debug if necessary

16 slide 16 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Creating a Clock Function  Create a new Pseudocode for a Clock which responds to the following commands : A sets the clock to adjust mode. In adjust mode the clock stops until it receives Digit in adjust mode, the digits are entered into 1021 the current time in adjust mode, go back to last entered digit in adjust mode, returns to clock mode

17 slide 17 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking What You Must Do  Again, you must first understand the problem.  In this example, the functionality isn’t so well defined – you have some options, e.g. o What is displayed on the PC in adjust mode o What is displayed on PC when a is received  When you have decided, write Pseudocode o A State Diagram may help planning  Produce the C program, compile, test and debug

18 slide 18 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Integrating the Functions  When both Stop watch and Clock are working :  Try to combine both Stop watch and Clock into 1 program.  The combined program should respond to the extra commands : C if in Stop watch mode, switch to Clock mode S if in Clock mode, switch to Stop watch mode

19 slide 19 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking The Combined Clock  The Clock must keep the right time, even if it is in Stop watch mode.  Hence, clock must keep running in both modes  The program will need a separate variables for the Clock and Stop watch.  The Stop Watch can keep running in Clock mode  The Clock will stop in adjust mode – you can decide what the Stop watch does.

20 slide 20 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Working with the Push Button  So far, all control has been using the PC keyboard sending ASCII characters to the microcontroller.  Here, go back to the Stop watch to make it controlled by the button on the card  Control is : Push buttontoggles the stop watch on and off Hold buttonif pushed >1sec, time resets to zero

21 slide 21 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking What you must submit  For all 4 programs, you must submit a short report on your program containing: o The Pseudocode o The C program (including comments) o A description of the operation of the program  Submit report when all 4 programs are done.  Your supervisor will check to see your program working before moving to the next stage.

22 slide 22 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking For the Brighter Students  It is possible that some groups will finish the three programs within 4 weeks.  We do not expect all groups to finish that quickly. However, you must finish all three programs.  The faster groups can then move on the next project task – implementing a network.  This task has scope for groups to make their own design.


Download ppt "Slide 1 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Task 2 Briefing The Design of a Computer."

Similar presentations


Ads by Google