CSE 466 Lab1 - Siren

 

Goals

 

    1. Become familiar with the Keil 8051 development tools, particularly use of the debugger.

    2. Become familiar with the laboratory equipment (scopes, programmer).

    3. Investigate audible frequency ranges for small 8-ohm speakers driven by a 5V square wave.

 

The objective of this lab is to determine the effective frequency range of your 8Ohm speaker driven by a 5volt square wave.  The frequency range should be demonstrated in by siren (American sirens are better for this than European!).  The range of audible frequencies is from about 100 Hz to about 20 KHz, what part of this range generates a reasonably good tone on your speaker? Although there are on-chip timers, we won't use them for this lab. All timing should be done with delay loops in software.  The schematic below should give you the basic idea.

 

 

Instructions

  1. Setup the hardware as shown in the diagram above.  Be sure to connect GND, VCC, and !EA to the appropriate voltage levels. 

  2. Hook up the logic probe to Power and Ground on the protoboard, plug in the power, and test the logic probe by touching it to power and ground.

  3. Build the power-on reset circuit recommended in the AT89 Series Hardware Description.

  4. Hook up the speaker as shown above.

  5. Connect a crystal between pins XTAL1 and XTAL2.  Use the scope to look at the signal generated by crystal. Does the frequency match whatever is printed on the crystal case?  Measure ALE?  How does ALE compare to the crystal frequency? If ALE is not moving, check your reset circuit. 

  6. Open the Keil2 development environment (eval version).  Select "New Project" from the Project menu and give the project a name.  Be sure to save the project in a network drive that is accessible to you. When prompted to select the device to use for the project, select 89C55.  Right click on the target folder at the left side of your screen and select "Options for target".  In the box that pops up set Xtal to the frequency of your crystal.  Set the memory model to "Small" and the Code Rom Size to "Compact". Now click the OUTPUT tab and select the "create hex file" check box. "HEX" is the binary format that will be programmed into your microcontroller.

  7. Create a new file and call it "main.c".  Under the Project menu select add file and add the newly created source file to your project.  At the top of your source file add the line "#include <At89x55.h>".  This tells the compiler to include macro definitions appropriate to the 89C55.  Go ahead and open the file At89x55.h to get an idea of the macros that are defined.  All of the macro are defined to be addresses on the chip but you don't need to worry too much about these addresses at the moment.  For example, the address for Port 0 is assigned to P0.  If you want to access just the least-significant bit (pin) of Port 0, you can use the macro P0_0.  Use a Port 1 pin to drive the speaker.

  8. Write a simple program to generate a 1KHz square wave on the speaker drive pin using a simple software delay loop.  Use the simulator to figure out the proper delay before testing it in hardware. Its worth spending a little time to learn about the various features of the debugger.

  9. In the debugger, open the disassembly window and look at the assembly code generated by the compiler (view->disassembly).  Hit reset on the simulator and single step through the assembly.  Does the code do anything other than what your C code specified?  If so, what does it do? (It's ok if you don't understand the specific assembly instructions, just try to make some sense of what is happening by stepping through the code and looking at the code.)

  10. Burn it.  Load the hex file generated by your build onto a floppy disk (it will have the same name as your project name, with a .hex extension).  Take the floppy and your chip to the black programmer.  Place the chip in the holder.  Make sure the device that is selected is the Atmel 89C55.   From the File menu select Name and give the name of your file (i.e. "a:\lab1.hex").  From the File menu select Load to load the file into a buffer.  Hit ESC to go back to a higher menu. From the PROM menu select Program to program the chip with the code in the buffer. Fix it if it doesn't work.

  11. Use the oscilloscope to verify that you have a1KHz tone, and to measure the voltage drop across the speaker when it is energized. How much peak current is passing through the speaker? and what is the peak power that is being dissipated by the speaker?

  12. Modify your program to produce some kind of siren that demonstrates the full useful frequency range of your speaker. What is the effective range such that it is audible and that can be perceived as a tone rather than a series of clicks? Demonstrate your siren to Douglas or Larry.

To Turn-In (Neatness Counts)

Last update: 09/27/2000 11:41 AM