Sie sind auf Seite 1von 8

`Telephone Message Watchdog

Home Telephone Message Forwarding Device

Project #: H3232
Abstract
This project is to design and build a home telephone message forwarding system using the Renesas
microcontroller H8S/2398 (MCU) by implementing a touch tone (Dual-Tone Multi-Frequency or DTMF)
detector and a DTMF generator.
The constructed device is a simple, useful, low-cost device. It is connected in serial between a
telephone port and an answering machine. The device continuously monitors the telephone line loop-
current. When an incoming call arrives while the owner of the device is not at home, the answering
machine is engaged. The increased line loop-current triggers the device to start the touch tone detection.
The answering machine greeting voice instructs the caller to either leave a voice message or key in his/her
telephone number. The device monitors the phone line and captures any touch tone presented during this
telephone call process into the MCU memory storage. After the caller terminates the call and hangs up
his/her telephone, the answering machine disengages the line. The drop of the line loop-current triggers
the device to enter a message forwarding stage. In this stage, the device checks the telephone line
condition and automatically engages the line if it is not busy. The device then starts a touch tone generator
to dial an owner-preset pager number. After connecting to the pager center, the device uses the touch tone
generator again to send either the caller’s telephone number if it was entered or the owner’s home
telephone number (preset) if the caller left only a voice message. By reviewing the forwarded number on
his pager, the owner can directly contact the caller by using the callback number or check the voice
message left on the home answering machine (Figure 1).
In order to utilize the Renesas MCU to the maximal extent and lower the construction cost, the device
uses only software to detect and create DTMF signals without using any external hardware DTMF
detectors and generators. The DTMF tone detection process consists of 8 Modified Goertzel discrete
Fourier transform (DFT) filters, one for each DTMF standard frequency, and 2 additional DFT filters for
2nd harmonic detection to further discriminate the voice signal. A rail-to-rail operational amplifier
conditions the incoming audio signal to a 5V range and feeds the signal to the on-chip A/D converter. The
A/D converter is driven by the on-chip 16-bit timer unit at an 8 KHz sampling rate, which is above the
Nyquist sampling rate requirement. The acquired data is forwarded from the A/D converter to double-
buffered memory storage for DTMF filtering using a DMA channel. At the 20 MHz MCU system clock
rate, the 10 DFT filters are performed continuously every 14ms period.
The DTMF tone generation is constructed by using 2 channels of the on-chip D/A converter and a
sine wave lookup table. The sine wave is generated at a rate of 50 samples/cycle in any of the DTMF
frequencies, which provides up to 80 KHz sampling rate high quality sound output (much higher than
audio CD 44.1KHz sampling rate).
The device complies with FCC part-68 requirements. All peripheral parts and MCU are isolated from
telephone line by using a transformer and optocouplers. The DTMF signal injected to the telephone line is
tuned to 0 dBm at 600 ohm.
Port for setting
pager/home numbers
Telephone

V+
Ring IC2

Setting
Normal Loop current Answering
S1 sensor Machine

Line Answer Machine


condition Condition
detection ADC
circuitry
MCU
Dial Tone
Output
IC4
Line Busy

Line
busy IC3
Line
Engage
Off
hook

Tip

Telephone line interface diagram

2
Hardware resource

A/D output
DTMF A/D
buffer (1 word)

8000 Hz
End of
transfer Interrupt
System TPU Service
DMA Routine
clock φ φ/2500
20.00MHz

Filter Filter
buffer buffer Swap
Double
buffering block 1 block 2
(115 (115
words) words)

Start

697 770 852 941 2nd


Row filters MHz MHz MHz MHz Harmonic

1209 1336 1477 1633 2nd


Column filters MHz MHz MHz MHz Harmonic

Goertzel DFT Filters

DTMF analysis logic

Block diagram of DTMF tone detection

3
Starter Kit board and telephone line interface board

4
Telephone line interface board schematic

5
List 1. Goertzel DFT Filter Assembly Codes

;****************************************************************************
;* Function: GoertzelDFT *
;* Description: This is Goertzel DFT filter *
;* Parameters: *
;* R0: Cosine coefficient of the frequency (premultiplied by 2^16) *
;* *
;* Return: *
;* R0 Magnititude^2 of the filtered frequency *
;* *
;* Note: *
;* *
;* Gozertzel algorithm: *
;* Sk[n] = x[n] + 2*coefficient*Sk[n-1] - Sk[n-2] *
;* Only last N (do once): *
;* Mag^2 = SK[N]^2 - 2*coefficient*SK[N]*SK[N-1] + SK[N-1]^2 *
;* *
;* The operation is using fixed point data format *
;* Upper 18bit is integer part of the real data *
;* Lower 14bit is fraction port of the real data *
;* *
;* Register usage: *
;* ER0: Sk[n] *
;* ER1: Sk[n-1] *
;* ER2: Sk[n-2] *
;* E3 coefficient * 4 *
;* R3L loop count *
;* ER4 input sample pointer *
;* ER5 for temp reg *
;****************************************************************************
SKN1 .REG (ER1)
SKN2 .REG (ER2)
COE: .REG (E3)
LPCOUNT .REG (R3L)
NEGFLG .REG (R3H)
SAMPLEPTR .REG (ER4)
SKN1HIGH .REG (E1)
SKN1LOW .REG (R1)
SKN2HIGH .REG (E2)
SKN2LOW .REG (R2)

GoertzelDFT:
;Save working registers
PUSH.L ER2 ;ER0 and ER1 don't to save (for arguments)
PUSH.L ER3
PUSH.L ER4
PUSH.L ER5

MOV.W R0, COE ;save coefficient on R3


SUB.L SKN1, SKN1 ;initial SKN1
SUB.L SKN2, SKN2 ;and SKN2
MOV.L @_DTMFBUFFPTR,SAMPLEPTR ;pointer to first sample
MOV.B #DTMFCOUNT, LPCOUNT ;set loop counts

GozertzelLoop:

MOV.L SKN1, ER0 ;use ER0 for temp reg


BPL ?0010 ;if Sk[n-1] is positive number, go
;ahead
NEG.L ER0 ;else change it to positive number
?0010:

6
SHAL.L ER0 ;Sk[n-1] * 2

;Multiply lower portion of Sk[n-1] with cosine coefficient


MOV.L ER0, ER5 ;ER5 for fraction(Sk[n-1])
MULXU.W COE, ER5 ;fraction(Sk[n-1]) * 2 *
;Coefficient
MOV.W E5, R5 ;move upper word to lower
EXTU.L ER5 ;clear upper word

;Multiply upper portino of Sk[n-1] with cosine coefficient


MOV.W E0, R0
MULXU.W COE, ER0 ;temp = integer(Sk[n-1]) * 4*
; Coefficient

;combine fraction potion and integer portion of


;multiplication result

ADD.L ER0, ER5 ;result is in ER5

MOV.L SKN1, ER0 ;test Sk[n-1]


BPL ?0020 ;if postive, do nothing
NEG.L ER5 ;else change multiplication result
;to positive number
?0020:
;load a sample data
SUB.L ER0,ER0 ;clear ER0
MOV.W @SAMPLEPTR+, E0 ;Get next sample to higher order
;word (integer potion)
SHLR.L #2, ER0 ;divide by 4

ADD.L ER5, ER0 ;Sk[n] = Sample+


; Sk[n-1]*2*Coefficient
SUB.L SKN2, ER0 ; - Sk[n-2]

;move to next state


MOV.L SKN1, SKN2 ;Sk[n-2] = Sk[n-1]
MOV.L ER0, SKN1 ;Sk[n-1] = Sk[n]

DEC.B LPCOUNT ;count--


BNE GozertzelLoop ;if count != 0, repeat

;Calculate magnitude^2 ;note: we take only upper 16-bit


;integer data
SUB.B R0L, R0L ;clear R0L for sign indicator
MOV.W SKN1HIGH,SKN1LOW ;only integer portion is used
BPL ?0030 ;check if negtive
NEG.W SKN1LOW ;if change it to positive
INC.B R0L ;neg indication
?0030:
MOV.W SKN2HIGH,SKN2LOW ;only integer portion is used
BPL ?0040 ;check if negtive
NEG.W SKN2LOW ;if change it to positive
INC.B R0L ;neg indication
?0040:
MOV.L SKN1, ER5 ;
SHAL.L ER5 ;Sk[n-1] * 2
MULXU.W COE, ER5 ;integer(Sk[n-1]) * 2* Coefficient
MOV.W E5, R5 ;take the integer portion of result
MULXU.W SKN2LOW, ER5 ;2*Coefficient*integer
; (Sk[n-1])*integer(Sk[n-2])

MULXU.W SKN1LOW, SKN1 ;integer(Sk[n-1])^2


MULXU.W SKN2LOW, SKN2 ;integer(Sk[n-2])^2

7
ADD.L SKN2, SKN1 ;Sk[n-1]^2 + Sk[n-2]^2
BTST #0, R0L ;check the sign of product term
BEQ ?0050 ;if positive, do subtraction
ADD.L ER5, SKN1 ;else, do addition
BRA ?0060
?0050
SUB.L ER5, SKN1 ;- 2*Coeff*Sk[n-1]*Sk[n-2]
?0060
MOV.L SKN1, ER0 ;result in ER0

;Restore working registers


POP.L ER5
POP.L ER4
POP.L ER3
POP.L ER2

RTS

Das könnte Ihnen auch gefallen