4000 series CMOS 24 hour clock

 For the last couple months a friend and I have been working on a 4000 series based clock in electronics class. After having failed building a FM receiver, we opted for a clock. We didn't go the microcontroller way, but old school ICs. So, we created a circuit for a simple clock. I opted for a 24-hour version, while my friend made the 12-hour equivalent. 

The above image was the basis of the circuit. Not shown was a 4060 and 4013 IC to make a nice 1Hz signal which we can use for the seconds. The rest is fairly simple: allow the seconds and minutes to count to 59 and use AND gates to reset at 60. Also pictured is the buttons to set the time. We used two 2N2222 transitors to make a NOT gate. Though, this ended up being too glitchy so I opted for a 4011 to create stable square wave.

And here's the clock. Incredibly disorganized but it works.

A couple months learning and work and we finally have it working! We used a 7805 voltage regulator for the entire circuit since I didn't want to add resistors to the displays. 9 volts would be much better though. 

I started using EagleCAD for the schematic but I messed up. I was adding lines instead of nets. So, my friend found DesignSpark and we used that. As far as free goes, the program is pretty easy to get going. One pain in the ass was that DesignSpark didn't have the right 7 segment display. We ended up creating them from scratch, see the attachments to download it. 

I didn't have enough time to create a PCB out of it which is disappointing. Although, my friend ended up making his, albeit with his schematic rather than mine, the PCB turned out to be a bit larger than an A4 sheet of paper. Not small at all.

Anyway, it was a fun project to make and I definitely learned quite a bit along the way. 

See the attachments at the bottom to download the schematic as a PDF or the DesignSpark project.

Edit: Note that the 1N4004 diodes should be 1N4148 instead. DesignSpark does not have these diodes in the libaries.

Reverse postal code lookup in PHP

 I've never played with any geolocation tools before but I thought I'd take a whack at it. After stumbling across GeoHelper, I thought I'd test things out with it. Well, after finding that the only reverse postal code lookup is Canada Post, I might as well make my own.

Download GeoHelper and script at the bottom of the page and place it in the same directory. That's pretty much it, the code explains itself. It can also do a reverse lookup on IPs.


Live demo here




How not to order RAM

So, back in June or so, I ordered four sticks of 2GBs of RAM for my main workstation, DDR2 PC6400. Couldn't wait to get them right? So, a month goes by and they finally come in. Now, the board I have right now is a Supermicro X6DVL-EG2 which accepts ECC RAM. I thought my current RAM was non-ECC so I said fuck it and ordered non-ECC RAM. Wrong. RAM came in, tried it, motherboard beeped at me. Fuck. So I sent it back out east for a refund (to Newegg). A week or two goes by until I get the refund so I go ahead and order DDR2 PC6400 RAM. Though, when I remember installing the last sticks of RAM, I remember reading "DDR2 400MHZ ECC ONLY" on my motherboard. Ahh, fuck it. New RAM comes in and, oh, surprise! It doesn't work! 


So, now I'm sending it back to Newegg for the second time but I have to pay for shipping ($20) to get a refund. Turns out, the right RAM (PC3200 ECC) is $45 per stick, when the PC6400 ECC was $30. I found a cheaper price on eBay so woohoo. Next time, I'll be more careful.

Templating with Twig

I've been working on this shitty video sharing site for a couple weeks now and thought I'd try out some new things. I' used phpass for the password management and ended up using Twig as a template framework. I've never used a template engine before so I was new to using one. Twig is actually quite easy to implement into any of your projects. In your PHP script add:


require_once 'Twig/Autoloader.php';

$loader = new Twig_Loader_Filesystem('templates');
$twig = new Twig_Environment($loader);
$template = $twig->loadTemplate('index.html');
echo $template->render(array('value' => 'test');

And that's it. In the example, 'index.html' is the template file. The array passes the variables onto the template. So, your index.html would look something like this:


This is a {{ value }} 

That would echo 'test'. The documentation for Twig is alright but it doesn't show how one uses the core extensions. See the below example as a block is transated for Twig's use:

      $a = $s + ($limit);
       if ($a > $numrows):
       $a = $numrows;
       $b = $s + 1;
       echo "Showing results $b to $a of $numrows";


{% set a = s + limit %}
    {% if a > numrows %}
        {% set a = numrows %}
    {% endif %}    
{% set b = s + 1 %}  
   Showing results {{ b }} to {{ a }} of  {{ numrows }}


I figured out when you're calling a template, you're able to call two. So for example, the follow code will pass the variables into both index.tmpl and menu.tmpl

 $template = $twig->loadTemplate('index.tmpl', 'menu.tmpl');

I needed to do this because index.tmpl was my main page as to keep the entire sites template intact, I also needed to pass two variables to menu.tmpl. Before, I included my menu file, menu.inc.php' into the pages but that became broken after a while. What I changed was that I added Twig variables to menu.tmpl, which changes on whether a user is logged in. So, rather than using menu.inc.php anymore, I went to the template.
To include templates is simple:

{% include 'menu.tmpl' %}

Also, one could also extend one template with another. There are no foreach or while loops available in Twig but you can use this as a foreach statement:

{% for message,thing in test %}
    {{ message }} contains {{ thing }}
{% endfor %}

Twig also has a sandbox feature which seems great for sanitizing input and such. I'm definitely glad I found out about Twig; my code is much cleaner and doesn't look [as ] hideous.

New hardware


So, I recently came into posession of an IBM Model M (1391401) and wow. This beats the hell out of my Logitech G15. A long with the keyboard, I thought I'd buy myself a new mouse while I was at it. Well, I ended up buying a Kensington Orbit with scroll ring.


The keyboard is amazing to type on. Though some may find it a bit loud, it's a pay off for the sheer coolness of it. I'm still getting used to my trackball and, as you can see, it has an extra wrist-rest attached to it.

I finally got the PowerEdge 6400 going. Turns out it was the RAM. It needs to have one entire bank to be filled, rather than two DIMMS. Debian Squeeze and even CentOS 5 didn't detect the RAID card so it couldn't see the disks at all. For the hell of it, I popped in Windows Server 2003 (as it only has a CD drive and no PXE) and what do you know: it sees the card. I installed Server 2003 and got VMware Server running on it. Although this setup is not lightweight, it does the job.



PowerEdge 6400


So I got this Dell PowerEdge 6400 and wow. First, this thing is gigantic. Eight hot swappable SCSI bays in the front. Free is a good price ;)

Inside this thing has two Intel Pentium III Xeon processors, running at 750MHz each. Where you see the RAM is actually a tray of RAM. You can remove the tray and fill up 16 DIMMs. Hot swappable PCI ports too. Three redundant power supplies in case a tornado hits or something. I'm planning on getting a SCSI drive or two and getting Solaris running (or perhaps Nexenta).

Life update

Haven't posted in a bit, thought I'd tell everyone that I'm still alive. Schools started again, so that'll take some time away from coding. New motherboard has been running superbly. One of my other computers with an Asus P4PE board has a voice over when it's booting. So the other day, it's booting up and I hear voices coming from the headset. Finally figure out it's the BIOS that's speaking to me. I will say that I do admire my Solaris server. It's quite rock-solid (well, other than the random reboots when untar'ing something large) and everything feels like it's complete.

Other than that, life's been the same. My breadboard came in a little while ago so I've been experimenting with IC's and such. 

Well, back to doing nothing.


Dual Xeon build

I've had these Xeon processors sitting around for a while now and I thought it's about time to get a motherboard for them. Two are clocked at 3.0Ghz/1MB/800, other two are at 2.8Ghz/512/533. I ordered a Super Micro X6DVL-EG2  from eBay for $120 of which I seen this motherboard up to $250. Anyway, came the other day and finally put it together. Heatsinks didn't screw into the case as it should, so I had to screw the nut right onto the heatsink. 

The BIOS has a plethora of options to mess around with, most of which I don't even know. XP x64 running on here and it's running quite good. My first 64-bit system :)

Other than that, I haven't done any coding. Although I did make a change or two to Sysode the other day. 

Place of education


Photo by aussiegall

With school finished with the exception of an exam or two and my domain back, I think I'll now have the motivation to get shit done.

Sysode is nearing completion: one of my projects that looks have decent. On the bad side, it uses PTB which would make it hardly scalable if at all. I could recode it so Sysode uses SQLite but I'd rather write it from scratch than transfer it. To make it feel better, a VPS would be ideal but wouldn't solve the problem.

Anyway, with my domain back (woot!) I think I'll go about fixing some stuff on this site.



iPhone borken

Yes, I purposely spelled that wrong. Anyway, the entire left of the touchscreen on my iPhone doesn't work. Plugged it in at night, then didn't work in the morning. So, I've had to suffer only using the right side of the screen for the last two weeks. Going to have to restore back to factory defaults, package it up and send it off.


Luckily, I've been somewhat productive lately. I've added some new features toSysode, the free project management app I've been working on since late August. There only needs to be a couple features added (member search, user control panel, etc.) and then it'll be mostly done (err..). And, for once, it looks half decent.


School'll be out in about two weeks; summer job then. Makin' bank...