Audio Phrase Repeater

 

 

 

 

 

Sashisu Bajracharya

ECE 447 Senior Design Project

Fall 2001

 

 

 

 

 

 

 

 

Instructor: Dr. Kris Gaj

TA: Kevin Lilly

 

Table of Contenets:

 

 

 

Appendices

A1. High-level hardware design

A2. High-level software design

A3. Detailed hardware design

A4. Part list with vendors and prices

A5. Memory map with the list of sections

A6. User interface Printouts

A7. Amount of time devoted to the particulare phases

A8. Pointers to the electronic versions of the component specification sheets

 

Executive Summary

 

 

My design project is about Audio Phrase Repeater. Audio Phrase Repeater records important reminding phrases and messages to hear it anytime later by playing it back. It does so by using MC65HC11 microcontroller and voice chip. It records audio phrases through speaker inside voice chip in multilevel storage array and it plays back the recorded phrases to the speaker when needed. It uses additionally keypad and LCD display unit to have user friendly interface. The user can record messages, stop recording, play messages one at a time, go on to next message, erase all messages and look at time remaining to record through pushing different buttons in the keypad. The LCD panel will show menu and corresponding information on different stages of operation. The microcontroller displays updated time remaining through LCD while recording in intervals of 2 sec. Moreover, while playing back phrases, it displays the number of message and the time length of that message up to the resoultion of ten milliseconds.

 

 

 

 

 

 

Introduction and Project Background

 

 

 

Problem to Solve

The problem was to store reminding phrases and messages and to play them in audio format. Thus the user does not have to write down messages and search for them later on. The user should be able to record multiple phrases and play them back with certain characteristics of the messages. The interesting challenge was to have time measurement and storage through 68HC11’s timing unit.

 

 

Purpose of Microcontroller

The microcontroller is needed to control different sequences of operations to record and play back messages through voice chip, microphone and speaker. The microntroller is required to provide timing while recording to the user and to measure lengths of messages and store them in organized manner. It displays the message number and message length while the message is playing as it has strong timing capability and various internal input/output devices dedicated for the wide range of timing needs like input capture, timer counter and other devices. Moreover, the microcontroller is needed to provide interface to user through keypad and LCD panel to handle different operations in the process of recording and playing back messages like for displaying menu, starting and stopping to record, playing messages, going on to next message, erasing messages, and showing time remaining to record.

 

 

 

 

 

 

 

 

Hardware Design and Implementation

The alternative was to use the external memory supported by the 68HC11 microcontroller for 64K bytes to store recorded messages in digital format. However, 8K is reserved by EPROM buffalo monitor, about 8K needed for program and data variables, some space needed for I/O registers and base RAM which gives maximum of 48K memory for data. The voice samples have to be measured in 8KHz for fairly recognizable clear voice that gives about 5-6 sec of recording capacity which is too low for my original intent of recording multiple messages where each message can take about 3-5 sec on minimum. The other alternative I proposed was to use out of chip external 128K ram to store recorded messages, but it needed to control external RAM with many address pins which seemed fairly time consuming than doable in the short implementation duration of the project in the semester. So, I finally decided to use Voice Chip for storing recorded message upto 60 sec and since it has built in A/D and converting digital to analog signal to speaker, I decided to focus more on various timing aspects of timing unit of microcontroller relevant to my project and handling multiple message operations with cascaded interrupts and logic and various control features.

The internal I/O devices that I used are Timer Input capture 1 and Timer Counter features with I/O ports and interrupt logic:

Timer Input Capture 1

It provides the interrupt for key pressed in the keypad. The Output Enable pin of Key Encoder produces a high pulse whenever a key is pressed in keypad and it is connected to the Port A pin 2 (counting from 0) which is for Timer Input Capture 1 input. The interrupt is set for rising edge active for this device. This device generates interrupt when key is pressed and records cycle time in 2 bytes TIC1 I/O register of when interrupt is occurred. This is used in determining start and stop cycles in conjunction with number of overflows of Timer Counter for measuring the time interval of each message while recording.

Timer Counter

This device generates the interrupt whenever the counter overflows. This interrupt is enabled when the function for Record is called and the interrupt service routine counts number of overflows occurred and determines time remaining in total and time interval of each message. The interrupt is disabled when Stop is pressed so that counting of overflows do not occur out of Record mode.

 

The external I/O devices that I used are:

Matrix Keypad (3 X4)

This device is 3X4 matrix keypad with 4 rows and 3 columns with key buttons going as 1,2,3,4,5,6,7,8,9,#,0,* .It is used for input out of different selections of menu for recording ,stopping, playing, going to next message, erasing messages and displaying time remaining. The 7 pins of this device are connected to the 16-key encoder in the corresponding row and column pins.

 

16-Key Encoder (MM74C922)

This device is used to interface with matrix keypad. It scans rows and columns of keypad and produces Data Available pin high when key is pressed with output 4-bit code of key pressed. The Output Enable\ pin of this device is grounded to make the 4-data output pins always active The Data Available pin is connected to PortA pin2 for invoking interrupt. The 4 output pins are connected to Port E pins 0 to 3 for input.

32*2 Line LCD Unit( Optrex DMC 32239a)

This device is used for showing menu and other messages relevant to operation mode to the user. It is also used to ask response from the user. The eight Data pins of this device is connected to Port B eight pins. The three control pins RS,R/W,E are connected to Port A pin 3,4 and 5. The microcontroller sets the control pin R/W to 0, RS to 1 for data or 0 for instruction output and drives E low and high to enable writing of data or control instruction to LCD.

Voice Chip (ISD 2560)

This device is used to record and store messages in multilevel storage cells. It is also used to playback recorded messages through speaker. The device is set in operational mode push button by setting M6(A6)pin to logic 1. The device is connected to microphone through series of analog circuits with resistors and capacitors. The speaker is connected to its output terminal SP+ and SP-. The three control pins CE, PD, P/R are connected to Port D pin 2,3&4 for controlling operations of Voice chip. PD low would make activate power on Voice Chip for the operations, P/R is 1 for play and 0 for record and CE will initiate the corresponding action.

 

FET Microphone

This device is used to convert analog audio voice to electric signal and is connected to MIC and MICREF pins of Voice Chip with resistors and capacitors for biasing and filtering out DC .

Speaker

This device is used to convert electric signal to analog audio voice and is connected to SP+ and SP- pins of Voice Chip.

 

All of the above devices were tested and implemented successfully in the project.

Modifications of board

The large modifications to the 68HC11 board was not needed but extra 8K RAM was used in U2 slot for extra storage needed for extra .text (code) required by including stdio.h header files while testing with the program code.

Problems Encountered

Initially, I could not make up the LCD to show up anything even when supplying power. Later, I found out that the contrast pin (Vee) has to be low voltage. Another problem encountered was not being able to make voice chip circuit to work to record messages in operational mode setting with active message cueing mode (pin A0 of Voice Chip high) on testing. Finally, I had to make pin A0 low and used push button mode(A6 high) to make it to work to record one message and then to record multiple messages with playing it back.

Software Design and Implementation

 

User Interface:

The user interface is provided by keypad and LCD display unit. The input for doing different operations is entered into the keypad by the user. The keypad is associated with the following options:

1 – Record

2 – Stop

3 – Play

4 – Next

5 – Erase

6 – Time Remaining

During the initial power boot up or after stop is pressed or after finishing playing all messages, the LCD display will show on 32*2 line display the ‘default menu display’ –

1-RECORD 2-STOP 3-PLAY

4-NEXT 5-ERASE 6-TIME REM.

 

When 1-Record is pressed the LCD will display

RECORDING

Time Remaining(sec): __

 

When 2-STOP is pressed, it stops recording and go to default state to show ‘default display’

When 3-PLAY is pressed, the LCD will display

PLAYING MESSAGE:_ __.__ sec

Press 4 for next

When 4-NEXT is pressed, next message will be played with corresponding PLAY message.

When all messages are played ‘default display’ will be shown.

When there are no messages, if the 3-PLAY is pressed, the LCD will display

There are no messages

for 3 sec and goes back to the display menu.

When 5-ERASE is pressed, the program will ask the user to erase or not.

Erase All Messages?
Yes - 7 No - 8

 

When 7 is pressed, the messages are erased and the display will show

Erased All

for 3 sec and ‘default display’ will be shown.

When 6-TIME REM. is pressed, the display will show

Time Remaining(sec): __
Press 9 to continue

 

 

Description of the high level software design

The main program starts and initializes direction for ports and does setting for interrupts enabling for Timer Input Capture1. It initializes LCD by initialization routine and makes it ready for data output later. It initializes the control lines of Voice Chip then it shows the main menu of different options and wait for input interrupt. When 1-Record is pressed, the interrupt service routine is called which then identifies the key pressed and calls record function which activates the Counter Overflow interrupt and clears I flag. This allows other external interrupts and sets the Voice Chip to start recording and meanwhile the microcontroller shows updated time remaining in seconds to the LCD. If the 2-Stop is pressed, another interrupt occurs and gives indication for previous Record function to stop and stops timing measurement of the present message and stores it in the correct position of the array for that message and go back to display menu. When 3-Play is pressed the Play function is invoked which checks if any message is present and if present plays first message with displaying its number and length and stops and waits for 4-Next key to be pressed. When 4-Next is pressed it goes on to play next message and the similar process occurs until the last message and then it goes back to display mode of main menu and wait state. If 5-Erase is pressed, the program asks for conformation message to erase and after getting confirmation deletes all messages otherwise just goes to default mode of menu display and wait. If 6-Time Remaining is pressed, the time remaining is converted to character and displayed to LCD and waits for key 9 to continue to go to default mode of displaying menu.

 

Choice Between C and Assembly Language

The choice between C and assembly language was made based on strength and capabilities of C and assembly language. C is more user friendly and makes it easy to handle the testing of multiple conditions and implementing multiple selective structure and looping executions. Moreover, calling function with many arguments is simple in C. So, definitely my main() function is in C, so are other functions like key_isr(), Record(), Stop(), Play(), Erase(), Time_Rem(), some LCD functions and others. Assembly language is powerful in handling program of timing operation. So, delay functions definitely are in assembly language. Also set_jmp_table() function is in assembly by its nature. Moreover, assembly language function handles type in loose manner, so it is easy to go from byte variable to int variable of 2 bytes and long types and type changing is easy in assembly and there are different strong byte manipulation instructions in assembly language. So I chose assembly language for operations of converting binary numerical value to two byte character representations for output to LCD properly. Also, in assembly, the codes are tight, takes little space, executes faster than C, so some of my LCD functions, I chose in assembly language like LCD_initialize().

 

Choice Between Polling and Interrupts

I chose interrupt because I wanted to know more about how interrupts work and handling interrupts is a challenging task which I like to do. The choice of interrupt implementation can give me a feel of how regular operation is interrupted and interrupt operation is handled and previous interrupted operation is resumed. Key pressed on keypad causes interrupt on Timer Input Capture 1 and in fact, I made cascaded interrupt provisions inside Record, Play and Erase functions. Also, timer counter worked under timer overflow interrupt. Moreover, the interrupt frees the processor to do another job without having to be busy waiting for flag to be set.

 

Timing and Accuracy Considerations

In my project, while pressing record, the interrupt service routine identifies key pressed and calls record function which has to enable certain interrupts, clear flag, write to LCD before starting recording, so recording does not actually start at the instant the key is pressed , however, the delay are too minor of few tens of cycles which is negligible compared to the length of recording purpose. Also, the TIC1 register actually stores the starting time when the key is actually pressed and also the ending time when the key is actually pressed.

 

Problems Encountered

Initially there were many syntax errors in program functions like of same identifier but difference in capital and small letter and the debugger was not so good to identify that. Afterwards, I tried to run initialization routine on LCD and some display functions, but nothing showed up. I rechecked my initialization routine many times and compared that with specification sheet. Then I ordered up the sequence of procedures with right delays in initialization routine to finally get something in the display unit.

The other problem was to make the code to work. I had to debug many times for LCD routines to work and keypad input testing to work.. The most difficult was the main software procedures on controlling recording and playing to work. Even minor error would take a lot of time to be fetched out. I had to use many printf statements in program to find when the interrupt occurred, whether certain subroutine was called or not and some execution statements were performed or not.

 

 

Interaction between Hardware and Software

 

The tradeoff basically occurred for keypad interface. If I were to directly connect keypad lines to input/output pins of 68HC11, I would have to make more software to scan columns while one of the rows are driven low and repeat that to each row to find the key pressed and its identification. However, if I used the 16-Key Encoder(MM74C922), the chip does the scanning of the rows and columns by itself and takes care of debouncing by certain external capacitors to its two output pins(OSC and KDM). The Encoder generates its Data Available output pin to high pulse while key is pressed, then four output data pins can be checked to identify the key pressed. So, it will reduce the software load and also take load out of controller being busy to scan most of the time. So, I chose the 16-key hardware which decreases the software load but also meanwhile increases more hardware connections and components(capacitors).

 

 

Testing Procedure

Order of Software Testing and Testing procedure

I tested my functions step by step. Initially I tested my delay functions if they generate proper delays or not by testing them by debugger and checking start cycle when the functions started and stop cycle when the function execution finished. In that way I verified them. Then I went on to test LCD functions by running those functions on 68HC11 with LCD connected to it. I called on functions LCD_initialize(), Set_DDRAM(), LCD_write_string(display1) with display1 as a test string. Initially, it didn’t gave me anything, I put ‘printf()’ statements inside corresponding functions to see how they were called, then I rechecked my LCD_initialize routine and matched it up with specification sheet procedure with correct delays after each instruction download. Finally, I got my message display1 to display on the LCD. Then I tested other LCD functions like LCD_clear(), LCD_place_cursor(), move_cursor_left(), move_cursor_right().

After then I went on to test input interrupt function key_isr() with keypad connected to the board through 16-Key Encoder. I had already done hardware testing of the 16-Key Encoder with keypad to light up combinations of LED’s. So, I know beforehand before software tests that hardware functions right and went on to have input key interrupt function that transfer signal values of Key Encoder’s output to output port B to light up LED’s. I found out bugs with the testing and was able to make it work.

Then I tested functions relating to record and playback on voice chip having already done hardware testing on voice chip circuit to record and play messages. Now, since I know my input interrupt functions and LCD functions work right, I tested my Record(), Stop(), Play() function for one message, I debugged many errors with the help of printf() statements at certain position in code. Then I went on to add my timer interrupt and time measurement functions on previous working codes and found out errors and corrected them. Then I added converting binary number to character representations for output to LCD on top of that. In that way, I finished testing my whole program.

 

Order of Hardware Assembly and Testing procedure

The hardware was tested on a similar manner part by part. The testing of LCD was already proved in hardware too by the software testing operating on hardware to display strings on LCD.

I tested the keypad with 16-Key encoder separately to light corresponding binary sequence of LED’s when certain key is pressed. Initially I found out that some of output bit sequences were right but some were not and some changed during pressing key and releasing key. I figured out the problem was extra column pin for Col.4 which I had tied high before, but it should be open( not connected to anywhere) as the encoder drives column low one after another in scanning and there was bus conflict in Col. 4 due to that. After correcting errors , I was able to make the keypad with Key-Encoder work.

I tested microphone and speaker in a circuit with Voice Chip. Initially I didn’t get the playback then I troubleshooted that when operational mode of message cueing (pin A0 high in operational mode set by A8 and A9 high of Voice Chip)was used, it didn’t record and playback. When I disabled message cueing, then only I was able to record and playback messages. I figured how the voice chip operated while recording and playing back multiple messages. Then I found out that pushbutton mode(pin A6 high in operational mode setting of Voice Chip) would be suitable for my project since the address pointer to messages do not reset back to beginning when all the messages are played in this mode which had occurred without this mode setting. This would allow the chip to record new messages at the end of previous messages when the playback cycle is already completed and will not overwrite previous messages by starting to record from the beginning.

Final Results

I/O Devices

Installed

Tested Successfully

Timer Input Capture 1 [Internal]

Yes

Yes

Timer Counter [Internal]

Yes

Yes

Matrix Keypad(3X4) [External]

Yes

Yes

16-Key Encoder(MM74C922) [External]

Yes

Yes

32*2 Line LCD unit [External]

Yes

Yes

Voice Chip (ISD 2560) [External]

Yes

Yes

Microphone [External]

Yes

Yes

Speaker [External]

Yes

Yes

 

 

 

 

Major I/O functions

Coded

Debugged Successfully

main()

Yes

Yes

__interrupt key_isr()

Yes

Yes

set_jmp_table ( void (*)(void), int )

Yes

Yes

__interrupt counter_overflow()

Yes

Yes

Record()

Yes

Yes

Stop()

Yes

Yes

Play()

Yes

Yes

Next()

Yes

Yes

Erase()

Yes

Yes

Time_Rem()

Yes

Yes

int key(unsigned char num)

Yes

Yes

Compute_time()

Yes

Yes

Get_time()

Yes

Yes

char* Convert_to_char(unsigned char num)

Yes

Yes

Convert_to_char_sec( unsigned char num )

Yes

Yes

unsigned int Convert_to_char_time(unsigned char num)

Yes

Yes

LCD_initialize()

Yes

Yes

LCD_init_control()

Yes

Yes

LCD_clear()

Yes

Yes

Set_DDRAM

Yes

Yes

LCD_write(char c)

Yes

Yes

LCD_write_string(char *s)

Yes

Yes

LCD_write()

Yes

Yes

LCD_place_cursor(row, column)

Yes

Yes

DDRAM_addr(row,column)

Yes

Yes

move_cursor_left( num) & move_cursor_right(num)

Yes

Yes

Delay_msec( x)

Yes

Yes

Delay_sec(x)

Yes

Yes

Delay40us()

Yes

Yes

Delay100us()

Yes

Yes

 

 

 

 

 

 

 

 

Deviations from the original specification

The project took the alternate implementation of Initial Software/Hardware Design using Voice Chip with more emphasis on timing issues while recording and playing back. The Skip function was not used in the final implementation because it was not supported by the Voice Chip which I tested many times to support for skipping function. Instead as an alternative there is Next() function and 4-Next key that makes the Audio Repeater to move on to the next message when the present message is being finished playing. The interrupt for Data Available output of key-encoder is changed from STRA to TIC1 pin to use the Timer Input Capture function. Output Enable pin is always grounded as the microcontroller will check for four binary inputs of data only when the Data Available interrupt occurs. The control line EOM(End of Marker) from Voice Chip to microcontroller was not used because while testing it caused unnecessary interrupts even when the playing back of one message was not finished. The control line OVF from Voice Chip to microcontroller was not used because microcontroller itself keeps track of time and stops recording when time remaining goes to 0 sec. Also, XCLK line to Voice Chip was not used as I had originally thought of using Output Compare function. But as my peer reviewer Dave Dowgiallo has pointed out that the line needs the frequency input of 1024 KHz and not 8KHz as shown in specification of Voice Chip and generating 1024 Khz could not be done by output compare feature as even 1 instruction takes more than 2 cycle, so I decided to use the internal clock of Voice Chip. These modifications eliminated the need of software functions like __interrupt EOM(), __interrupt Overflow(), __interrupt void Sq_wave-OC2_isr(void), init_OC2(void) as proposed in Final Hardware/Software design. The buzzer was also not used because the messages were played one at a time and user presses key for next message instead of playing all messages continuously with beep in between.

Moreover, new enhancements were added like measuring the time length of each message while recording through use of counter overflow and timer input capture and storing them in array in corresponding message’s position in character representation which requires addition of many complex functions and some variables.

Conclusion

The final result that I got was the complete workable circuit with microcontroller which can store multiple messages upto 60 seconds and plays them back when desired. The user can see the updated version of time remaining in intervals of 2 sec to optimize the duration of message provided for new message on sequence of old messages. Moreover, the user can erase all messages and record new ones from the beginning and the user can press 6-Time Remaining to look at time remaining to record. Moreover, the properties of message which are message number and message length are displayed to the user when playing them back.

The possible extension would be to interface this circuitry with telephone line to build answering machine and also the capability to erase particular message in the sequence of many messages.

The lessons that I learned are to plan properly beforehand for the design as time becomes very scarce at the last minute while actually implementing the designed software and hardware to test each components for errors which can take a lot of time. Also, the other thing I learned was the significance of testing part by part and step by step which helps a lot in the design of large project.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Appendices

A1. High Level Hardware Design



A2. High Level Software Design:












A4. Parts List with Vendors and Prices

Part Name

Part Number

Price($)

Vendor

68HC11 Microcontroller EVB

77.50

New Micros, Inc.

5V Power Supply @5A

12801PS

14.95

MPJA, Inc

Matrix Keypad(3X4)

190561

6.95

Jameco Electronics

32*2 Line LCD

DMC32239A

9.95

MPJA, Inc

16 Key Encoder

MM74C922

6.95

Jameco Electronics

Voice Chip

ISD 2560P

9.95

Jameco Electronics

Microphone(FET mike)

8384 MK

0.50

MPJA, Inc

Speaker

 

 

31958

1.95

Jameco Electronics

Resistors(1k,10k,470k,5.1kohm)

2.00

Sue Davis & RadioShack

Capacitors(0.1u,220u,22u,4.7u,1uF)

3.50

Sue Davis & RadioShack

 

 

 

A5. Memory map with the list of sections







A6. User Interface printouts

During the initial power boot up or after stop is pressed or after finishing playing all messages, the LCD display will show on 32*2 line display the ‘default menu display’ –

1-RECORD 2-STOP 3-PLAY

4-NEXT 5-ERASE 6-TIME REM.

 

When 1-Record is pressed the LCD will display

RECORDING

Time Remaining(sec): __

 

When 2-STOP is pressed, it stops recording and go to default state to show ‘default display’

When 3-PLAY is pressed, the LCD will display

PLAYING MESSAGE: __.__ sec

Press 4 for next

When 4-NEXT is pressed, next message will be played with corresponding PLAY message.

When all messages are played ‘default display’ will be shown.

When there are no messages, if the 3-PLAY is pressed, the LCD will display

There are no messages

When 5-ERASE is pressed, the program will ask the user to erase or not.

Erase All Messages?
Yes - 7 No - 8

 

When 7 is pressed, the messages are erased and the display wil show

Erased All

for 3 sec and ‘default display’ will be shown.

When 6-TIME REM. is pressed, the display will show

Time Remaining(sec): __
Press 9 to continue

 

 

 

A7. Amount of time devoted to the particular phases of the project

The time devoted for different phases are approximate of the original time spent.

Project Proposal : 5 hour

Initial Software/Hardware Design: 6 hour

Parts Research and Purchases: 6 hour

Final Software/Hardware Design: 20 hour

Testing and Coding and Implementation: 50 hour

Demonstration: 14 hour

Final Report: 17 hour

 

 

 

 

 

 

A8. Pointers to the electronic versions of the component specification sheets