PIC-based voice recorder

[Vinod] just finished building a voice recorder and it turned out even better than he thought it would. The video after the break shows him recording what is surely one of your favorite songs from his cellphone and then playing it back. The audio quality does sound quite good for a project with very few components.

A PIC 16F877A makes up the majority of the build. Its ADC is used to capture the incoming line from an amplified microphone input (you’ll find that amp schematic half way through his post). He’s storing the data on an MMC card, which was a bit of a hack since the PIC has limited RAM to manage that overhead. The stored data is in a raw format, as the card is not accessed using a file system. This makes it easy to record at a high bit rate, leading to better audio quality. Playback consists of connecting a speaker via a low-pass filter and amplifier circuit to the hardware PWM output on the PIC.

Comments

  1. sbrk says:

    Nice to see a non-Arduino project posted on HaD. :-)
    Good job!

  2. Mattster says:

    Just for the info on using an MMC card without having to use a file system the article was worth it.

  3. Bogdan says:

    I really like the documentation, specially the part about using the card, well done. I think an improvement can come from biasing the analog in to VCC/2 by adding another 220K resistor from the pin to VCC. The amplifier should have a dc blocking cap. This should improve the quality.

    I’ve designed some sort of music/info playing box that could play a file stored on an SPI flash memory(required high temp functionality that SD/MMC could not provide) and found that 8bit R2R resistor made DAC was much better than PWM in terms of quality, and a 10bit R2R DAC could improve on the 8bit, but further resolution increasing provided no gain. So, you might try an R2R DAC and see if improves.

    This post reminds me of when i was learning to use the ADC on an 16F876. A friend told me about an ATMEGA8. 4x RAM, faster, no external oscillator and 1/3 of the price of the PIC. Never used an 8bit pic since, but i do like the dsPIC thou…

    • jwrm22 says:

      PIC vs AVR, wich is best… Well the price doesn’t matter much any more.
      16F876: 5,59E <dip28, pretty hard to get and pricy.
      16F877: 6,14E <dip40, popular hobby PIC.
      18F4455: 5,48E <dip40, my choice atm
      Atemega8: 4,14 <dip28,

      What I'm interested at, why is an AVR considered faster then a PIC, even when they run on the same clock freq.

      Not that I'm going to change microcontroller brand soon, just because I've still got 20-30 pics laying around!

      How is the supply of AVR atm? Last time i checked at my suplier in china most AVR where out of stock for the last 18 months.

      • bogdan says:

        Your price and availability varies greatly depending on your available suppliers. The time i was talking about is quite somev years back and things are changed now. One thing today is that you can get many 16/32 bit microscwith more stuff for the money than 8 bit ones. Also there are superior 8 bit pics thaj the ones mentioned which are cheaper….

      • Daid says:

        I love the ATMega8. But to help you with your question, I know AVR instructions are almost always 1 cycle long. Maybe the PIC is slower because it needs more cycles per instruction?

        (Seeing how people use them I guess both AVR and PIC are awesome chips. I only have experience with AVR so I cannot judge on PIC)

      • ksjoberg says:

        The reason why an AVR is faster than PIC is because an AVR runs one instruction each clockcycle, whereas a PIC only manages to do 1/4th instruction for each clockcycle. Or to put it in other words, a PIC needs 4 clockcycles for each instruction. (Argument holds for all non-branch instructions)

      • Ben Ryves says:

        The AVR runs at one clock cycle per instruction cycle, whereas an 8-bit PIC runs at four clock cycles per instruction cycle. This means that an AVR will execute approximately four times as many instructions per second as a PIC at the same clock frequency (I say “approximately” as a handful of instructions take more than one instruction cycle on both devices).
        This isn’t true for all PICs, however; the 16-bit dsPIC33F series has single clock cycle instructions (with a few exceptions), for example.

      • jwrm22 says:

        @david etc.
        I already found that AVR do 1 instruction for each clock. But I’m interested in the technical stuff, Most chips use 4 stages and need 4 clock-pulses for each instruction. AVR is different, what makes it interesting because an AVR still needs the 4 stages: Instruction fetch, Instruction decode, Execute and save.

        Higher end chips use pipelining, but i never seen it in a 8bit chip. I guess it would be an overkill.

      • therian says:

        @jwrm22
        all 8bit PICs use pipelining

  4. N0LKK says:

    I love the proclamation across the top of Vinod’s blog “ELECTRONICS THE KING OF HOBBIES ” far I out. While I’m unlikely to duplicate this project, but what was new information to me will be going into the current note book. Nice find Mike.

  5. jwrm22 says:

    How good will it sound with a propper DAC? Its realy good for just PWM music!

  6. I have played with MMC without a file system, was always 50/50 on it, today, I am like duh, makes sense. Good job!

  7. bogdan says:

    My experience with playing 16bit 44khz wave on 10bit resistor r2r dac on good audio system showed better than expected quality.
    With a proper 16 bit dac you can get very good quality and maybe have sufficient time available on a card using wave format. I would recommend using a regular file system as you could just plug your card into the computer and download the file.

  8. xorpunk says:

    Lets hope RIAA and/or license holders don’t see this..

  9. menotme says:

    What amplifier did you use? yeah using a RC HPF would help some with sound.

    a uC talking to flash chip is cool

    daps

  10. SpiralBrain says:

    This is pretty cool, I cant get my way around how timing is achieved during playback. Have seen a few projects using PWM as audio DAC but this one is perhaps the best.

  11. Jas says:

    Actually, you want a lowpass filter.

  12. MarkF says:

    Awesome, great to see this being done on a PIC. Back before PCs had sound cards, we used to use a similar trick to play ADPCM audio on the PC speaker by using one of the 3 timers to generate a periodic interrupt and another set to one-shot mode to generate each PWM pulse. If you set the frequency high enough (e.g. double each sample and play back at 88kHz) then the speaker itself forms the low-pass filter and you don’t need the RC components on the output (doesn’t work on piezos though).

    • NewCommenter1283 says:

      i have a device driver for DOS i think to do this. sounded like crap but i was still amazed at how much more detail was in the sound compared to standard 1-bit square-wave beeps!

      PS: thisone i have somehow works on a piezo but sounds wayyy much better on standard speaker like you say. ie u cant make out the words on piezo but u can tell what song is playing.

  13. roliop says:

    Nice project, but, as so often, a bad choice of music. The video cannot be viewed in Germany because the licencing authority can somehow prevent it :-(
    rp

  14. VINOD S says:

    Yes, you are right….unfortunately it is a bad choice of music…
    :-(

    Any way,

    THANKS FOR ALL THE SUGGESTIONS AND COMMENTS …
    I will try to improve it and update in by blog…

    • signal7 says:

      If this is for a voice application, it would be nice to see voice being used for the example audio. It’s hard to compare the quality of music in/out to voice in/out since the frequency bandwidth required for music is much wider than that of the human voice. The output may actually sound better that way. If you don’t want to use your own voice, I don’t think it would be too hard to find a recording of someone reading a book or some other example text.

      Nice project though. Might play around with the idea on a maple I have here.

  15. qwerty says:

    Great project and awesome documentation, bravo! Thanks also to the author for sharing the code!

    The audio in the video could be distorted, 8 bit aside, because of input overload or clipping. The mic preamp capsule resistor seems too high to me and should be somewhere between 2.2k and 22k, usually 10k with 9-12 Vdc, much less with 5Vdc.
    Also, a true common emitter preamp like this one would be better.

  16. Harvie.CZ says:

    You’ve been titanicroll’d

  17. jani says:

    HEy i need a source code. can u share me source code pls!!!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 93,929 other followers