Code

ClimateSmart Efergy Data Logger

An on-going project to log the data stream from the Efergy power monitor system installed by ClimateSmart.

RC5 Infrared Remote Decoding Algorithm

I wrote this article: An Efficient Algorithm for Decoding RC5 Remote Control Signals
back in 2000, after getting interested in IR remote control for embedded systems.

RC5 is a common transmission standard for infrared remote controls, originally developed by Phillips. RC5 encodes commands as 14-bit words (3 sync bits + 5-bit system number, + 6-bit command number) using a bi-phase encoding method. RC6 is a minor variation on the RC5 code.

The article describes a state-machine-based algorithm that is very robust against timing errors. Variations of this algorithm can now be found in many IR/RC5 projects.

ABN Validation Code

The Australian Tax Office has published an algorithm for validating Australian Business Numbers. It can be hard to find on the ATO website, and it moves from time to time. Right now it is here:
http://www.ato.gov.au/businesses/content.asp?doc=/content/13187.htm

Below is my PHP implementation of the algorithm.

You might also be interested in this version by Paul Ferrett which includes ACN validation, based on the ACN validation algorithm. published by ASIC. Nice.

//   ValidateABN
//     Checks ABN for validity using the published ABN checksum algorithm.
//     Returns: true if the ABN is valid, false otherwise.
//      Source: http://www.clearwater.com.au/code
//      Author: Guy Carpenter
//     License: The author claims no rights to this code.  Use it as you wish.

function ValidateABN($abn)
{
    $weight = array(10, 1, 3, 5, 7, 9, 11, 13, 15, 17, 19);

    // strip anything other than digits
    $abn = preg_replace("/[^\d]/","",$abn);

    // check length is 11 digits
    if (strlen($abn)!=11) {
        // ABN is not valid - must have 11 digits
        return false;
    }

    // apply ato check method 
    // http://www.taxreform.ato.gov.au/content.asp?doc=/content/13187.htm&placement=TR/BS/TNP/ABN&from=TR/BS
    // http://www.ato.gov.au/businesses/content.asp?doc=/content/13187.htm

    $sum = 0;
    for ($i=0;$i<11;$i++) {
        $digit = $abn[$i] - ($i ? 0 : 1);
        $sum += $weight[$i] * $digit;
    }
    return ($sum % 89)==0;
}

Compiling MSVAD under Windows 2000

I have written a blow-by-blow account of the steps required to build the Microsoft sample virtual audio driver MSVAD under Windows 2000 . The information in this article is getting rather old now, but I'm leaving it here because there are so many sites that link to this article.