In the code you posted above he started the dithering audio engine, I am trying his regular dac engine with the volume turned up to 100. So if your audio pins are P25 and P26 then you would write dac.dacenginestart(25, 26, 100)
EDIT: I have not tested this but if you can't get it to work I will try to play the chimes file on my PropBOE.
It is not working. I tried placing the dac.dacenginestart(25, 26, 100)in various locations and each time I get a different result. I did have to had the dacengine to the OBJ list, otherwise I got an error.
I looked closer at Kye's engine and it uses a SD card to play the wav file from and you have to include a start to the SD card. Perhaps you might post an archive of your code that last worked for us to look at by using the Propeller tool - File/Archive/Project... and attach the zip file it creates here.
NW I made this short demo that just repeat plays the chimes sound using Kye's engine. The pin #'s in the CON section will need to match your setup for the SD card's DO, DI, CLK, and CS pins. Audio's _lpin, _rpin. The pin#'s listed are for the PropBOE. I used an IF NOT statement to make sure the player is finished before trying to play again. Make sure the chimes wav file is put into the folder you download.
OK. I will give this a try some time this week. I have a lot going on right now and think there may be a bit of confusion as to what I am trying to do. I will explain in full detail when I get back to my office.
OK. So the program you wrote works fine. I am able to play chimes.wav using it. However, I need to call that OBJ from my main program which is where the problem lies. I named the new program Testwav. See attached code for what I am trying to do. I was able to get it to work using the ASM wav player OBJ but it is way more than I need and also outputs to Serial terminal which I did not need. I modified that code and was able to get it to work. I am just trying to get a slimmed down version to work.
{{
Pressure Sensor and BarGraph DEMO.spin
Program Date: 1/4/2013
Version: 1.1 Modified version to add the ability to turn a servo on and off at specified pressure.
Description:
This program reads voltage values from the Propeller BOE's ADC and prints the raw value to
the Parallax Serial Terminal program running on your PC. The program also uses a cog to
show a linear representation of the pressure sensed on a 10-segment LED bar graph.
Propeller BOE Wiring Diagram
=== Pressure Sensor Pin Connections ===
+5v

│
┌─────────────┐ │
│ │ │
│ MPX5010 │ │
│ │ │
└─┬─┬─┬─┬─┬─┬─┘ │
Pin 1 │ │ │ x x x │
AD0 ───┘ │ └─────────┘

GND
=== LED Bar Graph Pin Connections ===
P0 ──────┐
P1 ──────┫
P2 ──────┫
P3 ──────┫
P4 ──────┫
P5 ──────┫
P6 ──────┫
P7 ──────┫
P8 ──────┫
P9 ──────┫
220Ω │
│
 GND
}}
CON
'let the compiler know which crystal and PLL settings to use
_xinfreq = 5_000_000
_clkmode = xtal1 + pll16x
_timeStepInMilliseconds = 20
_updateFrequencyInHertz = 50
INPUT = false 'bit pattern is all 0s
OUTPUT = true 'bit pattern is all 1s
PC_BAUD = 115_200 'PC serial terminal's baud rate
ADC_CH0 = 1 << 0
ADC_CH1 = 1 << 1
ADC_CH2 = 1 << 2
ADC_CH3 = 1 << 3
ADC_ALL = ADC_CH0 + ADC_CH1 + ADC_CH2 + ADC_CH3
'LED Bar graph pin definitions
BAR_GRAPH_0 = 0
BAR_GRAPH_1 = 1
BAR_GRAPH_2 = 2
BAR_GRAPH_3 = 3
BAR_GRAPH_4 = 4
BAR_GRAPH_5 = 5
BAR_GRAPH_6 = 6
BAR_GRAPH_7 = 7
BAR_GRAPH_8 = 8
BAR_GRAPH_9 = 9
Servo_Run = 14
OBJ
adc : "PropBOE ADC" 'Requires 1 cog
pc : "Parallax Serial Terminal" 'Requires 1 cog
system : "Propeller Board of Education" 'PropBOE configuration tools
time : "Timing" 'Timekeeping and delay object
servo : "PropBOE Servos" 'Servo control object
dac : "TestWav" ' SD Card/Wave Plaer
VAR
'Globally accessible variables, shared by all cogs
byte pressure
long cogStack[20]
PUB Go | rawReading
'Start other objects
pc.Start(PC_BAUD)
adc.Start(ADC_CH0)
'Launch additional cogs
cognew(RunBarGraph, @cogStack)
repeat
rawReading := adc.In(0) 'Get the reading from channel 0 on the ADC.
pressure := rawReading / 25 'Scale the raw reading to be displayed on the LED bar graph.
'Note that this scaled reading does not correspond with a particular
'unit of pressure such as mmH2O, mmHg, kPa, or PSI. Check the sensor's
'datasheet (MPX5010DP) for the mV/mmH2O conversion value if you want an
'absolute reading in a particular unit of pressure.
'
'The global variable "pressure" is shared between this cog and the cog
'that is controlling the LED bar graph.
'===== Print to the PC serial terminal =====
pc.Home
pc.Str(string("=== Pressure Sensor Test ==="))
pc.NewLine
pc.NewLine
pc.Str(string("Raw ADC Value: "))
pc.dec(rawReading)
pc.Chars(" ", 5)
pc.NewLine
if rawReading >= 150 ' Set rawReading accordingly to turn servo on
servo.Set(14, 200) ' Servo on pin 14 counterclockwise
servo.Set(15, -200)
dira[11] :=1
outa[11] :=1
Chimes ' like this put the call here, although I don't have a way of testing this to see if the call affects the servos running
elseif rawReading <149 ' Set rawReading accordingly to stop servo
servo.stop
servo.stop
dira[11] :=0
outa[11] :=0 ' Stop servo
waitcnt(cnt + clkfreq/20) 'wait for ~1/20th seconds so as not to flood the computer's serial port with data.
PUB Chimes
dac.playwavfile(string("Chimes.wav"))
PUB RunBarGraph | i
dira[BAR_GRAPH_9..BAR_GRAPH_0] := OUTPUT 'set range of pins to output
'(this works in this case because the pins are consecutive)
repeat
outa[BAR_GRAPH_9..BAR_GRAPH_0] := 1<<pressure - 1 'Continually set the value of the scaled pressure to the LED bar graph pins.
'Do a little bitwise manipulation to make the LEDs look nice.
DAT
{{
That did not work. I hear the speaker kick on and then off but the rest of the program does not run correctly and the chimes.wav file does not play. What I am trying to accomplish is when the pressure reaches 150 the 2 servos run, the bar graph runs, an LED lights up and a wav file will play. I have everything but the wav file portion working correctly. I may just go back to the one I know that worked even though it is overkill on the code.
I do not have that sensor but running your code I get the chimes sound constantly repeating. I notice you need to indent one line "dac.playwavfile(string("chimes.wav")) " a couple of spaces. But I get sound indented or not. Are you using a PropBOE board?
OK. I got it figured out. I need a little more power to run everything. I commented out one of my servos and it worked. Once I uncommented the servo it quit working again. Just need to dig up a 12V wall wart and all should be fine. Thanks again for all your help.
All fixed now. I swapped out the 9V wall wart for a 12V one and it works great now. I ended up placing your code after the last BarGraph code and left PUB Chimes. I then placed a call to Chimes in my IF RawReading >= 150. I also modified the code so the Servo and LED start and stop function jumped to PUB Start and PUB Stop. This is working as expected now. Not that anyone will ever need this code but I am attaching it any how just in case someone needs an example to start from. Thanks again for all your help.
Comments
EDIT: I have not tested this but if you can't get it to work I will try to play the chimes file on my PropBOE.
You can also put more than one wav file on your SD card and call those sounds by substituting the name "chimes.wav" in your program to play that wav.
Edit. There must be an issue somewhere as the chimes.wav file should only play once the pressure reaches 150.
12 volts is awful high for that regulator to handle.
Look at the warts carefully.
Every one of them has a rating statement somewhere.
It will say X volts - Y ma
or X volts DC - Y watts
What was the 9 volt current rating?
What is the 12 volt wart's rating?
What you probably want is a 7 volt 2 amp wart.
Not so much voltage to drop across the regulator and plenty of current.