PDA

View Full Version : Need help with speakjet project



kicknitinkc
04-15-2010, 11:13 AM
I am basically using a bs2, speakjet chip, an lm386 op amp, and an 8 ohm speaker.

This is the circuit I'm using straight from the user's manual:
http://letsmakerobots.com/files/userpics/u564/speakjet_pic.jpg
(ignore the picaxe comment)

This the op-amp circuit I am using:
http://letsmakerobots.com/files/userpics/u559/lm386.gif

I am having issues with this circuit. When I flip the on switch of the board of education, the speaker will play the first two serout commands and then just pause after that. I can still hear that the speaker has power so I'm thinking it may be an issue with the BS2. Maybe too much power is being drained by the op-amp? How can I fix this? Your input is greatly appreciated.

Thanks,

Sam

Franklin
04-15-2010, 11:28 AM
Attaching your code will allow others to see what you have programmed it to do and a complete schematic would help. You say maybe too much power is being drawn but you don't show where the power is comming from.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen

kicknitinkc
04-15-2010, 11:43 AM
I am using the 5v regulated power supply from the board of education. A 9v battery is connected to the board. Here is my code, it is for a mechatronics project that I can't yet give all the details on. Most of the constants stuff is for the speakjet. All I am doing with this program right now is making sure I have the speakjet and amp working properly, which appears to be the case. I'm almost positive it has something to do with the BS2 now because when the speakjet/speaker stops playing sounds, my computer can't find the BS2 when I try to reload the program.




' {$STAMP BS2}
' {$PBASIC 2.5}

#SELECT $stamp
#CASE BS2, BS2E, BS2PE
T2400 CON 396
T4800 CON 188
T9600 CON 84
T19K2 CON 32
#CASE BS2SX, BS2P
T2400 CON 1021
T4800 CON 500
T9600 CON 240
T19K2 CON 110
#ENDSELECT

Inverted CON $4000
Baud CON T9600

PA0 CON 0 ' pauses
PA1 CON 1
PA2 CON 2
PA3 CON 3
PA4 CON 4
PA5 CON 5
PA6 CON 6

Fast CON 7
Slow CON 8
Stress CON 14
Relax CON 15
_Wait CON 16 ' note underscore
Soft CON 18
Volume CON 20
Speed CON 21
Pitch CON 22
Bend CON 23
PortCtr CON 24
Port CON 25
Repeat CON 26
CallPhr CON 28
GotoPhr CON 29
Delay CON 30
Reset CON 31

IY CON 128
IH CON 129
EY CON 130
EH CON 131
AY CON 132
AX CON 133
UX CON 134
OH CON 135
AW CON 136
OW CON 137
UH CON 138
UW CON 139
MM CON 140
NE CON 141
NO CON 142
NGE CON 143
NGO CON 144
LE CON 145
LO CON 146
WW CON 147
RR CON 148
IYRR CON 149
EYRR CON 150
AXRR CON 151
AWRR CON 152
OWRR CON 153
EYIY CON 154
OHIY CON 155
OWIY CON 156
OHIH CON 157
IYEH CON 158
EHLL CON 159
IYUW CON 160
AXUW CON 161
IHWW CON 162
AYWW CON 163
OWWW CON 164
JH CON 165
VV CON 166
ZZ CON 167
ZH CON 168
DH CON 169
BE CON 170
BO CON 171
EB CON 172
OB CON 173
DE CON 174
_DO CON 175 ' note underscore
ED CON 176
OD CON 177
GE CON 178
GO CON 179
EG CON 180
OG CON 181
CH CON 182
HE CON 183
HO CON 184
WH CON 185
FF CON 186
SE CON 187
SO CON 188
SH CON 189
TH CON 190
TT CON 191
TU CON 192
TS CON 193
KE CON 194
KO CON 195
EK CON 196
OK CON 197
PE CON 198
PO CON 199

RO CON 200
R1 CON 201
R2 CON 202
R3 CON 203
R4 CON 204
R5 CON 205
R6 CON 206
R7 CON 207
R8 CON 208
R9 CON 209

A0 CON 210
A1 CON 211
A2 CON 212
A3 CON 213
A4 CON 214
A5 CON 215
A6 CON 216
A7 CON 217
A8 CON 218
A9 CON 219

_B0 CON 220 ' note underscore
_B1 CON 221
_B2 CON 222
_B3 CON 223
_B4 CON 224
_B5 CON 225
_B6 CON 226
_B7 CON 227
_B8 CON 228
_B9 CON 229

C0 CON 230
C1 CON 231
C2 CON 232
C3 CON 233
C4 CON 234
C5 CON 235
C6 CON 236
C7 CON 237
C8 CON 238
C9 CON 239

D0 CON 240 ' DTMF tones
D1 CON 241
D2 CON 242
D3 CON 243
D4 CON 244
D5 CON 245
D6 CON 246
D7 CON 247
D8 CON 248
D9 CON 249
D10 CON 250
D11 CON 251

M0 CON 252 ' sonar pin
M1 CON 253 ' pistol shot
M2 CON 254 ' WOW
EOS CON 255 ' end of string


' -----[ Variables ]-------------------------------------------------------

eeAddr VAR Word ' address of speech element
element VAR Byte ' speech element / code
idx VAR Word


tx PIN 15
rdy PIN 4

DO

'ONE VOLT

SEROUT TX, $0054, [WW,UX,NO,VV,OW,LO,TT]


'ANOTHER NAIL IN YOUR COFFIN
SEROUT tx, $0054, [21,110,M1,M1,M1,21,110,UX,22,105,NO,21,100,22,110, UX,21,127,22, 100,TH,AXRR,0,21,120,ne,eyiy,LO,0,IH,NO,0,21,125,I YUW,OWRR,0,21,110,KE,AW,FF,IH,NE]

'SAM
SEROUT tx, $0054, [20,127,188, 22, 174,21,25,22,180,132,140]

PAUSE 5000

LOOP

PJ Allen
04-15-2010, 08:51 PM
That's not attaching your "code", that's posting it.· Push the freaking Attachment Manager button!

kicknitinkc
04-15-2010, 09:54 PM
Haha really?! I really don't see a difference besides having to copy and paste my code if one were to try running it. I assume most people don't have a speakjet so being able to just look at the code will be more convienient. If you must have the code in an attachment, I'll attach it in a post after I get home from work. I.

RobotWorkshop
04-15-2010, 10:55 PM
In order to help you should really post a schematic of your actual circuit and not just fragments for others. With the whole schematic we can look for omissions or wiring errors that would cause problems.

It looks like you're just sending a bunch of phonemes to the SpeakJet (open loop) without checking for any feedback from the SpeakJet. It has a 64-byte buffer so you should be ok for the first pass case but it would be a problem if you start sending a lot of text to the chip. You can use the buffer half full signal from the SpeakJet as a way to throttle the amount of data you send to it.

From the original description there really isn't any way to tell for sure what the issue is. To start I would connect an LED to one of the other un-used pins and within your code you can toggle that pin. At least that way you can tell if the Stamp is still processing. You'll need to start testing otherwise it is all purely speculation. If you have a meter I would also measure the current draw of the whole circuit and if it seems high try to pinpoint the issue by removing power to your amp circuit first and then the SpeakJet. Are you powering everything from a 5V supply?

I've used the SpeakJet quite a bit and it is a good chip. You can find out some more about how that chip is used if you pickup the December 2007 issue of SERVO. It has an article on using the SpeakJet to replace an older SC-01 speech chip.

Good luck,

Robert

kicknitinkc
04-16-2010, 01:14 AM
Ok I'll try to get a schematic up sometime soon. The main difference with my circuit is that there is a 10k pot hooked up in place of the 50k pot. On the amp circuit, there is no pot because it is already on the speakjet circuit. It does the job for controlling volume. I've disconnected the amp and communitcation is restored. I have both amp and speakjet powered by the 5v supply. I tried powering the speakjet separately and it seemed to work a little longer but still has the same problem. I know the code works because I've hooked up the speakjet through the computers mic Jack and it worked flawlessly. I dont have a meter handy or I would definitely give that a shot. Would it make a difference if I had the amp ground wires connected to a common ground?

kicknitinkc
04-16-2010, 02:05 AM
Hey RobotWorkshop, is there any way you could post a schematic of one of your old speakjet projects? Maybe that would help. I tried looking at the SERVO magazine online but you have to pay to view it so I had to pass on that one.

RobotWorkshop
04-16-2010, 02:25 AM
The schematics don't have any amp section at all and just show the basic connections which are already shown in the SpeakJet manual. In the case of the SC-01 to SpeakJet conversion the project relied on the amp already present on another board which the SC-01 chip drove. In the example used in the article the particular amp chip is an obsolete part so that wouldn't be useful in this case. In the other case I just used and off the shelf amp kit but there are plenty of designs online that use the LM386 which should work well:

http://www.techlib.com/electronics/audioamps.html

http://www.rason.org/Projects/icamps/icamps.htm

kicknitinkc
04-16-2010, 08:28 AM
So is there a common phenomenon that causes the bs2 to stop working mid-program? I'm gonna try messing around with different capacitors and see if that fixes anything. If that doesn't I suppose I'll try different resistors also. If THAT doesn't work then I'm going to have to try using a different op-amp circuit I've seen online.

RobotWorkshop
04-16-2010, 08:59 AM
Well that is an excellent question hung but we don't know if the Stamp is hung up somehow. They are pretty robust so that usually isn't the first thing I would look at. I'm not saying that it can't happen, just that is not the most likely problem. That is why I would at least recommend adding some sort of LED that you can flash on/off during your program so you can tell if the Stamp is active. If you have a logic probe you could also see if there is any activity on data out going to the SpeakJet.

electrosys
04-17-2010, 10:07 PM
Hello Kicknitinkc!

Try to·download this code to your BS2, the code that I have attached here, is a·Parallax demonstration·code, for SpeakJet Demo Borard's.

You may have to change some of the·Pins·connections at your BS2 to SpeakJets circuit.··

kicknitinkc
04-30-2010, 08:11 AM
I finally had time to get some help and I found out that my problem was simply a battery with low charge. http://forums.parallax.com/images/smilies/hop.gif
Time to tackle the next pieces of my project: data logging, ir detection, motor control, and LCD.

electrosys
05-01-2010, 07:46 PM
Hello kicknitinkc,

·At your code, you have declared·the flow control Pin (rdy PIN 4),·but you are not using·it,·at the SEROUT line!

part of your code:
----------------------------------------------
tx·PIN·15
rdy·PIN·4· '<----- flow control Pin

SEROUT·TX,·$0054,·[WW,UX,NO,VV,OW,LO,TT]
------------------------------------------------

In the other codes for -SpeakJet-·(as the one I have attached before) the SEROUT line looks like this:

SEROUT Tx\Rdy, Baud, [element]

Wouldn't be a problem, with·no·flow control at the SEROUT line?

kicknitinkc
05-02-2010, 12:43 AM
I haven't had much problems without flow control except sometimes it will repeat a saying a few times if the signal is held on for longer than normal. I don't understand how to use flow control. Do you put the ready pin in place of TX in the serout command or do you put a slash after TX and then rdy like you posted in your reply? Not really sure how to use it.

electrosys
05-03-2010, 02:47 AM
You just put a slash after TX and then rdy :

SEROUT Tx\rdy,




·

kicknitinkc
05-03-2010, 03:47 AM
I've done that to my code and don't see any difference. I still don't understand how that executes "flow control " or even what flow contol does. I've also tried using the "speaking" and "buffer half full" output pins to monitor what the speakjet is doing. However, I cannot get any useful info to output in the debug window. The reason I've attempted to do this is because the speakjet keeps outputting a sound when the beam is kept broken in my light detection cicuit when what I really want is one sound per each time the beam is broken. Essentially the speakjet is overflowing the buffer and I can't figure out any useful way to control it. Let me know if you can help me in any way. Thanks.

electrosys
05-03-2010, 04:20 AM
You can read all about SEROUT and flow control, at BASIC Stamp Syntax and Reference Manual 2.2 -Page 415- SEROUT command -
Functions explained as Tpin and Fpin

in·SpeakJet case, Tpin=Tx and Fpin= rdy

·

kicknitinkc
05-07-2010, 08:25 AM
Well I got my project pretty much finished. Its a cigarette dispenser that talks trash to the user and stores data about how much cigarettes they smoke and how much money they spend on them. My original plans were to use infrared for light detection but I couldn't get it working right so I used a red LED to give the phototransistor enough light to detect a break in the beam from a cigarette being dispensed. There are two pushbuttons. One is used to reset the EEPROM data and the other is supposed to display (# of cigarettes) when the user holds it down. I have already presented my project but would like to eventually make it better. I have a few questions: 1. I had the "money spent" data displaying the dollars and cents to the nearest quarter correctly last night but now it counts up in increments of 50 cents and the dollar value doesn't always add to the next digit. I have no idea what I changed to mess it up, any ideas? 2. How can I set my light detection with IR and have it fast enough to notice a quick break in the beam of light? I used the infrared receiver but it didn't seem to detect very well in small areas (3 inch gap) so I switched to using RCtime with a phototransistor and an IR LED. The phototransistor wouldnt pick up the infrared light for anything. I messed around a little with the infrared transistor that Parallax sells but had no luck. 3. What is the best way to use my button2 command so I can get the LCD to display "# of cigarettes" when the user holds down button 2? Thanks,

Sam

here's the code if you don't want to download it:



' {$STAMP BS2e}
' {$PBASIC 2.5}

#SELECT $stamp
#CASE BS2, BS2E, BS2PE
T2400 CON 396
T4800 CON 188
T9600 CON 84
T19K2 CON 32
#CASE BS2SX, BS2P
T2400 CON 1021
T4800 CON 500
T9600 CON 240
T19K2 CON 110
#ENDSELECT

Inverted CON $4000
Baud CON T9600

PA0 CON 0 ' pauses
PA1 CON 1
PA2 CON 2
PA3 CON 3
PA4 CON 4
PA5 CON 5
PA6 CON 6

Fast CON 7
Slow CON 8
Stress CON 14
Relax CON 15
_Wait CON 16 ' note underscore
Soft CON 18
Volume CON 20
Speed CON 21
Pitch CON 22
Bend CON 23
PortCtr CON 24
Port CON 25
Repeat CON 26
CallPhr CON 28
GotoPhr CON 29
Delay CON 30
Reset CON 31

IY CON 128
IH CON 129
EY CON 130
EH CON 131
AY CON 132
AX CON 133
UX CON 134
OH CON 135
AW CON 136
OW CON 137
UH CON 138
UW CON 139
MM CON 140
NE CON 141
NO CON 142
NGE CON 143
NGO CON 144
LE CON 145
LO CON 146
WW CON 147
RR CON 148
IYRR CON 149
EYRR CON 150
AXRR CON 151
AWRR CON 152
OWRR CON 153
EYIY CON 154
OHIY CON 155
OWIY CON 156
OHIH CON 157
IYEH CON 158
EHLL CON 159
IYUW CON 160
AXUW CON 161
IHWW CON 162
AYWW CON 163
OWWW CON 164
JH CON 165
VV CON 166
ZZ CON 167
ZH CON 168
DH CON 169
BE CON 170
BO CON 171
EB CON 172
OB CON 173
DE CON 174
_DO CON 175 ' note underscore
ED CON 176
OD CON 177
GE CON 178
GO CON 179
EG CON 180
OG CON 181
CH CON 182
HE CON 183
HO CON 184
WH CON 185
FF CON 186
SE CON 187
SO CON 188
SH CON 189
TH CON 190
TT CON 191
TU CON 192
TS CON 193
KE CON 194
KO CON 195
EK CON 196
OK CON 197
PE CON 198
PO CON 199

RO CON 200
R1 CON 201
R2 CON 202
R3 CON 203
R4 CON 204
R5 CON 205
R6 CON 206
R7 CON 207
R8 CON 208
R9 CON 209

A0 CON 210
A1 CON 211
A2 CON 212
A3 CON 213
A4 CON 214
A5 CON 215
A6 CON 216
A7 CON 217
A8 CON 218
A9 CON 219

_B0 CON 220 ' note underscore
_B1 CON 221
_B2 CON 222
_B3 CON 223
_B4 CON 224
_B5 CON 225
_B6 CON 226
_B7 CON 227
_B8 CON 228
_B9 CON 229

C0 CON 230
C1 CON 231
C2 CON 232
C3 CON 233
C4 CON 234
C5 CON 235
C6 CON 236
C7 CON 237
C8 CON 238
C9 CON 239

D0 CON 240 ' DTMF tones
D1 CON 241
D2 CON 242
D3 CON 243
D4 CON 244
D5 CON 245
D6 CON 246
D7 CON 247
D8 CON 248
D9 CON 249
D10 CON 250
D11 CON 251

M0 CON 252 ' sonar pin
M1 CON 253 ' pistol shot
M2 CON 254 ' WOW
EOS CON 255 ' end of string

button1 PIN 0 ' button pin
button2 PIN 2
lcdTX PIN 3 ' serial output to LCD
LcdBaud CON 32 ' LCD baudrate = 19,200
LcdCls CON $0C ' clear LCD (use PAUSE 5 after)
LcdBLon CON $11 ' backlight on
LcdBLoff CON $12 ' backlight off
LcdOff CON $15 ' LCD off
LcdOn1 CON $16 ' LCD on; cursor off, blink off
LcdCC0 CON $F8 ' define custom char 0
LcdCC1 CON $F9 ' define custom char 1
LcdCC2 CON $FA ' define custom char 2
LcdLine1 CON $80 ' move to line 1, column 0
LcdLine2 CON $94 ' move to line 2, column 0



PhotoCircuit PIN 1


' -----[ Variables ]-------------------------------------------------------


' -----[ Variables ]-------------------------------------------------------

eeAddr VAR Word ' address of speech element
element VAR Byte ' speech element / code

PhotoVal VAR Word
calibrate VAR Word
COUNTER VAR Byte
TABLEIDX VAR Byte
PHRASE VAR Byte
dollar VAR Byte
cents VAR Byte
tx PIN 15
rdy PIN 14

'speakjet phrases

SHOT DATA ro,r1,r2,r3,r2,r1,ro, eos
COFFIN DATA 21,110,M1,M1,M1,21,110,UX,22,105,NO,21,100,22,110, UX,21,127,22, 100,TH,AXRR,0,21,120,ne,eyiy,LO,0,IH,NO,0,21,125,I YUW,OWRR,0,21,110,KE,AW,FF,IH,NE, EOS
ANOTHER DATA SO,MM,OW,EK,UX,NO,UX,TH,AXRR,WW,UX,NO,EOS
KILLING DATA IYUW,FAST,OwRr,KE,FAST,IH,FAST,LO,FAST,LE,FAST,IY, NGE,IYUW,FAST,OWRR,SO,EH,LO,FF,SE,SLOW,AY,MM,EOS
ASHTRAY DATA IYUW,SO,MM,EH,LO,LE,OHIH,OK,AY,NO,AY,SH,TU,RR,EYIY ,EOS
SMOKING DATA SE,TU,AW,PO,SE,MM,OW,KE,IY,NGO,TH,AY,TU,KE,RR,AY,P O,EOS
DIE DATA 22,50,IYUW,DE,OW,NO,TU,AW,LE,WW,FAST,EYIY,SO,DE,OH IH,FF,RR,UX,MM,TU,UX,SLOW,BE,SLOW,AY,KE,SLOW,OW,OW ,OW,OW,OW,OW,EOS
BIOTCH DATA 22,75,MM,MM,MM,MM,WW,UX,TU,IYUW,WW,UX,NO,TU,PA5,BE ,IY,AW,AW,AW,TU,CH,EOS

'display data with intro message

PAUSE 1000
READ 0, counter
cents = ((counter) // 4)*25
READ 1, dollar
SEROUT Tx, Baud, [21,120,20,127,22,200,he,eh,eh,le,le,lo,ow,ow,ow,SE ,AY,AY,AY,MM,PA2,WW,UH,LO,DE,IYUW,LE,OHIH,KO,EYIY, KE,AY,NO,SE,AXRR,SE,TU,IH,OK,eos ]
SEROUT lcdtx,lcdbaud, [lcdblon,(lcdline1), " Money Spent",(lcdline2)," $",DEC dollar,".",DEC2 cents]

HIGH PhotoCircuit ' Set to output
PAUSE 3 ' Pause for 3 ms to charge
RCTIME PhotoCircuit,1,PhotoVal 'measure rctime
calibrate = photoval 'calibrate light setting before starting


DO

IF button1 = 0 THEN 'if button is pressed, reset data
WRITE 0,0
READ 0, counter
WRITE 1,0
READ 1, dollar

'display zeros on LCD
SEROUT lcdTX, LcdBaud, [lcdblon,(lcdline1), " Money Spent",(lcdline2)," $","0",".","00"]

ENDIF
'DEBUG ? button2

'IF button2 = 0 THEN
'SEROUT lcdTX, LcdBaud, [(lcdline1),"# of Cigarettes",(lcdline2)," ",DEC counter]
'ENDIF

GOSUB charge
GOSUB detect


LOOP


charge:
' Measure RC time
HIGH PhotoCircuit ' Set to output
PAUSE 3 ' Pause for 3 ms to charge
RCTIME PhotoCircuit,1,PhotoVal ' measure rctime

detect:

DEBUG HOME, DEC4 photoval ,CR, DEC4 calibrate,CR, DEC3 COUNTER

IF photoval > calibrate + 125 THEN
SEROUT lcdtx, lcdbaud, [lcdcls,lcdblon]
'SEROUT lcdTX, LcdBaud, [(lcdline1),"# of Cigarretes",(lcdline2),DEC counter]

cents = ((counter+1) // 4)*25 'create decimal place for cents

'LCD: display money spent on cigarretes
SEROUT lcdTX, LcdBaud, [(lcdline1), " Money Spent",(lcdline2)," $",DEC dollar,".",DEC2 cents]

'Set volume and pitch for speakjet
SEROUT Tx\RDY,84,[volume,127,pitch,100]
'lookup phrase
LOOKUP TABLEIDX, [SHOT, COFFIN,ANOTHER,KILLING,ASHTRAY,SMOKING, DIE, BIOTCH ], PHRASE
'set address to phrase
eeAddr = PHRASE
'play phrase
GOSUB Play_String
PAUSE 1000

'math to hold dollars place
IF cents = 75 THEN
dollar = dollar + 1
ENDIF

'update counter
COUNTER = COUNTER + 1
'write values to eeprom for storage
WRITE 0 , counter
WRITE 1 , dollar
ENDIF
RETURN




Play_String:
'run a loop to play phrase and exit at end of phrase
DO
READ eeAddr, element ' get phrase element from eeprom

eeAddr = eeAddr + 1 ' point to next
IF (element = EOS) THEN EXIT ' end? if yes we're done
SEROUT Tx, Baud, [element] ' send element to SpeakJet
LOOP
'get ready to play next phrase
TABLEIDX = TABLEIDX + 1
'if at end of table go to beginning
IF TABLEIDX = 9 THEN
TABLEIDX = 0
ENDIF
RETURN


Post Edited (kicknitinkc) : 5/7/2010 2:50:06 AM GMT

kicknitinkc
05-26-2010, 12:31 AM
Bump....... anyone have any ideas?

electrosys
05-26-2010, 06:15 PM
Great job Kicknitinkc, I have also a SpeakJet IC, it is one of my favorite chip.
I think I'll try your progeram codes, first the part you have write for the SpeakJet,
then I may go further and try the rest, who knows, maybe it could stop me to smoke!

Don't you want to put your project at the Completed Projects?

Keep the Good work

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔

kicknitinkc
05-27-2010, 01:52 AM
Well its not completed quite yet. I need to address the issues previously stated and if I can find the oscillator crystal for the real time clock chip I'll have much more data collection possibilities.