Emic Sound Module: Volume Adjust --Help
stuartX
Posts: 88
Hi all,
I know this subject has been hashed out in the past. But, I check the post and did not see this specific request. I connected and used the example code for the Emic board and it works fine.
What I'm trying to do is adjust the volume and that's not working (its my code). I tried different examples and still can't get the volume to change. I also tried reset as well.
Can someone tell me what I'm doing wrong please? The code is below.
THIS CODE WORKS:
Tx PIN 0 ' connects to Emic SIn
Rx PIN 1 ' connects to Emic SOut
Busy PIN 2 ' 1 = busy
'
[ Constants ]
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
Baud CON 396 ' 2400 baud, N81
#CASE BS2SX, BS2P
Baud CON 1021
#ENDSELECT
Yes CON 1
No CON 0
' Emic Commands (Hex Mode)
Say CON $00 ' say Engish text
Volume CON $02 ' set volume, 0 - 7
Speed CON $04 ' set speed, 0 - 4
Pitch CON $03 ' set pitch, 0 - 6
AddAbbr CON $04 ' add abbreviation
DelAbbr CON $05 ' delete abbreviation
ListAbbr CON $06 ' list abbreviations
Version CON $07 ' get version
Reset CON $08 ' soft reset
Audio CON $09 ' enable audio in
PhT CON $10 ' start of phonetic text
Help CON $FE ' display help
EOM CON $AA ' end of message
OK CON $55 ' "okay" for hex mode
'
[ Program Code ]
vol VAR Byte
response VAR Nib
Main:
GOSUB Check_Busy
SEROUT Tx, Baud, [Say, "Testing 1 2 3.", EOM]
PAUSE 100
Check_Busy:
PAUSE 1 ' allow busy to activate
' DO WHILE (Busy = Yes) : LOOP ' wait until not busy
RETURN
Set_Volume:
vol = 2
SEROUT TX, Baud, [Volume, DEC1 vol, EOM] ' send to Emic
GOTO Main
END
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
When I replace Main with the following to adjust volume, it does not work:
Main:
GOSUB Set_Volume
GOSUB Check_Busy
SEROUT Tx, Baud, [Say, "Testing 1 2 3.", EOM]
PAUSE 100
Help is appreciated.
Thanks (in advance)
I know this subject has been hashed out in the past. But, I check the post and did not see this specific request. I connected and used the example code for the Emic board and it works fine.
What I'm trying to do is adjust the volume and that's not working (its my code). I tried different examples and still can't get the volume to change. I also tried reset as well.
Can someone tell me what I'm doing wrong please? The code is below.
THIS CODE WORKS:
Tx PIN 0 ' connects to Emic SIn
Rx PIN 1 ' connects to Emic SOut
Busy PIN 2 ' 1 = busy
'
[ Constants ]
#SELECT $STAMP
#CASE BS2, BS2E, BS2PE
Baud CON 396 ' 2400 baud, N81
#CASE BS2SX, BS2P
Baud CON 1021
#ENDSELECT
Yes CON 1
No CON 0
' Emic Commands (Hex Mode)
Say CON $00 ' say Engish text
Volume CON $02 ' set volume, 0 - 7
Speed CON $04 ' set speed, 0 - 4
Pitch CON $03 ' set pitch, 0 - 6
AddAbbr CON $04 ' add abbreviation
DelAbbr CON $05 ' delete abbreviation
ListAbbr CON $06 ' list abbreviations
Version CON $07 ' get version
Reset CON $08 ' soft reset
Audio CON $09 ' enable audio in
PhT CON $10 ' start of phonetic text
Help CON $FE ' display help
EOM CON $AA ' end of message
OK CON $55 ' "okay" for hex mode
'
[ Program Code ]
vol VAR Byte
response VAR Nib
Main:
GOSUB Check_Busy
SEROUT Tx, Baud, [Say, "Testing 1 2 3.", EOM]
PAUSE 100
Check_Busy:
PAUSE 1 ' allow busy to activate
' DO WHILE (Busy = Yes) : LOOP ' wait until not busy
RETURN
Set_Volume:
vol = 2
SEROUT TX, Baud, [Volume, DEC1 vol, EOM] ' send to Emic
GOTO Main
END
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
When I replace Main with the following to adjust volume, it does not work:
Main:
GOSUB Set_Volume
GOSUB Check_Busy
SEROUT Tx, Baud, [Say, "Testing 1 2 3.", EOM]
PAUSE 100
Help is appreciated.
Thanks (in advance)
Comments
Should be:
$02 is used to adjust speed.
I also tried the:
SEROUT TX, Baud, [Volume, DEC1 vol, EOM] ' send to Emic
to adjust the volume....still no luck.
Try adding a "PAUSE 500" after setting the volume and before trying to have the emic say anything.
Make sure you set the "vol" varible before using the SEROUT command.
Another thing you could try is:
code:
[code]
Main:
GOSUB Check_Busy
vol = 1 ' set pgm vars to defaults
SEROUT Tx, Baud, ["volume=1;"]
PAUSE 500
SEROUT Tx, Baud, [Say, "1 2 3 Testing.", EOM]
END
[code/]
I use a Emic a lot but I generally just leave the volume at 7 and adjust the volume on the speakers (built into the VGA monitor I use with a Prop).
I don't think I've ever tried to dynamically adjust the volume with commands to the Emic.
What is your sound circuit like? Are you using the "AOUT" pin or the "SP-" and "SP+" pins?
I personally don't use Basic Stamps anymore so I'm not very sure about any Stamp code I may offer.
How do I know if my volume is set to 7?
When I read through the pdf it says it defaults to 3 or 4.
If I can make it set to a particular volume, I'm good with that. The dynamic volume was just me testing.
I connected my speaker to the "SP-" and "SP+".
I also tried the "AOUT", but thats just a set volume which I don't think adjust. ( just for amplifier output according to the pdf, if i read correctly).
Thanks for the block explanation. Just to be sure...Do i use [/code] for the beginning of the code and [/code] at the end of the code?
I noticed that adjusting the vol changes the volume. Adjusting the "volume" in the serout cmd does not change.
[/code]
GOSUB Check_Busy
vol = 7 ' set pgm vars to defaults
'SEROUT Tx, Baud, ["volume=1;"]
SEROUT Tx, Baud, [Volume, DEC1 vol, EOM]
PAUSE 500
SEROUT Tx, Baud, [Say, "1 2 3 Testing.", EOM]
END
It appears that the "Volume" in the SEROUT command adjust the volume for the AOUT pin of the EMIC.
Thanks again for all your FAST help. I was trying to figure this thing out for hours!!
Thank you very much.
I assume it's at 7 because I just copied this code from the Emic Propeller demo.
I've just left that part of the code alone ever since I started using an Emic (a couple of years ago).
You use [/code] at the end of your code and [code] at the beginning.
I have a second Emic that I've wanted to use with a robot. (The first Emic is used with my data logging equipment. I don't want to mess with that one.) I'll test out my 2nd Emic with an 8 ohm speaker to make sure I can really adjust the volume. I'll let you know what I find out.
Check my post before yours, I have the right syntax working now. You can refer to that if you use the stamp.
Thanks for all your help.
Thanks for the code block help also.
I have three EMIC which I bought a few years ago. I'm using one for my robot. As an amplifier, I hacked a Lego amplifier which is perfect.
I connected an 8 ohm speaker with it also. The volume adjust work. But if its outside or around additional ambient sound, an amplifier is needed.
If I can help in any way, let me know, I learned through my mistakes...lol.
Let me know how it goes with your 2nd Emic.