Brian Khuu


Brian’s is a creator and problem solver.

He loves to work on solutions, collaborating with teams to tackle multidimensional problems on issues pertaining to technology, automation, social justice, and the economy/society.

Along with a foundation in electrical engineering, he has enjoyed adapting and acquiring skills to work on previous projects in business systems automation, coding, design, and product creation.

Brian is currently on the look out for opportunities to work with start-ups or established companies as part of their team. Contact Brian here


Business Automation

  • Custom Business Fulfilment System: Automated aspects of order sales for a company. more
  • Investigate styrofoam PLCvacuum: Work out a way to modify the Programmable Logic Controller (PLC) routine to change when the vacuum pump should activate. more


  • CYMK QR Code Concept: The idea is to combine multiple QR code and blend it together to make a single QR (non-standard) code with 3x the data capacity. Using colour. more
  • Javascript Algorithmic Art Sandbox: Here is a collection of standalone pages (heck you can even download it), where you can create algorithmic art using code more

Hardware (electronics)

  • TR_N7 Protocol Analysis: Attempting to Understand and Reverse Engineer the protocol for the TR-N7 XinChang Radio more
  • AD8236 Breakout Board: A breakout pcb board for the surface mount instrumentation operational amplifier chip. more
  • ADXL345 Breakout Board: A breakout pcb board for the surface mount instrumentation operational amplifier chip. more
  • Raspberry Pi Mini AV Display: Teardown and analysis of a car AV display re purposed as a raspberry pi display more
  • Finding Sequential Items via barcode: Experimental barcode scanner to locate items without databases. more
  • Game Console: Create a game console more
  • Gameboy Camera Extraction Via Arduino: Extract images via arduino script and some javascript more
  • Internet Connectivity Watchdog: Detects loss of internet and resets modem more
  • MiniDP adaptor tear down: Teardown and analysis of a generic Mini Display input Port to vga and hdmi output. more
  • Saner AVR Bitfield Headers: To make things easier, I created a quick python script to generate a header file that makes addressing bit fields in AVRs a little easier. more


  • Aussie Tee: Assisted a client with creating a set of T-shirt designs. more
  • EL bag: This was a design exercise for a bag that is both useful from a safety standpoint, environmentally friendly, and is cool to look at. more
  • Logo Designs: Occasionally I do logo design works for others and myself (In addition to flyers, mock-ups, etc... contact me for further examples). more
  • Status Bug: This was a design exercise to tackle the need for some spontaneity in daily situations. more

Personal Projects Log

  • Rockwell Automation Presentation Events Notes

    I attended a day presentation where they showed some interesting development in the field of Industrial Automation. They are really pushing for integrating factories into the internet via the internet to enable new data analytic opportunities. Here is a few quick notes I made of some of the key interesting things I noted on the day.

    read more
  • gameboy printer emulation via arduino

    A while ago, I went online and purchased a couple of old gameboy camera carts, I found that it had a bunch of old images taken by the previous owner. Got me thinking that we really should try to save all these images. Thus to assist with this, I written a way to extract images from these old cameras, that can be done on the cheap via an arduino, a link cable and a PC.

    read more
  • Tips On Testing From Electronex

    During electronex, I’ve made some notes on good designs shown below. These are good tips in general to keep in mind.:

    read more
  • Cheap Ebay BLE Tag Teardown (iTag via iTracing app)

    Scored really cheap from ebay. Wonder whats inside, and if it can be reprogrammed at all?


    read more
  • V2.0 AVR Convenient Register Macros for digital pins (for at least atmega family)

    Ninja edit: I probbly should reworded with a name that properly specifies that this is mostly useful for manipulating digital pins only.

    read more
  • understanding more about AVR Programming

    This is just a note for me to recall on how or what really happens in coding an AVR program:

    ATMEL STUDIO 6 Observation

    x= register letter (e.g. DDRA DDRB etc... )
    DDRx :~ Data Direction Register (read/write)
        : Defines if pin is output=1 or input=0
    PORTx :~ Pin Output Mode Register (read/write)
        : If input then
           - pullup=1 floating=0
        : If output then
           - high=1 low=0
    PINx :~ Pin INput register (read only)
        : sense @ pin: 1=highIn 0=lowIn

    How are port registers location defined? e.g. What does PORTD refer to?

    In atmel studio 6 in this location:

    C:\Program Files (x86)\Atmel\Atmel Toolchain\AVR Assembler\Native\2.1.1175\avrassembler\include

    You have an entry in file like:

    .equ	PORTD	= 0x0b
    .equ	DDRD	= 0x0a
    .equ	PIND	= 0x09
    .equ	PORTC	= 0x08
    .equ	DDRC	= 0x07
    .equ	PINC	= 0x06
    .equ	PORTB	= 0x05
    .equ	DDRB	= 0x04
    .equ	PINB	= 0x03

    Which defines the IO register pointers in AVR memory.

    What the hell is .equ ?


    Assembler Directives

    All assembler directives have names that begin with a period (`.’). The rest of the name is letters, usually in lower case.

    .equ symbol = expression

    The EQU directive assigns a value to a label. This label can then be used in later expressions. A label assigned to a value by the EQU directive is a constant and can not be changed or redefined.

    Very similar to #define, but can only be defined once.

    Seems to be similar to :

    But I think the AVR assembler is a modified version of GCC to accept .equ symbol = expression instead/inaddition? to .equ symbol, expression (Maybe someone can clarify this?)

    API :~ application programming interfaces define interfaces between program

    ABI :~ application binary interface (ABI) is the interface between two program modules

    included in avr/io.h ?

    Btw Whats in ‘ #include <avr/io.h> ‘ ? Ans: The compiler and the IDE will include in this location, the officially atmel recognized definition e.g.”avr/iom328p.h - definitions for ATmega328P”

    /* $Id: iom328p.h 2444 2014-08-11 22:10:47Z joerg_wunsch $ */
    /* avr/iom328p.h - definitions for ATmega328P. */
    /* This file should only be included from <avr/io.h>, never directly. */
    #ifndef _AVR_IO_H_
    #  error "Include <avr/io.h> instead of this file."
    #ifndef _AVR_IOXXX_H_
    #  define _AVR_IOXXX_H_ "iom328p.h"
    #  error "Attempt to include more than one <avr/ioXXX.h> file."
    #ifndef _AVR_IOM328P_H_
    #define _AVR_IOM328P_H_ 1
    /* Registers and associated bit numbers */
    #define PINB _SFR_IO8(0x03)
    #define PINB0 0
    #define PINB1 1
    #define PINB2 2
    #define PINB3 3
    #define PINB4 4
    #define PINB5 5
    #define PINB6 6
    #define PINB7 7
    #define DDRB _SFR_IO8(0x04)
    #define DDB0 0
    #define DDB1 1
    #define DDB2 2
    #define DDB3 3

    Arduino Observation

    I see the above is probbly just for AVR Studio with their AVR Assembler.

    For arduino, their source code is a bit different in terms of how it references ports in a chip, using AVR-GCC.

    e.g. You find that in:

    C:\Program Files (x86)\Arduino\hardware\tools\avr\avr\include\avr

    They would define a memmory mapped register as:

    #ifndef _AVR_ATmega32U6_H_
    #define _AVR_ATmega32U6_H_ 1
    /* Registers and associated bit numbers. */
    #define PINA _SFR_IO8(0x00)
    #define PINA0 0
    #define PINA1 1
    #define PINA2 2
    #define PINA3 3
    #define PINA4 4
    #define PINA5 5
    #define PINA6 6
    #define PINA7 7
    #define DDRA _SFR_IO8(0x01)
    #define DDA0 0
    #define DDA1 1
    #define DDA2 2
    #define DDA3 3
    #define DDA4 4
    #define DDA5 5
    #define DDA6 6
    #define DDA7 7

    using this cryptic _SFR_IO8 function. But actually, it is not a function, it is a directive.

    As shown in


    The _SFR_IO8() converts the I/O address to the memory address. It is a macro that returns a byte of data at an address of io_addr + __SFR_OFFSET.

    Source Code

    The _SFR_IO8() is defined in hardware/tools/avr/avr/include/avr/sfr_defs.h as below.

    #define _SFR_IO8(io_addr) _MMIO_BYTE((io_addr) + __SFR_OFFSET)
    #define __SFR_OFFSET 0x20
    Adding __SFR_OFFSET to io_addr, then calls _MMIO_BYTE().


    The use of io_addr + __SFR_OFFSET makes more sense when you see this link

    The memmory stucture of AVR is like this

    # FLASH (16 Bits wide) (start at 0x000, ends at FLASHEND )
     * Application 
      - Flash section ( Read while Write )
      - Optional Flash Section (No Read while Write)
     * Optional Bootloader
    # Ram (8bit wide)
     0x0000 : 32 General Purpose Registers
     0x0020 : 64 I/O Registers ( THIS IS WHAT __SFR_OFFSET refers to ) 
     0x0060 : 160 Extended I/O Registers
     0x0100 : Internal Ram (Accessable for variables etc...)
     RAMEND : End of internal Ram
     RAMEND+1: External RAM
     0xFFFF : Max memmory address.
    # EEPROM ( 8 bit wide) ( start at 0x000, ends at EEPROMEND )

    So that should give you an idea, of what exactly is going on… At least for AVR-GCC (and AVR Assembler too)



    • - AVR Assembler User Guide (By Atmel)


    read more
  • OpenPGP Card V2.0 Factory Reset

    Had quite a close call with bricking my OpenPGP card which is specifically V2.0 .

    read more
  • gpg+gpa and a openpgp smartcard

    This is an ongoing log of setting up, installing and then using an open sourced privacy suite.

    read more
  • cheap quadrocopter toy

    Just recently got my hands on a really tiny quadrocopter. It’s very cool, especially how they managed to get everything to such a tiny form factor. This is no doubt in part of using the PCBs as part of the support structure.

    This wouldn’t be possible without MEMS technologies that you find in a smart phone like accelerometers and gyroscope, in miniaturising components that use to be rather bulky and expensive to use.

    The major ICs onboards are:


    It’s expected it would use a more beefy ARM processor than something like an AVR, since it is doing a closed loop feedback (PID?) control of 4 motors at the same time.

    IC Markings

    -ZZ   _ARM_


    + Core
     - ARM Cortex-M0 core runs up to 50 MHz
     - One 24-bit system timer
     - Support low power sleep mode
     - Single-cycle 32-bit hardware multiplier
     - NVIC for the 32 interrupt inputs, each with 4-levels of priority
     - Support Serial Wire Debug (SWD) interface and 2 watchpoints/4 breakpoints
    + Memory
     - 32K/64K/128K bytes flash memory for program memory
     (APROM) (128K bytes supports NUC100 Medium Density only)
     - 4K bytes flash memory for loader memory (LDROM)
     - Configurable data flash address and size for 128K bytes system,
     fixed 4K bytes data flash (DataFlash) for the 32K bytes and 64K bytes system
     - 4K/8K/16K bytes embedded SRAM (16K bytes supports NUC100
     Medium Density only)
     - Support PDMA mode
    + Clock Control
     - Flexible selection from different clock sources
     - Build-in 22.1184 MHz high speed oscillator (trimmed to 1%) for
     system operation, and low power 10 KHz low speed oscillator
     for Watchdog timer and Wake-up operation
     - Support one PLL, up to 50 MHz, for high performance system operation
     - External 4 ~ 24 MHz high speed crystal input for precise timing operation
     - External 32.768 KHz low speed crystal input for RTC function
     and low power system operation
    + Timers
     - Support 4 sets of 32-bit timers with 24-bit up-timer and one 8-bit pre-scale counter
     - Independent clock source for each timer
     - Provide one-shot, periodic, toggle and continuous counting
     operation modes (NUC100 Medium Density supports one-shot and periodic mode only)
     - Support event counting function (NUC100 Low Density only)
    + PWM
     - Built-in up to four 16-bit PWM generators provide eight PWM
     outputs or four complementary paired PWM outputs
     - Each PWM generator equipped with one clock source selector,
     one clock divider, one 8-bit pre-scale and one Dead-Zone
     generator for complementary paired PWM
     - Up to eight 16-bit digital capture timers (shared with PWM
     timers) provide eight rising/falling capture inputs
     - Support capture interrupt
    + ADC
     - 12-bit SAR ADC with 600K SPS
     - Up to 8-ch single-end input or 4-ch differential input
     - Single scan/single cycle scan/continuous scan
     - Each channel with individual result register
     - Scan on enabled channels
     - Threshold voltage detection
     - Conversion start by software programming or external input
     - Support PDMA mode
    + Communication Interface
     - Maximum 3 UARTs, up to 1 Mbit/s with flow control
     - Maximum 4 SPIs, up to 16 MHz (Master@5V), 10 MHz (Salve)
     - 2 I2Cs
     - Support IrDA (SIR) function
     - Support RS485
    + I2S
     - Interface with external audio CODEC
     - Operate as either master or slave mode
     - Capable of handling 8-, 16-, 24- and 32-bit word sizes
     - Support mono and stereo audio data
    + Analog Comparator
     - Up to two analog comparators
     - External input or internal bandgap voltage selectable at
     negative node
     - Interrupt when compare result change
    + RTC
     - Support software compensation by setting frequency compensate register (FCR)
     - Support RTC counter (second, minute, hour) and calendar counter (day, month, year)
     - Support alarm registers (second, minute, hour, day, month, year)
    + EBI Bus (External bus interface supports NUC100 Low Density 64-pin package only)
     - Accessible space: 64K bytes in 8-bit mode or 128K bytes in 16-bit mode
     - Support 8-/16-bit data width
     - Support byte write in 16-bit data width mode
    + Brownout Detector
     - With 4 levels: 4.5V / 3.8V / 2.7V / 2.2V
     - Support brownout interrupt and reset option
    + GPIOs
     - Up to 80 general-purpose I/O (GPIO) pins
     - Four I/O modes: Quasi bi-direction, Push-Pull output, Open-Drain output, Input only with high impendence
     - TTL/Schmitt trigger input selectable
     - All GPIO pins can be configured as interrupt source with
     edge/level setting
    + Built-in LDO for Wide Operating Voltage Range
     - 2.5V to 5.5V
    + Operating Temperature
     - - 40oC ~ 85oC
    + Packages (RoHS)
     - LQFP48 (7x7mm)
     - LQFP64 (10x10mm)

    Motion Processing Unit

    I recognize this! It’s an invensense MPU 6050! A 6 axis MPU (3 axis accerometer + 3 axis gyro)

    IC Markings

    EL 1411 E


    Radio Chip

    This appears to be a radio chip, due to it’s proximity to the antenna

    IC Markings


    Datasheet found:

    BEKEN BK2423:
    Low Power High Performance 2.4 GHz GFSK Transceiver 
    2400-2483.5 MHz ISM band operation:
    ? Support 250Kbps, 1Mbps and 2 Mbps air data rate
    ? Programmable output power
    ? Low power consumption
    ? Tolerate +/- 60ppm 16 MHz crystal
    ? Variable payload length from 1 to 32bytes
    ? Automatic packet processing
    ? 6 data pipes for 1:6 star networks
    ? 1.9V to 3.6V power supply
    ? 4-pin SPI interface with maximum 8 MHz clock rate
    ? Compact 20-pin 3x3 or 4x4mm QFN package 


    What would be interesting, is if the quadrocopter can be reprogrammed to add other motions besides the 360 flip in one of it’s auto acrobatic stunts button (one press and it does a flip in air).

    Either way, it shows how far we have come since the first toy helicopters a few years ago (2015)

    BTW: in jekyll I had a problem with unicode causing problems with page generation here. Solved it by stripping all non unicode via [^\x00-\x7F]+ regex expression. Thanks ProGM from

    read more
  • 6x6 tap code experimentation

    Tap codes has a pretty cool history, you can read more about it in the wikipedia entry for tap codes. A minor issue is that the C and K in the 5x5 tap codes are mushed together. What if we extend the table to 6x6. And what if we arrange it in different ways. Here is just some experimentations to that reguards.

    read more
  • !! archive of all posts !!

subscribe via RSS


  • Email: