Connecting the SP03 Speech Module to the Dios Mini Ultra

Introduction
One of the methods the SP03 modules uses for communication is the I2C bus . This example shows how to connect
the SP03 to the Dios. The SDA (data) and SCL (clock) lines are connected to
Port0 and Port1 on the Dios.
Circuit Schematic for connecting the SP03 Speech Module to the Dios Mini Ultra
The schematic above shows 4k7 pull-up resistors on the SCL and SDA lines to Vdd. For greater noise immunity, I recommend pulling up using 1k8 resistors.
Software
The following shows how easy it is to use the Dios with the Speech Module, a
single line command is all that is required to speak any of the 30 pre-loaded
phrases. Your own text strings of up to 80 characters in length may be sent to
the synthesizer for conversion to speech.
The sample code below can be downloaded here.
'*********************************************************** '** ** '** I2C Routines for the Dios to demonstrate ** '** the use of the SP03 text to speech synthesizer ** '** ** '** It speaks preloaded phrase number 2 followed ** '** by the SP03 software Revision number ** '** ** '** Written by Gerald Coe - August 2003 ** '** ** '*********************************************************** gconst SP03 $C4 ' SP03 I2C bus address gconst Cmd_reg 0 ' Command register gconst Ver_reg 1 ' Software Version address gconst LDBUF 0 ' Load SP03 buffer command gconst SPKBUF $40 ' Speak buffer command gconst VOLUME 0 ' See SP03 documentation for these valuse gconst PITCH 5 gconst SPEED 2 global Text(60) as string ' Text buffer holds phrase to be spoken func main() const sda 0 const scl 1 dim Ver loop: I2cout(sda,scl,SP03,Cmd_reg, 2) ' speak phrase number 2 wait4shutup(sda, scl) Ver = I2cin(sda,scl,SP03, Ver_reg) strout @Text, "You're using revision ", dec Ver, " software on the SP03", 0 speakstring(sda, scl, @Text) goto loop endfunc ' speakstring sends the Volume, Pitch, Speed and Text to the ' SP03 in a single I2C transaction, using the low level I2C functions ' built into the Dios \lib\DiosI2c.lib. func speakstring(sda, scl, addr) dim dat I2c_start(sda,scl) I2c_sendbyte(sda,scl,SP03) ' Sp03 I2C address I2c_getack(sda,scl) I2c_sendbyte(sda,scl,Cmd_reg) I2c_getack(sda,scl) I2c_sendbyte(sda,scl,LDBUF) I2c_getack(sda,scl) I2c_sendbyte(sda,scl,VOLUME) I2c_getack(sda,scl) I2c_sendbyte(sda,scl,PITCH) I2c_getack(sda,scl) I2c_sendbyte(sda,scl,SPEED) I2c_getack(sda,scl) loop: getstringbyte addr,dat,done I2c_sendbyte(sda,scl, dat) ' Send supplied string to SP03 internal buffer I2c_getack(sda,scl) goto loop done: I2c_stop(sda,scl) I2cout(sda,scl,SP03,Cmd_reg, SPKBUF) ' Speak the SP03 internal buffer wait4shutup() ' wait until talking finished endfunc func wait4shutup(sda, scl)
dim stat
Wait:
stat = I2cin(sda,scl,SP03, Cmd_reg) ' Read status register
if stat>0 then
goto Wait ' and wait until its zero
endif
endfunc
include \lib\DiosI2c.lib |
You can find more information on the SP03 here and the PICAXE here