I've been talking to Owen who has a commission for the group which - if successful - could bring in about £500.
He's after 50 modified alarm clocks - basically every time the alarm rings, the alarm clock plays a single, pre-programmed sound. He wants these modifying so that we can store seven different sounds (of varying length) and trigger them either from the clock alarm signal or a pushbutton on the case.
The hardware looks simple enough, and it's really just a case of replacing the sound playing board with one a little more sophisticated.
Bearing in mind that these are cost-sensitive, I was looking at a microcontroller and a DAC hooked up to a speaker through a simple transistor to amplify the signal. Of course I'm going down the PIC route and found these - they have a built-in 8-bit DAC http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf
The mcu is actually not important (other than we want to keep the price right down) but has anyone any experience of playing WAV files without any expensive extra hardware? (no expensive wav shields please!) PIC16F1782 wouldn't require a DAC and costs only £1.49, but there are plenty of other little cheap mcus that could be hooked up to an external DAC if necessary. Remembering that we'd have to make 50 or 60 of these should the design work keeping it simple (and cheap) is top priority! (volunteers for pcb etching and soldering/assembling nearer the time would be helpful)
There's about £500 for the group if we pull this one off.
Any suggestions or ideas would be appreciated.
My only experience of this stuff is the wave shield thing I made for the phonics owl, but I can chip in with some recommendations...
...WAV files are big and the best way to store them cheaply is SD cards.
...If you use micro SD cards you can often get a micro SD adaptor thrown in free. These make excellent sockets.. you can solder onto the pads on the adaptor and simply slot in the micro SD card. The SD cards can be removed easily for saving the WAV files to them from another adaptor attached to a computer.
...standard SD cards support an SPI interface, but not all micro SD cards do... so care needed when buying or it would complicate interfacing to them
...SD cards are 3V logic so to avoid the cost of a level shifting buffer IC it might be good to use a 3v3 MCU (you can use resistor dividers but it seems they might not always protect the SD card). Or you can use a buffer (not too pricey) with a 5V MCU
...You really want the SD card FAT formatted so that WAV files can be dropped onto it easily. This means using a library. I know RiegelFAT was created for PIC and ported to AVR for the Waveshield. I am not sure how hard it is to use directly on PIC as I only used it on AVR but would be a good resource.
...I would not discount AVR out of hand since that has the advantage of existing open source code that can be easily borrowed (waveshield code). Otherwise the code part could be complex (Waveshield needs to stream data from WAV files through the FAT filing system and underlying SPI interface, buffer it in memory and stream it out to a DAC from interrupt service routines, plus managing reading the next block ahead of the current one finishing) Its not a simple bit of code and depending how much you really want to reinvent it you might want to look at the existing waveshield firmware.
...DAC chips (especially 8 bit ones) are cheap – I would not get hung up about getting one built into an MCU. You can even make a DAC out of resistors using a bunch of digital outputs. The Waveshield uses a 12 bit DAC. You might want to validate 8 bits would be good enough sound quality.
...Opamps are the easiest way to drive a speaker (you can avoid need for a dual supply).
...you could probably get the PCBs properly made cheaply (Matt found a really cheap place)
From: Chris Holden Sent: Friday, October 05, 2012 8:55 PM
To: brightonhackerspace@googlegroups.com Subject: [brighton-hacker-space] DAC for audio output
I've been talking to Owen who has a commission for the group which - if successful - could bring in about £500. He's after 50 modified alarm clocks - basically every time the alarm rings, the alarm clock plays a single, pre-programmed sound. He wants these modifying so that we can store seven different sounds (of varying length) and trigger them either from the clock alarm signal or a pushbutton on the case.
The hardware looks simple enough, and it's really just a case of replacing the sound playing board with one a little more sophisticated.
Bearing in mind that these are cost-sensitive, I was looking at a microcontroller and a DAC hooked up to a speaker through a simple transistor to amplify the signal. Of course I'm going down the PIC route and found these - they have a built-in 8-bit DAC http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf
The mcu is actually not important (other than we want to keep the price right down) but has anyone any experience of playing WAV files without any expensive extra hardware? (no expensive wav shields please!) PIC16F1782 wouldn't require a DAC and costs only £1.49, but there are plenty of other little cheap mcus that could be hooked up to an external DAC if necessary. Remembering that we'd have to make 50 or 60 of these should the design work keeping it simple (and cheap) is top priority! (volunteers for pcb etching and soldering/assembling nearer the time would be helpful)
There's about £500 for the group if we pull this one off.
Any suggestions or ideas would be appreciated.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/brightonhackerspace/-/AleaQq5-6fkJ.
For more options, visit https://groups.google.com/groups/opt_out.
The sound player part of the project runs off 2xAA batteries, so we're looking at 2.4v-3v.
I was looking at the low voltage (LF) versions of PICs that could run from 1.8v-3.5v
However, I'm not such a fan of PWM. To me, it made sense to take a single byte (8-bit value) from a byte stream and just send it to a DAC output and run a timer interrupt to do this as many times per second as the wav required (so an 8-bit wav at 11khz sends 11000 bytes to the DAC per second, for example).
I did try using FAT32 some time ago with SD cards and struggled to get them working. I could write and read data serially though, in SPI mode, so I figured some dedicated hardware could just write the wavs serially onto the sd card and skip the whole FAT32 tables thing that caused me headaches last time!
To clarify, the clocks are being supplied by a UK supplier (though I'm trying to convince Owen to go to Alibaba to cut this cost in half) and come with all the hardware for clock/alarm generation, which runs off 2xAA batteries. I'm not against using AVR if it's going to work and come in at a reasonable price. WAVShields would be far too expensive to use - we're trying to keep the sound playback hardware to under �5 max.
> My only experience of this stuff is the wave shield thing I made for > the phonics owl, but I can chip in with some recommendations...
> ...WAV files are big and the best way to store them cheaply is SD cards.
> ...If you use micro SD cards you can often get a micro SD adaptor > thrown in free. These make excellent sockets.. you can solder onto the > pads on the adaptor and simply slot in the micro SD card. The SD cards > can be removed easily for saving the WAV files to them from another > adaptor attached to a computer.
> ...standard SD cards support an SPI interface, but not all micro SD > cards do... so care needed when buying or it would complicate > interfacing to them
> ...SD cards are 3V logic so to avoid the cost of a level shifting > buffer IC it might be good to use a 3v3 MCU (you can use resistor > dividers but it seems they might not always protect the SD card). Or > you can use a buffer (not too pricey) with a 5V MCU
> ...You really want the SD card FAT formatted so that WAV files can be > dropped onto it easily. This means using a library. I know RiegelFAT > was created for PIC and ported to AVR for the Waveshield. I am not > sure how hard it is to use directly on PIC as I only used it on AVR > but would be a good resource.
> ...I would not discount AVR out of hand since that has the advantage > of existing open source code that can be easily borrowed (waveshield > code). Otherwise the code part could be complex (Waveshield needs to > stream data from WAV files through the FAT filing system and > underlying SPI interface, buffer it in memory and stream it out to a > DAC from interrupt service routines, plus managing reading the next > block ahead of the current one finishing) Its not a simple bit of code > and depending how much you really want to reinvent it you might want > to look at the existing waveshield firmware.
> ...DAC chips (especially 8 bit ones) are cheap � I would not get hung > up about getting one built into an MCU. You can even make a DAC out of > resistors using a bunch of digital outputs. The Waveshield uses a 12 > bit DAC. You might want to validate 8 bits would be good enough sound > quality.
> ...Opamps are the easiest way to drive a speaker (you can avoid need > for a dual supply).
> ...you could probably get the PCBs properly made cheaply (Matt found a > really cheap place)
> *From:* Chris Holden <mailto:chris.hol...@multiedge-net.co.uk>
> *Sent:* Friday, October 05, 2012 8:55 PM
> *To:* brightonhackerspace@googlegroups.com > <mailto:brightonhackerspace@googlegroups.com>
> *Subject:* [brighton-hacker-space] DAC for audio output
> I've been talking to Owen who has a commission for the group which - > if successful - could bring in about �500.
> He's after 50 modified alarm clocks - basically every time the alarm > rings, the alarm clock plays a single, pre-programmed sound. He wants > these modifying so that we can store seven different sounds (of > varying length) and trigger them either from the clock alarm signal or > a pushbutton on the case.
> The hardware looks simple enough, and it's really just a case of > replacing the sound playing board with one a little more sophisticated.
> Bearing in mind that these are cost-sensitive, I was looking at a > microcontroller and a DAC hooked up to a speaker through a simple > transistor to amplify the signal. Of course I'm going down the PIC > route and found these - they have a built-in 8-bit DAC > http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf > The mcu is actually not important (other than we want to keep the > price right down) but has anyone any experience of playing WAV files > without any expensive extra hardware? (no expensive wav shields > please!) PIC16F1782 wouldn't require a DAC and costs only �1.49, but > there are plenty of other little cheap mcus that could be hooked up to > an external DAC if necessary. Remembering that we'd have to make 50 or > 60 of these should the design work keeping it simple (and cheap) is > top priority! (volunteers for pcb etching and soldering/assembling > nearer the time would be helpful)
> There's about �500 for the group if we pull this one off.
> Any suggestions or ideas would be appreciated.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> To view this discussion on the web visit > https://groups.google.com/d/msg/brightonhackerspace/-/AleaQq5-6fkJ.
> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
Iv'e made low component count sampler using and ardiuno and an sd card(with a few resistors to level shift), i had some success improving the output bit depth to close to 16bit by using two pwm outputs,1 pwm outputting a 8bit MSB signal and the other a 8 bit difference signal then summing them together (with the difference signal at a gain 1/128) with a few opamps. I just messed around with an ardiuno with 16MHz clock give you a maximum sample rate of ~32kHz but using atmega328 and a 20MHz clock you should get a sample rate of ~40kHz.
On Friday, October 5, 2012 8:55:38 PM UTC+1, Chris Holden wrote:
> I've been talking to Owen who has a commission for the group which - if > successful - could bring in about £500.
> He's after 50 modified alarm clocks - basically every time the alarm > rings, the alarm clock plays a single, pre-programmed sound. He wants these > modifying so that we can store seven different sounds (of varying length) > and trigger them either from the clock alarm signal or a pushbutton on the > case.
> The hardware looks simple enough, and it's really just a case of replacing > the sound playing board with one a little more sophisticated.
> Bearing in mind that these are cost-sensitive, I was looking at a > microcontroller and a DAC hooked up to a speaker through a simple > transistor to amplify the signal. Of course I'm going down the PIC route > and found these - they have a built-in 8-bit DAC > http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf
> The mcu is actually not important (other than we want to keep the price > right down) but has anyone any experience of playing WAV files without any > expensive extra hardware? (no expensive wav shields please!) PIC16F1782 > wouldn't require a DAC and costs only £1.49, but there are plenty of other > little cheap mcus that could be hooked up to an external DAC if > necessary. Remembering that we'd have to make 50 or 60 of these should the > design work keeping it simple (and cheap) is top priority! (volunteers for > pcb etching and soldering/assembling nearer the time would be helpful)
> There's about £500 for the group if we pull this one off.
> Any suggestions or ideas would be appreciated.
This sounds like just the job! 8-bit 22khz should be good enough, if this simplifies things.
(although I'm intrigued by the 2 x pwm channel idea and boosting by 1/128 for the least significant byte to get a 16-bit output)
Do you use the SD card in SPI mode or "proper" FAT16/32?
> Iv'e made low component count sampler using and ardiuno and an sd > card(with a few resistors to level shift), i had some success > improving the output bit depth to close to 16bit by using two pwm > outputs,1 pwm outputting a 8bit MSB signal and the other a 8 > bit difference signal then summing them together (with the difference > signal at a gain 1/128) with a few opamps. I just messed around with > an ardiuno with 16MHz clock give you a maximum sample rate of ~32kHz > but using atmega328 and a 20MHz clock you should get a sample rate of > ~40kHz.
> On Friday, October 5, 2012 8:55:38 PM UTC+1, Chris Holden wrote:
> I've been talking to Owen who has a commission for the group which
> - if successful - could bring in about �500.
> He's after 50 modified alarm clocks - basically every time the
> alarm rings, the alarm clock plays a single, pre-programmed sound.
> He wants these modifying so that we can store seven different
> sounds (of varying length) and trigger them either from the clock
> alarm signal or a pushbutton on the case.
> The hardware looks simple enough, and it's really just a case of
> replacing the sound playing board with one a little more
> sophisticated.
> The mcu is actually not important (other than we want to keep the
> price right down) but has anyone any experience of playing WAV
> files without any expensive extra hardware? (no expensive wav
> shields please!) PIC16F1782 wouldn't require a DAC and costs only
> �1.49, but there are plenty of other little cheap mcus that could
> be hooked up to an external DAC if necessary. Remembering that
> we'd have to make 50 or 60 of these should the design work keeping
> it simple (and cheap) is top priority! (volunteers for pcb etching
> and soldering/assembling nearer the time would be helpful)
> There's about �500 for the group if we pull this one off.
> Any suggestions or ideas would be appreciated.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> To view this discussion on the web visit > https://groups.google.com/d/msg/brightonhackerspace/-/bwz_h_mY5ikJ.
> For more options, visit https://groups.google.com/groups/opt_out.
Just out of interest, did you use hardware PWM or build it in software using timers/interrupts.
Did you use distributed PWM? Apparently this is easier to filter for audio applicaitons.
http://www.datadog.com/pwm_tutorial.pdf
I'm very tempted to ditch PWM and just shove an 8-bit parallel DAC onto an output port.
Then using a timer/interrupt just send a different byte to the port every 1/22050th sec;
that should keep things really simple - at least from a coding point of view - and I wouldn't have to worry about buffer underruns and all that. It'd give 8-bit sound at 22.1khz and there'd be plenty of cpu cycles for doing boring stuff like interfacing with an SD card (although it does add �1.20 per unit to the cost of building the thing!)
All that said, I'm very interested to see how you did it with PWM.
From what I understand, you need to create a PWM frequency tens or hundreds of times faster than the sound frequency you want to play - if I'm going to be changing the duty cycle 22050 times per second, I'd expect the pwm to be much faster than this. What rate was your PWM and how did you get it so fast?
> This sounds like just the job! 8-bit 22khz should be good enough, if > this simplifies things.
> (although I'm intrigued by the 2 x pwm channel idea and boosting by > 1/128 for the least significant byte to get a 16-bit output)
> Do you use the SD card in SPI mode or "proper" FAT16/32?
> On 05/10/2012 23:52, subrunner wrote:
>> Iv'e made low component count sampler using and ardiuno and an sd >> card(with a few resistors to level shift), i had some success >> improving the output bit depth to close to 16bit by using two pwm >> outputs,1 pwm outputting a 8bit MSB signal and the other a 8 >> bit difference signal then summing them together (with the difference >> signal at a gain 1/128) with a few opamps. I just messed around with >> an ardiuno with 16MHz clock give you a maximum sample rate of ~32kHz >> but using atmega328 and a 20MHz clock you should get a sample rate of >> ~40kHz.
>> On Friday, October 5, 2012 8:55:38 PM UTC+1, Chris Holden wrote:
>> I've been talking to Owen who has a commission for the group
>> which - if successful - could bring in about �500.
>> He's after 50 modified alarm clocks - basically every time the
>> alarm rings, the alarm clock plays a single, pre-programmed
>> sound. He wants these modifying so that we can store seven
>> different sounds (of varying length) and trigger them either from
>> the clock alarm signal or a pushbutton on the case.
>> The hardware looks simple enough, and it's really just a case of
>> replacing the sound playing board with one a little more
>> sophisticated.
>> The mcu is actually not important (other than we want to keep the
>> price right down) but has anyone any experience of playing WAV
>> files without any expensive extra hardware? (no expensive wav
>> shields please!) PIC16F1782 wouldn't require a DAC and costs only
>> �1.49, but there are plenty of other little cheap mcus that could
>> be hooked up to an external DAC if necessary. Remembering that
>> we'd have to make 50 or 60 of these should the design work
>> keeping it simple (and cheap) is top priority! (volunteers for
>> pcb etching and soldering/assembling nearer the time would be
>> helpful)
>> There's about �500 for the group if we pull this one off.
>> Any suggestions or ideas would be appreciated.
>> -- >> You received this message because you are subscribed to the Google >> Groups "BuildBrighton - the Brighton Hacker Space" group.
>> To post to this group, send email to >> brightonhackerspace@googlegroups.com.
>> To unsubscribe from this group, send email to >> brightonhackerspace+unsubscribe@googlegroups.com.
>> To view this discussion on the web visit >> https://groups.google.com/d/msg/brightonhackerspace/-/bwz_h_mY5ikJ.
>> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
I've got one of these shields, haven't got around to finding out what
the sound quality is like.
It wouldn't be difficult to make a dedicated version with just the
essentials rather than a whole arduino.
On Sat, Oct 6, 2012 at 5:27 PM, Chris <chris.hol...@multiedge-net.co.uk> wrote:
> Just out of interest, did you use hardware PWM or build it in software using
> timers/interrupts.
> Did you use distributed PWM? Apparently this is easier to filter for audio
> applicaitons.
> http://www.datadog.com/pwm_tutorial.pdf
> I'm very tempted to ditch PWM and just shove an 8-bit parallel DAC onto an
> output port.
> Then using a timer/interrupt just send a different byte to the port every
> 1/22050th sec;
> that should keep things really simple - at least from a coding point of view
> - and I wouldn't have to worry about buffer underruns and all that. It'd
> give 8-bit sound at 22.1khz and there'd be plenty of cpu cycles for doing
> boring stuff like interfacing with an SD card (although it does add £1.20
> per unit to the cost of building the thing!)
> All that said, I'm very interested to see how you did it with PWM.
> From what I understand, you need to create a PWM frequency tens or hundreds
> of times faster than the sound frequency you want to play - if I'm going to
> be changing the duty cycle 22050 times per second, I'd expect the pwm to be
> much faster than this. What rate was your PWM and how did you get it so
> fast?
> On 06/10/2012 00:01, Chris wrote:
> This sounds like just the job! 8-bit 22khz should be good enough, if this
> simplifies things.
> (although I'm intrigued by the 2 x pwm channel idea and boosting by 1/128
> for the least significant byte to get a 16-bit output)
> Do you use the SD card in SPI mode or "proper" FAT16/32?
> On 05/10/2012 23:52, subrunner wrote:
> Iv'e made low component count sampler using and ardiuno and an sd card(with
> a few resistors to level shift), i had some success improving the output bit
> depth to close to 16bit by using two pwm outputs,1 pwm outputting a 8bit
> MSB signal and the other a 8 bit difference signal then summing them
> together (with the difference signal at a gain 1/128) with a few opamps. I
> just messed around with an ardiuno with 16MHz clock give you a maximum
> sample rate of ~32kHz but using atmega328 and a 20MHz clock you should get a
> sample rate of ~40kHz.
> On Friday, October 5, 2012 8:55:38 PM UTC+1, Chris Holden wrote:
>> I've been talking to Owen who has a commission for the group which - if
>> successful - could bring in about £500.
>> He's after 50 modified alarm clocks - basically every time the alarm
>> rings, the alarm clock plays a single, pre-programmed sound. He wants these
>> modifying so that we can store seven different sounds (of varying length)
>> and trigger them either from the clock alarm signal or a pushbutton on the
>> case.
>> The hardware looks simple enough, and it's really just a case of replacing
>> the sound playing board with one a little more sophisticated.
>> Bearing in mind that these are cost-sensitive, I was looking at a
>> microcontroller and a DAC hooked up to a speaker through a simple transistor
>> to amplify the signal. Of course I'm going down the PIC route and found
>> these - they have a built-in 8-bit DAC
>> http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf
>> The mcu is actually not important (other than we want to keep the price
>> right down) but has anyone any experience of playing WAV files without any
>> expensive extra hardware? (no expensive wav shields please!) PIC16F1782
>> wouldn't require a DAC and costs only £1.49, but there are plenty of other
>> little cheap mcus that could be hooked up to an external DAC if necessary.
>> Remembering that we'd have to make 50 or 60 of these should the design work
>> keeping it simple (and cheap) is top priority! (volunteers for pcb etching
>> and soldering/assembling nearer the time would be helpful)
>> There's about £500 for the group if we pull this one off.
>> Any suggestions or ideas would be appreciated.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/brightonhackerspace/-/bwz_h_mY5ikJ.
> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
On Friday, 5 October 2012 20:55:38 UTC+1, Chris Holden wrote:
> I've been talking to Owen who has a commission for the group which - if > successful - could bring in about £500.
> He's after 50 modified alarm clocks - basically every time the alarm > rings, the alarm clock plays a single, pre-programmed sound. He wants these > modifying so that we can store seven different sounds (of varying length) > and trigger them either from the clock alarm signal or a pushbutton on the > case.
> The hardware looks simple enough, and it's really just a case of replacing > the sound playing board with one a little more sophisticated.
> Bearing in mind that these are cost-sensitive, I was looking at a > microcontroller and a DAC hooked up to a speaker through a simple > transistor to amplify the signal. Of course I'm going down the PIC route > and found these - they have a built-in 8-bit DAC > http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf
> The mcu is actually not important (other than we want to keep the price > right down) but has anyone any experience of playing WAV files without any > expensive extra hardware? (no expensive wav shields please!) PIC16F1782 > wouldn't require a DAC and costs only £1.49, but there are plenty of other > little cheap mcus that could be hooked up to an external DAC if > necessary. Remembering that we'd have to make 50 or 60 of these should the > design work keeping it simple (and cheap) is top priority! (volunteers for > pcb etching and soldering/assembling nearer the time would be helpful)
> There's about £500 for the group if we pull this one off.
> Any suggestions or ideas would be appreciated.
The SD cards would come in very handy!
Even the smaller sized ones should be suitable since we're only working with relatively small samples (I hope!)
I deliberately avoided PWM because
a) it uses a lot of clock cycles
b) the code gets quite complicated, getting the timings right for the PWM as well as changing the rate of PWM to match the sampling rate and reading and buffering the data off the SD card in a timely manner.
c) to get a decent output I'd need to run using a high speed crystal - which in turn chews the battery; for example, for about 32khz quality samples, I'd need to use a 20Mhz crystal on a PIC (I like PICs for their speedy low-level register access).
By using a DAC, I can use a cheapo 99p 16F628A and its internal oscillator at 4Mhz (1/5th speed =~ 1/4 power consumption)
I'd love to use PWM for audio in a future project, just as an exercise in doing it - but this is against a deadline, so DACs keep the code simpler, as well as provide the extra benefits above (plus if DACs work, I've got an audio platform for other projects with plenty of cpu cycles left to integrate with other peripherals).
> On Friday, 5 October 2012 20:55:38 UTC+1, Chris Holden wrote:
> I've been talking to Owen who has a commission for the group which
> - if successful - could bring in about �500.
> He's after 50 modified alarm clocks - basically every time the
> alarm rings, the alarm clock plays a single, pre-programmed sound.
> He wants these modifying so that we can store seven different
> sounds (of varying length) and trigger them either from the clock
> alarm signal or a pushbutton on the case.
> The hardware looks simple enough, and it's really just a case of
> replacing the sound playing board with one a little more
> sophisticated.
> The mcu is actually not important (other than we want to keep the
> price right down) but has anyone any experience of playing WAV
> files without any expensive extra hardware? (no expensive wav
> shields please!) PIC16F1782 wouldn't require a DAC and costs only
> �1.49, but there are plenty of other little cheap mcus that could
> be hooked up to an external DAC if necessary. Remembering that
> we'd have to make 50 or 60 of these should the design work keeping
> it simple (and cheap) is top priority! (volunteers for pcb etching
> and soldering/assembling nearer the time would be helpful)
> There's about �500 for the group if we pull this one off.
> Any suggestions or ideas would be appreciated.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> To view this discussion on the web visit > https://groups.google.com/d/msg/brightonhackerspace/-/LTiK9CZMkLgJ.
> For more options, visit https://groups.google.com/groups/opt_out.
I'll be using PWM for audio soon for a little synth project I'm working on.
If all goes to plan it'll use a slightly hacked Zombie Badge board, with
the RGB LED replaced with an audio output.
On Tue, Oct 9, 2012 at 11:10 PM, Chris <chris.hol...@multiedge-net.co.uk>wrote:
> The SD cards would come in very handy!
> Even the smaller sized ones should be suitable since we're only working
> with relatively small samples (I hope!)
> I deliberately avoided PWM because
> a) it uses a lot of clock cycles
> b) the code gets quite complicated, getting the timings right for the PWM
> as well as changing the rate of PWM to match the sampling rate and reading
> and buffering the data off the SD card in a timely manner.
> c) to get a decent output I'd need to run using a high speed crystal -
> which in turn chews the battery; for example, for about 32khz quality
> samples, I'd need to use a 20Mhz crystal on a PIC (I like PICs for their
> speedy low-level register access).
> By using a DAC, I can use a cheapo 99p 16F628A and its internal oscillator
> at 4Mhz (1/5th speed =~ 1/4 power consumption)
> I'd love to use PWM for audio in a future project, just as an exercise in
> doing it - but this is against a deadline, so DACs keep the code simpler,
> as well as provide the extra benefits above (plus if DACs work, I've got an
> audio platform for other projects with plenty of cpu cycles left to
> integrate with other peripherals).
> On 09/10/2012 22:55, Samuel Wright wrote:
> Hi
> There is a pile of (full sized) SD card somewhere on the donation shelves.
> They are 32 and 128Mbyte. I have some more.
> On Friday, 5 October 2012 20:55:38 UTC+1, Chris Holden wrote:
>> I've been talking to Owen who has a commission for the group which - if
>> successful - could bring in about £500.
>> He's after 50 modified alarm clocks - basically every time the alarm
>> rings, the alarm clock plays a single, pre-programmed sound. He wants these
>> modifying so that we can store seven different sounds (of varying length)
>> and trigger them either from the clock alarm signal or a pushbutton on the
>> case.
>> The hardware looks simple enough, and it's really just a case of
>> replacing the sound playing board with one a little more sophisticated.
>> The mcu is actually not important (other than we want to keep the price
>> right down) but has anyone any experience of playing WAV files without any
>> expensive extra hardware? (no expensive wav shields please!) PIC16F1782
>> wouldn't require a DAC and costs only £1.49, but there are plenty of other
>> little cheap mcus that could be hooked up to an external DAC if
>> necessary. Remembering that we'd have to make 50 or 60 of these should the
>> design work keeping it simple (and cheap) is top priority! (volunteers for
>> pcb etching and soldering/assembling nearer the time would be helpful)
>> There's about £500 for the group if we pull this one off.
>> Any suggestions or ideas would be appreciated.
>> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/brightonhackerspace/-/LTiK9CZMkLgJ.
> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
That's interesting. I don't know much about PWM - I have been tinkering with a netduino that can generate PWM output but the mechanics of the process seem to be wrapped up in the provided environment.
As you probably know, Clive Sinclair used PWM for cheap audio amps in the last century (Class D).
One thing - do you need high quality audio for an alarm clock? Telephones (for example) apparently have a bandwidth of 3 KHZ. Might not be necessary to go to high frequency (even if the top frequency is more than 3 KHZ) that should also help save clock cycles, Depends on user requirements however.
Samuel
On Friday, 5 October 2012 20:55:38 UTC+1, Chris Holden wrote:
> I've been talking to Owen who has a commission for the group which - if > successful - could bring in about £500.
> He's after 50 modified alarm clocks - basically every time the alarm > rings, the alarm clock plays a single, pre-programmed sound. He wants these > modifying so that we can store seven different sounds (of varying length) > and trigger them either from the clock alarm signal or a pushbutton on the > case.
> The hardware looks simple enough, and it's really just a case of replacing > the sound playing board with one a little more sophisticated.
> Bearing in mind that these are cost-sensitive, I was looking at a > microcontroller and a DAC hooked up to a speaker through a simple > transistor to amplify the signal. Of course I'm going down the PIC route > and found these - they have a built-in 8-bit DAC > http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf
> The mcu is actually not important (other than we want to keep the price > right down) but has anyone any experience of playing WAV files without any > expensive extra hardware? (no expensive wav shields please!) PIC16F1782 > wouldn't require a DAC and costs only £1.49, but there are plenty of other > little cheap mcus that could be hooked up to an external DAC if > necessary. Remembering that we'd have to make 50 or 60 of these should the > design work keeping it simple (and cheap) is top priority! (volunteers for > pcb etching and soldering/assembling nearer the time would be helpful)
> There's about £500 for the group if we pull this one off.
> Any suggestions or ideas would be appreciated.
- If you use hardware PWM then it won’t use extra clock cycles. Also I don’t think it needs a particularly fast system clock – the link Samuel sent shows someone generating audio with a 62kHz PWM clock.
- Setting a PWM duty at each sample should be no more complex or slow than writing an external parallel load DAC (it will be significantly faster than using a serial load DAC)
- Certain parts of your code will need to be there irrelevant of whether you use a DAC or PWM for output. In particular you need to buffer the incoming data from the SD card, and this needs an MCU with a decent amount of RAM for the buffers.
When I worked with the Waveshield code for phonics owl the Atmega168 (1k RAM) was not enough for decent buffering and an Atmega328 (2k RAM) was needed. I think that ran at 22kHz sample rate with 8 bit samples so obviously a lower sample rate can let you get away with smaller buffers but I think the PIC you point out has less than 256 bytes of RAM.
I only have experience of the waveshield way of doing things though... perhaps there are alternative and simpler ways to stream the data that can avoid buffering, but I don’t think the choice of PWM vs parallel load DAC for output would be relevant to that.
- I reckon you can only benefit from a faster clock – MCUs use tiny amounts of current compared to things like 7 segment LEDs.
For less than 99p you can get PICs with 32MHz internal clocks (you can prescale them down if you want) and more memory (this week I got some pic16f1824’s with 1k RAM and 32Mhz internal clock and lots of other built-in goodies for 91p from Farnell). Even with 1k I’d still experiment to make sure that is enough RAM for your application.
- I think a DAC could let you go to higher bit resolution (e.g. 12 bit sampling) to give you better sound quality than PWM, but at greater component cost and count.
You could make a parallel DAC from resistors but I don’t think it would give better results than PWM (resistor tolerances etc). Also if you are only using 8 bit samples I’m not sure it would make an audible difference. I would be tempted to keep it simple and use PWM, especially as you pointed out some sample code before that already does the job on an 8 pin PIC with just a couple of caps and transistors.
- Finally, I use PICs and AVRs equally. Direct I/O port and peripheral register access on an AVR works exactly the same as a PIC (even in the Arduino environment - if you avoid the hellishly slow digitalWrite function) so I would not let that sway your decision. I know you’re a PIC fan but remember there is a bunch of open source AVR code (Waveshield) you could steal if you used an Atmega32...
Hope that’s helpful
Jason
From: Chris Sent: Tuesday, October 09, 2012 11:10 PM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] Re: DAC for audio output
The SD cards would come in very handy!
Even the smaller sized ones should be suitable since we're only working with relatively small samples (I hope!)
I deliberately avoided PWM because
a) it uses a lot of clock cycles
b) the code gets quite complicated, getting the timings right for the PWM as well as changing the rate of PWM to match the sampling rate and reading and buffering the data off the SD card in a timely manner.
c) to get a decent output I'd need to run using a high speed crystal - which in turn chews the battery; for example, for about 32khz quality samples, I'd need to use a 20Mhz crystal on a PIC (I like PICs for their speedy low-level register access).
By using a DAC, I can use a cheapo 99p 16F628A and its internal oscillator at 4Mhz (1/5th speed =~ 1/4 power consumption)
I'd love to use PWM for audio in a future project, just as an exercise in doing it - but this is against a deadline, so DACs keep the code simpler, as well as provide the extra benefits above (plus if DACs work, I've got an audio platform for other projects with plenty of cpu cycles left to integrate with other peripherals).
On 09/10/2012 22:55, Samuel Wright wrote:
Hi There is a pile of (full sized) SD card somewhere on the donation shelves. They are 32 and 128Mbyte. I have some more.
On Friday, 5 October 2012 20:55:38 UTC+1, Chris Holden wrote: I've been talking to Owen who has a commission for the group which - if successful - could bring in about £500. He's after 50 modified alarm clocks - basically every time the alarm rings, the alarm clock plays a single, pre-programmed sound. He wants these modifying so that we can store seven different sounds (of varying length) and trigger them either from the clock alarm signal or a pushbutton on the case.
The hardware looks simple enough, and it's really just a case of replacing the sound playing board with one a little more sophisticated.
Bearing in mind that these are cost-sensitive, I was looking at a microcontroller and a DAC hooked up to a speaker through a simple transistor to amplify the signal. Of course I'm going down the PIC route and found these - they have a built-in 8-bit DAC http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf
The mcu is actually not important (other than we want to keep the price right down) but has anyone any experience of playing WAV files without any expensive extra hardware? (no expensive wav shields please!) PIC16F1782 wouldn't require a DAC and costs only £1.49, but there are plenty of other little cheap mcus that could be hooked up to an external DAC if necessary. Remembering that we'd have to make 50 or 60 of these should the design work keeping it simple (and cheap) is top priority! (volunteers for pcb etching and soldering/assembling nearer the time would be helpful)
There's about £500 for the group if we pull this one off.
Any suggestions or ideas would be appreciated.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/brightonhackerspace/-/LTiK9CZMkLgJ.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Errata: the waveshield uses 16 bit WAV files – and truncates them to a 12 bit DAC. So if you can use 8 bit samples you can probably get away buffering inside 1K....
From: Jason Hotchkiss Sent: Wednesday, October 10, 2012 9:27 AM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] Re: DAC for audio output
Hey Chris
Just to chip in my 2p’s worth..
- If you use hardware PWM then it won’t use extra clock cycles. Also I don’t think it needs a particularly fast system clock – the link Samuel sent shows someone generating audio with a 62kHz PWM clock.
- Setting a PWM duty at each sample should be no more complex or slow than writing an external parallel load DAC (it will be significantly faster than using a serial load DAC)
- Certain parts of your code will need to be there irrelevant of whether you use a DAC or PWM for output. In particular you need to buffer the incoming data from the SD card, and this needs an MCU with a decent amount of RAM for the buffers.
When I worked with the Waveshield code for phonics owl the Atmega168 (1k RAM) was not enough for decent buffering and an Atmega328 (2k RAM) was needed. I think that ran at 22kHz sample rate with 8 bit samples so obviously a lower sample rate can let you get away with smaller buffers but I think the PIC you point out has less than 256 bytes of RAM.
I only have experience of the waveshield way of doing things though... perhaps there are alternative and simpler ways to stream the data that can avoid buffering, but I don’t think the choice of PWM vs parallel load DAC for output would be relevant to that.
- I reckon you can only benefit from a faster clock – MCUs use tiny amounts of current compared to things like 7 segment LEDs.
For less than 99p you can get PICs with 32MHz internal clocks (you can prescale them down if you want) and more memory (this week I got some pic16f1824’s with 1k RAM and 32Mhz internal clock and lots of other built-in goodies for 91p from Farnell). Even with 1k I’d still experiment to make sure that is enough RAM for your application.
- I think a DAC could let you go to higher bit resolution (e.g. 12 bit sampling) to give you better sound quality than PWM, but at greater component cost and count.
You could make a parallel DAC from resistors but I don’t think it would give better results than PWM (resistor tolerances etc). Also if you are only using 8 bit samples I’m not sure it would make an audible difference. I would be tempted to keep it simple and use PWM, especially as you pointed out some sample code before that already does the job on an 8 pin PIC with just a couple of caps and transistors.
- Finally, I use PICs and AVRs equally. Direct I/O port and peripheral register access on an AVR works exactly the same as a PIC (even in the Arduino environment - if you avoid the hellishly slow digitalWrite function) so I would not let that sway your decision. I know you’re a PIC fan but remember there is a bunch of open source AVR code (Waveshield) you could steal if you used an Atmega32...
Hope that’s helpful
Jason
From: Chris Sent: Tuesday, October 09, 2012 11:10 PM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] Re: DAC for audio output
The SD cards would come in very handy!
Even the smaller sized ones should be suitable since we're only working with relatively small samples (I hope!)
I deliberately avoided PWM because
a) it uses a lot of clock cycles
b) the code gets quite complicated, getting the timings right for the PWM as well as changing the rate of PWM to match the sampling rate and reading and buffering the data off the SD card in a timely manner.
c) to get a decent output I'd need to run using a high speed crystal - which in turn chews the battery; for example, for about 32khz quality samples, I'd need to use a 20Mhz crystal on a PIC (I like PICs for their speedy low-level register access).
By using a DAC, I can use a cheapo 99p 16F628A and its internal oscillator at 4Mhz (1/5th speed =~ 1/4 power consumption)
I'd love to use PWM for audio in a future project, just as an exercise in doing it - but this is against a deadline, so DACs keep the code simpler, as well as provide the extra benefits above (plus if DACs work, I've got an audio platform for other projects with plenty of cpu cycles left to integrate with other peripherals).
On 09/10/2012 22:55, Samuel Wright wrote:
Hi There is a pile of (full sized) SD card somewhere on the donation shelves. They are 32 and 128Mbyte. I have some more.
On Friday, 5 October 2012 20:55:38 UTC+1, Chris Holden wrote: I've been talking to Owen who has a commission for the group which - if successful - could bring in about £500. He's after 50 modified alarm clocks - basically every time the alarm rings, the alarm clock plays a single, pre-programmed sound. He wants these modifying so that we can store seven different sounds (of varying length) and trigger them either from the clock alarm signal or a pushbutton on the case.
The hardware looks simple enough, and it's really just a case of replacing the sound playing board with one a little more sophisticated.
Bearing in mind that these are cost-sensitive, I was looking at a microcontroller and a DAC hooked up to a speaker through a simple transistor to amplify the signal. Of course I'm going down the PIC route and found these - they have a built-in 8-bit DAC http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf
The mcu is actually not important (other than we want to keep the price right down) but has anyone any experience of playing WAV files without any expensive extra hardware? (no expensive wav shields please!) PIC16F1782 wouldn't require a DAC and costs only £1.49, but there are plenty of other little cheap mcus that could be hooked up to an external DAC if necessary. Remembering that we'd have to make 50 or 60 of these should the design work keeping it simple (and cheap) is top priority! (volunteers for pcb etching and soldering/assembling nearer the time would be helpful)
There's about £500 for the group if we pull this one off.
Any suggestions or ideas would be appreciated.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/brightonhackerspace/-/LTiK9CZMkLgJ.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Sorry to keep spamming your inbox but I thought of something else... I think with a DAC you need an external op-amp to drive a speaker, but the PWM project we looked at the other day could drive the speaker with just a transistor and a cap. Maybe another cost consideration to make PWM more attractive From: Jason Hotchkiss Sent: Wednesday, October 10, 2012 9:31 AM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] Re: DAC for audio output
Errata: the waveshield uses 16 bit WAV files – and truncates them to a 12 bit DAC. So if you can use 8 bit samples you can probably get away buffering inside 1K....
From: Jason Hotchkiss Sent: Wednesday, October 10, 2012 9:27 AM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] Re: DAC for audio output
Hey Chris
Just to chip in my 2p’s worth..
- If you use hardware PWM then it won’t use extra clock cycles. Also I don’t think it needs a particularly fast system clock – the link Samuel sent shows someone generating audio with a 62kHz PWM clock.
- Setting a PWM duty at each sample should be no more complex or slow than writing an external parallel load DAC (it will be significantly faster than using a serial load DAC)
- Certain parts of your code will need to be there irrelevant of whether you use a DAC or PWM for output. In particular you need to buffer the incoming data from the SD card, and this needs an MCU with a decent amount of RAM for the buffers.
When I worked with the Waveshield code for phonics owl the Atmega168 (1k RAM) was not enough for decent buffering and an Atmega328 (2k RAM) was needed. I think that ran at 22kHz sample rate with 8 bit samples so obviously a lower sample rate can let you get away with smaller buffers but I think the PIC you point out has less than 256 bytes of RAM.
I only have experience of the waveshield way of doing things though... perhaps there are alternative and simpler ways to stream the data that can avoid buffering, but I don’t think the choice of PWM vs parallel load DAC for output would be relevant to that.
- I reckon you can only benefit from a faster clock – MCUs use tiny amounts of current compared to things like 7 segment LEDs.
For less than 99p you can get PICs with 32MHz internal clocks (you can prescale them down if you want) and more memory (this week I got some pic16f1824’s with 1k RAM and 32Mhz internal clock and lots of other built-in goodies for 91p from Farnell). Even with 1k I’d still experiment to make sure that is enough RAM for your application.
- I think a DAC could let you go to higher bit resolution (e.g. 12 bit sampling) to give you better sound quality than PWM, but at greater component cost and count.
You could make a parallel DAC from resistors but I don’t think it would give better results than PWM (resistor tolerances etc). Also if you are only using 8 bit samples I’m not sure it would make an audible difference. I would be tempted to keep it simple and use PWM, especially as you pointed out some sample code before that already does the job on an 8 pin PIC with just a couple of caps and transistors.
- Finally, I use PICs and AVRs equally. Direct I/O port and peripheral register access on an AVR works exactly the same as a PIC (even in the Arduino environment - if you avoid the hellishly slow digitalWrite function) so I would not let that sway your decision. I know you’re a PIC fan but remember there is a bunch of open source AVR code (Waveshield) you could steal if you used an Atmega32...
Hope that’s helpful
Jason
From: Chris Sent: Tuesday, October 09, 2012 11:10 PM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] Re: DAC for audio output
The SD cards would come in very handy!
Even the smaller sized ones should be suitable since we're only working with relatively small samples (I hope!)
I deliberately avoided PWM because
a) it uses a lot of clock cycles
b) the code gets quite complicated, getting the timings right for the PWM as well as changing the rate of PWM to match the sampling rate and reading and buffering the data off the SD card in a timely manner.
c) to get a decent output I'd need to run using a high speed crystal - which in turn chews the battery; for example, for about 32khz quality samples, I'd need to use a 20Mhz crystal on a PIC (I like PICs for their speedy low-level register access).
By using a DAC, I can use a cheapo 99p 16F628A and its internal oscillator at 4Mhz (1/5th speed =~ 1/4 power consumption)
I'd love to use PWM for audio in a future project, just as an exercise in doing it - but this is against a deadline, so DACs keep the code simpler, as well as provide the extra benefits above (plus if DACs work, I've got an audio platform for other projects with plenty of cpu cycles left to integrate with other peripherals).
On 09/10/2012 22:55, Samuel Wright wrote:
Hi There is a pile of (full sized) SD card somewhere on the donation shelves. They are 32 and 128Mbyte. I have some more.
On Friday, 5 October 2012 20:55:38 UTC+1, Chris Holden wrote: I've been talking to Owen who has a commission for the group which - if successful - could bring in about £500. He's after 50 modified alarm clocks - basically every time the alarm rings, the alarm clock plays a single, pre-programmed sound. He wants these modifying so that we can store seven different sounds (of varying length) and trigger them either from the clock alarm signal or a pushbutton on the case.
The hardware looks simple enough, and it's really just a case of replacing the sound playing board with one a little more sophisticated.
Bearing in mind that these are cost-sensitive, I was looking at a microcontroller and a DAC hooked up to a speaker through a simple transistor to amplify the signal. Of course I'm going down the PIC route and found these - they have a built-in 8-bit DAC http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf
The mcu is actually not important (other than we want to keep the price right down) but has anyone any experience of playing WAV files without any expensive extra hardware? (no expensive wav shields please!) PIC16F1782 wouldn't require a DAC and costs only £1.49, but there are plenty of other little cheap mcus that could be hooked up to an external DAC if necessary. Remembering that we'd have to make 50 or 60 of these should the design work keeping it simple (and cheap) is top priority! (volunteers for pcb etching and soldering/assembling nearer the time would be helpful)
There's about £500 for the group if we pull this one off.
Any suggestions or ideas would be appreciated.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/brightonhackerspace/-/LTiK9CZMkLgJ.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Funnily enough, I got some DACs in the post yesterday and just to try them out, sent random SPI values to generate a "moving" voltage on the output pin and the volume wasn't brilliant. I may have done it wrong, but I'm thinking that maybe PWM isn't such a pain after all, given the simpler hardware/assembly requirements - after all, we're going to need to make 50-60 of these things, including etching boards and soldering components in place, so a lower component count does sound appealing!
I'm checking out those PICs you mentioned.
To be honest, I've not looked at the full range of MCUs for quite some time - I just tend to stick to what I know; I need to get familiar with them all again. A software selectable 32Mhz int oscillator looks great - run at 32khz for "sleep" mode then ramp up to full speed to play a sample before dropping back down to snooze.
They have cap sensing inputs too? I think I've just got a new favourite PIC ;-)
> Sorry to keep spamming your inbox but I thought of something else... I > think with a DAC you need an external op-amp to drive a speaker, but > the PWM project we looked at the other day could drive the speaker > with just a transistor and a cap. Maybe another cost consideration to > make PWM more attractive Smile
> *From:* Jason Hotchkiss <mailto:jason_hotchk...@hotmail.com>
> *Sent:* Wednesday, October 10, 2012 9:31 AM
> *To:* brightonhackerspace@googlegroups.com > <mailto:brightonhackerspace@googlegroups.com>
> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
> Errata: the waveshield uses 16 bit WAV files � and truncates them to a > 12 bit DAC. So if you can use 8 bit samples you can probably get away > buffering inside 1K....
> *From:* Jason Hotchkiss <mailto:jason_hotchk...@hotmail.com>
> *Sent:* Wednesday, October 10, 2012 9:27 AM
> *To:* brightonhackerspace@googlegroups.com > <mailto:brightonhackerspace@googlegroups.com>
> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
> Hey Chris
> Just to chip in my 2p�s worth..
> - If you use hardware PWM then it won�t use extra clock cycles. Also I > don�t think it needs a particularly fast system clock � the link > Samuel sent shows someone generating audio with a 62kHz PWM clock.
> - Setting a PWM duty at each sample should be no more complex or slow > than writing an external parallel load DAC (it will be significantly > faster than using a serial load DAC)
> - Certain parts of your code will need to be there irrelevant of > whether you use a DAC or PWM for output. In particular you need to > buffer the incoming data from the SD card, and this needs an MCU with > a decent amount of RAM for the buffers.
> When I worked with the Waveshield code for phonics owl the Atmega168 > (1k RAM) was not enough for decent buffering and an Atmega328 (2k RAM) > was needed. I think that ran at 22kHz sample rate with 8 bit samples > so obviously a lower sample rate can let you get away with smaller > buffers but I think the PIC you point out has less than 256 bytes of RAM.
> I only have experience of the waveshield way of doing things though... > perhaps there are alternative and simpler ways to stream the data that > can avoid buffering, but I don�t think the choice of PWM vs parallel > load DAC for output would be relevant to that.
> - I reckon you can only benefit from a faster clock � MCUs use tiny > amounts of current compared to things like 7 segment LEDs.
> For less than 99p you can get PICs with 32MHz internal clocks (you can > prescale them down if you want) and more memory (this week I got some > pic16f1824�s with 1k RAM and 32Mhz internal clock and lots of other > built-in goodies for 91p from Farnell). Even with 1k I�d still > experiment to make sure that is enough RAM for your application.
> - I think a DAC could let you go to higher bit resolution (e.g. 12 bit > sampling) to give you better sound quality than PWM, but at greater > component cost and count.
> You could make a parallel DAC from resistors but I don�t think it > would give better results than PWM (resistor tolerances etc). Also if > you are only using 8 bit samples I�m not sure it would make an audible > difference. I would be tempted to keep it simple and use PWM, > especially as you pointed out some sample code before that already > does the job on an 8 pin PIC with just a couple of caps and transistors.
> - Finally, I use PICs and AVRs equally. Direct I/O port and peripheral > register access on an AVR works exactly the same as a PIC (even in the > Arduino environment - if you avoid the hellishly slow digitalWrite > function) so I would not let that sway your decision. I know you�re a > PIC fan but remember there is a bunch of open source AVR code > (Waveshield) you could steal if you used an Atmega32...
> Hope that�s helpful
> Jason
> *From:* Chris <mailto:chris.hol...@multiedge-net.co.uk>
> *Sent:* Tuesday, October 09, 2012 11:10 PM
> *To:* brightonhackerspace@googlegroups.com > <mailto:brightonhackerspace@googlegroups.com>
> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
> The SD cards would come in very handy!
> Even the smaller sized ones should be suitable since we're only > working with relatively small samples (I hope!)
> I deliberately avoided PWM because
> a) it uses a lot of clock cycles
> b) the code gets quite complicated, getting the timings right for the > PWM as well as changing the rate of PWM to match the sampling rate and > reading and buffering the data off the SD card in a timely manner.
> c) to get a decent output I'd need to run using a high speed crystal - > which in turn chews the battery; for example, for about 32khz quality > samples, I'd need to use a 20Mhz crystal on a PIC (I like PICs for > their speedy low-level register access).
> By using a DAC, I can use a cheapo 99p 16F628A and its internal > oscillator at 4Mhz (1/5th speed =~ 1/4 power consumption)
> I'd love to use PWM for audio in a future project, just as an exercise > in doing it - but this is against a deadline, so DACs keep the code > simpler, as well as provide the extra benefits above (plus if DACs > work, I've got an audio platform for other projects with plenty of cpu > cycles left to integrate with other peripherals).
>> On Friday, 5 October 2012 20:55:38 UTC+1, Chris Holden wrote:
>> I've been talking to Owen who has a commission for the group
>> which - if successful - could bring in about �500.
>> He's after 50 modified alarm clocks - basically every time the
>> alarm rings, the alarm clock plays a single, pre-programmed
>> sound. He wants these modifying so that we can store seven
>> different sounds (of varying length) and trigger them either from
>> the clock alarm signal or a pushbutton on the case.
>> The hardware looks simple enough, and it's really just a case of
>> replacing the sound playing board with one a little more
>> sophisticated.
>> Bearing in mind that these are cost-sensitive, I was looking at a
>> microcontroller and a DAC hooked up to a speaker through a simple
>> transistor to amplify the signal. Of course I'm going down the
>> PIC route and found these - they have a built-in 8-bit DAC
>> http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf >> <http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf>
>> The mcu is actually not important (other than we want to keep the
>> price right down) but has anyone any experience of playing WAV
>> files without any expensive extra hardware? (no expensive wav
>> shields please!) PIC16F1782 wouldn't require a DAC and costs only
>> �1.49, but there are plenty of other little cheap mcus that could
>> be hooked up to an external DAC if necessary. Remembering that
>> we'd have to make 50 or 60 of these should the design work
>> keeping it simple (and cheap) is top priority! (volunteers for
>> pcb etching and soldering/assembling nearer the time would be
>> helpful)
>> There's about �500 for the group if we pull this one off.
>> Any suggestions or ideas would be appreciated.
>> -- >> You received this message because you are subscribed to the Google >> Groups "BuildBrighton - the Brighton Hacker Space" group.
>> To post to this group, send email to >> brightonhackerspace@googlegroups.com.
>> To unsubscribe from this group, send email to >> brightonhackerspace+unsubscribe@googlegroups.com.
>> To view this discussion on the web visit >> https://groups.google.com/d/msg/brightonhackerspace/-/LTiK9CZMkLgJ.
>> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this
Just stumbled across something that looks almost perfect for your project
Chris. I was doing some research for my own ATTINY based audio synth stuff,
and someone's written an SD card based audio player for the tiny85:
http://elm-chan.org/works/sd8p/report.html Check out the schematic! it's, well, tiny!
http://elm-chan.org/works/sd8p/sd8p_mo.png
On Wed, Oct 10, 2012 at 10:41 AM, Chris <chris.hol...@multiedge-net.co.uk>wrote:
> Funnily enough, I got some DACs in the post yesterday and just to try them
> out, sent random SPI values to generate a "moving" voltage on the output
> pin and the volume wasn't brilliant. I may have done it wrong, but I'm
> thinking that maybe PWM isn't such a pain after all, given the simpler
> hardware/assembly requirements - after all, we're going to need to make
> 50-60 of these things, including etching boards and soldering components in
> place, so a lower component count does sound appealing!
> I'm checking out those PICs you mentioned.
> To be honest, I've not looked at the full range of MCUs for quite some
> time - I just tend to stick to what I know; I need to get familiar with
> them all again. A software selectable 32Mhz int oscillator looks great -
> run at 32khz for "sleep" mode then ramp up to full speed to play a sample
> before dropping back down to snooze.
> They have cap sensing inputs too? I think I've just got a new favourite
> PIC ;-)
> On 10/10/2012 09:39, Jason Hotchkiss wrote:
> Sorry to keep spamming your inbox but I thought of something else... I
> think with a DAC you need an external op-amp to drive a speaker, but the
> PWM project we looked at the other day could drive the speaker with just a
> transistor and a cap. Maybe another cost consideration to make PWM more
> attractive [image: Smile]
> *From:* Jason Hotchkiss <jason_hotchk...@hotmail.com>
> *Sent:* Wednesday, October 10, 2012 9:31 AM
> *To:* brightonhackerspace@googlegroups.com
> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
> Errata: the waveshield uses 16 bit WAV files – and truncates them to a
> 12 bit DAC. So if you can use 8 bit samples you can probably get away
> buffering inside 1K....
> *From:* Jason Hotchkiss <jason_hotchk...@hotmail.com>
> *Sent:* Wednesday, October 10, 2012 9:27 AM
> *To:* brightonhackerspace@googlegroups.com
> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
> Hey Chris
> Just to chip in my 2p’s worth..
> - If you use hardware PWM then it won’t use extra clock cycles. Also I
> don’t think it needs a particularly fast system clock – the link Samuel
> sent shows someone generating audio with a 62kHz PWM clock.
> - Setting a PWM duty at each sample should be no more complex or slow than
> writing an external parallel load DAC (it will be significantly faster than
> using a serial load DAC)
> - Certain parts of your code will need to be there irrelevant of whether
> you use a DAC or PWM for output. In particular you need to buffer the
> incoming data from the SD card, and this needs an MCU with a decent amount
> of RAM for the buffers.
> When I worked with the Waveshield code for phonics owl the Atmega168 (1k
> RAM) was not enough for decent buffering and an Atmega328 (2k RAM) was
> needed. I think that ran at 22kHz sample rate with 8 bit samples so
> obviously a lower sample rate can let you get away with smaller buffers but
> I think the PIC you point out has less than 256 bytes of RAM.
> I only have experience of the waveshield way of doing things though...
> perhaps there are alternative and simpler ways to stream the data that can
> avoid buffering, but I don’t think the choice of PWM vs parallel load DAC
> for output would be relevant to that.
> - I reckon you can only benefit from a faster clock – MCUs use tiny
> amounts of current compared to things like 7 segment LEDs.
> For less than 99p you can get PICs with 32MHz internal clocks (you can
> prescale them down if you want) and more memory (this week I got some
> pic16f1824’s with 1k RAM and 32Mhz internal clock and lots of other
> built-in goodies for 91p from Farnell). Even with 1k I’d still experiment
> to make sure that is enough RAM for your application.
> - I think a DAC could let you go to higher bit resolution (e.g. 12 bit
> sampling) to give you better sound quality than PWM, but at greater
> component cost and count.
> You could make a parallel DAC from resistors but I don’t think it would
> give better results than PWM (resistor tolerances etc). Also if you are
> only using 8 bit samples I’m not sure it would make an audible difference.
> I would be tempted to keep it simple and use PWM, especially as you pointed
> out some sample code before that already does the job on an 8 pin PIC with
> just a couple of caps and transistors.
> - Finally, I use PICs and AVRs equally. Direct I/O port and peripheral
> register access on an AVR works exactly the same as a PIC (even in the
> Arduino environment - if you avoid the hellishly slow digitalWrite
> function) so I would not let that sway your decision. I know you’re a PIC
> fan but remember there is a bunch of open source AVR code (Waveshield) you
> could steal if you used an Atmega32...
> Hope that’s helpful
> Jason
> *From:* Chris <chris.hol...@multiedge-net.co.uk>
> *Sent:* Tuesday, October 09, 2012 11:10 PM
> *To:* brightonhackerspace@googlegroups.com
> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
> The SD cards would come in very handy!
> Even the smaller sized ones should be suitable since we're only working
> with relatively small samples (I hope!)
> I deliberately avoided PWM because
> a) it uses a lot of clock cycles
> b) the code gets quite complicated, getting the timings right for the PWM
> as well as changing the rate of PWM to match the sampling rate and reading
> and buffering the data off the SD card in a timely manner.
> c) to get a decent output I'd need to run using a high speed crystal -
> which in turn chews the battery; for example, for about 32khz quality
> samples, I'd need to use a 20Mhz crystal on a PIC (I like PICs for their
> speedy low-level register access).
> By using a DAC, I can use a cheapo 99p 16F628A and its internal oscillator
> at 4Mhz (1/5th speed =~ 1/4 power consumption)
> I'd love to use PWM for audio in a future project, just as an exercise in
> doing it - but this is against a deadline, so DACs keep the code simpler,
> as well as provide the extra benefits above (plus if DACs work, I've got an
> audio platform for other projects with plenty of cpu cycles left to
> integrate with other peripherals).
> On 09/10/2012 22:55, Samuel Wright wrote:
> Hi
> There is a pile of (full sized) SD card somewhere on the donation shelves.
> They are 32 and 128Mbyte. I have some more.
> On Friday, 5 October 2012 20:55:38 UTC+1, Chris Holden wrote:
>> I've been talking to Owen who has a commission for the group which - if
>> successful - could bring in about £500.
>> He's after 50 modified alarm clocks - basically every time the alarm
>> rings, the alarm clock plays a single, pre-programmed sound. He wants these
>> modifying so that we can store seven different sounds (of varying length)
>> and trigger them either from the clock alarm signal or a pushbutton on the
>> case.
>> The hardware looks simple enough, and it's really just a case of
>> replacing the sound playing board with one a little more sophisticated.
>> The mcu is actually not important (other than we want to keep the price
>> right down) but has anyone any experience of playing WAV files without any
>> expensive extra hardware? (no expensive wav shields please!) PIC16F1782
>> wouldn't require a DAC and costs only £1.49, but there are plenty of other
>> little cheap mcus that could be hooked up to an external DAC if necessary.
>> Remembering that we'd have to make 50 or 60 of these should the design work
>> keeping it simple (and cheap) is top priority! (volunteers for pcb etching
>> and soldering/assembling nearer the time would be helpful)
>> There's about £500 for the group if we pull this one off.
>> Any suggestions or ideas would be appreciated.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/brightonhackerspace/-/LTiK9CZMkLgJ.
> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton -
> Just stumbled across something that looks almost perfect for your > project Chris. I was doing some research for my own ATTINY based audio > synth stuff, and someone's written an SD card based audio player for > the tiny85: http://elm-chan.org/works/sd8p/report.html > Check out the schematic! it's, well, tiny! > http://elm-chan.org/works/sd8p/sd8p_mo.png
> On Wed, Oct 10, 2012 at 10:41 AM, Chris > <chris.hol...@multiedge-net.co.uk > <mailto:chris.hol...@multiedge-net.co.uk>> wrote:
> Funnily enough, I got some DACs in the post yesterday and just to
> try them out, sent random SPI values to generate a "moving"
> voltage on the output pin and the volume wasn't brilliant. I may
> have done it wrong, but I'm thinking that maybe PWM isn't such a
> pain after all, given the simpler hardware/assembly requirements -
> after all, we're going to need to make 50-60 of these things,
> including etching boards and soldering components in place, so a
> lower component count does sound appealing!
> I'm checking out those PICs you mentioned.
> To be honest, I've not looked at the full range of MCUs for quite
> some time - I just tend to stick to what I know; I need to get
> familiar with them all again. A software selectable 32Mhz int
> oscillator looks great - run at 32khz for "sleep" mode then ramp
> up to full speed to play a sample before dropping back down to snooze.
> They have cap sensing inputs too? I think I've just got a new
> favourite PIC ;-)
> On 10/10/2012 09:39, Jason Hotchkiss wrote:
>> Sorry to keep spamming your inbox but I thought of something
>> else... I think with a DAC you need an external op-amp to drive a
>> speaker, but the PWM project we looked at the other day could
>> drive the speaker with just a transistor and a cap. Maybe another
>> cost consideration to make PWM more attractive Smile
>> *From:* Jason Hotchkiss <mailto:jason_hotchk...@hotmail.com>
>> *Sent:* Wednesday, October 10, 2012 9:31 AM
>> *To:* brightonhackerspace@googlegroups.com
>> <mailto:brightonhackerspace@googlegroups.com>
>> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
>> Errata: the waveshield uses 16 bit WAV files � and truncates them
>> to a 12 bit DAC. So if you can use 8 bit samples you can probably
>> get away buffering inside 1K....
>> *From:* Jason Hotchkiss <mailto:jason_hotchk...@hotmail.com>
>> *Sent:* Wednesday, October 10, 2012 9:27 AM
>> *To:* brightonhackerspace@googlegroups.com
>> <mailto:brightonhackerspace@googlegroups.com>
>> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
>> Hey Chris
>> Just to chip in my 2p�s worth..
>> - If you use hardware PWM then it won�t use extra clock cycles.
>> Also I don�t think it needs a particularly fast system clock �
>> the link Samuel sent shows someone generating audio with a 62kHz
>> PWM clock.
>> - Setting a PWM duty at each sample should be no more complex or
>> slow than writing an external parallel load DAC (it will be
>> significantly faster than using a serial load DAC)
>> - Certain parts of your code will need to be there irrelevant of
>> whether you use a DAC or PWM for output. In particular you need
>> to buffer the incoming data from the SD card, and this needs an
>> MCU with a decent amount of RAM for the buffers.
>> When I worked with the Waveshield code for phonics owl the
>> Atmega168 (1k RAM) was not enough for decent buffering and an
>> Atmega328 (2k RAM) was needed. I think that ran at 22kHz sample
>> rate with 8 bit samples so obviously a lower sample rate can let
>> you get away with smaller buffers but I think the PIC you point
>> out has less than 256 bytes of RAM.
>> I only have experience of the waveshield way of doing things
>> though... perhaps there are alternative and simpler ways to
>> stream the data that can avoid buffering, but I don�t think the
>> choice of PWM vs parallel load DAC for output would be relevant
>> to that.
>> - I reckon you can only benefit from a faster clock � MCUs use
>> tiny amounts of current compared to things like 7 segment LEDs.
>> For less than 99p you can get PICs with 32MHz internal clocks
>> (you can prescale them down if you want) and more memory (this
>> week I got some pic16f1824�s with 1k RAM and 32Mhz internal clock
>> and lots of other built-in goodies for 91p from Farnell). Even
>> with 1k I�d still experiment to make sure that is enough RAM for
>> your application.
>> - I think a DAC could let you go to higher bit resolution (e.g.
>> 12 bit sampling) to give you better sound quality than PWM, but
>> at greater component cost and count.
>> You could make a parallel DAC from resistors but I don�t think it
>> would give better results than PWM (resistor tolerances etc).
>> Also if you are only using 8 bit samples I�m not sure it would
>> make an audible difference. I would be tempted to keep it simple
>> and use PWM, especially as you pointed out some sample code
>> before that already does the job on an 8 pin PIC with just a
>> couple of caps and transistors.
>> - Finally, I use PICs and AVRs equally. Direct I/O port and
>> peripheral register access on an AVR works exactly the same as a
>> PIC (even in the Arduino environment - if you avoid the hellishly
>> slow digitalWrite function) so I would not let that sway your
>> decision. I know you�re a PIC fan but remember there is a bunch
>> of open source AVR code (Waveshield) you could steal if you used
>> an Atmega32...
>> Hope that�s helpful
>> Jason
>> *From:* Chris <mailto:chris.hol...@multiedge-net.co.uk>
>> *Sent:* Tuesday, October 09, 2012 11:10 PM
>> *To:* brightonhackerspace@googlegroups.com
>> <mailto:brightonhackerspace@googlegroups.com>
>> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
>> The SD cards would come in very handy!
>> Even the smaller sized ones should be suitable since we're only
>> working with relatively small samples (I hope!)
>> I deliberately avoided PWM because
>> a) it uses a lot of clock cycles
>> b) the code gets quite complicated, getting the timings right for
>> the PWM as well as changing the rate of PWM to match the sampling
>> rate and reading and buffering the data off the SD card in a
>> timely manner.
>> c) to get a decent output I'd need to run using a high speed
>> crystal - which in turn chews the battery; for example, for about
>> 32khz quality samples, I'd need to use a 20Mhz crystal on a PIC
>> (I like PICs for their speedy low-level register access).
>> By using a DAC, I can use a cheapo 99p 16F628A and its internal
>> oscillator at 4Mhz (1/5th speed =~ 1/4 power consumption)
>> I'd love to use PWM for audio in a future project, just as an
>> exercise in doing it - but this is against a deadline, so DACs
>> keep the code simpler, as well as provide the extra benefits
>> above (plus if DACs work, I've got an audio platform for other
>> projects with plenty of cpu cycles left to integrate with other
>> peripherals).
>> On 09/10/2012 22:55, Samuel Wright wrote:
>>> Hi
>>> There is a pile of (full sized) SD card somewhere on the
>>> donation shelves. They are 32 and 128Mbyte. I have some more.
>>> Can you use a PCM oputput? See
>>> http://www.maxwellrosspierson.com/2009/05/29/generate-real-time-audio...
>>> Perhaps a DAC allows cheaper chips.
>>> On Friday, 5 October 2012 20:55:38 UTC+1, Chris Holden wrote:
>>> I've been talking to Owen who has a commission for the group
>>> which - if successful - could bring in about �500.
>>> He's after 50 modified alarm clocks - basically every time
>>> the alarm rings, the alarm clock plays a single,
>>> pre-programmed sound. He wants these modifying so that we
>>> can store seven different sounds (of varying length) and
>>> trigger them either from the clock alarm signal or a
>>> pushbutton on the case.
>>> The hardware looks simple enough, and it's really just a
>>> case of replacing the sound playing board with one a little
>>> more sophisticated.
>>> Bearing in mind that these are cost-sensitive, I was looking
>>> at a microcontroller and a DAC hooked up to a speaker
>>> through a simple transistor to amplify the signal. Of course
>>> I'm going down the PIC route and found these - they have a
>>> built-in 8-bit DAC
>>> http://ww1.microchip.com/downloads/en/DeviceDoc/41579C.pdf >>> The mcu is actually not important (other than we want to
>>> keep the price right down) but has anyone any experience of
>>> playing WAV files without any expensive extra hardware? (no
>>> expensive wav shields please!) PIC16F1782 wouldn't require a
>>> DAC and costs only �1.49, but there are plenty of other
>>> little cheap mcus that could be hooked up to an external DAC
>>> if necessary. Remembering that we'd have to make 50 or 60 of
>>> these should the design work keeping it simple (and cheap)
>>> is top priority! (volunteers for pcb etching and
>>> soldering/assembling
I'm hoping to solder the filter components & jack socket onto the IR badge
board. The code itself doesn't look too bad (I'm not that great with C but
I can follow what it's doing).
You can get ATTiny 85's on eBay for about a quid each if you grab 10 at a
time. If you don't want 10, I'll grab some off you :)
> That looks awesome.
> Now I just need to learn how to code AVR and get hold of an attiny or
> two....
> On 11/10/2012 16:51, Toby Cole wrote:
> Just stumbled across something that looks almost perfect for your project
> Chris. I was doing some research for my own ATTINY based audio synth stuff,
> and someone's written an SD card based audio player for the tiny85:
> http://elm-chan.org/works/sd8p/report.html > Check out the schematic! it's, well, tiny!
> http://elm-chan.org/works/sd8p/sd8p_mo.png
> On Wed, Oct 10, 2012 at 10:41 AM, Chris <chris.hol...@multiedge-net.co.uk>wrote:
> Funnily enough, I got some DACs in the post yesterday and just to try them
> out, sent random SPI values to generate a "moving" voltage on the output
> pin and the volume wasn't brilliant. I may have done it wrong, but I'm
> thinking that maybe PWM isn't such a pain after all, given the simpler
> hardware/assembly requirements - after all, we're going to need to make
> 50-60 of these things, including etching boards and soldering components in
> place, so a lower component count does sound appealing!
> I'm checking out those PICs you mentioned.
> To be honest, I've not looked at the full range of MCUs for quite some
> time - I just tend to stick to what I know; I need to get familiar with
> them all again. A software selectable 32Mhz int oscillator looks great -
> run at 32khz for "sleep" mode then ramp up to full speed to play a sample
> before dropping back down to snooze.
> They have cap sensing inputs too? I think I've just got a new favourite
> PIC ;-)
> On 10/10/2012 09:39, Jason Hotchkiss wrote:
> Sorry to keep spamming your inbox but I thought of something else... I
> think with a DAC you need an external op-amp to drive a speaker, but the
> PWM project we looked at the other day could drive the speaker with just a
> transistor and a cap. Maybe another cost consideration to make PWM more
> attractive [image: Smile]
> *From:* Jason Hotchkiss
> *Sent:* Wednesday, October 10, 2012 9:31 AM
> *To:* brightonhackerspace@googlegroups.com
> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
> Errata: the waveshield uses 16 bit WAV files – and truncates them to a
> 12 bit DAC. So if you can use 8 bit samples you can probably get away
> buffering inside 1K....
> --
> You received this message because you are subscribed to the Google Groups
> "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com<javascript:_e({}, 'cvml', 'brightonhackerspace@googlegroups.com');>
> .
> To unsubscribe from this group, send email to
> brightonhackerspace+unsubscribe@googlegroups.com <javascript:_e({},
> 'cvml', 'brightonhackerspace%2Bunsubscribe@googlegroups.com');>.
> For more options, visit https://groups.google.com/groups/opt_out.
I just ordered some tiny85’s you can have a couple (though they may take a while to arrive)
Though I am also playing with a very similar single-chip SD player project using an 8 pin PIC
From: Toby Cole Sent: Friday, October 12, 2012 9:12 AM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] DAC for audio output
I'm hoping to solder the filter components & jack socket onto the IR badge board. The code itself doesn't look too bad (I'm not that great with C but I can follow what it's doing).
You can get ATTiny 85's on eBay for about a quid each if you grab 10 at a time. If you don't want 10, I'll grab some off you :)
On Thursday, October 11, 2012, Chris wrote:
That looks awesome.
Now I just need to learn how to code AVR and get hold of an attiny or two....
On 11/10/2012 16:51, Toby Cole wrote:
Just stumbled across something that looks almost perfect for your project Chris. I was doing some research for my own ATTINY based audio synth stuff, and someone's written an SD card based audio player for the tiny85: http://elm-chan.org/works/sd8p/report.html Check out the schematic! it's, well, tiny! http://elm-chan.org/works/sd8p/sd8p_mo.png
On Wed, Oct 10, 2012 at 10:41 AM, Chris <chris.hol...@multiedge-net.co.uk> wrote:
Funnily enough, I got some DACs in the post yesterday and just to try them out, sent random SPI values to generate a "moving" voltage on the output pin and the volume wasn't brilliant. I may have done it wrong, but I'm thinking that maybe PWM isn't such a pain after all, given the simpler hardware/assembly requirements - after all, we're going to need to make 50-60 of these things, including etching boards and soldering components in place, so a lower component count does sound appealing!
I'm checking out those PICs you mentioned.
To be honest, I've not looked at the full range of MCUs for quite some time - I just tend to stick to what I know; I need to get familiar with them all again. A software selectable 32Mhz int oscillator looks great - run at 32khz for "sleep" mode then ramp up to full speed to play a sample before dropping back down to snooze.
They have cap sensing inputs too? I think I've just got a new favourite PIC ;-)
On 10/10/2012 09:39, Jason Hotchkiss wrote:
Sorry to keep spamming your inbox but I thought of something else... I think with a DAC you need an external op-amp to drive a speaker, but the PWM project we looked at the other day could drive the speaker with just a transistor and a cap. Maybe another cost consideration to make PWM more attractive From: Jason Hotchkiss Sent: Wednesday, October 10, 2012 9:31 AM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] Re: DAC for audio output
Errata: the waveshield uses 16 bit WAV files – and truncates them to a 12 bit DAC. So if you can use 8 bit samples you can probably get away buffering inside 1K....
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to javascript:_e({}, 'cvml', 'brightonhackerspace@googlegroups.com');.
To unsubscribe from this group, send email to javascript:_e({}, 'cvml', 'brightonhackerspace%2Bunsubscribe@googlegroups.com');.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Jason, did you get anywhere using the hardware SPI and PWM on those PICs?
I'm trying to recreate the audio project but understand it from the start - but I came across this: http://ww1.microchip.com/downloads/en/DeviceDoc/39632e.pdf section 13.3 mentions Timer2. This is used for hardware PWM but it's also used as a clock source for SPI.
I'm just wondering how these are affected, as I'm trying to use hardware for SPI and PWM.
Obviously I can create both of these in software (and I can understand exactly what they're doing, since I wrote the code!) but I wondered if you'd had any issues with using hardware PWM and SPI together?
A lot of examples I've seen on the 'net use software/bit-banging for SPI.
I guess I should just try doing the whole lot in software and seeing if it works.......
Another thing - running under about 2.8v I think the max oscillator speed available is 16Mhz (on my 18f chips, it's a sliding scale, but those 16f1825 chips have a definite cut off under the electrical characteristics). A lot of (PIC-based) audio examples use a 20Mhz crystal to get a higher sample frequency - I think the max speed running off 2xAA batteries is going to be just 16Mhz.
Toby, I'm buying �20 worth of stuff from Farnell (most of my stuff from them arrives on next day delivery) including attiny chips so I'll bring some along next time. It's about time I stopped comparing PICs to Sinclairs and Arduinos to C64 and just use whichever works ;-)
(I still struggle putting my trust in other people's libraries - I like to know what's going on under the hood)
> I just ordered some tiny85�sSmile you can have a couple (though they > may take a while to arrive)
> Though I am also playing with a very similar single-chip SD player > project using an 8 pin PIC
> *From:* Toby Cole <mailto:t...@tubs.org.uk>
> *Sent:* Friday, October 12, 2012 9:12 AM
> *To:* brightonhackerspace@googlegroups.com > <mailto:brightonhackerspace@googlegroups.com>
> *Subject:* Re: [brighton-hacker-space] DAC for audio output
> I'm hoping to solder the filter components & jack socket onto the IR > badge board. The code itself doesn't look too bad (I'm not that great > with C but I can follow what it's doing).
> You can get ATTiny 85's on eBay for about a quid each if you grab 10 > at a time. If you don't want 10, I'll grab some off you :)
> On Thursday, October 11, 2012, Chris wrote:
> That looks awesome.
> Now I just need to learn how to code AVR and get hold of an attiny
> or two....
> On 11/10/2012 16:51, Toby Cole wrote:
>> Just stumbled across something that looks almost perfect for your
>> project Chris. I was doing some research for my own ATTINY based
>> audio synth stuff, and someone's written an SD card based audio
>> player for the tiny85: http://elm-chan.org/works/sd8p/report.html >> Check out the schematic! it's, well, tiny!
>> http://elm-chan.org/works/sd8p/sd8p_mo.png
>> On Wed, Oct 10, 2012 at 10:41 AM, Chris
>> <chris.hol...@multiedge-net.co.uk> wrote:
>> Funnily enough, I got some DACs in the post yesterday and
>> just to try them out, sent random SPI values to generate a
>> "moving" voltage on the output pin and the volume wasn't
>> brilliant. I may have done it wrong, but I'm thinking that
>> maybe PWM isn't such a pain after all, given the simpler
>> hardware/assembly requirements - after all, we're going to
>> need to make 50-60 of these things, including etching boards
>> and soldering components in place, so a lower component count
>> does sound appealing!
>> I'm checking out those PICs you mentioned.
>> To be honest, I've not looked at the full range of MCUs for
>> quite some time - I just tend to stick to what I know; I need
>> to get familiar with them all again. A software selectable
>> 32Mhz int oscillator looks great - run at 32khz for "sleep"
>> mode then ramp up to full speed to play a sample before
>> dropping back down to snooze.
>> They have cap sensing inputs too? I think I've just got a new
>> favourite PIC ;-)
>> On 10/10/2012 09:39, Jason Hotchkiss wrote:
>>> Sorry to keep spamming your inbox but I thought of something
>>> else... I think with a DAC you need an external op-amp to
>>> drive a speaker, but the PWM project we looked at the other
>>> day could drive the speaker with just a transistor and a
>>> cap. Maybe another cost consideration to make PWM more
>>> attractive Smile
>>> *From:* Jason Hotchkiss
>>> *Sent:* Wednesday, October 10, 2012 9:31 AM
>>> *To:* brightonhackerspace@googlegroups.com
>>> *Subject:* Re: [brighton-hacker-space] Re: DAC for audio output
>>> Errata: the waveshield uses 16 bit WAV files � and truncates
>>> them to a 12 bit DAC. So if you can use 8 bit samples you
>>> can probably get away buffering inside 1K....
> -- > You received this message because you are subscribed to the Google
> Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to javascript:_e({}, 'cvml',
> 'brightonhackerspace@googlegroups.com'); <javascript:_e({},
> 'cvml', 'brightonhackerspace@googlegroups.com');>.
> To unsubscribe from this group, send email to javascript:_e({},
> 'cvml', 'brightonhackerspace%2Bunsubscribe@googlegroups.com');
> <javascript:_e({}, 'cvml',
> 'brightonhackerspace%2Bunsubscribe@googlegroups.com');>.
> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
I started porting the PIC12F Hitec C code to run under SourceBoost on 16F1825. Good news is these PICs are very similar, but I didn’t get to the point where anything worked yet. I’d assume you can use hardware PWM and SPI at the same time but can’t say for certain. I think that PIC12F project was overclocked at 33MHz running on 3.3v so not sure you have an issue there
From: Chris Sent: Friday, October 12, 2012 10:40 AM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] DAC for audio output
Jason, did you get anywhere using the hardware SPI and PWM on those PICs?
I'm trying to recreate the audio project but understand it from the start - but I came across this: http://ww1.microchip.com/downloads/en/DeviceDoc/39632e.pdf section 13.3 mentions Timer2. This is used for hardware PWM but it's also used as a clock source for SPI.
I'm just wondering how these are affected, as I'm trying to use hardware for SPI and PWM.
Obviously I can create both of these in software (and I can understand exactly what they're doing, since I wrote the code!) but I wondered if you'd had any issues with using hardware PWM and SPI together?
A lot of examples I've seen on the 'net use software/bit-banging for SPI.
I guess I should just try doing the whole lot in software and seeing if it works.......
Another thing - running under about 2.8v I think the max oscillator speed available is 16Mhz (on my 18f chips, it's a sliding scale, but those 16f1825 chips have a definite cut off under the electrical characteristics). A lot of (PIC-based) audio examples use a 20Mhz crystal to get a higher sample frequency - I think the max speed running off 2xAA batteries is going to be just 16Mhz.
Toby, I'm buying £20 worth of stuff from Farnell (most of my stuff from them arrives on next day delivery) including attiny chips so I'll bring some along next time. It's about time I stopped comparing PICs to Sinclairs and Arduinos to C64 and just use whichever works ;-)
(I still struggle putting my trust in other people's libraries - I like to know what's going on under the hood)
On 12/10/2012 09:19, Jason Hotchkiss wrote:
I just ordered some tiny85’s you can have a couple (though they may take a while to arrive)
Though I am also playing with a very similar single-chip SD player project using an 8 pin PIC
From: Toby Cole Sent: Friday, October 12, 2012 9:12 AM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] DAC for audio output
I'm hoping to solder the filter components & jack socket onto the IR badge board. The code itself doesn't look too bad (I'm not that great with C but I can follow what it's doing).
You can get ATTiny 85's on eBay for about a quid each if you grab 10 at a time. If you don't want 10, I'll grab some off you :)
On Thursday, October 11, 2012, Chris wrote:
That looks awesome.
Now I just need to learn how to code AVR and get hold of an attiny or two....
On 11/10/2012 16:51, Toby Cole wrote:
Just stumbled across something that looks almost perfect for your project Chris. I was doing some research for my own ATTINY based audio synth stuff, and someone's written an SD card based audio player for the tiny85: http://elm-chan.org/works/sd8p/report.html Check out the schematic! it's, well, tiny! http://elm-chan.org/works/sd8p/sd8p_mo.png
On Wed, Oct 10, 2012 at 10:41 AM, Chris <chris.hol...@multiedge-net.co.uk> wrote:
Funnily enough, I got some DACs in the post yesterday and just to try them out, sent random SPI values to generate a "moving" voltage on the output pin and the volume wasn't brilliant. I may have done it wrong, but I'm thinking that maybe PWM isn't such a pain after all, given the simpler hardware/assembly requirements - after all, we're going to need to make 50-60 of these things, including etching boards and soldering components in place, so a lower component count does sound appealing!
I'm checking out those PICs you mentioned.
To be honest, I've not looked at the full range of MCUs for quite some time - I just tend to stick to what I know; I need to get familiar with them all again. A software selectable 32Mhz int oscillator looks great - run at 32khz for "sleep" mode then ramp up to full speed to play a sample before dropping back down to snooze.
They have cap sensing inputs too? I think I've just got a new favourite PIC ;-)
On 10/10/2012 09:39, Jason Hotchkiss wrote:
Sorry to keep spamming your inbox but I thought of something else... I think with a DAC you need an external op-amp to drive a speaker, but the PWM project we looked at the other day could drive the speaker with just a transistor and a cap. Maybe another cost consideration to make PWM more attractive From: Jason Hotchkiss Sent: Wednesday, October 10, 2012 9:31 AM
To: brightonhackerspace@googlegroups.com Subject: Re: [brighton-hacker-space] Re: DAC for audio output
Errata: the waveshield uses 16 bit WAV files – and truncates them to a 12 bit DAC. So if you can use 8 bit samples you can probably get away buffering inside 1K....
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to javascript:_e({}, 'cvml', 'brightonhackerspace@googlegroups.com');.
To unsubscribe from this group, send email to javascript:_e({}, 'cvml','brightonhackerspace%2Bunsubscribe@googlegroups.com');.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
-- You received this message because you are subscribed to the Google Groups "BuildBrighton - the Brighton Hacker Space" group.
To post to this group, send email to brightonhackerspace@googlegroups.com.
To unsubscribe from this group, send email to brightonhackerspace+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Don't shoot me please for suggesting a rather different route - I looked at doing this kind of thing for a pinball table ages ago, in a world before Arduino & PIC (or at least before I'd discovered them ;-))
At the time, I was looking at dedicated ICs to do it - basically you want something like this: http://www.maplin.co.uk/single-message-record-playback-kit-265464 with all the extraneous gumph removed. Getting samples in & out would be harder than via SD cards, but it must end up being WAY cheaper....
Suggesting a different route - whether or not it eventually gets taken - is always good to hear; unexpected answers to long-standing problems can often come out of going completely left-field so don't worry about suggesting them!
I had considered using a dedicated sound playback module - you can get them on eBay (from China) for about 1.60 each (I have three of them here) but they're very time limited - about 10 seconds - and very poor playback quality. To get a reasonable length of time, we'd have to have some kind of storage and it just so happens that SD cards are a very cheap way of adding lots of storage. I've used serial i2c eeprom and flash-based memory chips but they're not huge (in terms of storage space).
The crazy thing is, a single PIC/AVR chip capable of playing back audio (once the firmware has been sorted) costs about 90p in volume, and an SD card can be had for about 99p, so they work out comparable - if not cheaper in the long run - to those sound modules, and (should) offer better playback quality and longer samples.
But thanks for the input - even if it turn out not to be the final answer for a particular problem, it's always great to hear a different point of view. Keep the ideas coming!
> Don't shoot me please for suggesting a rather different route - I > looked at doing this kind of thing for a pinball table ages ago, in a > world before Arduino & PIC (or at least before I'd discovered them ;-))
> At the time, I was looking at dedicated ICs to do it - basically you > want something like this:
> http://www.maplin.co.uk/single-message-record-playback-kit-265464 > with all the extraneous gumph removed. Getting samples in & out would > be harder than via SD cards, but it must end up being WAY cheaper....
> Cheers,
> James H
> -- > You received this message because you are subscribed to the Google > Groups "BuildBrighton - the Brighton Hacker Space" group.
> To post to this group, send email to brightonhackerspace@googlegroups.com.
> To unsubscribe from this group, send email to > brightonhackerspace+unsubscribe@googlegroups.com.
> To view this discussion on the web visit > https://groups.google.com/d/msg/brightonhackerspace/-/eqds85fwtLYJ.
> For more options, visit https://groups.google.com/groups/opt_out.