Reverse engineering a power supply

When it comes to old tech I am a bit of a hoarder. I don’t like the idea of working (albeit obsolete) technology ending up on the scrap heap. The other day I had an idea; re-purpose the housing and power supply for something else. I decided to re-purpose an old blue ray player into an enclosure for one or my raspberry pi projects. I will be putting a separate post up about that soon so check back if you want more information.

Whist taking on the project I realized how how useful old players might be. They have a power supply inside, a front panel with a display and buttons and a rear panel with connection on.

The rest of this post details how to reverse engineer a power supply. I am assuming that the device has a separate PCB for the power supply.

If you are reading this and are tempted to have a go yourself please take the following warnings. You will be getting close to mains voltages that can kill you. I am not going to take any responsibility for any personal injury or death you may cause to yourself or others.

My advice is to make sure you are plugging your projects into an RCD protected circuit as this minimises the chance of getting a deadly shock. Work on your project when someone else is around and make sure they know what to do if you did get shocked.

find what the outputs do
The most important part of this step is to keep the device in tack and all interconnect boards connected. I made the mistake of ripping my device apart only to have to re-connect everything.

Before doing anything else just look at what you have in front of you. Read the writing on the PCBs and look up anything you don’t understand. On the two units I have opened up to re-use almost all the wiring is labeled so the next steps are just a sanity check but still very much worth doing. PCB labels can be like comments in code, misleading, critic and out of date.

With your intact innards, the next step is to find a ground somewhere on the device. There are a number of approaches to this stage. Set your multi meter to continuity mode and try to find two or three points that all share a common rail. Ground rails often tend to be tied to the chassis some way so the screws that hold pcbs down are a good start. Connectors on the rear are likely to have a pin or shield tied to ground. It is not in common for push switches to have a one side connected to ground and often heat sinks will be grounded. My first step to to use the chassis and double check it to one of the locations mentioned above.

Now we have ground, or at least and educated guess at it, we can start to find the positive rails. Set your multimeter to volts dc and connect the negative probe to the ground point you found. With the positive probe measure the voltage of any outputs from the psu and make a note of the voltage. I had to do this step twice, once with the unit in standby and once when it was turned on.

example 1
The DVD player in this example is a nice one for a first go as it doesn’t have any fancy power features. The dc outputs are on all the time the player is on, even when it’s in standby.

DVD Play intact with lid off, Power supply PCB at the bottom

DVD Play intact with lid off, Power supply PCB at the bottom


Close up of power supply PCB output cables. If you zoom in you will be able to see the labels on the PCB

I simply checked the outputs on here with a multimeter to check the labels where correct. They where so I now have an enclosure with 12V & 5V power rails.

example 2
The blue ray player in this example was a little more tricky. It has a switch line back to the power supply pcb that activates more outputs when the unit comes out of standby. This is one way the designers reduce standby power consumption.

Blue Ray player with lid removed and main power supply loom recovered from underneath the drive.

Blue Ray player with lid removed and main power supply loom recovered from underneath the drive.

When I first inspected the power supply i noticed a number of the outputs had the letters ‘sw’ in front of some of the voltages. I suspected this meant switched and this was proved when I tested with a volt meter. All the labels on the PCB where correct.

The next step was to find the input pin that operated the switched outputs. Again the labels on the board where the biggest help here. A pin marked ‘ata’ was the odd one out and had an unusual voltage 3.8v when the unit was on, opposed to the 12v & 5v I had seen everywhere else. At this point I cut that wire and checked the voltage when the unit was in standby and when it was in full power mode. I measured the voltage on both sides of the cut wire and could see that the 3.8v was coming from the main PCB not the power supply PCB and this was only present after the on switch had been pressed. This confirmed to be that the ATA line was indeed the line that enabled the switched outputs.

One final test was to loop the ata pin to a 5v pin and see if the switched outputs came alive. They did!

A fancy on/off button
I could have used a toggle switch in order to make full use of the second example. I wanted to take it a step further and mimic what the on off switch did originally.

I used a d state flip flop with the inverted output fed into the data input and the clock connected to the on off switch. This meant the data out line would change state every time I pressed the switch.

Simple toggle latch from d-type flip flop

Simple toggle latch from d-type flip flop

I made the flip from from NAND gates, mainly because I had a few 4001 chips lying around. Below is the final logic schematic.

Logic schematic for toggle latch using two input NAND gates

Logic schematic for toggle latch using two input NAND gates

The input pin on this was connected to the switch (normally open closed to ground) and a 10K pull up resistor. I connected the output from this circuit to the ata line of the power supply pcb and it worked. A single press on off switch.

Toggle latch bread boarded. The bottom three resistors are not in use

Toggle latch bread boarded. The bottom three resistors are not in use


Toggle latch on strip board.

This second power supply provided enough power to drive a Raspberry PI and a CD ROM drive.


Replacing rear shocks on volvo 850

There are not many pictures of this job mainly because it’s not particularly difficult.

You start by jacking up the rear and supporting it on axle stands. Don’t put the stands on the suspension. I used the sub frame.

You will need to remove the floor in the boot to get to the upper mounting points. I undid the upper mounting points from the chassis first.

There is an 18mm nut that needs to be taken off where the shock meets the suspension arm on the under side of the car. This was really seized up on my car. I did worry that I had messed up the nut for a while but the new shocks came with replacements.

To get the shocks off you will need to compress the spring a bit so there is no load on the shock. I did this with a trolley jack.

The final part of removal is to get the top mounting bracket off the old shock. Clamp the old shock in something and undo the top nut.

Refitting is the opposite to removal. I did spend a few hours perplexed with one part which is really the motivation for the post. When i tried to fix the shock to the top mounting bracket the shock kept spinning as I tried to tighten it up. I had to use a ring spanner to tighten the nut and an adjustable spanner to hold the part of the shock that stopped it from spinning.


Repairing ABS on my volvo 850

So a few months ago my Volvo 850 turned on the ABS warning light. Here is what I found and how I fixed it. I didn’t have to touch the break lines, just the electronics.

Read the fault codes
My car is old enough to have an odbII port. I borrowed a friends reader and found out that the error it was throwing was “ABS pump / motor fault”.

After some reading I found that people had two complaints from this fault. The first was the insulation round the pump wires had decayed and was shorting. The second was the ABS ECU has some dry joints that needed touching up.

Remove the pump motor
The pump motor is located here:


I have removed the air filter box in the picture above as that made the job a whole lot easier.

I removed the ecu next. Picture was taken after it was removed. The cables unplug relatively easily and there are four star headed bolts to undo.

There is a black cover on the pump motor that does pull off. I had to prise it a bit with a flat blade screwdriver but it will come off. What I was the. presented with was a set of wires with no insulation left.

There where some torque bolts in the top of the motor that come out and the motor will slide out of the pump mechanism. important:
Lift the motor at the angle it’s mounted. The output of the motor is a circular motion and if you lift it out at an angle you risk taking a slip ring with it that sits between two plungers.

Here is a picture of the motor I took out:


Repairing the motor
I cut back the wires to as close to the motor as I dared and solders new ones on. I then pushed heat shrink as far into the motor as it would go to prevent shorting inside. I used the existing connector and did a similar trick soldering as close as I could to the connector.


Repairing the ECU
Time was not on my side on this job but if it was I wouldn’t have touched the ECU to start with to see if the motor repairs alone solved my issue. To get into the ECU you need to cut all the way around the seal making sure you don’t cut the pillars. I used a hacksaw but only allowed 2mm of the blade to enter the box.

Once I was in the ECU I started inspecting for dry joints and unsurprisingly the the joints for the motor connection where looking a little worse for ware. I scratched back the silicone that covered the joints and re-soldered them.

I recovered the joints using some external grade silicone sealant and then used the same sealant to fix the lid on.


Was the reverse of removal. I the. Cleared the fault log using the odbII reader and went for a long drive. Problem solved.

I still haven’t proved this yet but I am purity sure the ABS pump runs all the time your foot is on the break peddle. I used to be one of these people that sat on the foot break in traffic and so was probably running the pump far more than I needed to.

DIY Tilling gauge

I have spent the last two months ripping out our old bathroom, moving things around and installing a new bathroom suite. Recently I got round to starting the tilling.

After my normal batch of research I found a number of people talking about using a tilling gauge. In the past I have just screwed a batten to the wall i’m going to tile as a gauge but after looking into an adjustable gauge I decided it was the better option.

As a DIYer I have built up a plethora of tools and I have very rarely regretted buying any of them. I just couldn’t bring myself to pay the price tag for a professional tilling gauge when it would be used once every few years.

I had the idea of how to make a low cost tilling gauge using readily available parts and tools I already had. the rest of this post is how I did it.

What you need:

  • A straight edge (timber, metal, anything strong enough to support the weight of tiles)
  • some M8 or M10 threaded bar.
  • Something to make some feet with (I used off cuts of timber)
  • Nuts and washers to go with the threaded bar


I initially over looked these but the feet you find on the bottom of a bath frame look ideal and if like me your ripping a bath out you will probably have 4 / 5 of them. It would replace the feet and threaded bar

You will also need a drill. drill bits and spade bits.

Making the feet

start by marking out the center of the hole based on the size of the washers you have. You want to get the threaded bar as close to the edge of the wooden foot as possible. Now drill a pilot hole all the way through, I used a 3mm drill for this.

now drill down with the spade bit to a depth that allows a nut and washer to be hidden.


Next open the pilot hole up to the size of the threaded bar. I used a 10mm drill bit for my M10 bar to ensure its a tight fit.

Now bolt the foot two a length of threaded bar using two nuts and two washers. I had to knock the bar in place initially.


Making the gauge

This bit is relatively simple. Drill two holes using the correct size for your bar, just to one edge of the straight edge you want to use. I happen to have an old spirit level I use as a straight edge so I drilled some holes in that.


To assemble put a nut on each foot followed by a washer. Now put the straight edge on followed by another washer and a wing nut.

I ended up making some different length gauges from timber I had left over.


I think the pictures show this better. You just adjust the nuts to get the desired tilling hight.

International Talking Clocks

Today I found myself fault finding a sip server I set up that could not dial international numbers.

Not wanting to annoying an end user lots and lots, and not knowing anyone internationally to dial I started using talking clocks from different countries.

I found two numbers that worked well from the uk:

Germany: 004940428990.
US: 001 202 762 1401

Solar convection heater

As part of my mission to improve the climate inside my garage I set about building a solar convection heater to try and raise the internal temperature a little and hopefully help keep the building dry and free from frost.

Why solar?

The main reason is because its free. I have electricity in my garage but the thought of running an electric heater when I only use it one or two days a week makes me wince. My other reason for choosing solar as a heat source was I figured it would be relatively easy to harvest the energy and would require the least amount of installation work as id only have to get the panel on the roof.


I spent a long time deliberating between a water based heater and an air based heater. I eventually settled on an air based heater for my first adventure into the world of solar heating as the water based approach would have required more parts such as a storage tank, pumps and some radiators to get the heat into the space.

Fortunately the internet is full of people who have had a go at making a solar heater and almost everyone uses the same design. A number of collectors in the middle capture the solar radiation and convert it to heat. These collectors heat the air up inside them and so create a convention current forcing the warm air upwards. The collectors are connected at the bottom to a common inlet. The collectors are also connected at the top with a common outlet

That’s it! The air that enters the bottom gets pulled into the collectors by the convention current where it is heated and forced out the top.

Because I wanted my solar heater to be situated on the roof I knew I was going to need a force the hot air back down using a fan. If i had a south facing wall I could mount the solar heater to I wouldn’t need a fan because I could mount the panel at the bottom and just rely on the convention current..


I started by finding all the parts I needed for my design. A number of people on the internet have used tin cans painted black as the collectors. I didn’t have many tin cans around at the time so I decided to use some old drain pipe I have had in the garage for a while. I was prepared for this not to work as well as a metal collector but I thought I would give it a go.

I also knew I would need some timber (which I always seem to have plenty of) and some perspex that I decided I would buy when I knew how large the sheet needed to be.

The build

I started by cutting the drain pipe into four lengths and cut some timber that would make the frame.

Frame and tubes cut to size

Next I screwed the frame together and double checked it was big enough to take the four tubes that would become the reflectors.

Frame assembled

At this stage I screwed a sheet of 6mm ply wood to the back of the frame. I then cut two lengths of timber to fit inside the box to hold the tubes.

Timber to hold tubes

I then clamped the two lengths together and drilled holes to hold the tubes using a hole saw:

Cutting the holes to hold the tubes

The finished holders:

The finished holders

Next i installed the tubes. I found the easiest way was to fit the tubes in the holes first and install the timber holders while the tubes where inside. If I did this again I might screw the tubes to the holders before installing.

Tubes being installed

At this stage a did a little test to see how well the unit worked. I had some spare polysheet kicking around that I screwed where the perspect sheet would go, to see how warm it got. In direct sunlight I found the top was getting a few degrees warmer than the bottom so this gave me the confidence to carry on.


I painted the tubes black. This might have been a mistake because I used bitumen roofing felt adhesive I had lying around. The reason this may have been a mistake is I think it has some solar reflective properties, but by the time I found this out it I had painted the tubes. I also added some kitchen foil to reflect the sunlight to the back of the tubes as well. I stuck the foil down with carpet tape.

You will also see a small fan in the picture, its in the top right corner. This was eventually removed as it did not work very well. I decided I would put the fan inside the garage as that gave me the best chance of upgrading it in the future.


I added some thermistors (temperature dependent resistors) to the top and bottom chambers so I could monitor the temperatures in them in the future. I then sealed the perspex sheet on with silicone sealant and screwed down.


I added some feet to tilt it a little and situated it on the roof pointing south.


The final hurdle was to get the air flowing from the garage to the bottom of the heater and then from the top of the heater back to the garage. I used garden hose to move the air around. I doubled up the hose to allow more air to flow.


I then made a small fan unit using an old PC case fan to suck the air from the top of the solar heater to a lower level in the garage. This may look a bit overkill but I found getting the fan in a duct type configuration really helped draw the air though.


The results

So far we have not had much sunlight to find out if this has been effective at all. I will add some updates to this post once we have actually had a day of less cloud cover.

Raspberry PI shutdown button

During my adventures into over clocking my raspberry pi I had a number of SD cards become corrupt. I read a lot of forum posts asking how people had shut down their devices before they got the corrupt card and this got me a little frustrated.

I tend to run my pis headless, unless I’m getting a new one started. They are fantastic for this job as you can hide one away almost anywhere you have an Ethernet connection. Now what gets me frustrated is this shutting headless pis down safely. I know I should SSH in and issue a halt command but to put it bluntly I’m lazy and when I want that electrical socket for five minutes the last thing I want to be doing is finding a device I can ssh with. The rest of this post is my solution to this laziness, a shut down button for the pi.

Reading the input

I started with the following guide on how to access the GPIO using c.

I wanted to use c as I knew I would eventually want to create a daemon to monitor for a button press. The above guide led me to the bcm2835 library which contained an example of how to read the status of an GPIO pin. I used the instructions on this guide to install the bcm2835 library.

I set pin 11 up as a input pin, and applied an internal pull up just like the example does. The pull up will make the status a 1 unless the pin has been shorted to ground when it will become a 0. I chose pin 11 as it was next to a ground pin (pin 9) on the GPIO header so I could test just by shorting pins 11 and 9 with a screwdriver.

The following code shows the setup process and my loop for reading the input pin:

if (!bcm2835_init())
  return 1;

// Set RPI pin to be an input
bcm2835_gpio_fsel(PIN, BCM2835_GPIO_FSEL_INPT);

// with a pullup
bcm2835_gpio_set_pud(PIN, BCM2835_GPIO_PUD_UP);

// enter checking loop
while (1)
  // Read pin status
  uint8_t value = bcm2835_gpio_lev(PIN);
  if (value == 0)
    printf ("reset button has been pressed \n");

  // wait 1s

Starting the shutdown

This bit is quite easy, the only catch is we have to make sure the application is running as root.

system ("halt");

This does the trick quite nicely

Starting a deamon

I can remember trying to write a daemon once before but I remember scrapping the project quite early on. The next two links where very helpful in getting a crude daemon written:

The one thing that took me a while to get my head around where the multiple outputs from the fork() command. fork() is the key to starting a daemon and what it does make a copy of all the necessary program elements (mainly the stack) and starts a new process with this copy pre-loaded. At this point you have two copies of identical code running with one difference, the output return value from fork(). The table below explains what they mean:

fork() return value meaning
0 The fork was successful and we are executing in the new process
< 0 The fork process was unsuccessful and we are executing as the original process
> 0 The fork was successful and we are executing as the original process

This is why you normally see three if tests after a fork. One to check we have forked and to do the work of the new “forked process”. One to check the fork happened and to safely finish the current process to the fork can run in the background . The final test is to detect a failed fork. The tests probably wont appear in that order but this one

pID = fork();
if (pID == 0)
  // we have forked and are executing as the new process
  // what will follow will probably be an infinite loop
else if (pID < 0)
  // the fork failed and we are still the old process
  // the fork was successful and we are still the old process
  // clean up and finish this process leaving the
  // forked process to do the work

Creating a build process

I have put this towards the end of the post but in reality it was one of the first tasks I did. I used to hate Makefiles, I found them incomprehensible piles of gibberish (and sometime I still do!). Just recently I have found myself being converted, it has something to do with my whole build process being automated and consistent.

A very simple make file needs 7 lines, here are my 7:

default: all

 gcc -o shutdown-btn -l rt main.c -l bcm2835

 rm shutdown-btn

The default line makes sure all is called when nothing else is specified after make. The “all:” section does the building of the application. I only had one file so this was simple.

The clean section removes any files that the other processes have created.

The following link was very helpful when it came to Makefiles:


Installing this application was the part that took the most of my time. I knew I wanted to get the application to run at start up but I also wanted to do this as close to the right way as I possible could.

The first step was to copy the built program to /sbin . Once there you could call it like you can any other application, by just typing the name.

The next step was to write a script that would live in /etc/init.d and could be called at boot. I used the switch-cpu-govner <<find right file name>> script as a guide as that seemed to be one of the last things the boot process started and so I decided it would be a good time for my daemon to start.

I made a copy of that script and modified it for my new daemon. I had to remove a number of lines and just put a call to /sbin/shutdown-btn in the section relating to start. I kept all the boot dependency the same and only modified the name and description headers.

The commands for installing this script was as follows:

cp shutdown-btn-start /etc/init.d/shutdown-btn
sudo update-rc.d shutdown-btn defaults
sudo update-rc.d shutdown-btn enable

After running these commands you have a start script in the right place with all the correct symbolic links that are required to make it be executed at startup.

the following page helped me out alot with figuring this part out

The finished product

The daemon worked a treat! I can now turn off my pi safely by just holding the button down for five seconds. i can even trust other people to do it knowing my file system should be all safe and sound afterwards. I have put an archive of the project on this post.

the full source code can be downloaded here:

I also created a small bread board to sit on top of the GPIO headder. I found I could line up a small button with one of the holes in the case I have so that you could depress it with a pen, or other small tool.