Can I do other things while playing WAV files with Atmega 328?

I am wondering about a project in which an Atmega 328 running at 8MHz (3.7v) would be installed in a model train, receive commands with an NRF24 transceiver, control the motor (probably via a DRV8833) and be required to play sound from different WAV files on an SD Card all at the same time. I am assuming that 11ksps mono sound files would good enough.

I haven't been able to find any discussion of what percentage of the Atmega 328's CPU cycles is used up when playing a WAV file.

Alternatively, is anyone aware of a significantly faster chip with a similar footprint to a DIP Atmega328. Just to clarify, a SparkFun proMicro would be much too big for what I want. I don't plan on mounting the 328 on any PCB.

...R

How about the Same footprint? How are you connecting it to the other bits of your project?
At 16 MHz, Arduino is fast enough to play 16-bit, 44.1KHz sound (mono CD quality) thru an external DAC.
http://forum.arduino.cc/index.php?topic=180769.0
Slowing the sample rate to 1/4 of that should leave time for other stuff.

Robin2:
I am wondering about a project in which an Atmega 328 running at 8MHz (3.7v) would be installed in a model train, receive commands with an NRF24 transceiver, control the motor (probably via a DRV8833) and be required to play sound from different WAV files on an SD Card all at the same time. I am assuming that 11ksps mono sound files would good enough.

I haven't been able to find any discussion of what percentage of the Atmega 328's CPU cycles is used up when playing a WAV file.

Alternatively, is anyone aware of a significantly faster chip with a similar footprint to a DIP Atmega328. Just to clarify, a SparkFun proMicro would be much too big for what I want. I don't plan on mounting the 328 on any PCB.

...R

You could use 2 X SMD Atmega328s, but I suspect that their dimensions may not allow them to fit in an N gauge loco.

Henry_Best:
You could use 2 X SMD Atmega328s, but I suspect that their dimensions may not allow them to fit in an N gauge loco.

This is for an OO Gauge loco. I'm wondering how much I can "stuff" in at a much cheaper price than DCC sound (as well as having battery powered radio control). Mainly just some fun exploration of an anarchic approach.

@CrossRoads, your comments on the speed are very useful. The device in your image would be much too tall. I'm thinking of flattening the pins on the 328 or bending half of them over the back and half over the front. I did that successfully with an Attiny a while back.

...R

Robin2:
This is for an OO Gauge loco.

4472? You'll have space in two tenders! ;D

Henry_Best:
4472? You'll have space in two tenders! ;D

The first guinea-pig is a 2-6-2 tank loco :slight_smile:

...R

Robin2:
The first guinea-pig is a 2-6-2 tank loco :slight_smile:

...R

So you have space in the bunker and tanks. You might get two SMD 328s and most of your other electronics in there if they are arranged vertically. The problem might be heat build up, though. Wouldn't want to melt the plastic/white-metal.

Henry_Best:
You might get two SMD 328s ...

Do you know where I can get cheap SMD 328s mounted on a very small breakout board?
I don't have the ability to deal with SMD chips.

(Cheap = £5 or so - I know where I can get them for £28).


I spent yesterday figuring out how to make a minimal WAV file player program and I will do some testing today. However I don't think it is practical to use the same 328 for sound and for controlling the loco.

May I repeat my request for suggestions for a more powerful MCU that would be capable of doing both tasks and is available either in DIP format or on a small breakout board.

...R

I'd expect the issue to be the SD lib and not processor speed. Last time I looked the SD lib is blocking so you will need to double buffer the data which may well give memory (SRAM) issues.

Which DAC do you intend to use and which SD lib?

Mark

holmes4:
Which DAC do you intend to use and which SD lib?

I have not investigate the SD lib - I am just using the regular one.

At the moment I have no DAC (and no plan for one) - I just connected Pin3 and Gnd to the 3mm jack plug for an amplified speaker.

However at 11,025 Hz there is an interrupt every 90 µsecs and I got the impression that even simple Serial.print() would not work in parallel with that. But I have not yet done any testing today.

If there is not a more powerful small and cheap MCU then it may be simpler just to use a second 328 dedicated to the sound.

Keep in mind also that it will be necessary to select from several sound files in a seemless fashion.

...R

Robin2:
Do you know where I can get cheap SMD 328s mounted on a very small breakout board?

I've seen breakout boards here: http://www.aliexpress.com/item/10pcs-lot-FQFP-TQFP-32-44-64-80-100-LQFP-SMD-DIP-0-5-0-8mm/32514584937.html?spm=2114.01020208.3.35.KJWkW8&ws_ab_test=searchweb201556_1_79_78_77_80_61,searchweb201644_0,searchweb201560_1
but they look like they're too large, about 2" X 1.6" from the photo. You can email the supplier to ask the exact size.

Atmel SMD 328P: http://www.aliexpress.com/wholesale?shipCountry=uk&shipFromCountry=&shipCompanies=&SearchText=Atmel+328p&exception=&minPrice=&maxPrice=&minQuantity=&maxQuantity=&isFreeShip=y&isFavorite=n&isRtl=n&isOnSale=n&isBigSale=n&similar_style=n&similar_style_id=&CatId=0&g=y&initiative_id=SB_20151203210000&needQuery=y

I don't have the ability to deal with SMD chips.

Look here to find your nearest hackspace: http://www.hackspace.org.uk/wiki/Main_Page.
Contact them to see if they have a reflow oven. If so, they can solder all 10 at once, probably for the cost of a couple of pints for the operator.
I calculate that as about £25 for 10.

Robin2:
May I repeat my request for suggestions for a more powerful MCU that would be capable of doing both tasks and is available either in DIP format or on a small breakout board.

The Propeller could certainly play WAV files while doing other things.

I think there are small PCBs available but I haven't seen many which are smaller than an inch squared.

This is one I made for my own use.

I can get 9 Propellers on a single 5cm x 5 cm PCB.

If you're interested in trying the Propeller, I could help you track down a small PCB.

Edit: Here's a picture of one of the Propeller PCBs next to a Nano clone.

PropAndNano.jpg

I know I've seen PCB just barely larger than the surface mount chip. The I/O pins were broken out to castelated pads.

Thanks Duane, I will read up about the propeller.

Just to put things in persepctive, the small (and expensive - £28) Atmega328 Deltino boards that I have measure 12x21mm and include a 2.4GHz transceiver and a h-bridge as well as the 328.

It's hard to say what are the limits to the size. Long and thin might fit in one space and a more "square" footprint might fit another space. The 328 DIP chip is about 35mm long and that is almost too long. The third dimension (height) also needs to be as small as possible - 3mm is a lot. 5mm may be too much.

...R

Have you considered a dedicated WAV player module like this. It seems quite small and has an SD card slot for your sounds built in. It looks like it can be controlled using serial or simulated button presses and people have done write-ups on it's use from arduino here and here.

As an alternative MCU package maybe the Moteino will fit the bill as it's small form factor with built on RF module.

Thanks @Riva, that WAV player looks interesting. However I don't think I have the patience to order it from Hong Kong.

Interestingly I ordered a few parts from RS Components last week and I believe they came from Japan in 5 days at no postage cost to me - and the parts cost about £10 in total.

...R

Robin2:
Thanks @Riva, that WAV player looks interesting. However I don't think I have the patience to order it from Hong Kong.

If you look you will find UK suppliers selling it for delivery in a couple of days but they cost about £5.

This one is not as small as the ebay audio player:

You can let it play one of the 8 mp3 music files if you trigger it on one of the 8 input pins, using simple buttons.