How to build your own PC

November 1st, 2010

This is a beginners guide to building your own PC from start to finish. Building your own PC is easier than you might think, you can build a computer that matches your needs as closely as possible and it will cost less money than buying one pre-built.

What do you need from your computer?

The most important thing about building your own computer is to determine your needs. For example, will you be playing 3D games on it? Do you need to be able to take it places? Are you on a budget? Does it have a particular purpose such as a NAS or a home theatre PC? etc.

The issue of portability decides whether you need a desktop or a laptop. The majority of laptop owners I know never unplug their laptops, they leave them on their desk plugged in all year. This tends to ruin their batteries and means that when they eventually do unplug their laptops on those very rare occasions, they cannot hold enough charge to make them portable anyway. This is the situation in which you should be using a desktop instead of a laptop. The best solution may be to build a powerful desktop for everyday use and buy a cheap laptop such as a netbook for taking with you on the go, if your phone can’t already do everything you need when you’re away from the computer anyway.

For this example I will assume that the desktop does not need to be portable and will play some 3D games as well as watch high definition video content, but be built on a low budget. This is quite a common scenario.

Choosing hardware

In every computer there are some essential components. These are:

  • Motherboard
  • Processor (CPU)
  • Memory (RAM)
  • Power supply unit (PSU)
  • Storage (hard drive)
  • Case

Optionally, most computers also have:

  • Graphics card
  • Optical drive (DVD/Blu-ray)
  • Peripherals (mouse, keyboard, monitor, speakers, printer, etc)

You will also need an Operating System, such as Windows or Linux.

Motherboard
The most important piece of hardware to choose is the motherboard. In recent years, more and more of the core components of the computer have migrated to the motherboard. It is generally no longer necessary to purchase a discrete network card or sound card, for example. If you do not need good 3D graphics performance, you can get a motherboard with integrated graphics, such as an Intel G45 or H55 (with CPU graphics). In this example, we will be using a discrete graphics card for performance 3D graphics but other on-board motherboard features such as networking, sound and storage controllers will be fine.

The motherboard determines which CPU, memory and graphics card you can use, among other components, and the size of the case required. If you need a smaller case, you may need a Micro ATX motherboard.

Once you know which features you require, the best motherboard to choose is generally the least expensive Asus motherboard you can find with all of those features. The choice of an Asus motherboard is partly my personal preference but mostly my experience with motherboards of various brands. MSI and Gigabyte motherboards are OK too but I have had problems with them in the past and never had a problem with an Asus motherboard, despite the fact that I use them more than any other brand of motherboards. In addition they are excellent for overclocking, if you choose to do that, and offer great features for doing things like flashing a new BIOS directly from it.

The Asus P7P55 LX is an inexpensive P55 motherboard in the ATX form factor, uses Socket 1156 for Intel Core i3 and i5 CPUs, has 4 DDR3 memory slots and a PCI-Express 2.0 x16 slot for the graphics card (and another with x4 bandwidth for AMD crossfire, if you get two AMD graphics cards). It also has gigabit ethernet, 7.1 audio, 6 internal SATA 3gbps ports for connecting hard drives and optical drives and 8 rear USB 2.0 ports.

Processor (CPU)
Because the motherboard is Socket 1156, we need a CPU that fits in that socket. The Intel Core i5 760 is a good quad core CPU running at 2.8GHz. It does not have on-board graphics but we don’t need them.

Memory
For memory there is a sweet spot between performance and price. In this case, we need DDR3 and 1066, 1333 or 1600MHz. We also want something with heat sinks on it so that it doesn’t overheat. To check for this, just make sure you can’t see the individual chips on the modules – there should be a metal case around the whole thing. Corsair is an amazing brand for memory and the standard for most overclockers. 2GB of Corsair Value Select 1333MHz DDR3 will do. 4GB if you want to get more.

PSU
A common misconception with power supplies is that bigger is better. However, a quality power supply will provide smoother power and this allows for a longer life for your hardware and more stable overclocks. In general, if it has all of the connectors you need, it provides enough power. Unless you are running multiple graphics cards, a 500W PSU will be plenty for most computers. It will not draw this much power if you don’t need it. Enermax make excellent PSUs but they tend to be on the expensive side. Other brands such as Silverstone, Cooler Master, Antec and Corsair are fine but beware of strange brands.

Whether it is modular or not is up to you. Modular PSUs allow you to change which power cables are connected to it, which can make them easier to use and tidier but doesn’t have much of an effect on performance. There is some debate as to whether modular PSUs are better or worse than normal PSUs but most people won’t see a difference.

Bigger fans tend to be quieter, so 80mm fans on a PSU may be quite audible. The Corsair CX500 should be fine and is reasonably priced.

Storage
For hard drives, get a Seagate or a Western Digital drive. For solid state drives, Intel is great but can be quite expensive. OCZ are still good but less expensive. Avoid Hitachi if you can. The 1TB Seagate Barracuda 7200.12 is good value and has good performance.

Case
This is really down to personal preference. The case should have good cooling and ideally be as quiet as possible but mostly you just want one that you like the look of. Antec make some pretty nice cases that are reasonably priced, such as the Antec P183

Graphics card
Your choice here is either NVIDIA or AMD (formerly ATI). NVIDIA cards tend to be more powerful and offer features such as PhysX but also tend to be more expensive, so are great for people building their machine to be as powerful as possible. AMD graphics cards tend to give better value for money, so are great for system builders on a budget. The motherboard chosen earlier supports Crossfire but not SLI, which means you could use multiple AMD graphics cards but if you use NVIDIA you can only use one. Using multiple graphics cards means that you can start smaller and add another card later to give performance a boost, but you may prefer having a single good card. As this example is on a budget, an ATI Radeon HD 5750 is a reasonable choice right now. The 6000 series will probably be better at the same price range but as of this post, the 6850 is the least expensive card in the 6000 series and is still quite expensive.

Optical drive
DVD drives are roughly £15 to £20. Blu-ray read-only drives (can still write DVDs, just can’t write Blu-rays) are down to about £50. It’s your choice, and you will probably need to buy extra software such as AnyDVD HD or PowerDVD to actually watch Blu-rays. In addition, you need a roughly 22″ or bigger monitor to be able to view them in 1080p. If you go for DVD, just about any writer will do so go for the least expensive. If you go for Blu-ray, the Samsung SH-B123L 12x is a good choice.

Peripherals
Keyboard: Get something that feels good to type on. This usually means deep buttons that click when you type on them. Shallow buttons that are quiet may seem nicer but if you type a lot they will probably start to hurt after a while and may make touch typing more difficult. Luckily, most of the cheapest keyboards available are also very nice to type on. Logitech is a good brand in general for keyboards.

Mouse: Don’t get a ball mouse. Other than that, get as cheap as you can get. A cheap optical mouse with a scroll wheel is probably best unless you like having lots of extra buttons. Razer make some excellent gaming mice (and mouse pads) but they tend to be expensive.

Monitor: At the very least get something with a DVI input and 720p resolution. Ideally get something with HDMI and 1080p. Ignore dynamic contrast ratios as a useless statistic but get something with a good viewing angle if you can. If you want built in speakers, a small HDTV might be what you want. A single HDMI port means that you can get a HDMI switch and have multiple inputs, if you want to use the same screen for a game console, for example. Just don’t get a very large screen with a low resolution if you’re going to be staring at it all day. 19″ is a good size for 720p (1366×768, for example) and 24″ is a good size for 1080p (1920×1200, for example). Bigger TVs require you to sit further back to view them comfortably so a 40″ screen 1 metre from your eyes will not be comfortable to use over long periods.

Speakers: Cheap stereo speakers will probably do. Bulkier speakers will probably sound better. If you need something more then you’re probably an audiophile and know exactly what you want anyway. Just because the motherboard does 7.1 sound, it doesn’t mean you have to use it all.

Building it

Now that you have all of your parts, it’s time to start building it. The first thing to do is put the CPU in the motherboard. Be very careful and earth yourself to avoid static while you do this. You can earth yourself by plugging the PSU into the mains electricity supply without turning it on and simply touching it (or touching the case it is in), or touch a tap or radiator, for example. Take the motherboard out of its anti-static packaging and place it on top of it.

Lift the lever on the motherboard CPU socket. Remove the protective cover and insert the CPU. Note the notches on the edge of the CPU so that you insert it in the correct direction. There will probably also be a triangle in one corner. Put the lever back down to lock the CPU in but do not force it. If you need to force it, you have probably put it in wrong and will break it by pushing too hard.

Next put the heatsink and fan on the CPU. On Socket 1156 CPUs this tends to be done by pushing on opposite corners diagonally. Make sure the cable will reach the fan header for the CPU on the motherboard and plug it in.

Screw the PSU into the case (screws on the rear). You can connect the power supply cable to earth it but keep the PSU switched off.

Screw the motherboard into the case. There will probably be 9 screws for an ATX motherboard.

Look for the power switch connector coming from the front of your case, and plug it into the correct pins on the “front panel” connector on the motherboard. This will be a long set of pins in the bottom-right corner of the motherboard near the SATA ports. You may need to look at your motherboard manual to see which pins are for the power switch.

Pull the tabs on the memory slots back and push the memory into the slots on the motherboard. You can tell which way around it goes by the notch near the middle of the module. It will only go one way so don’t force it. It helps if the motherboard is lying flat while you do this. Push the module into the motherboard on either end until the tabs click back into place, then push the tabs in to make sure they have locked. The memory should be pushed in securely by the same amount over its length – it should not be sticking out more one one end than the other.

Put the graphics card in the top PCI-Express x16 slot. This will be the longest horizontal slot on the motherboard, closest to the CPU and may be a different colour to the other slots to indicate that it is the primary slot for use with your graphics card.

Now that you have all of the main components installed, you can connect them up. Put the 24-pin power connector from the PSU into the motherboard. It will only go one way. Now put the 4 or 8 pin power connector into the motherboard in another slot near the CPU. This is very important and often forgotten. Plug a 6-pin PCI-E power connector into the graphics card.

Screw your hard drive and optical drive into the case and connect both of these to the PSU by the SATA power cables (flat connectors with an orange wire) and into the motherboard by the SATA data cables.

At this point, the inside of the computer should be complete. Plug the keyboard, mouse, monitor and network cable into the back of the computer. Flip the switch on the PSU and then press the power switch to turn it on.

Once it is working, you may want to go back and plug in additional cables, such as the front USB cables, LEDs, front audio cables and the reset switch.

Faulty hardware

If you think your hardware has a manufacturer defect, you can send it back for a RMA to get a replacement. However, you need to be sure of which part has failed and be able to reproduce the problem. Remember that the shop will test your part and if they can’t find a problem with it, they will just send it back to you and you will have wasted money on postage as well as been missing the part for probably a few weeks.

If you are in the UK and buy your parts from scan.co.uk, they offer “scansure insurance” against you damaging it during installation. If it is your first time building a computer and you have ordered expensive and fragile parts, such as CPUs, this may be worth getting. If you are just buying cables, for example, it is probably not. Always check whether you want it or not before you buy because it is added to your order by default on that website. I also once had an issue where they wouldn’t let me return a part for a replacement even with this insurance because I had opened it but not damaged it, claiming it was not resalable, which is crazy because it would have been even less resalable if it was damaged as the insurance covered.

“Pingbacks”

October 10th, 2010

Can someone explain the point in “pingbacks” to me, because to me it seems like someone just ripping off my posts and pretending they are their own, with no reference to the original post and only using pingbacks to spam the URL of the duplicate article.

(serac.universal.edu.au/blog)

WordPress’ description of pingbacks suggests that they are just remote comments, but as the other site just copied the content verbatim with no additional comments, and even copied site-wide preferences such as the “tagline”, this doesn’t seem right.

Printer friendly Fudzilla RSS

September 29th, 2010

Fudzilla is a nice site for catching up with daily tech news. I prefer to set up my email client Thunderbird to aggregate the RSS, but when you have a 1920×1200 monitor and Fudzilla still puts so much crap at the top of the article that it ends up looking like this and you have to scroll down before you can even read a few lines of text, its becomes a terrible user experience.

Wouldn’t it be better to get the text at a reasonable size, taking 100% of the width available, with no crap at the top that you have to scroll past?

Well, you can. The printer friendly view does all of this, and all you have to do is change the link in the RSS to use the printer friendly URL instead of the standard one. Here is some php do do just that! Just put this on a server somewhere and subscribe to that URL instead of the normal fudzilla feed.

<?php
header("Content-Type: application/rss+xml; charset=utf-8");
 
$url = "http://www.fudzilla.com/?format=feed";
 
$rss = fopen($url, "rb");
$contents = stream_get_contents($rss);
fclose($rss);
 
$contents = str_replace("?</guid>", "%3f</guid>", $contents);
$contents = str_replace("</guid>", "?tmpl=component&amp;print=1</guid>", $contents);
echo($contents);
?>

You may be able to just view the description in your RSS aggregator, but it tends not to show the whole article. In the past, fudzilla has put just the subtitle in there, for example.


Update: This has been broken by fudzilla using a HTTP 302 redirect and a cookie but anything that will take the cookie from the first request and use it for the second request should be able to handle this easily. Here’s a function for it that uses cURL.

function download_string_curl($url)
{
  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_AUTOREFERER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
  curl_setopt($ch, CURLOPT_COOKIEFILE, "THIS_FILE_DOES_NOT_EXIST");
  $contents = curl_exec($ch);
  curl_close($ch);
  return $contents;
}

As a note to Fudzilla: This is only necessary because of the sheer amount of crap you put at the top of your page. You shouldn’t have to scroll down an entire screen height before you can even see the content of that page. That’s just poor design. If adding cookies and a redirect was an attempt to stop screen scraping, it didn’t work. You can disable that now and save yourself some bandwidth.

Compiling zlib.lib on Windows

August 26th, 2010

Update: see comments section for a more up to date method of doing this. Don’t forget to run contrib\masmx86\bld_ml32.bat from the Visual Studio Command Prompt before compiling this way though.

This article still applies if you want to compile on older versions e.g. MSVC 6.0, for older projects or if you have problems with the new method.


zlib is the standard for lossless data compression. The DEFLATE compression algorithm is the basis for just about every lossless compression format out there, including “zip” and “gzip”, which is itself part of zlib.

There are two ways that it can be used from C/C++ projects in Windows.

Firstly, it can be used by dynamic linking (dll). This means using zdll.lib and shipping the appropriate version of zlib1.dll with your project. This is not a problem, as Windows versions of both of these files are provided.

The second way is to use static linking. That is, having all of the code in one .lib file and compiling it into your exe so that you do not have to distribute zlib1.dll. This means compiling zlib.lib.

In version 1.2.4 of zlib, a “projects” directory was provided, with a Microsoft Visual C++ 6.0 project. However, it seems that version 1.2.5 has not included this project. This means that the best solution is to go and get the 1.2.4 source and compile it yourself. However, the zlib project seems to be kept inside the libpng project on sourceforge.net, so it is not immediately obvious where to find older versions of the zlib source code.

zlib 1.2.4 source (zip)

Extract the zip, open projects\visualc6\zlib.dsp in Visual Studio (I used 2005) and compile “LIB Release” (and optionally “LIB Debug”)

Copy zlib.h and zconf.h from “include” to your Visual Studio “include” directory, and zlib.lib (and zlibd.lib if you made it) to your Visual Studio “lib” directory.

On 64 bit Windows, with Visual Studio 2005, this is “C:\Program Files (x86)\Microsoft Visual Studio 8\VC\” so adjust for your version of Visual Studio.

You now just need to add “zlib.lib” to your “Linker -> Input -> Additional Dependencies” line in your C++ project configuration to use it (and optionally zlibd.lib for the debug version).

Fix Windows 7 MBR after GRUB

August 24th, 2010

During a Linux install to my 2nd hard drive, GRUB was automatically installed to the wrong MBR (master boot record). The files were on the /boot of the Linux drive, but the Windows’ drive’s MBR was used. This meant without both drives, I could not boot either operating system.

So I installed GRUB manually with grub-install /dev/sdb. Now I needed to restore the original Windows 7 MBR so that it didn’t require GRUB to boot it.

The Windows 7 “startup repair” from the installation disc detected the OS but didn’t find any boot problems with it, so I went to the command prompt on the disc.

There are several commands for this. A lot of web pages suggest using “bootsect”. However, this did not fix anything. The fact that it was for use on individual partitions was probably a clue on that. Some web pages even used “bootcfg” which is for older Windows installs such as XP (it affects your boot.ini), but is still included on the Windows 7 disc to add to the confusion.

The command that did work was:

bootrec /fixmbr

Afterwards, for good measure, I also ran:

bootrec /fixboot

How to compile ffmpeg from source

June 9th, 2010

ffmpeg is a free and very powerful video encoding tool that is the basis of many other popular video encoding tools, with a command line interface.

Because of the frequent updates to ffmpeg and the codecs it uses, it is often best to download the latest source and compile it yourself. These updates usually include new features, bug fixes, support for new codecs and noticeable speed improvements. Most Linux distributions have outdated packages in their repositories so being able to compile the latest code from source is very useful

I use ffmpeg to output H.264 video with AAC audio in a MP4 container. I also occasionally convert audio to mp3. This means I will be compiling the following:

Preparing to compile on Linux

(If you already compile things on Linux, skip to the next section.)
First make sure that you have all of the tools and headers required to compile on Linux. On Debian based systems (including Ubuntu) you can usually run the following as root to get everything you need. First update your system. It is important that you get the latest kernel and the correct sources for it.

apt-get update
apt-get dist-upgrade

A reboot may be required here if your kernel updated.

Now get the compilers, tools and headers needed to compile software on Linux:

apt-get install build-essential linux-headers-`uname -r` git subversion yasm

NB: your “git” package may be called something like “git-core”

Compile ffmpeg (empty)

Because some libraries require ffmpeg to be installed, we will first install a blank copy with no additional codecs specified.

When I update, I often find that I need to recompile a blank version of ffmpeg before I can compile x264.

Download the latest ffmpeg source with subversion, configure, compile:

svn checkout svn://svn.ffmpeg.org/ffmpeg/trunk ffmpeg
cd ffmpeg
./configure
make

If this all worked with no errors (you can check with echo $?), run

make install

as root. Use su or sudo if you need to. I use su.

Compile faac and faad

Download and extract faac and faad from audiocoding.com.

As above, run

./configure
make
su -c 'make install'

on both libraries.

You can optionally do the same thing with LAME if you want to be able to encode mp3 audio.

NB: if you get a strcasestr error compiling faac, just comment it out in faac_1.28/common/mp4v2/mpeg4ip.h

Compile x264

Download and compile the latest x264 source with git:

git clone git://git.videolan.org/x264.git
cd x264
./configure --enable-static --enable-shared
make
su -c 'make install'

Compile ffmpeg with the above codecs

Now that we have all of the codecs (x264, aac, mp3) successfully installed as libraries on the system, we can reinstall ffmpeg to incorporate these libraries. First go back to the ffmpeg source directory and clean off the previous compile.

cd ffmpeg
make clean

Now configure to enable all of the installed libraries and recompile:

./configure --enable-gpl --enable-nonfree --enable-pthreads --enable-libx264 --enable-libfaac --enable-libfaad --enable-libmp3lame
make

(if it tells you that –enable-libfaad is not an option, just remove it. It’s probably either been rolled into faac or ffmpeg has it built in)

If it all worked, run make install as root.

su -c 'make install'

Testing

As long as /usr/local/bin/ is on your $PATH environment variable, you should be able to just type ffmpeg to check that it is all installed. It should look something like this:

$ ffmpeg
FFmpeg version SVN-r23548, Copyright (c) 2000-2010 the FFmpeg developers
  built on Jun  9 2010 13:35:17 with gcc 4.4.4
  configuration: --enable-gpl --enable-nonfree --enable-pthreads --enable-libx264 --enable-libfaac --enable-libfaad --enable-libmp3lame
  libavutil     50.18. 0 / 50.18. 0
  libavcodec    52.75. 1 / 52.75. 1
  libavformat   52.68. 0 / 52.68. 0
  libavdevice   52. 2. 0 / 52. 2. 0
  libavfilter    1.20. 0 /  1.20. 0
  libswscale     0.11. 0 /  0.11. 0
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
 
Use -h to get full help or, even better, run 'man ffmpeg'

Using ffmpeg

I have written a small Python video encoding script to make encoding as easy as

enc -t cd file.vob

If anyone has any suggestions to improve this, please feel free to post them in the comments.

Remote recursive sha1sum with php

June 2nd, 2010

To calculate the SHA-1 sums, display them and make them available for download in a sums.gz file:

<?php echo(`find ./some_directory/ -type f | grep -v sums.gz | xargs sha1sum | gzip -c | tee sums.gz | zcat`); ?>

To check the sums:

<?php echo(`zcat sums.gz | sha1sum -c -`); ?>

Get external IP address with Python

May 26th, 2010

Here’s a quick snippet of Python code (tested in 3.0) to quickly look up your external IP address over HTTP and display it:

import urllib.request
print(str(urllib.request.urlopen("http://automation.whatismyip.com/n09230945.asp").read(), "utf8"))

Sign language scammers

May 21st, 2010

Sometimes I think these people are just taking the piss to see who will notice.

Courier notifications

March 26th, 2010

Most couriers know where their drivers are at all times. They should update their tracking shortly before delivery, so that people are ready to collect at the door. Email or SMS notification 30 minutes before delivery would be very useful. Some couriers currently phone before they get there to make sure that you are in before they even bother delivering, but that just doubles the chance for you to miss them because you have to be there for both the phone call and the delivery.

Websites that already offer SMS notifications and links to tracking websites could easily be notified by a courier’s tracking API and send out a SMS accordingly.

This would probably save a fortune in redelivery costs to couriers too.

Just a thought.