Kodi Community Forum

Full Version: My custom HTPC/Amp build
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Once upon a time i was using a lower end Sony bluray home theater system to provide 5.1 sound and play movies and such. It did work but it had quite a few annoying aspects to it, the main one being slow as heck as a lot of modern consumer electronics tend to be. Also the 5.1 audio it provided was not exactly terrific.

Eventually one day i decide that i can do better and go build my own HTPC to replace it. But i didn't just want to plug a PC in to a extra HDMI port and that it. I wanted to also replace the 5.1 sound system, but if i have a separate AV receiver to run it that's one more thing you have to turn on and off and fiddle with. I also wanted to be able to control the HTPC without turning on the TV when listening to music. As a result i resorted to building one from scratch.

This project was done about a year ago, but i decided to do a write up on it in a build log style since the project involves a lot more than just a building a PC from parts. Most of the components had there warranty voided due to being modified, there are electronics involved to make a 5.1 amplifier from parts, there is programming involved in other to make Kodi play nice with the front panel and remote etc.

Part 1


It all starts with a case. This case is the Chieftec HM-03SL-OP .Its made mostly out of aluminum, looks very Hi-Fi-y and is as quality built as it looks.

Once i had the case it was time to fill it with a computer. Its not exactly a monster but the requirement was that it should be able to decode all common formats at up to 1080p 60fps. Keeping the horsepower under the hood low also helps in making it quieter as this particular case does not have a lot of ventilation.

-Micro ATX Motherboard Asrock B85M Pro3
-CPU: Intel Pentium G3440T 2.8GHz
-RAM: 4GB DDR3 1600MHz Kingston KVR16N11S6
-SSD: Intel 530 120GB
-PSU: Chieftec PSF-400A 400W
-Sound card: Asus Xonar HDG


While the case is not particularly small it is not a standard PC case, as a result a special low profile CPU cooler had to be used. Since that Pentium CPU is so power efficient this small heatsink is plenty good enough once a low rpm fan gives it just a gentle breeze.(Even works with no fan if downclocked some)


Here is how the internals of the brand new case look like. Nice little plastic tray they screw in on the motherboard mounts to hold all the case acessories. Those include varius screws for mounting everythyng with plenty left over, adhesive cable ties and a IR remote control that works with the built in IR receiver (Can be trained to use other remotes tho).

In the bottom left are dual desktop hard drive mounts and a fan that is decent (It becomes pretty quiet once speed controlled down to about 30%). To the right of it is the optical drive mount that uses plastic standoffs for vibration resistance. Bellow that is a board that contains a USB hub, card reader and audio jacks. The weird cable in between the two belongs to the VFD display module on the front of the case. The remote allows for powering up the PC from a complete shutdown and as such it uses the 5V standby rail that is only available on the motherboards ATX power connector.(This ugly cable gets taken care of shortly)


Here is what that VFD display on the front looks like. I quite like the retro look of it and it is not too bright so it wont be blaring at you in a dark living room, alto as a result it does get hard to read in the sun. When the PC is off it also can display the date and time in this ugly format so i rather disabled that feature.


And here is how it looks like in its natural habitat.

In the next part i will go over adding the 5.1 speaker amplifier in to this case and how to make it work with the PC.

EDIT: Fixed photos
Looks really cool !!

I am particularly interested in the second part, as I am currently without an amp on my bedroom PC and the audio output is rather less than reasonable at the moment.
Moved to hardware showcase. Nice build though.
Part 2
The amplifier

Now that we have a working computer its time to put together the speaker amplifier so that it can be installed. For this purpose i bought some ready made amplifier modules ( http://www.banggood.com/TDA7492-2x50W-D-...35957.html ) Each one gives me a pair of stereo channels so i use 3 of those to get the 6 channels i need. The important part is that they are D class amplifiers. This means they are very efficient so that i wont have to get rid of a lot of heat in such a tight spot.


These modules need DC power between 18 to 30V so the existing power rails on the ATX power supply can't be used. Even if they could run from the 12V rail there would likely be problems due to noise as all the major parts of the PC run off that rail and spit electrical noise on to it. So to provide my amplifier with juice i am using this standard power supply module that takes in 230V mains and creates 24V at 150W. This particular one is a TDK-Lambda LS150-24


As you can see these power supply modules have no power switch on them. They simply turn on as soon as you plug them in, while we want it to turn on whenever we turn the PC on. This is where things get serious and we bring out a soldering iron. We add in a relay(blue and black boxy thing) inside the power supply and connect its coil to the 5V rail of the PC. That way when the PC turns on we get power on the 5V rail, that power turns on the relay and causes it to connect the power supply to the mains and so turns on the amplifier. There are a few more wires in that photo because i also wired a mute signal to the amplifiers. This is because the way this power supply turns off it causes the amplifiers to create a slight pop in the speakers. Muting the amplifiers when the power supply turns off seams to completely eliminate that issue. If you are not experienced in electronics do NOT do this on your own.


To hold it all together i simply made some plastic standoffs and screwed them in to the convenient grid pattern on the power supplies case. This is now a self contained amplifier module ready to be installed in to the PC.
Part 3
Preparing connections

Here is then the battle plan on how to wire it all up once inside. First we need to get mains power from somewhere. To do that we need to open up the ATX PSU and add a wire for that. Then we also need to get the audio from the sound card to the amplifier and lastly we need to bring the outputs of the amplifier to the back panel where you can connect speakers to it.


Lets start by modding the PSU to get what we need out of it. While we are at it we can take care of the ugly front panel display adapter cable from before. I simply cut off the adapter and soldered the wires directly in to the power supply. Once that was done i also soldered another cable on to the mains input connector and fed it trough a hole i drilled in the back of the power supply. Cable is fed trough a cable gland to hold it and keep it from getting cut on the sharp metal

Image Image Image

Now that we have a power cable ready for the amplifier we still need to get some audio signals to it. First of all the PCI mounting bracket has to be swapped out for a low profile one, luckily the sound card comes with one of those. The card also has some connectors on the top for getting audio out of it, but those are only for stereo or SPDIF so are useless for what we want to do. Because of that i had to solder a cable on to the rear panel connectors to get all 6 channels i need for 5.1. The connectors on the ends of those cables can then plug in to my amplifier module.

Image Image

Lastly we need to get the amplified audio out of the case so we can connect speakers to it. To do this i cut down a PCI bracket from a old network card in order to make it a low profile bracket and made a hole in it for the connector. A DB-15 connector (Used to be used for the game port in the old days) was then put on some cables and installed. A cable with a matching connector is then used to connect the HTPC to the junction box in the wall that brings in all the speaker cables.

Image Image Image
Part 4
Putting it all together

Now the case has all the connections required for the amplifier, but in order to make room for it the hard drive mounting bracket had to be removed from the case. So to mount the SSD i simply drilled some extra holes in the optical drive mounting bracket and used that instead. Also to mount the amplifier module some extra holes had to be drilled in to the bottom of the case.

Image Image Image

Now we just need to put in all the other bits like optical drive and fans. Since we want to make the most out of the limited airflow in the case it is very beneficial to duct the air to where we want it to go. The strange fan at an angle is there to provide airflow over the motherboards chipset as i noticed it gets pretty hot in this case configuration. To test how effective this was i used cardboard, i meant to buy some plexy and replace it once i knew what works, but i never got around to it. Works perfectly fine tho.

Image Image

This is it for the hardware part of things. The next part will go over the software for making it all work.
Really cool device!

I like the idea to combine all functionality into one device. Currently I try to achive the same with my setup, which supports gaming (windows & steam), developing (currently Windows and Linux) for Kodi, internet, e-mail and of course htpc functionality through Kodi (PVR, BluRay...). The only thing that I currently miss is a nice LCD and a amp class D amplifier.

More details will following when I publish my thread about my HTPC.

Thanks for the hints with the amplifier.
Great concept, love how you excuted your ideas, including(!) the card board ducts (please don't even think about replacing those!) and excellent documentation of your project. Gee, I haven't touched my soldering iron for at least 10 years, but somehow feel the urge to go and solder stuff together now... ;-)

Hat's off to you, Bernie8k! Awesome build!
Would love to see what you come up with wisler.

Thanks for the comments. Don't be afraid of the soldering iron as long as you hold it on the right end. Tho i did void the warranty on almost every component in here.

I am an electronics engineer so i felt pretty comfortable making the amplifier from parts. You can still buy amplifiers as complete modules where you put 220V in to it along with the audio and out it goes in to the speakers. But do be careful when working with mains voltage, ask someone when not sure.
Part 5

Now to make it all work. Getting Kodi to run on windows is not exactly rocket science, download, install and away we go. Next thing is installing the software and drivers for the VFD display on the front. This is actualy a OEM module made by SoundGraph called iMON. It is usually offered as a optical drive bay module http://www.soundgraph.com/vfd-feature-en/ but in my opinion it looks miles better when worked in to the design of a HiFi style case. Along with it also goes a IR remote to get you the full HTPC package.


Pretty much every button on the remote is user configurable inside the software. You basically assign a keyboard combination to each button, and it is even capable of switching between key mappings depending on what application is currently in focus. The two push-able knobs on the front panel are treated the same as all the IR remote buttons, letting you map anything you want to it. There are also certain low level things you can assign to a button such as power on. Pushing that button is able to turn the PC on from even the lowest power states since it does so by sucking power from the 5V standby rail and turns the PC on by emulating the front power button being pushed. Once the PC is running that button is handed over to software control so that you can set it for example to go in to sleep mode rather than turning the PC off. Very nicely done in my opinion.


I wont go over the entire button layout im using but for example here is what the front panel knobs are configured for:
Left Knob:
-Turn left: Volume down
-Turn right: Volume up
-Push: Mute
-Long push: Win+Shift+K (Used to launch Kodi)
Right Knob:
-Turn left: Scroll down
-Turn right: Scroll up
-Push: Enter
-Long push: Backspace

Such a button layout allows me to do pretty much everything from the front panel (After some adjustments). Now since this HTPC was meant for also playing music (local or radio streaming) it would be nice if it was navigable without having the TV turned on. This means that i want Kodis menu structure to show on the display as i am navigating trough it. The first thing to try is to see what can be set in the iMON software to get us that. As you can see there are various things that the display can show (Including a audio spectral VU meter that is actually pretty neat) and one page actually has a Kodi checkbox. Sweeet!...well it could have been if i got the thing to work. I was fiddling about with stuff and nothing really worked that well. Then i found a LCD plugin for Kodi, but it was outdated and i never really got anything good out of it.


Also if you used Kodi you will know that just a scroll wheel is not enough to move trough Kodis menu structure due to the main menu being able to move in 4 directions. Luckily that was easy enough to solve by getting a skin with vertical menu support. I know its not the prettiest of skins but it gets the job done. Also this particular skin features customization menus and that let me add a Radio menu that lists all the files in a directory where i keep *.m3u files for streaming radio stations.


So menus are nicely navigable now but i still don't have the menu items appearing on the VFD display as i wanted. I looked around for ways to do it but nothing seamed to work all that well. So i have decided to take matters in to my own hands and wrote a program to do exactly that. First i needed access to the VFD display. Because of the display being completely proprietary i had to use the software that came with it, luckily there is an API interface to the display for showing text on it. But unluckily the API was thrown together just before they decided to stop supporting the product, forum contains broken links, no documentation etc. Eventually i managed to scrape together the API DLL and some code that used it to figure out how to work it. To save anyone else the trouble i posted a small example of how to do it using Visual Studio https://sourceforge.net/projects/imondis...mplevbnet/ . Once i had that working i had to pull the required information out of Kodi. I already got a good hint of how to do that when trying to make the original iMON software work with Kodi. There are multiple ways to do it but i went for a TCP based JSON-RPC that is turned on here:


This makes Kodi start listening on TCP port 9090. All you have to do is connect to the port and send it commands in json format. The list of all available commands is here JSON-RPC_API/v6 (wiki) . Using this you can for example make Kodi play a file by sending this string over TCP


It looks a bit complicated because its designed to be very universal. It allows you to do a lot more advanced stuff like pull lists of files from the library, create playlists, adjust most settings etc. One of the interesting ones for me was using it to read the global property "GUI.Property.Name" and "GUI.Window" These two contain the text of the currently selected button and the where in the menu structure you are. Pushing those two to the display means you can pretty much navigate trough everything now. So i got to work on the software.


All in all its about 1000 lines of VB.net code (I know C# is better but i come from VB6 when it comes to windows development, i prefer raw oldschool C)


This is what the end software looks like


Its not the fanciest looking of things but its just for setting it up, in day to day use it stays hidden in the tray.


It uses a few DLLs around it to make it work while it stores various settings in *.ini files. The imon DLLs are the API to it and some wrappers to make it work well in .net. The CoreAudioApi is a interface to the modern windows sound API, but i don't actually access the sound card in any way, i just use it to check the system volume setting. This is used to show the volume on the display when you are turning the volume knob or pushing the volume buttons.


Here is an example of it in action, pulling information from Kodi. It works for pretty much all menu structures. For when Kodi is on the playback screen this switches over to showing the current track along with the time (Can also optionally blank out the display when playing back video).


There are also other features like for example showing information about the currently active window. This is in case something pops up over it when you are navigating without the TV turned on. Its not comprehensive enough to actually let you navigate trough programs but gives you an idea where you are.


There are also other small features i put inside of this app for convenience. That Win+Shift+K shortcut you saw earlier is intercepted here and is used to bring you in to Kodi. When you press it the app checks if Kodi is already running. If it is not running then it simply runs it, otherwise it finds the window that belongs to Kodi and brings it to front and in focus so it can be interacted with. Additionally it sends Kodi a command to jump to the home screen aswell as stops the playback if anything is playing. This lets you easily get in to Kodis main menu no matter what by just pushing a button.

Additionally since this is being used for internet radio its nice to map your favorite radio stations to a few buttons. I have mapped less useful area of the IR remote to pressing the Shift+Alt+F1 to F9 keys. Upon detecting one of these the app looks up what radio station is mapped to that key and sends a command to Kodi to play it. Additionally since we found ourselfs listening to the radio on it each morning i added a small feature to do it automaticaly. If the HTPC is woken from sleep mode between those two times it will automatically tell Kodi to play a file (In this case a *.m3u pointing to a live stream)


This is pretty much it for the build. It has taken a good deal of work to get all of this put together and working but it was worth it. The unit is used pretty much daily to listen to media and as a set of speakers for the TV. This being run on windows it did have a hiccup here or there, but nothing a reboot doesn't fix. Since there is no PC on that floor of the house it turned out pretty convenient to have the HTPC sitting there for checking something on the web and similar. As you have noticed there is only a SSD as internal storage. To provide the actual storage for media a external 1TB USB 3.0 hard drive is used. I don't keep a ton of content around so it is good enough. It is still connected in to my home LAN over gigabit ethernet so i can always just put up a big NAS if i need tons of storage, for now i use the HTPC itself as a NAS by sharing the USB hard drive over the network in order to drop files on to it for playback.

Despite being on for most of the day the dust situation is not all that bad due to the fine mesh air intakes cleaning up the air. On the down side the meshes do restrict the flow a lot, but as there is not much horsepower under the hood there is no need for a lot of cooling in the first place. I do have another powerful gaming PC on the network so games could be streamed from there if i really wanted to use it as a gaming console.

Hope the build log inspired any of you to create something for yourself. Its not that hard, no need for a ton of experience to do something like this.

I would love to hear what you think of my build.
(2016-05-10, 20:58)Berni8k Wrote: [ -> ]I am an electronics engineer so i felt pretty comfortable making the amplifier from parts. You can still buy amplifiers as complete modules where you put 220V in to it along with the audio and out it goes in to the speakers. But do be careful when working with mains voltage, ask someone when not sure.

Many thanks for your concerns and empathy, but complete modules are boring and IMHO wouldn't do justice to the beauty of your project!

Thanks god I'm a theoretical physicist. We know absolutely EVERYTHING, are always able to predict what SHOULD have been done and analyse what went wrong AFTER we messed up, which is pretty much all the time. Not afraid! Wink
(2016-05-10, 21:37)M4tt0 Wrote: [ -> ]Thanks god I'm a theoretical physicist. We know absolutely EVERYTHING, are always able to predict what SHOULD have been done and analyse what went wrong AFTER we messed up, which is pretty much all the time. Not afraid! Wink

We have a saying that "If you never let the smoke out of anything you never worked on electronics" sort of our take on learning from mistakes.

This project had its fair share of hiccups along the way, but luckily no expensive ones. That issue with the amplifiers causing a audible pop when powering off, had problems with the noise of the CPU getting in to the audio because of doing grounding wrong. Also had the PC wake up from sleep mode on its own constantly, eventually traced that down to the sound card and figured out if i use it in the 16x slot the problem went away for some odd reason. The amplifiers had too much gain and would clip when turning the volume past 30% so i soldered in some resistors to attenuate it down to where clipping was a little bit past 100% volume... etc. Solving such problems does help a lot to know what you are doing, but hey there are a lot of even smarter people on the internet.

Yeah, I would have stumbled at step 1 already. How long did your project take actually?
(2016-05-11, 19:52)M4tt0 Wrote: [ -> ]Smile

Yeah, I would have stumbled at step 1 already. How long did your project take actually?

Well it has taken a week of work, roughly half of it being the software. But obviously the project was planned in advance by a few weeks to get the parts together, Most of it was easy, just some parts like the amplifier modules take a while to get here due to being from china and such. By far the most dificult thing to get was the case. Such cases are not common on the cheep and this one was nowhere in stock so i had to wait for it, but it was totaly worth it(Also most expensive component of the whole build)