Thank you for your donation!

Cloudsmith graciously provides open-source package management and distribution for our project.

Idea: Upgrading my DAC Hat
Yes, it is mechanical HAT form factor.

Tim, I would be honored to build one for you as a small donation for the use of Moode.
(01-22-2023, 04:25 PM)hifinet Wrote: Yes, it is mechanical HAT form factor.

Tim, I would be honored to build one for you as a small donation for the use of Moode.

Super nice and many thanks :-)

Shoot me an email and I'll provide shipping address.
Enjoy the Music! | Mastodon Feed | GitHub
ProtoDAC TDA1387 X8 is a perfect project for the beginner. This is probably the easiest DIY NOS DAC HAT build. The number of parts and parts cost can be low.  The TDA1387 is very easy to implement. It directly uses I2S from the Raspberry Pi as input. This circuit is very simple due to the use of passive I/V.  Please refer to the schematic diagram below. The sound quality of the finished DAC is excellent, especially when using premium components. 

There is this proto board version described below, which a seasoned DIYer could assemble in less than an hour. Gerber files for PCB. BOM file for the PCB.  For more updated information follow on the Moode home page and project page here.

[Image: TDA1541-yedek-ip-8-paralel-TDA1387-do-ru....jpg_.webp]

This DAC is based on a TDA1387 x 8 module (pictured above), which is designed as a direct plug in replacement for the famous TDA1541, which is now difficult to obtain. The TDA1541 was a flagship Philips multibit 16 bit DAC in a 28 pin DIP/DIL, and is older and more complex. The TDA1387 is a later development multibit DAC with current output, and simplified. The TDA1387 has only 8 pins. The module uses eight TDA1387 chips in parallel. It also contains decoupling capacitors and pin 7 capacitors. The module can be purchased on eBay or AliExpress.

Philips Designers Guide August 1997

[Image: 52691744170_5f9cd15552_b.jpg]

TDA1387 Datasheet

The TDA1387 x 8 module has only 8 active pins. Four I2S lines, pins 1,2,3,4 (pins 2 and 4 are the same: BCK). Two power supply lines, V+ pin 28 and GND pin 5. The other two pins are for right channel output pin 6 and left channel output pin 25. The other 20 pins have no connection. Eight power supply decoupling capacitors are mounted on the underside of the module, so it will remain stable with external power applied, without an external decoupling capacitor. The DAC is capable of 16 bits (LSBs over 16 are ignored) and up to 384kHz sample rate. Paralleling the TDA1387 increases the output current capability, and allows the practical use of passive I/V (passive components = fixed resistors generate voltage from current). The combination of I2S input and passive I/V allows for a very simple Raspberry Pi based NOS DAC HAT. 


[Image: 52689031891_8802aca972_b.jpg]
This DAC HAT is built on a GeeekPi Proto board HAT, and is designed for the Raspberry Pi with 40 pin GPIO. Hole spacing is 0.1" . Holes are plated through. The holes can pass up to 20 gauge wire (0.032" dia). GeeekPi is a Chinese tech company. SKU K-0335. The black board model number is X002KJBA7H . They sell the boards on Amazon and AliExpress here and here in four colors red, blue, black and green. Blue appears to be sold out.

Here is some info on the I2S inputs:

Module pin          I2S               Strip GPIO#                 GPIO pin
1                        WS(LRCK)          #19                           35
2                        BCK                  #18                           12
3                        DATA                 #21                           40
4                        BCK                  #18                           12

The GND strips connect to most of the GPIO ground pins, but not pins 6, 9 and 14.

Strip GPIO# (Broadcom I/O #) is the number on the GeeekPi Proto board

[Image: 71KX0G8sMlL._AC_SX466_.jpg]

TDA1387 x 8 Module Pin Assignments:
1           WS (LRCK)
2           BCK
3           DATA
4           BCK
5           GND
6           Right channel audio out
7-24      N/C
25         Left channel audio out
26-27    N/C
28         Vcc +5VDC

28 pin DIP/DIL package
[Image: 52689596475_72f2db0f6f_b.jpg]

Bench testing the Modules:
Idle right channel voltage pin 6 with 475R I/V resistor at 5.04VDC Vcc     Number tested=9  Average=2.19V  (4.6mA)  SD=0.014
Idle left channel voltage pin 25 with 475R I/V resistor at 5.04VDC Vcc     Number tested=9  Average=2.18V  (4.6mA)  SD=0.02

This DAC can be built on a various types of prototyping boards with 0.1" hole spacing, and using jumper wires to the Raspberry Pi I2S GPIO connections indicated below. The GeeekPi Proto HATs are actually cheaper than buying perf boards + 40 pin headers + standoffs separately. 

I2S Connections on the Raspberry Pi 40 pin GPIO

[Image: nJHoL.jpg]
Step 1

[Image: 52688594972_e73f19af02_b.jpg]

Note that there are many way of making the wiring connections. There may be better ways to wire the module for your particular application. The schematic is simple. As posted above, the module is only connected by pins 1,2,3,4,5,6,25 and 28. Note that pins 2 and 4 are internally connected.

The module takes up a considerable amount of limited HAT space. Removing all of the pins from the module and soldering parts directly to the module can help. Access to pins 6 and 25 can be limited, because the I/V resistors and output coupling caps connect there. Film caps can take up a large amount of HAT real estate.

Orientation: The orange semicircle on the bottom represents the orientation of the TDA1387 module. Components on this side, solder to the flip side.

Plan the positioning of the RCA jacks and drill any holes before placing any components. See below. RCA jacks should be near the display ribbon end, at the top of the board pictures.

Solder a 470R 1/8W metal film resistor between the holes on the blue line. The body should be close to the module. Use some stripped wire insulation to insulate the exposed wire going to #21, because it crosses over the 3V3 and GND strip.

Solder ground wires between the holes on the green lines. You can also solder the wires on the bottom of the board, which may give you easier access to the pin 6 strip.

Solder the chosen I/V resistors between the holes on the red lines. More info on the choice of I/V resistors to follow. If you are using bulk metal foil resistors with radial leads, lead spacing is 0.15". Note that orientation of the two resistors is opposite with regard to current flow to ground. With naked bulk metal foil, the shiny side with lettering will be facing outward for both resistors.

Right channel audio output: Pin 6 
Left channel audio output: Pin 25 

Solder IC pin jacks in the holes along the yellow line, six on each side. I get IC sockets with round pins and cut the plastic into strips of six sockets in length. The module has round pins. The full socket is a DIL 28 pin. You may also solder the module directly to the Proto board. I currently think the best method is to remove all of the pins from the module, and then solder the parts directly to the module. In the diagram, there are only two holes available outside of the module for connecting parts. There are two connections at strip 6 and two at 25. This is where the I/V resistors and output coupling capacitors connect. The capacitors are often large, and the leads may not fit the holes, and need to be soldered to the surface of the strips. The extra room is a benefit.

Omit the socket for pin 4 or clip the pin from the module, since it is a duplicate and not used. This circuit layout will not work if pin 4 of the module is connected to the board.
Choice of I/V resistor:

Type of resistor: Vishay naked bulk metal foil are unsurpassed, and sound very transparent with excellent detail. This may be due to the very low noise or noninductive design. The improvement in detail compared to other resistor types is dramatic. Bulk metal foil can be ordered to spec, but they are expensive. Metal film sound OK, and have the advantage in that they are abundant and cheap. I would recommend starting with metal film to hear the possibilities of the DAC, and then move up to Vishay metal foil resistors (if not Z-foil, then S-foil) if you think the DAC shows promise.

Value of resistor: Critical. The I/V resistor should be no larger than 430R for Vcc of 5 VDC.  I measured THD with 0 dB 1kHz sine wave input to the DAC with various I/V resistances. See the chart below. Distortion at 223.5R is measured at 0.0080% and at 322R it is 0.0097%, and THD increases linearly with resistance up to just past 430R. Then distortion starts to increase exponentially, indicating clipping.

[Image: 52688524257_19bdddaee6_b.jpg]

Excessive distortion is created when the DAC is clipping. Fortunately, the TDA1387 has a high voltage compliance of 3.5V at 5V Vcc. Clipping occurs if the AC signal exceeds +3.5V or 0V. The final calculation depends on the I/V resistance and the module with its particular characteristics (DC current at idle, and the peak to peak current at full signal).  The I/V resistor should be no larger than 430R for Vcc of 5 VDC.

Since there are variations in the modules, it would be prudent to measure the distortion with various resistances in the target range with your module, before buying expensive I/V resistors. This would be especially the case if you are trying to push the 430R limit or the Vcc maximum of the TDA1387. You can measure distortion with a computer, USB audio interface and REW. The most reliable method would be to use cheap metal films in 430R value, and check distortion with the variations in resistance values, based on accurate resistance measurements with a DMM. Another factor will be supply voltage, which can change full scale output current. So use the same supply voltage with the expensive I/V resistors.

The Vishay Z-foil resistors from Texas Components (TX2575) come in either 470R (too high) or 390R (possibly too low) as a standard resistance, but not 430R. They sell custom values for the same price. Charcroft does sell a Z-foil resistor in 430R. Note the tolerance is +/- 0.1%.

The output signal voltage decreases with a lower I/V resistor, and this may be a factor to consider in your particular system. Do you have a preamplifier that can amplify a weak signal from the DAC?

The value of the I/V resistor affects the choice of Vcc electrolytic decoupling capacitor in an inverse relationship. As the I/V resistor decreases, the capacitor needs to increase. If the capacitor is too low in value for the I/V resistor, the sound with be anemic, with weak bass and dynamics, but more 3D with deep soundstage. If the capacitor value is too high for the I/V resistor, the depth of soundstage will decrease. For a 430R I/V resistor, 1800-2200uF is about right. You can use capacitors in parallel for better sound quality. Additional caps can be added in the open area below the module and between the output coupling caps. Connect positive to the 5V strip and negative to the 3V3 side GND strip with jumper wires. Listen to various values by press fitting before soldering.

TeraDak TDA1387 x8 uses 390R I/V with 8000uF, which has a screen-like image (no depth). I have seen earlier versions with a 560R I/V resistor, so it seems they have corrected this problem with more recent versions. The larger capacitance somewhat compensates sonically for clipping. The L1387 USB x8 uses 560R with 1300uF. The I/V resistor is too high, clipping will occur at 0dB.

The source of Vishay S and Z-foil resistors in the US is Texas Components, and in Europe it is Charcroft . TX2575 are about $13 each without shipping. The TX2352 or S-foil is the "original" foil naked audio resistor, and are about $9 each. The Vishay S and Z foil resistors are vastly better performing in this DAC than other types.
I2S resistors:

430R or 470R generic 1/8 or 1/4W metal film. The purpose is to limit high frequency noise on the I2S lines. I have used unshielded 10cm jumpers to an outboard proto board without a problem. Mount close to the module.
Step 2

[Image: 52689415334_9aa877d2bd_b.jpg]

Orientation: The board has been flipped. Components on this side. Notice the strips for pins 1 and 28 are labeled in the picture.

Solder two 470R I2S resistors between the holes in blue. Resistor body mounted close to the module. Note that resistors are mounted on the underside of the board. You will need an insulated wire to solder between #18 and the resistor for BCK, since the path is long. The long lead wire should route straight down to strip 2 to avoid other solder joints. The exposed lead from the #19 resistor should also be insulated, since it crosses over the +3V3 and GND strips.

Solder ground wires between the holes in green. Note that the wires cross and should be separate. Mount one on the top side and the other on the bottom. The wire from pin 5 to 26 is a power supply ground. If you have removed all of the pins from the module, and are soldering directly to it, connect the ground wire from 5 to 27. The electrolytic cap positive will go from module hole 28 to strip 27.  Pin 4 to 23 is a signal ground (connects to the I/V resistors). The DAC will not work if pin 4 of the module is connected to the board.  There is ground on strip four. If pin 4 on the module is connected to ground, it will ground BCK and the DAC will not work. I simply clip pin 4 of the module, since it is a duplicate of pin 2.

Solder an insulated wire between the holes along the red line. This carries +5VDC to pin 28 of the module.
Step 3

[Image: 52689461790_c5d9519f53_b.jpg]

Orientation: the top side of the board. The TDA1387 x 8 module will fit approximately in the yellow outline. Note that 16 pins will be hanging in the air. They have no internal connections to the module.

Solder the 40 pin GPIO connector (connector on the under side, pins soldered to the top side).

This would be a good point to recheck all connections and solder joints. If everything looks OK, you can install the module on the board. You can use jumpers to ground the I2S lines at GPIO 12, 35 and 40, and then apply 5V to GPIO 2 and ground to GPIO 39. You should read 1.5-2.0 VDC on module pins 6 and 25. If the board passes, then power down and place the HAT on the Raspberry Pi. Power up Moode. Use either of the generic I2S DACs 1 or 2. Again verify the DC voltage on module pins 6 and 25. Then play a 0dB 50 or 60Hz sine wave track on repeat, you should measure an AC voltage (approximately 1.2 VAC RMS with a 420R I/V resistor) on module pins 6 and 25 with a DMM. 

Solder the 2200 uF audio grade electrolytic capacitor with negative in the green hole and positive in the red hole. I like the sound of Nichicon UKA 2200uF 25V. It is large in diameter for the available space and needs to sit above the board to allow access to the left channel audio output. Once the capacitor has been soldered in place, it will limit access to the pin 25 strip, which connects the I/V resistor and output coupling capacitor. The DAC will function without this capacitor, since power supply decoupling capacitors are contained in the module. The capacitor will affect the sound quality of the DAC.

Soldering the electrolytic capacitor should be one of the final assembly steps.

If you have removed the pins from the module and are soldering parts directly to the module, the positive of the cap solders to hole 28 of the module, and the negative is now able to solder to the outermost hole of strip 27. 

Be sure to check the polarity of the capacitor. Ground connects to green and positive connects to red. Irreparable damage to the capacitor will occur if this is reversed.

You can press fit different electrolytic capacitor values, and determine the value that sounds best to you. If you like the sound of a lot of capacitance, you can also add capacitors in parallel to the +5V/GND strip, if space permits. If the +5V/GND strips are covered by output coupling caps, there is also open space in the center of the board, between the module and RCAs, that can accommodate a very large amount of capacitance. You will need to solder jumper wires to the +5V and GND strips.
Step 4

[Image: 52688519647_47a5d35347_b.jpg]

The DAC is nearly completed. The last steps will take a little ingenuity, because it involves placement of the output coupling capacitors. These capacitors can vary considerably in size, quality and price. You may want to press fit these in place to try different types before soldering.

The value should be around 10 uF, but can be as low as 4.7 uF. With standard 10k impedence, 10 uF will give a low frequency -3dB of 1.59 Hz. 4.7 uF will give a low frequency -3dB of 3.38 Hz.  You want the low frequency cutoff to be well below 20 Hz, ideally less than 2 Hz.

A metal foil and film capacitor will be the highest quality, but physically larger and more expensive.  

A basic polypropylene metallized film capacitor is a WIMA MKP4 or MKP10 with radial leads. The lead spacing will be either 27.5mm (1.08") or 37.5mm (1.48"), which is slightly different from the 0.1" spacing of the board. The size is very compact for the capacitance. Digi-Key has MKP4D046806F00JSSD which is a 6.8uF 100VDC currently in stock. Price is about $4.29 each. WIMA MKP are commonly available, competent sounding and are a good choice for this project. Generally, most polypropylene capacitors will be satisfactory. Panasonic ECW and EZP PP caps are good, and relatively small for capacitance. PP caps can also be purchased from speaker components suppliers, where they are used as crossover caps. For example, Parts-Express, Madisound, Speaker City USA, etc. It is best to get the lowest voltage rating available, which will reduce the size. Panasonic, Solen and WIMA PP caps tend to be neutral sounding without any annoying qualities.  Humble Homemade Hifi has some capacitor ratings. 

Boutique film capacitors can be very expensive and are often too large for the available space on the HAT. Metallized polypropylene tend to be the best value.

Solder the right channel output capacitor to the hole of the red line near pin 6 of the module. Note that the right channel I/V resistor is also connected to pin 6.

Solder the left channel output capacitor to the hole of the white line near pin 25 of the module. Note that the left channel I/V resistor is also connected to pin 25.

Solder the left and right channel PC mount RCA output jacks near the top (near the display cable notch in the board). Connect the coupling capacitor to the signal (positive) of the RCA. Connect the ground of the RCA to the ground strips on the board.

You can also connect 1-2M ohm resistors from the signal (positive) RCA to ground, if you like. They are "politeness parts" and can prevent pops when you select then DAC with the preamp switch. They do affect sound quality, and I typically omit them.

I use RCA jacks as pictured below. They are available on eBay with search terms: RCA PCB DAC. They have a part number RJ-255. High quality parts use gold plated brass and teflon (PTFE) white insulator around the signal. Teflon has superior insulating properties, and is also extremely heat resistant. Typical plastics will melt with the heat of a soldering iron. I found some inexpensive parts at ELECbee , which are listed as gold plated brass, but the insulator is POM or ABS (i.e. not teflon). I have not found a Chinese supplier that uses teflon signal insulator.

If you are using chassis mount RCA jacks, it is best to use the type that have a soldered ground and mounting nuts on the outside. The ground is more secure soldered. With the nut on the outside, you can easily remove the RCA jack from the chassis without needing to desolder.

You can cut the trace on the board to separate the two poles, or bend the center signal wire to the next strip. You will need to drill two holes for the mounting post. Be careful not to drill into the 5V power tracing on the right channel side of the board, which is close. Plan the placement of the RCA and drill any holes before mounting any components. The left channel post hole center is 3mm from the top edge and 12mm from the side edge. The drill is 5/64". It is best to use a drill press. The right channel post hole will drill out most of the "G" in GND (centered 3mm from the top edge). Keep the drill clear of the "N", which is right over the 5V trace. Refer to the board layers in the picture below. Expect that you may need to do some fine filing to fit them straight. Soldering the RCA jacks is one of the final assembly steps. You can save board space by omitting the RCA jacks, and soldering wires from the outputs to external RCA jacks or a 3.5mm plug.
[Image: VAMPIRE-88330.jpg]
With a simple circuit like this, sound quality depends on 1) I/V resistor quality, 2) coupling capacitor quality and 3) power supply quality. With quality resistors and caps, I have run the DAC directly on the RPi, getting power from the RPi with a cheap SMPS (wall wart), and it sounds excellent. It sounds even better with an Allo Kali reclocker for low jitter and a better power supply. 

[Image: 71WYP0lUCIL._AC_SL1000_.jpg]

Changing the main Vcc electrolytic decoupling cap will affect the sound considerably. With a well regulated 5V supply and no cap, the sound is very 3D, with large soundstage and excellent depth, but also anemic with weak bass and no dynamics. The proper capacitor will add bass and dynamics, and maintain a good soundstage. If the capacitor is too large, the depth of the image will become very thin. There is also some dynamic range compression and peak limiting. The bass remains strong. Some people prefer this. The smaller the I/V resistor, the larger the capacitor. I would recommend 1800-2200uF Vcc capacitor with a typical 430R I/V resistor (audio grade Nichicon UKA are very good). It would make sense to press fit various capacitors in place and audition several values before final soldering.

I have tried stacking boards (by removing all the pins and soldering connecting wires through 1, 2, 3, 5, 6, 25, 28). The I/V resistor value needs to be halved and the Vcc cap doubled. This will reduce output impedence and noise, but I didn't think it was worth it. Noise is reduced 3dB with every doubling.

I have read that you can stack the chips directly, but SO8 are difficult to solder that way, and if there is a bad chip in the middle of the stack, you are in for an ordeal. 
[Image: img_1358-jpg.1049389]
[Image: 52689536553_9ecab61599_b.jpg]

Assembled DAC with CRC 10uF film caps (which, along with the module, physically dominates the available space) and Texas Components TX2575 naked bulk metal foil I/V resistors. The CRC (Component Research Corp) caps are metallized polycarbonate (similar audio properties to polypropylene), and are used pulls from military equipment. In my opinion, the audio qualities of PC and PP tend to parallel their optical properties. Polycarbonate is optically clearer than polypropylene, and is used in eyeglasses. I do not know of a current manufacturer of polycarbonate capacitors. WIMA made the MKC series polycarbonate caps. The 10uF at 40VAC is very compact 11x21x31.5mm (1.240" L x 0.433" W). No personal experience. PC was replaced by PPS. This dielectric apparently sounds excellent, and the capacitors are small in size. Both PC and PPS are hard to find. Polypropylene will be the easiest film caps to find.

An Allo Kali reclocker will reduce jitter and improve sound quality. Power applied to the Kali is providing power to the Raspberry Pi and DAC HAT.

Let the DAC "burn-in" for at least 60 hours before doing critical listening tests. The Nichicon UKA caps need a good 60 hours of burn-in time. 

A couple of notes. The output polarity of this DAC is inverted. Use polarity inversion in Moode. Configure...Audio...MPD Options...DSP options...Polarity inversion ON. This inverts polarity for both channels.

This DAC has no output filter. This creates a sinc droop or 2.5dB roll off at 20kHz. Also, ultrasonic images (for 44.1kHz sample rate the images are >24kHz) pass unimpeded. This could potentially cause IM distortion in the audio band with some audio equipment. On my system, I hear no problems in this regard. Analog filters on the output can cause significant problems with music. From this Burr-Brown data sheet "...the phase response of an analog filter with these amplitude characteristics [i.e. higher order (9-13 pole) analog filter] is nonlinear and can disturb the pulse-shaped characteristic transients contained in music." Your ears (or tweeters) will filter images > 24kHz.

If you think that you are getting IM distortion due to unfiltered ultrasonic images, you can try upsampling with SoX. Upsampling to 384 kHz will push ultrasonic images past 192 kHz. Images at this frequency would be unlikely to cause IM distortion in the audio band.  It will also correct sinc droop. In my experience, SoX upsampling sounds worse than the native bitrate with this DAC. Upsampling with PGGB and millions of taps does a much better job (request a free trial).
Hardware: ProtoDAC TDA1387 X8 | PGA2311 | Icepower 500ASP | Harbeth SHL5
Software: Moode 8.3.0
Source: Win 10 NAS

Forum Jump: