task 2 briefing
Download
Skip this Video
Download Presentation
Task 2 Briefing

Loading in 2 Seconds...

play fullscreen
1 / 22

Task 2 Briefing - PowerPoint PPT Presentation


  • 116 Views
  • Uploaded on

Task 2 Briefing. T he Design of a C omputer Controlled S top Watch. 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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Task 2 Briefing' - clem


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
task 2 briefing
Task 2 Briefing

The Design of a

Computer Controlled

Stop Watch

the technology used
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
sample program
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)
first task
First Task
  • You first job is to understand the program and produce documentation for it.
  • To do this you should:
    • Compile and run the program
    • Add comments to the program
    • Produce Pseudocode for the program
  • Copies of the commented program and Pseudocode must be submitted to your Supervisor
compiling the program
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
the process of compiling
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
    • Make sure there are no errors
  • Transfer the file produced into the microcontroller (use EPROM programmer)
    • Compiler produces a HEX format file
  • Insert the microcontroller in your card and test.
documenting the program
Documenting the Program
  • Before starting to write a new program, you will gain some practice at documenting programs
  • You should :
  • Understand what the program does

(run it if necessary)

  • Add comments to the program
  • Write a Pseudocode description of the program

(this should be done before writing a program)

sample documentation
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.
pseudo code
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’

}

comments on techniques
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.
creating a stop watch function
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

<space> hitting the space bar will toggle the Stop watch on and off

R resets the display to zero

system diagram
System Diagram

00:01:45

Send ASCII characters of time to display

Type <space> to turn on

Type <space> to turn off

what you must do
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
creating a clock function
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 <CR>

Digit in adjust mode, the digits are entered into

1021 the current time

<BS> in adjust mode, go back to last entered digit

<CR> in adjust mode, returns to clock mode

what you must do1
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.
    • What is displayed on the PC in adjust mode
    • What is displayed on PC when a <BS> is received
  • When you have decided, write Pseudocode
    • A State Diagram may help planning
  • Produce the C program, compile, test and debug
integrating the functions
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

the combined clock
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.
working with the push button
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 button toggles the stop watch on and off

Hold button if pushed >1sec, time resets to zero

what you must submit
What you must submit
  • For all 4 programs, you must submit a short report on your program containing:
    • The Pseudocode
    • The C program (including comments)
    • 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.
for the brighter students
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.
ad