PDF For Talking Calculator

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 6

Entry # AT3295: Talking Calculator Abstract Microcontroller ATmega88

Circuit Cellar / Atmel AVR Design Contest

July 27 2006

th

Talking calculator
Overview
This work describes a talking calculator built just by three chips that can be very useful to blind people. The calculator operates with real numbers of simple precision. It has the four basic operations (addition, subtraction, multiplication and division), and the functions: clear all, change of sign (+/-), inverse (1/x), square root ( ), pi number ( ), add with memory (M+) and read from memory (MR). It also has the keys POWER_ON, POWER_OFF and VOICE to change between the Voice and No-voice modes. It works with a battery of 3 volts.

Figure 1: Talking calculator block diagram

The complete system is composed by 3 chips and an alphanumeric LCD display (optionally). The systems main component is the ATMEGA88 microcontroller, whose missions are: reading the keypad, doing mathematical calculations, showing the results, voice generating and the handling of the battery energy in order to increase its lifetime. The system uses a two-wire serial EEPROM that contains the codified sound that the computer uses to communicate the results and to inform on the keys pressed by the human operator. The Talking Calculator uses the speech waveform encoder RC-2 that needs only two resistors and one capacitor to do voice decoding. The LM4861, an Audio Power Amplifier with Shutdown Mode, is used to amplify the sound. To show the results we use a 3V alphanumeric LCD MDLS16166 of 16 characters x 1 line. This element is not essential because the calculator is completely operative without it.

Photo 1: The complete Talking calculator

AUDIO AMPLIFIER

C10 P1 C9
0.1uF 500K

VCC

RC2 SPEECH DECODER

2nF

R7
20k Vo1 5 6 7 8 SPEAKER

R2
PD0

6k8

R6
20k

U3
4 3 2 1 IN-

LS1

R3
PD1

6k8

IN+ VCC Bypa GND ShutD Vo2 LM4861

C6
0.1uF

C7
1u

C4
0.1uF

MDLS-16166-3V PC0 SHUTDOWN

LCD1

1 VSS 2 VDD 3 VEE

VCC_LCD PC1 PB0 PB1 PB2 PB3 PB4 PB5 PB6 PB7 PC0 PC2 SDA SCL MOSI MISO SCK

4 RS 5 RW 6 E

U1
14 15 16 17 18 19 9 10

100 PD0/RXD PD1/TXD PD2/INT0 PD3/INT1 PD4/XCK/T0 PD5/T1 PD6/AIN0 PD7/AIN1 2 3 4 5 6 11 12 13 PD0 PD1

PB0/ICP PB1/OC1A PB2/SS/OC1B PB3/MOSI/OC2 PB4/MISO PB5/SCK PB6/XTAL1/TOSC1 PB7/XTAL2/TOSC2 PC0/ADC0 PC2/ADC2 PC4/ADC4/SDA PC5/ADC5 /SCL PC6/RESET ATMEGA88

SHUTDOWN 23 VCC_LCD 25 27 28 1

7 8 9 10 11 12 13 14

D0 D1 D2 D3 D4 D5 D6 D7

R1

ISP CONNECTOR

C5
AVCC AREF 20 21 0.1uF 20k MISO SCK RESET 1 2 3

J3
6 5 4 CONN-DIL6 MOSI

RESET

C2
0.1uF

"VOICE"
PB4

"1/X"

"ROOT"

"+/-"

"OFF"

BAT1
3V

C1
0.1uF

C8
10u

"7"
PB3

"8"

"9"

"MR"

"M+"

"4"
PB2

"5"

"6"

"*"

"/"
VCC

C3 "1" "2" "3" "+" "-"


0.1uF

PB1

R4
10k 7 5 6

R5
10k

"0"
PB0

","

"EXP"

"="

"C/ON"

U2
3 2 1 A2 A1 A0 WP SDA SCL

SDA SCL

AT24C1024

Figure 2: Talking calculator complete schematic.

PC2

PC3

PB7

PB6

PB5

DIGITAL VOICE MEMORY

Software
The Codevision AVR C Compiler and the demo version of visualSTATE have been used to develop the software of the calculator. With visualSTATE the behavior of the calculator is described in a graphic way using UML statecharts, see figure 3.
/ [veVoice = 1] CalculatorOff Entry / InitCalcOff() Exit / InitCalcOn() eClear() / Say(veKey) eOn() / Say(CALCULATOR_ON) eOff() / Say(CALCULATOR_OFF)

CalculatorOn eVoice() [veVoice != 0] / Say(VOICE_OFF) [veVoice = ! veVoice] eVoice() [veVoice == 0] / [veVoice = !veVoice] Say(VOICE_ON) / [N=0] [Oper[0]=0] DisplayN() eSign() / [Oper[N]=-Oper[N]] DisplayN() eDig_0() / [Oper[N]=0] DisplayN() eExponent() / [Oper[N] = PI] DisplayN()

eFunction() / Say(veKey) Say('=') [Oper[N] = Function(veKey)] DisplayN()

eOperator() [N==0] / [N=1] Say(veKey) [viOperator=veKey ] [Oper[1]=Oper[0]]

DisplayN

eDig_1_9() / [viFrac=1] [viOperand = veKey & 0x0f] ClearLCD() PutLCD(veKey)

eOperator() [N==1] / Operate(viOperator) [Oper[1]=Oper[0]] [viOperator=veKey] Say('=') DisplayN() Say(veKey) eEqual() [N==1] / [N=0] Say('=') Operate(viOperator) DisplayN()

ePoint() / [viFrac = 10] [viOperand = 0] ClearLCD() PutLCD('0') PutLCD('.')

GetOperand Entry / [viNumDig=viFrac&1] [viExp=1] [viSign=1] Exit / [Oper[N] = viOperand]

Figure 3: Talking calculator statechart.

Digital Voice Generation


To generate the digital voice you only need the software: Windows Sound Recorder, the AVR Studio 4, and the RC Sound Encoder downloadable from the Circuit Cellar ftp site. First of all you must decide which sounds the talking calculator must reproduce. For our application 32 sounds are used. Next each of the sounds must be recorded, one by one, using Windows Sound Recorder. You can achieve good results by saving WAV files in PCM format 44.1 kHz, 16 bits, and one channel. After you have the WAV file, you must run the RC Sound Encoder to get an ASM file for each WAV file. To generate the encoded voice file we must create an AVR assembler project and use AVR Studio 4 to build the project and to get the Object file. Finally, use this object file to program the two-wire serial EEPROM.

Conclusions
The talking calculator is an interesting device built just by three chips that can be very useful to blind people. Its main features are: the use of an extremely simple digital audio decoder, its low cost and its reduced energy consumption. It can be adapted to different languages easily only changing the voice memory contents. I hope its simplicity stimulate other people to add audio capability to theirs microcontroller-based designs.

You might also like