7400 Logic Combination Lock

Reading Hackaday the other day I came across this article about a combination lock built from logic gates only. This reminded me of a similar circuit I designed and built at school for my electronics AS-Level and spurred me enough to dig it out and share it here 🙂

The Circuit:

7400 Logic Combination Lock


  1. A bank of momentary switches represents a keypad with ten digits (0-9), a ‘Reset’ and an ‘Enter’. This is similar to many mechanical door locks available.
  2. A bank of simple SP-ST switches act as a memory block and are used to store the combination. For the combination ‘1234’ simply close switches 1, 2, 3 and 4.


Inputting the correct combination and hitting ‘Enter’ will result in the output going high for around 5 seconds. In the circuit above the output is represented by an LED although in a real application this would most likely go to a transistor or relay to drive a solenoid for the lock mechanism.

How it works:

  1. A latch comprising of an Or and an AND on each input digit which holds high once the digit is pushed until the reset is triggered.
  2. An XNOR for each digit compares the value of the latch with the value of the corresponding ‘memory’ switch.
  3. A tree of AND gates evaluates the outputs of all digit blocks (the output of each XNOR) and outputs high if the combination was correctly entered.
  4. When the ‘Enter’ button is pressed:
    1. If the combination was incorrect an XOR gate is used to trigger the reset.
    2. If the combination was correct the a 555 monostable is triggered which holds the output high long enough for the user to enter the door.
  5. The moment the output of the monostable goes high, the reset is triggered.


The only real flaw that I see with this design is that you can enter the code in any order. However since many commercial mechanical locks have the same limitation I think I can live with it.

Does it work in real life?

I did actually build this thing many years ago, but I cannot for the life of me find any photos of it. I can confirm however that it did work and have found the photo evidence!:

Circuit on three breadboards

Additionally for those interested, you can download the circuit simulation from here and run it yourself in the quite fantastic Yenka simulation suite. Yenka is a free download and is free for home use.

Google Music & Hype Machine keyboard controls on Mac OSX

Update 9th March 2016: Fixed the workflows to work with new changes to both Google Play Music and Hype Machine

Music, music everywhere…

For some time now I have been using Google Music and Hypem as my main source of music. These services are great – Hypem always has a great selection of fresh music and a great user experience. Google Music is useful because of it’s companion app on my Android phone.

The only problem with these great services? Having to switch back to my browser and to the correct tab when ever I want to play, pause or skip to next or previous tracks. Frankly it’s a pain in the arse – particularly when you consider the music controls staring back at me from the top of my Mac’s keyboard.

The solution

Naturally I did some poking around on Google and found an interesting solution – use applescripts, registered as global services, accessed by key combinations.


  1. Download the Zip archive containing the workflows and extract it.
    • The code is available on GitHub if you want to contribute 🙂
  2. Move all three extracted workflows to ~/Library/Services/ (/Users/{you}/Library/Services/)
  3. Open System Preferences and open the Keyboard section.
  4. On the left-hand side, select ‘Services’.
  5. On the right hand side, scroll down to the ‘General’ section and you will find the three new services. Here you can enable them and select an appropriate key combination for each as per the screenshot below:
  6. Fire up Chrome, load up the Hype Machine or Google Music and give it a whirl.

Using Function Keys

The more hawk-eyed reader will notice that in the screenshot above I have mapped the three services to the playback control keys on a Mac keyboard. In fact, I haven’t – I have mapped them to the corresponding Fn keys.

OSX does not let you override actions assigned to the playback keys themselves. This means that if I wanted to use the Play/Pause service mapped to ⌘F8 I must press fn + F8.

Clearly reaching for the fn key is going to get tiresome very quickly. Luckily you can use a neat little tool called FunctionFlip to make the three playback keys default to their Fn value instead of their standard playback action so that you don’t have to press fn. Neat!


FunctionFlip stopped working on OSX Yosemite, but I got it working again. See here: FunctionFlip on OSX Yosemite

Update 26th July 2016: I can’t seem to get FunctionFlip to install on OSX El Capitan, but have found that Karabiner can do the same thing (and more). There are loads of intimidating settings – don’t panic though, you only need to enable the one shown in the image below:



  1. The scripts are written only to work with the Chrome browser. They could however be adapted to work with other browsers so by all means do so if you feel so inclined.
  2. If you have both Hypem and Google Music open in the same window, the one in the right-most tab will be controlled.
  3. Opening Hypem in one window and Google Music in another will not cause anything to explode, but you will have no way to predict which one will be controlled.


If you have any issues with these scripts please let me know in the comments below and I will try and help. If you would like to contribute any improvements, again leave a comment below and I will get back to you 🙂


This solution was originally implemented by nathanator11 over at Mac OSX Hints. I have simply picked up where he left off.

Also credit goes to k10g for his original work on this.

Thanks guys!

DD-WRT and PPPOA BT ADSL using a ST510 v6

This is something I did a while ago, but I thought I should write it up properly.

The problem:

DD-WRT does not support PPPoA ADSL.

For my old PPPOE ADSL internet connection I had a WRT610n v2 running DD-WRT and a separate simple ADSL2+ modem (ST510 v6) which I have running in bridged mode to avoid double NAT. This worked great as DD-WRT supports PPPOE, however I moved house and had to set up a new connection with British Telecom who use PPPOA.

Phoning BT tech support was as pointless as I thought it would be. DD-WRT does not appear on their scripted responses and they all think that the BT Home Hub is the best thing since boobs despite the fact that it is quite clearly crap – a single gigabit ethernet port! Really? WTF?

The solution:

Basically I had to set up the st510 v6 modem into half bridging mode. From what I understand of it, this involves getting the modem to handle the PPPoA connection, then enabling PPTP on it for the DD-WRT router to be able to connect to it and supply the credentials.

To configure the modem:

  1. Use the standard wizard in the web interface and choose any configuration you like (I picked a PPPoA template) but make sure that you choose a VPI/VCI that is NOT 0.38. Complete the wizard and let the thing settle.
  2. Use the web interface to configure the modem how you like. Things you probably want to do include:
    1. Disabling the firewall (the DD-WRT router has a better one)
    2. Setting the password to something decent
    3. Turning off DHCP (again we’ll let DD-WRT handle that)
    4. Simplifying the network interfaces. My modem defaults to have an IP of which is fine, but it also creates a vlan in the 192.168.1.x range. I removed this. N.B this is why you have to assign your local IP statically for this part.
  3. Restart the modem just to help it settle.
  4. Telnet into the modem (Google it if you’re not sure what telnet is)
  5. Issue the following commands:
    (You can ignore any messages about things being in use and unable to be deleted)

    ppp relay flush
    eth flush
    atm flush
    ppp flush
    atm phonebook flush
    atm phonebook add name=BrPPPoA_ph addr=0.38
    service system modify name=PPTP state=enabled
  6. Use the modem’s web interface to restart the modem.
  7. Hook the modem up to the wan port of the DD-WRT modem and log into DD-WRT.
  8. In the wan settings of DD-WRT use settings like mine:DD-WRT PPTP Settings
    (Don’t worry about the subnet mask and gateway, they will set itself when your connection is established).

That’s it! Good luck 🙂

Originally posted on the BT forums here: http://community.bt.com/t5/BB-Speed-Connection-Issues/Alternative-Modem-Router-using-DD-WRT/td-p/295165

DD-WRT on the Asus RT-N66U – with 64K CFE

UPDATE March 11 2014: I recently updated to the latest K3.x build (23598). I can confirm the following:

  • It is not necessary to upgrade your CFE if you intend to use a K3.x build.
  • USB & MMC support is now working.
  • It is possible to install Optware following these instructions: Optware The Right Way – Take 2
  • Enabling QoS results in reboots every few minutes, or more regularly if under load.
  • Apart form QoS issue above, it seems stable.

UPDATE Jun 10 2013: It would seem that Asus have released a new hardware variant of this model (B2) which is not compatible with this guide. Before you do anything you must check that you have an original hardware version. You have been warned.

UPDATE Nov 20 2013: Since writing this guide, the DD-WRT builds available have improved significantly and as such, the process of flashing them is probably a lot simpler. I am still running build 20363 which I originally flashed, when I have time I will try the new builds. When I have done so I will update this guide accordingly, however until that time you should probably not use the guide below and instead refer to the DD-WRT forums (linked below).

So today I received my fancy new router, chosen because it is a beast and from a quick peruse of the DD-WRT wiki and forum, it seemed I would be able to load DD-WRT on it without too much trouble.

For those who don’t know, DD-WRT is an open source, community maintained router firmware which can turn a consumer router into something any sysadmin would be proud of. I personally love it for the hundreds of features, easy to use UI and active community. From the first time I used it, DD-WRT compatibility has been a prerequisite for any new router purchase.

Check out the features here: What is DD-WRT?

From experience, flashing DD-WRT on a router can be challenging and has been known to result in an expensive paperweight or two so the golden rule is read all the forum threads you can find. This is particularly true if you are dealing with a newish device, since the kinks are probably being worked out and so it is important to have all the latest info before you start.

I have to give full credit to the DD-WRT community for making this possible, so all I want to do here is provide a write up of my experience to try and pull all the information together. Special thanks to Fractal for providing the 64K CFE compatible build.

N.B. This guide includes upgrading your CFE to 64K and at the time of writing means that you cannot install a standard DD-WRT firmware, Fractal has been kind enough to compile a 64K CFE compatible version which you must use.


  1. Fire up the new router, hook it up to your PC with an ethernet cable and point your browser to I aborted the Asus setup wizard it tried to take me through and just jumped straight into configuring manually.
  2. Install the latest version of the Merlin flavour of the Asus stock firmware. You need to do this because it supports SSH, which makes life easier and allows you to display the version of the CFE, which tells you whether or not you need to manually update the CFE.
    You can simply download the latest .trx file from Merlin and flash it using the router’s web GUI.
    IMPORTANT NOTE: It is essential to upgrade to the latest Merlin firmware before upgrading your CFE. If you don’t, you will end up with a brick.
  3. Let the router flash the Merlin firmware and wait until it has rebooted and settled down.

Upgrading the CFE:

UPDATE: There have been reports recently that flashing recent versions of the stock (and so also Merlin’s) firmware result in CFE version However, equally others have not found this to be the case. My suspicion is that ASUS has loaded units manufactured more recently with the CFE. You must flash the latest Merlin build and verify that the CFE is at version or higher using the GUI. If it is, you can skip this section – if not, you’ll have to update it yourself.

  1. Using your browser of choice (IE sucks by the way), load up again and click on ‘Tools’ on the left-hand menu. This will take you to a page where you can see the current CFE version. This will be currently. We will be upgrading to
  2. Under ‘Administration’ enable SSH and also Telnet (just in case).
  3. Follow these instructions to perform the update.
    1. Because you used the Merlin firmware earlier, you can easily use SSH to connect to the router to do this. If you are not familiar with SSH, you should probably not be attempting this.
    2. I hadn’t plugged my router into the internet yet, so I used SCP to transfer the cfe_n66u- file to the router instead of downloading it directly using wget as the guide suggests, but either is fine.
    3. Here’s the output from my upgrade:
      ASUSWRT RT-N66U_3.0.0.4 Sun Dec 16 01:33:41 UTC 2012admin@RT-N66U:/tmp/home/root# ls -alh
      drwx------ 3 admin root 80 Dec 31 12:10 .
      drwxr-xr-x 3 admin root 60 Dec 31 1969 ..
      drwx------ 2 admin root 60 Dec 31 12:04 .ssh
      -rw-r--r-- 1 admin root 156.5K Dec 31 12:10 cfe_n66u-
      admin@RT-N66U:/tmp/home/root# tar -zxvf ./cfe_n66u- 
      admin@RT-N66U:/tmp/home/root# ls -alh
      drwx------ 3 admin root 160 Dec 31 12:11 .
      drwxr-xr-x 3 admin root 60 Dec 31 1969 ..
      drwx------ 2 admin root 60 Dec 31 12:04 .ssh
      -rw-r--r-- 1 admin root 156.5K Dec 31 12:10 cfe_n66u-
      -rw-rw-rw- 1 1000 1000 130.3K Oct 2 2012 cfe_n66u-
      -rwxrwxr-x 1 1000 1000 1.8K Dec 3 2012 cfe_update.sh
      -rwxrwxr-x 1 1000 1000 90.5K Dec 3 2012 diff
      -rwxrwxr-x 1 1000 1000 8.8K Dec 3 2012 nvsimple-mipsel
      admin@RT-N66U:/tmp/home/root# ./cfe_update.sh /dev/mtd0ro
      [1/4] Dumping default NVRAM settings from original CFE…
      nvram header found:
      [2/4] Preparing new CFE…
      nvram header created:
      [4/5] Checking differences between NVRAM from old and new CFE's
      --- nvram_orig.txt2010-12-31 12:11:30.359770287 -1200
      +++ nvram_updated.txt2010-12-31 12:11:30.419770287 -1200
      @@ -1 +1 @@
      @@ -16,0 +17 @@
      If you see only two differences: one is for 'bl_version' variable change
      and second is a new 'odmpid=ASUS' variable then all goes well!
      [5/5] Flashing new CFE…
      Do you want to flash a new CFE bootloader that? [y,n]y...flashing…
      Update completed. Old CFE is stored to cfe.old file, a new one - to cfe.new
      It's strongly recommended to store them, just in case.
      Please note, your personal MAC addresses in there, do not distribute them.
    4. Really do back up your old CFE file, the script creates a backup for you, all you need to do is SCP it off and save it somewhere safe. You’ll probably never need it again, but if you do, you’ll really need it.
      • You can do this using SCP. On a Linux or OSX machine you can use the terminal:
        scp root@ .

        or you can use FileZilla or WinSCP to connect as an SFTP client if you want a nice gui to browse the router and download the file. This is probably the easiest way for Windows users.

    5. Check that the new CFE version is reflected in the web GUI under ‘Tools’. I didn’t seem to have to reboot for the change to be reflected.
    6. Re-boot the router. I just hit the power button.

Flashing DD-WRT:

  1. Flash Fractal’s special 64k CFE compatible firmware. I downloaded version 20363 from here, however there is a new version 21402 available here. You can just flash this through the web GUI as usual.
    1. Do check here for any newer builds. If you see a newer build, really do go and read the forum to find out how people are getting on with it.
    2. Make sure you flash a 64K build. These can be identified by the ‘_64K.trx’ file ending. The other builds are 32K and will result in bricking.
  2. Let the router flash the DD-WRT firmware and wait until it has rebooted and settled down for at least 5 – 10 minutes. Mine seemed to finish very quickly, but the advice of the forums is to give it some time.
  3. Perform a 30-30-30 reset to clear the NVRAM and round everything off.
    1. N.B. This router model uses the WPS button instead of the usual reset button. (Like the RT-N16).
  4. All done 🙂

At the time of writing I have just finished this and so can’t comment on stability just yet, but it seems solid enough and I have had no trouble configuring it. In 20 minutes I had swapped out my old router and the RT-N66U is now managing my whole home network. Seems good so far.
UPDATE: I have been running this build for several months now and I can confirm that it is solid as a rock.

This post was written to collect all the information at the time of writing together. Obviously it may get out-dated. As such it is essential to read the following for the latest updates before you attempt this yourself: