Skip to content

Audio Module Construction

Daniel Høier Øhrgaard edited this page Mar 12, 2018 · 1 revision

Overview

The audio module consists of a Raspberry Pi that’s responsible for input and output. Three buttons allow users to control playback (next, previous, and play/pause), and an LCD displays information about the current piece of audio. The LCD is also connected to a potentiometer to control its contrast.

Since the Raspberry Pi’s built-in audio-output is very low quality and noisy, a dedicated DAC (digital to analog) “hat” (i.e. Raspberry Pi-compatible board) is added to produce a better audio signal at line-level amplitude.

A potentiometer is used as volume control, after which the signal is passed through a switched mini-jack, and then to an amplifier that drives the audio module’s speaker. If headphones are plugged into the mini-jack, the amplifier and speaker are bypassed.

The amplifier has a trimpot as its own output volume control, allowing the maximum speaker volume to be set.

Notes

Some parts can be substituted with alternatives, but the following instructions assume that the parts listed below are used. The parts need not be bought from the mentioned retailers; the links are only given for reference.

Prerequisites

The following assumes you know the basics of painting, soldering, woodworking, etc. in order to fully assemble a Klogskabet audio module.

Parts

Amount Part Reference/notes
1x Raspberry Pi (model B 3) http://dk.rs-online.com/web/p/processor-og-mikrocontroller-udviklingssaet/8968660/
1x Raspberry Pi power supply http://dk.rs-online.com/web/p/stromforsyning-netstikshus/9098126/
1x JustBoom DAC hat https://www.sparkfun.com/products/14319
1x AdaFruit MAX9744 20W amplifier https://www.adafruit.com/product/1752
1x 12V amplifier power supply (min. 4A) https://dk.rs-online.com/web/p/stromforsyning-netstikshus/8215348/
1x 2x20 monochrome LCD https://dk.rs-online.com/web/p/lcd-monokrome-displays/1359753/
3x Normally-open momentary push buttons http://dk.rs-online.com/web/p/trykknapafbrydere-og-trykknapomskiftere/0841609/
1x 16.5cm, 8Ω speaker https://dk.rs-online.com/web/p/hojttalerdrivere/4318563/
1x Female 3.5mm switched mini-jack http://dk.farnell.com/cliff-electronic-components/fc681375v/stereo-jack-3-5mm-panel/dp/2518213
1x 1kΩ potentiometer https://dk.rs-online.com/web/p/potentiometre/7456772/
1x Volume knob http://dk.rs-online.com/web/p/potentiometer-knapper/0499955/
1x 10kΩ potentiometer https://dk.rs-online.com/web/p/potentiometre/2499238/
1x Small right-angle bracket (optional)
2x Male mini-jacks (stereo) with “pig tail” wire attached https://www.adafruit.com/product/1700
6” female-female jumper wires (min. 5 individual wires) Bundle of 20 wires: https://www.adafruit.com/product/266
12” female-female jumper wires (min. 20 individual wires) Bundle of 20 wires: https://www.adafruit.com/product/793
20x Male 2.56mm pin-headers
Mounting screws, stand-offs, cable ties etc.

Additionally, the laser-cut audio module front panel and brackets should be prepared.

Alternative parts

As mentioned, the following instructions assume that the exact items on the list above have been acquired. However, some components can be substituted with very similar alternatives though they may require alterations to the overall design. Notable alternatives are:

  • The JustBoom DAC can be replaced with a HiFiBerry DAC+ (standard) (requires different software setup, and possibly different wiring)
  • The AdaFruit MAX9744 20W amplifier can be replaced with any other simple amplifier circuit that can take line-level input and drive a 8Ω speaker.
  • The speaker can be replaced with a a 13.5cm, 8Ω speaker, though the laser cut speaker bracket will need to be redesigned.
  • The switched mini-jack can be replaced with any other switched mini-jack (stereo or mono), provided wiring is altered to match.
  • The LCD can be replaced with another 2 rows by 20 character Hitachi HD44780-compatible display with LED backlighting (or no backlighting), though the laser cut front panel and LCD bracket may need to be altered to fit. The display can in theory be any Hitachi HD44780-compatible LCD, provided the audio player software is altered to account for changes in row/character resolution. Note: LCDs with cold-fluorescent backlighting draw significantly more current, and should not be powered through the Raspberry Pi’s pins!
  • The 1kΩ volume potentiometer (VR1) can be either logarithmic or linear.
  • The 10kΩ LCD contrast adjustment potentiometer (VR2), can be replaced with any 10kΩ potentiometer or trimpot, though it may need to be mounted differently to the front panel.
  • The 3.5mm mini-jack pig-tail cables can be replaced assembled from parts instead of bought as cable assemblies.
  • The volume knob can be replaced with any other volume knob that fits the overall look of the module, and that fits on the VR1 potentiometer’s shaft.
  • The push buttons can be replaced with other momentarily-closed push buttons, provided they fit the laser cut front panel and overall look, or the front panel is altered to match.
  • The power supplies for the Raspberry Pi and amplifier can replaced with any other compatible power supply (i.e. ones that supply the required voltage and current).
  • All solder connections can be replaced with pin headers/crimp sockets - and vice versa. The following instructions make use of both techniques to leave the circuit fairly friendly to disassembly and modification, but everything could be soldered in place instead or use crimp connections.

Tools

For software setup and testing

  • Computer monitor with HDMI input
  • HDMI cable
  • USB keyboard
  • Accessible WiFi or Ethernet cable

For electronics assembly and testing

  • Soldering iron + solder
  • Wire stripper
  • Cutting pliers
  • Heat-shrink tubing and heat gun
  • Multimeter (recommended)
  • A pair of headphones

For module assembly

  • Paint (same as for furniture)
  • Black paint for button symbols
  • Strong wood glue
  • Sandpaper (coarse and fine grit)
  • Superglue
  • Sharp knife
  • 13mm hex socket
  • Adjustable spanner
  • 1.5mm Allen wrench (unbrako) to secure the volume knob’s grub screw
  • Short wood screws for attaching components
  • Screwdriver
  • Hacksaw blade
  • Cable ties and cable tie pads
  • Hot glue gun or silastic

Raspberry Pi setup

See the general Raspberry Pi setup instructions and the readme for the receipt module software.

Electronics assembly

Audio electronics assembly

The basic audio assembly goes as follows: The line-out signal from the DAC is volume-controlled by the 1kΩ logarithmic potentiometer; from there it’s connected to the switched mini-jack; then to the amplifier’s line-in; and finally to the speaker.

If headphones are plugged into the mini-jack, the speaker is cut out, and audio only plays over the headphones.

  1. Solder pin headers to the top of the JustBoom DAC’s two long rows of through-holes. These are pass-through to the Raspberry Pi’s GPIO pins when the DAC hat is mounted. Note: Not all the pins will be (or should be!) used, so it’s not necessary to add and solder all 40 pins. Refer to the pinout diagrams below. Note: The JustBoom DAC comes with 4 threaded plastic standoffs and plastic screws and an IR receiver. The IR receiver won’t be used, but keep the plastic standoffs and screws for later!
  2. Assemble the amplifier (solder on capacitor and screw terminals)
  3. Cut a 3.5mm mini-jack pigtail cable down to about 30cm (and keep the piece of cable you cut off for later).
  4. Solder the ends of the pigtail cable to the 1kΩ logarithmic potentiometer: Ground/sleeve lead to pin 3. Left and right leads to pin 1 (since the output is mono anyway)
  5. Cut the loose piece from before down to about 30cm.
  6. Solder the loose length of cable to the 1kΩ logarithmic potentiometer: Ground/sleeve lead to pin 3 (same as above). Left and right leads to pin 2.
  7. Solder the other end of the loose length of audio cable to the switched mini-jack socket: Ground/sleeve lead to pin 1. Left lead to pin 2. Right lead to pin 5. (Alternatively, pins 2 and 5 can be connected with a bit of wire, and both left and right leads connected to either pin)
  8. Solder another 3.5mm mini-jack pigtail cable to the switched mini-jack socket: Ground/sleeve to pin 1. Left and right leads to pin 4.
  9. Solder medium gauge wires to the speaker’s terminals. Also tin the other end of the wires to prevent fraying.
  10. Screw the other ends of speaker wires into the amplifier’s left or right speaker output terminal blocks.
  11. Test the audio assembly:
  12. Mount the DAC on the Raspberry Pi
  13. Plug the mini-jack cable running to the potentiometer into the DAC’s line-out jack.
  14. Plug the other mini-jack into the amplifier’s line-in jack.
  15. Ensure the volume potentiometer is turned to low.
  16. Ensure the amplifier’s volume potentiometer is turned to roughly 50%.
  17. Plug in the Raspberry Pi’s power supply and let it boot
  18. Plug in the amplifier power supply
  19. The Raspberry Pi should begin playing a track automatically once it boots. Adjust the volume potentiometer and ensure the sound/music is coming through the speaker. Also ensure that turning the potentiometer clockwise increases volume, and counter-clockwise lowers it (if not, pins #1 and #3 on the potentiometer should be swapped).
  20. Plug in a pair of headphones (after lowering the volume, just to be safe), and ensure that audio plays in the headphones only (i.e. the speaker is cut out).
  21. Once satisfied, turn off all the components again. If things do not work, check all wiring, and that the Raspberry Pi’s software has been correctly installed and running.

Button assembly

The three buttons make use of the Raspberry Pi’s internal pull-up resistors, and are arranged to connect a GPIO pin to ground when pressed (i.e. momentary pull-low). I.e. the buttons share common ground on one side, but individual pins on the other.

  1. Cut off one end of 4 female-female jumper wires and strip 3-5mm of insulation.
  2. Prepare 3 push buttons by soldering a jumper wire to one of each button’s terminals.
  3. Solder the other terminal of the each button in series with small lengths of wire.
  4. Solder the 4th jumper wire to the series-connected side of one of the push buttons.
  5. Plug the free ends of the jumper wires onto the pin headers on the DAC: Series-connected to pin #9 (ground) The remaining three wires to pins #11, #13, and #15 (GPIO 17, 27, and 22 respectively)
  6. Test the button assembly:
  7. Turn on the Raspberry Pi and amplifier, and let the Raspberry Pi boot
  8. Test each of the buttons. One should go to the next track (pin #11), one should act as play/pause (pin #13), and one should go to the previous track (pin #15).
  9. Once satisfied, turn off all the components again. If things do not work, check all wiring, and that the Raspberry Pi’s software has been correctly installed and running.

LCD assembly

The LCD is a Hitachi HD44780-compatible parallel data bus driven display. It’s driven in 4-bit mode, with its R/W pin tied to ground. The LCD is also equipped with a 5V LED backlight with a built-in current-limiting resistor.

  1. Solder pin headers to the back of LCD board (i.e. pointing backwards from the screen itself). Note: Not all the pins will be (or should be!) used, so it’s not necessary to add and solder all 40 pins. Refer to the pinout diagrams below.
  2. Prepare 2x 1-to-3 spliced female-female jumper wire harnesses
  3. Connect the single end of one the spliced cables to pin #4 (5V DC) on the DAC.
  4. Connect (or cut and solder) one of the three loose ends to pin #1 of the 10kΩ linear potentiometer.
  5. Connect the other two loose ends to pins #2 and #16 of the LCD
  6. Connect the single end of the second spliced cable to pin #6 (ground) on the DAC.
  7. Connect (or cut and solder) one of the three loose ends to pin #3 of the 10kΩ linear potentiometer.
  8. Connect the other two loose ends to pins #1 and #15 of the LCD
  9. Connect a female-female jumper wire from pin #2 of the 10kΩ linear potentiometer to pin #3 of the LCD.
  10. Test the LCD power assembly:
  11. Turn on the Raspberry Pi.
  12. The display should light up (as its backlight is connected).
  13. There will not be anything readable on the display, since no data lines are connected, but you should see one full row of black blocks. If both lines are black blocks, the contrast is set too high; if nothing shows up, the contrast may be too low. Turn the potentiometer to adjust contrast.
  14. Once satisfied, turn off all the components again. If things do not work, check all wiring. If the display does not show a full row of blocks, regardless of contrast, it may be defective.
  15. Now connect the the remaining pins on the LCD to the remaining pins on the DAC in the following order: LCD pin #4 (RS) → DAC pin #29 (GPIO 05) LCD pin #5 (R/W) → DAC pin #39 (ground) LCD pin #6 (Enable) → DAC pin #31 (GPIO 06) LCD pin #11 (DB4) → DAC pin #33 (GPIO 13) LCD pin #12 (DB5) → DAC pin #37 (GPIO 26) LCD pin #13 (DB6) → DAC pin #38 (GPIO 16) LCD pin #14 (DB7) → DAC pin #36 (GPIO 20)
  16. Test the full assembly:
  17. Turn on the Raspberry Pi and let it boot up.
  18. Once booted, the LCD should display the title of the current track, and the current timestamp. Adjust the contrast as necessary to have high contrast while minimizing flickering during screen updates (updates happen each second while a track is playing - since the timestamp updates). Flickering means the contrast is probably set too low.
  19. Once satisfied, turn off all the components again. If things do not work, check all wiring, and that the Raspberry Pi’s software has been correctly installed and running. Checking wiring with a multimeter, the following should hold true: 1. Voltage across LCD pins #2 and #1 should be +5V 2. Voltage across LCD pins #16 and #15 should be +5V 3. Voltage across LCD pins #3 and #1 should be between 0V and +5V depending on the contrast adjustment potentiometer’s setting. 4. Continuity between LCD pins #1, #5, and #16, and a DAC ground pin.

Module assembly

  1. Test-fit the front panel in the furniture to make sure it fits with just a little bit of tolerance (to allow for layers of paint).
  2. Sand the front of the panel with fine-grit sandpaper to produce a smooth surface (do not sand the back of the panel, as it’ll be used for glue, and is better left rough).
  3. Paint the front panel (several coats should be applied and each allowed to dry for at least a day; the paint will fully cure/harden over several days). Note: The inner edges of the LCD and mini-jack cutouts should be sanded and painted. Other cutouts can be left unpainted. The speaker grill holes should receive only a single coat, and care should be taken that they don’t get plugged with paint.
  4. Paint the symbols onto the panel using the stencil, or vinyl cut the symbols and glue them in place.
  5. Glue the speaker and potentiometer brackets into place on the backside of the front panel. Be sure to carefully align the brackets with the cutouts in the front panel. Allow the glue some time to set.
  6. Screw the LCD loosely onto its bracket.
  7. Hold the LCD + bracket in place on the back of the panel to figure out where the bracket should be glued to properly align the LCD screen with its cutout. Mark the bracket’s position.
  8. Unscrew the LCD from the bracket, and glue it onto the back of the panel in the place you’ve marked. Allow the glue some time to set.
  9. Mount the mini-jack to its bracket. Its locking nut can be tightened by hand, by turning the jack itself, rather than the nut.
  10. Screw (or glue, using epoxy or superglue) the headphone jack bracket in place, again making sure to center/align it well with the cutout.
  11. Mount the speaker to its bracket. Be careful not to over-tighten the screws, but make them tight enough to hold the speaker so it won’t vibrate when playing.
  12. Mount LCD with four screws, making sure it’s still centred and aligned to its cutout.
  13. Carefully unmount the DAC from Raspberry Pi.
  14. Screw the Raspberry Pi into place with two screws and standoffs making sure its micro-USB power port can be accessed (align it so the power cable will run between the volume potentiometer bracket and the LCD bracket)
  15. Remount the DAC, and use 2 plastic threaded standoffs from the DAC to secure its “free“ side to the Raspberry Pi.
  16. Cut the two remaining plastic standoff in half, being careful to leave a clean, flat cut.
  17. Screw 3 of (halved) plastic standoffs onto the amplifier board as “feet”
  18. Use superglue to adhere the 3 plastic feet to the back of the front panel (making sure the surface is cleaned of splinters and the glue binds well).
  19. Mount the right-angle bracket in a convenient place using glue or screws.
  20. Mount the LCD contrast adjust potentiometer to the bracket.
  21. Unclip the switch housings from the push buttons, and insert the push buttons from the front, tightening the nuts from the back with a spanner. If the buttons came with a rubber gasket, that can be removed. Click the switch housings back in place. Note: After this, take care when moving/placing the panel, as it’ll have buttons standing slightly proud of the front.
  22. Mount the 1kΩ volume potentiometer - use the hex socket to tighten the nut holding the potentiometer in place. Note: After this, take care when moving/placing the panel, as it’ll have the potentiometer shaft sticking out the front.
  23. Test the whole assembly.
  24. Secure the loose wires with cable ties and/or hot glue/silastic. Hot glue/silastic is especially useful to hold the pin header-attached cables in place.
  25. Measure how much to cut off of the volume potentiometer’s shaft to fit the volume knob, and cut it to size (this can be done - carefully - with a hacksaw blade).
  26. Attach the volume knob, using a couple of sheets of paper to give it a bit of clearance to the panel itself.
  27. Plug in the power lines to the Raspberry Pi and amplifier, and secure the cables so they won’t be pulled out when mounting the module in the furniture.

And you're done!