by NovaOne » Sat Jul 28, 2007 9:08 am
by NovaOne
Sat Jul 28, 2007 9:08 am
I can't take credit for cracking i2c on RN, KurtE did that a while back.
I basically redigested George Coe's and KurtE code for single byte reads from the CMPS03
KurtE's routines were written for the SF10/08, so thet were much more complicated than needed for the compass. But I liked his byte shifting rountines better than the ones in the back of RN manual.
So I used George Coe's BasicStamp examples for the CMPS03 as my core code.
Anyway, I think the routines should work for the SP03.
Page 4 and 5 of the datasheet suggest that the following changes :
-warning this code is totally untested!
I2cAddr = &Hc4 'SP03 default address
FillSpeechBuffer:
GOSUB I2cStart 'Start sequence
I2cBuf = I2cAddr
GOSUB I2cOutByte 'Send SP03 address
I2cBuf = 0
GOSUB I2cOutByte 'Select Command Register
GOSUB I2cOutByte 'Send NOP
GOSUB I2cOutByte 'Max volume = Zero??
I2cBuf = &H05
GOSUB I2cOutByte 'Speech Speed
I2cBuf = &H03
GOSUB I2cOutByte 'Speech Pitch
'** Followed by the ASCII characters (85 maximum) of the words you would like RN to say for example, Hello
I2cBuf = &H48 'H
GOSUB I2cOutByte
I2cBuf = &H65 'e
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H06F o
GOSUB I2cOutByte
I2cBuf = 0 'Nul
GOSUB I2cOutByte
GOSUB I2cStop
RETURN
The datasheet then seems to say that if you wish to speak the contents of the buffer, you send the SPKBUF command &H40
I2cAddr = &Hc4 'SP03 default address
I2cReg = 0 'Command Register
I2cData = &H40 'Speak Buffer command
GOSUB I2cByteWrite
Using the free configuration program you can load upto 30 predefined phrases into memory. This should play a phrase back:
I2cAddr = &Hc4 'SP03 default address
I2cReg = 0 'Command Register
I2cData = &H01 'Speak 1st predefined phrase
GOSUB I2cByteWrite
Sorry for any mistakes. I hope they don't give anyone too much of a headache.
Chris
I can't take credit for cracking i2c on RN, KurtE did that a while back.
I basically redigested George Coe's and KurtE code for single byte reads from the CMPS03
KurtE's routines were written for the SF10/08, so thet were much more complicated than needed for the compass. But I liked his byte shifting rountines better than the ones in the back of RN manual.
So I used George Coe's BasicStamp examples for the CMPS03 as my core code.
Anyway, I think the routines should work for the SP03.
Page 4 and 5 of the datasheet suggest that the following changes :
-warning this code is totally untested!
I2cAddr = &Hc4 'SP03 default address
FillSpeechBuffer:
GOSUB I2cStart 'Start sequence
I2cBuf = I2cAddr
GOSUB I2cOutByte 'Send SP03 address
I2cBuf = 0
GOSUB I2cOutByte 'Select Command Register
GOSUB I2cOutByte 'Send NOP
GOSUB I2cOutByte 'Max volume = Zero??
I2cBuf = &H05
GOSUB I2cOutByte 'Speech Speed
I2cBuf = &H03
GOSUB I2cOutByte 'Speech Pitch
'** Followed by the ASCII characters (85 maximum) of the words you would like RN to say for example, Hello
I2cBuf = &H48 'H
GOSUB I2cOutByte
I2cBuf = &H65 'e
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H6C 'l
GOSUB I2cOutByte
I2cBuf = &H06F o
GOSUB I2cOutByte
I2cBuf = 0 'Nul
GOSUB I2cOutByte
GOSUB I2cStop
RETURN
The datasheet then seems to say that if you wish to speak the contents of the buffer, you send the SPKBUF command &H40
I2cAddr = &Hc4 'SP03 default address
I2cReg = 0 'Command Register
I2cData = &H40 'Speak Buffer command
GOSUB I2cByteWrite
Using the free configuration program you can load upto 30 predefined phrases into memory. This should play a phrase back:
I2cAddr = &Hc4 'SP03 default address
I2cReg = 0 'Command Register
I2cData = &H01 'Speak 1st predefined phrase
GOSUB I2cByteWrite
Sorry for any mistakes. I hope they don't give anyone too much of a headache.
Chris