Sunday 23 March 2014

ATX Bench Supply

I've been starting to fiddle more and more with electronics of late, and I've realised that at some point I'm going to have to power some stuff off something other than a Arduino/Launchpad etc.

In learning about power supplies and the electronics inside them, I've realised there are a lot of options for a bench top supply.  While I definitely plan to have a bit of play (evident from the regulators and other bits that arrived in the mail last week), one starting option was to take an ATX PC power supply and use that as a bench supply.  This will give me the 12v/5v/3.3v I need at the moment - and is pretty cost effective (if you already have the ATX supply).  I looked around at a few examples on the internet (there are heaps!) but the one I like the most was the Dangerous Prototypes ATX Breakoutboard.  I ordered one from Seeed Studio along with an Acrylic Case and waited by the mailbox.

The bits turned up last week and I got a chance to sit down today and put it together.


So looking at the docs for the ATX BB it notes that it comes with a 9Watt load resistor, that is not required with most modern supplies (it's used as an increased load on the 5v rail so the supply with start).  So with this in mind I plugged the ATX BB into the supply and powered it up!  Worked first go without the 9W load resistor.  I metered the voltages across the various terminals and all were spot on.

If you've ever put a PC together you'll know how many extra connectors there are on an ATX supply besides the motherboard connector.  If not you can see them in the picture above - everything other than the wires in the black mesh.  So I opened up the supply to have a look at how easy this might be.

PLEASE NOTE - I was warned by several nice guys to be careful of the capacitors inside once the supply has been on - as they can hold quite a voltage.


I then removed some cable ties and spaced the cables out.  Then I removed the 4 screws holding the PCB in and lifted it to one side.  Getting to the 5v (red) and Ground (black) cables easy enough so they could be removed fully.  However getting to rest of the cables at the base was not possible thanks to the capacitors and other bits on the main PCB.  So they were grouped together by voltage and cut off.  They were then taped together and heat shrink applied.


Once this was done I carefully plugged the ATX BB back in and powered up the supply.  No magic smoke - so I put the supply back together.


Not only is that a lot tidier, but I've now also got a chunk os spare wire in the drawer to boot.  Plugged it all back in - all done!

Wednesday 5 March 2014

Clock kit Part 3

So after the last post, I ordered a USB-FTDI adapter and some appropriate jumper cables so I could reprogram the STC12C5620AD.  They took about a week to show up - which brings me to this post.

First thing was to solder on a 4 pin header to the clock.  The 4 pins are marked pretty clearly as the ISP header between the hour and minute displays.

With that set to one side, it was time to setup the laptop to program this guy.  I first installed the FTDI driver package from the FTDI site.  I then plugged in the FTDI adapter to find that it wouldn't recognise properly.  I tried unplugging and plugging it back in a few times, as well as different USB ports to no avail.  I then decided to try a different mini usb cable I had and voila - it worked first go.  With the board recognised I had my new serial port to talk to the STC chip on.

Next step was to find the software to program this guy.  Thankfully STC now provide an english version of the ISP software.  It's available here.  This is just a standalone executable you run.

The software while not terribly user friendly, only requires a couple of settings.  Open it up, set the "MCU Type" (in this case STC12C5620AD) and the comm port that was setup when the FTDI adapter was installed.

It is important to note that to talk to the MCU with this ISP software, you need to start whatever action you desire in the software and then power on the MCU.  This MCU expects data on the RX when booting to action commands from the software.

So the way I did it was to first plug in all 4 jumper leads (VCC, GND, RX, TX).  With all 4 plugged in the clock should work as normal (thanks to the 5v supplied by the FTDI adapter).  If this is the case then unplug the GND jumper cable at one end.

In the ISP software now hit the "Check MCU" button, and the software should say waiting.  Then plug the GND jumper back in and you should see some info about the MCU type and F/W version show up like this:


If when you plug in the GND jumper you don't get the above and the software still says waiting, switch the RX and TX cables over and try again.

Now that i'd confirmed I could talk to the MCU, I planned to write the existing code I had received from the seller.  My expectation being that the behaviour of the clock would not change.

I received the source from the seller, and after setting up Keil with the header files required for this MCU, I tried to compile the source to the required HEX file.  I was caught out though, as the free version of Keil has some limitations on the amount of compile byte code it will generate - limitations that meant I couldn't compile the source for the clock.  I did email the Keil guys about purchasing the software, but unfortunately they don't offer a hobby type licence.  The retail cost was a little more than I could afford.

I started looking around at some open source alternatives, like SDCC.  While looking around I went back to the bundle of files I had been sent by the seller and noticed that there was already a HEX file there that looked about the right size.  

I figured this was the code that had been flashed to the MCU before sending it out, so thought i'd try flashing it.  This would allow me to confirm the flashing procedure worked with the clock behaviour expected to remain unchanged.

So to do this, hit the "Open Code File" button and select the HEX file you wish to flash.  Make sure the GND jumper is disconnected again and now hit the "Download/Program" button.  The software should say waiting, now plug in the GND jumper again.

You should see MCU being programmed and when finished you should see "Complete !" like this:


So I'd successfully flashed the HEX file I had, and this is what the clock looked like:


That looks strangely correct to me.  So I power cycled the clock to confirm and sure as anything - IT WORKED!!!  It would appear that the seller did have the correct version of the code for this clock compiled - but hadn't flashed that version to the MCU.  

I spent a little bit of time figuring out how to set the time with the remote.  Hit the "mute" key to put it in programming mode and a section will flash (hour/minute/seconds).  Set the value using the numbers on the remote.  Use the "skip track" keys to move between sections (hour/minute/seconds) to set each section.  Once complete hit the "play/pause" button to confirm.

I then put the battery in, and put the case on:


Pretty stocked with the outcome.  Nice learning exercise and good practice in SMD soldering, and a little bit of flashing a MCU.  Time for the next project.

Nixie Clock!

I've wanted a nixie clock for a long time.  A good mate and I talked about doing it over 10 years ago now - and he ordered some IN14 nix...