Close

Robo Sounds

A project log for Retro Robot Restomod

Breathing new life into a 22 year old robot toy

scottscott 04/01/2014 at 08:570 Comments

So what’s a toy robot without beeps and boops?

I’ve worked on a project before that played wav files off an SD card using an AVR, however it takes pretty much all the processing juice the chip has to play audio. So the idea is to have a separate chip dedicated to playing audio.

How will it work? (This is going to be specific for AVR/Arduino, but the principles are pretty generic)

If you run a PWM output in phase correct mode, it counts 8 bits up and down, giving 512 counts per period.

If the processor is clocked at 16Mhz, and we run the timer at prescaler div 1, we can get an overflow interrupt (whenever the timer counts back down to zero) at 31.250Khz. If we only update the PWM output compare register every second interrupt we will run at approximately 16Khz.

The main loop of the program will read as fast as possible from the SD card and fill a buffer. The interrupt will take the next sample off the buffer and set the PWM OCR.

The main loop will also have to service the UART/I2C to check for new commands.

Timer1 is also free, so we can probably use that to drive another servo.

-- Electronics --

It's all on breadboard at the moment.

To start the experimenting I soldered wires to an SD-Micro SD adapter. I then used zeners to drop the IO voltage.

My first issue was that I used 10K resistors with the zeners without thinking too much about it, turns out the response isn’t fast enough, so I changed to 330R, which is fast, but wastes (5-3.3/330)=5mA per IO line (3 of them) which isn’t ideal.

-- Firmware --

I’m trying the Arduino SdFat library, their hello world example runs okay, but when I tried to open a text file on the card it didn’t want to work. Unfortunately I ran out of time to investigate further.

I also setup the timer to test the PWM which seems good. I made the interrupt toggle an IO pin and it all seems good.

Discussions