element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Benefits of Membership
    • Achievement Levels
    • Members Area
    • Personal Blogs
    • Feedback and Support
    • What's New on element14
  • Learn
    Learn
    • Learning Center
    • eBooks
    • STEM Academy
    • Webinars, Training and Events
    • More
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • More
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • More
  • Products
    Products
    • Arduino
    • Dev Tools
    • Manufacturers
    • Raspberry Pi
    • RoadTests & Reviews
    • Avnet Boards Community
    • More
  • Store
    Store
    • Visit Your Store
    • Choose Another Store
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
BeagleBoard
  • Products
  • Dev Tools
  • Single-Board Computers
  • BeagleBoard
  • More
  • Cancel
BeagleBoard
Blog BBB - Building a DAC
  • Blog
  • Forum
  • Documents
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
BeagleBoard requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: shabaz
  • Date Created: 6 Jul 2013 7:19 PM Date Created
  • Views 1960 views
  • Likes 9 likes
  • Comments 126 comments
  • onsemi
  • audio
  • dac
  • bbb
  • texas_instruments
  • bb_black
  • beagle_bone_black
  • ti
Related
Recommended

BBB - Building a DAC

shabaz
shabaz
6 Jul 2013

Introduction

This project was about getting audio out of the BeagleBone Black. The aim was to have stereo audio, at least as good as an iPod. See further below for the circuit, and also a video showing it working.

Later, this project was used to build a PCB design (see below for the link to this part 2, and then the PCB was used to make a home Sonos-type hi-fi audio player (see the link to part 3 below).

 

The BBB has an on-board I2S interface, which makes interfacing an external DAC easy. The I2S interface is connected from the AM3359 processor to the HDMI chip (TDA19988) but it is not required for HDMI to be used in order to make use of the I2S interface. The I2S interface is brought out to some pins on port P9 (see here for details). It was encouraging that Technoshaman and Donald Miller had some success with the interface, so I wanted to try it out and I got some time today.

 

Part 2 to this post, which implements the prototype, can be found by clicking here.

Part 3 implements a complete design in an enclosure for a Sonos-like solution.

See Creating an Internet Radio for a complete project by the EAGLE team including board layouts

 

Parts Selection

Since the interface is capable of 24-bit/192kHz audio, it was worthwhile picking a nice DAC. A good but not over-the-top device seemed to be the Texas Instrument's PCM5101 which is nice because it has reasonable specs and also provides a built-in charge pump so that it can function from a single supply. A headphone amp was connected, and this was ON Semi's NCP2811A. The combination of PCM5101 (actually my prototype used PCM5101A which can also function from 1.8V, but this was not needed)  and NCP2811A was chosen so that the entire circuit could operate from the BBB supply if desired, even if it was from a Li-Ion battery that was powering the BBB, and for low noise and distortion. The only problem is that the PCM5101 has quite a high output (clearly a good thing!) but the audio amp minimum recommended gain is 1 and it cannot meet the required output voltage, and it means that it will distort at high volume. So, at a lower volume (and lower SNR) it will be fine, and I prefer this particular amp because of the very low distortion. The ON semi datasheet was sparse though.

 

Building It

This is the DAC prototype:

This is the whole thing connected up:

This is the rear of the board - a bit messier! It was built on a SMD to DIP adapter board with some copper tape for supply rails:

This is the audio amp - not a lot to it, since it is so integrated.

 

Testing It

I made a recording, but excuse the quality. The audio is from a small 64 ohm speaker picked up by a simple camera in-built microphone so it sounds bad, but connecting to headphones is a different story - it sounds as good as an ipod (although this is subjective - I don't have a way to measure). Another thing I still need to check is that originally I thought the data was read on the falling edge of the bitclock on the BBB, but I2S specifies the opposite. Maybe I made a mistake in my initial observations (I have not had a chance to re-check), or maybe it changed in a build. But the circuit as shown here works for me.

 

This is running on an not-recent Angstrom downloaded build (maybe a few weeks old image), and I still hear some very slight audio issues - it sounds like perhaps a break for a few tens of milliseconds occasionally, only if you're listening closely. I really hope it is resolved in a build soon (or maybe it is due to ffmpeg - perhaps avconv gives better results).

EDIT: I've since been using mplayer (command line is mplayer -ao alsa -volume 4 AmyWinehouse-BackToBlack.mp3  and either I'm not noticing any audio issues or they have disappeared). I've concluded it sounds at least as capable as my old ipod touch, maybe better).

 

I played audio using the command line:

ffmpeg -i AmyWinehouse-YouKnowImNoGood.mp3 -f alsa "default:CARD=Black" -re -vol 150

and it reported the stream as:

Stream #0.0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s

 

 

You don't have permission to edit metadata of this video.
Edit media
x
Upload Preview

 

Circuit Diagram

This is the circuit. All the 3.3V supplies were connected together for the prototype (I wouldn't do that for real, although it sounded very good in my limited tests). The amplifier V+ can be connected to 3.3V or the 5V supply (or the Li-Ion battery directly).

Note 16th Jan 2014: See the comments section below for more detail; the SCK pin on the PCM5101A was disconnected from 0V and instead connected to the BBB P9 pin 25. This will provide the lowest jitter by disabling the DAC's internal PLL. A sample capture of the audio quality (captured from the headphone output of the NCP2811A, just to give an approximate idea of what it sounds like from headphones) is attached to the post below, in the zip file dac-output.zip. More info on it in the comments section below.

Note 2: Please add a logic inverter to the bitclock connection. For more detail, see the comments below (search for the word 'bitclock' to make it easier to find). See the part 2 blog post, and the attached file there called dac-documentation.zip for the circuit diagram, showing the bitclock inversion. More recent BBB images may not need it, but it was certainly needed for the images I tested with.

 

Experiments with FLAC

I've also tried a FLAC file, but I'm hitting some limitation with ffmpeg it seems, and it picks a 16-bit format when it ought to be 24-bit. Meanwhile, avconv I couldn't get to work for MP3 or FLAC (it reported 'av_interleaved_write_frame(): Resource temporarily unavailable'). If anyone knows, any tips on how to play FLAC at 24-bit would be gratefully appreciated.

 

root@beaglebone:~# ffmpeg -i Taxman_2009_Digital_Remaster.flac -f alsa "default:CARD=Black" -re -vol 5
ffmpeg version v0.8.4, Copyright (c) 2000-2012 the Libav developers
  built on May 20 2013 13:00:42 with gcc 4.7.3 20130205 (prerelease)
This program is not developed anymore and is only provided for compatibility. Use avconv instead (see Changelog for the list of incompatible changes).
[flac @ 0x2da80] max_analyze_duration reached
Input #0, flac, from 'Taxman_2009_Digital_Remaster.flac':
  Metadata:
    ORIGREFERENCE   : 6C05C9F79EE74052A7991B9669B98533
    ORIGDATE        : 2009:09:14
    ORIGTIME        : 11:57:01
    TIMEREFERENCE   : 5292000
    CODINGHISTORY   : A=PCM,F=44100,W=24,M=stereo,T=SADiE5
    ORGANIZATION    : EMI
    TITLE           : Taxman
    track           : 1
    ARTIST          : The Beatles
    ALBUM           : Revolver (24 BIT Remastered)
    DATE            : 2009
  Duration: 00:02:37.85, bitrate: 1892 kb/s
    Stream #0.0: Audio: flac, 44100 Hz, 2 channels, s32
Incompatible sample format 's32' for codec 'pcm_s16le', auto-selecting format 's16'
Output #0, alsa, to 'default:CARD=Black':
  Metadata:
    ORIGREFERENCE   : 6C05C9F79EE74052A7991B9669B98533
    ORIGDATE        : 2009:09:14
    ORIGTIME        : 11:57:01
    TIMEREFERENCE   : 5292000
    CODINGHISTORY   : A=PCM,F=44100,W=24,M=stereo,T=SADiE5
    ORGANIZATION    : EMI
    TITLE           : Taxman
    track           : 1
    ARTIST          : The Beatles
    ALBUM           : Revolver (24 BIT Remastered)
    DATE            : 2009
    encoder         : Lavf53.21.0
    Stream #0.0: Audio: pcm_s16le, 44100 Hz, 2 channels, s16, 1411 kb/s
Stream mapping:
  Stream #0.0 -> #0.0

Attachments:
dac-output.zip
Anonymous

Top Comments

  • Former Member
    Former Member over 8 years ago in reply to Former Member +2

    Current test rig. BBB ($45), cs4271 on breadboard (about $15 parts and dozens of hours of labor), Cary Audio SE-1 amp (about $1K), pair of B&W DM302 speakers (about $200). I assembled this system that…

  • shabaz
    shabaz over 4 years ago in reply to shabaz +2

    Also, unrelated, but for after you have resolved the device tree issue, I just wanted to confirm, if you're following the circuit, make sure you include the 'bitclock inversion' functionality. The BBB…

  • shabaz
    shabaz over 4 years ago in reply to jithu_element14 +2

    Hi Jithu,

     

    Just to follow up on this, I re-tried on another image too, but still no luck.

    I've posted a request for help on the Beagleboard.org BBB-Wireless forum, in case anyone else has had success.…

  • shabaz
    shabaz over 4 years ago in reply to jithu_element14

    jithu_element14  wrote:

     

    So is it because any other audio packages need to be installed or anything else. and is there any way to check whether BBB is able to detect the DAC circuit connected to it?

     

    Thanks,

    Jithu

    Unfortunatley this hardware was tested on BBB on a very old image, not on BBB-Wireless with recent images, since BBB-Wireless did not exist 5 years ago. So I'm not sure if you need audio packages, this is something I do not know unfortunately.

    To check, you could connect an oscilloscope and see if any data is streaming on the I2S lines.

    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
  • jithu_element14
    jithu_element14 over 4 years ago in reply to jithu_element14

    So is it because any other audio packages need to be installed or anything else. and is there any way to check whether BBB is able to detect the DAC circuit connected to it?

     

    Thanks,

    Jithu

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • jithu_element14
    jithu_element14 over 4 years ago in reply to shabaz

    Actually today i tried it on debian 7.9 with 3.8 kernel version.So the jorge-audio-cape overlay was successfully loaded to the slots. When i checked

    cat  /sys/devices/bone_capemgr.9/slots --> it showed jorge-audio-cape as well. But even after that when i tried playing audio mp3 file it was not giving me any sound as shown below:

     

    root@beaglebone:~# ffmpeg -i sample.mp3 -f alsa "default:CARD=Black" -re -vol 150

    ffmpeg version 0.8.21-6:0.8.21-0+deb7u1, Copyright (c) 2000-2014 the Libav developers

      built on Oct 21 2017 10:25:39 with gcc 4.6.3

    The ffmpeg program is only provided for script compatibility and will be removed

    in a future release. It has been deprecated in the Libav project to allow for

    incompatible command line syntax improvements in its replacement called avconv

    (see Changelog for details). Please use avconv instead.

    [mp3 @ 0x40b00] Estimating duration from bitrate, this may be inaccurate

    Input #0, mp3, from 'sample.mp3':

      Metadata:

        encoder         : Lavf52.66.0

      Duration: 00:00:03.45, start: 0.000000, bitrate: 127 kb/s

        Stream #0.0: Audio: mp3, 44100 Hz, stereo, s16, 128 kb/s

    Output #0, alsa, to 'default:CARD=Black':

      Metadata:

        encoder         : Lavf53.21.1

        Stream #0.0: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/s

    Stream mapping:

      Stream #0.0 -> #0.0

    Press ctrl-c to stop encoding

    size=      -0kB time=3.45 bitrate=  -0.1kbits/s

    video:0kB audio:594kB global headers:0kB muxing overhead -100.003617%

     

     

     

     

    root@beaglebone:~# mplayer -ao alsa -volume 20 sample.mp3

     

    MPlayer svn r34540 (Debian), built with gcc-4.6 (C) 2000-2012 MPlayer Team

    mplayer: could not connect to socket

    mplayer: No such file or directory

    Failed to open LIRC support. You will not be able to use your remote control.

    Playing sample.mp3.

    libavformat version 53.21.1 (external)

    Mismatching header version 53.19.0

    Audio only file format detected.

    Load subtitles in ./

    ==========================================================================

    Requested audio codec family [mpg123] (afm=mpg123) not available.

    Enable it at compilation.

    Opening audio decoder: [ffmpeg] FFmpeg/libavcodec audio decoders

    libavcodec version 53.35.0 (external)

    Mismatching header version 53.32.2

    AUDIO: 44100 Hz, 2 ch, floatle, 128.0 kbit/4.54% (ratio: 16000->352800)

    Selected audio codec: [ffmp3float] afm: ffmpeg (FFmpeg MPEG layer-3 audio)

    ==========================================================================

    AO: [alsa] 48000Hz 2ch floatle (4 bytes per sample)

    [AO_ALSA] Unable to find simple control 'PCM',0.

    [Mixer] No hardware mixing, inserting volume filter.

    Video: no video

    Starting playback...

    A:   3.1 (03.1) of 3.0 (03.0) 32.3%

    Exiting... (End of file)

     

     

     

     

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • jithu_element14
    jithu_element14 over 4 years ago in reply to shabaz

    Okay, but where is this bb-justboom-dac-00A0 overlay file available? is there any link available?

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
  • shabaz
    shabaz over 4 years ago in reply to jithu_element14

    H Jithu,

     

    I didn't, apart from a suggestion to use a different dts file and modify it. I have not tried this:

    Best approach might be to edit the bb-justboom-dac-00A0 overlay to disable HDMI audio.
    • Cancel
    • Up +1 Down
    • Reply
    • More
    • Cancel
>
Element14

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2022 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • Facebook
  • Twitter
  • linkedin
  • YouTube