Wednesday, January 1, 2014

3D Perspective Projection

I have wanted to write a 3D rendering engine for years and I have finally decided to spend some time on the problem. I decided to implement a simplistic rendering engine that supports the following basic features:
  • 3D Perspective Projection (far objects are smaller than near objects)
  • Triangular Polygons for Rendering
  • Simplistic Lighting Model
  • Colored Polygon Faces (no texturing)
The largest hurdle for me was getting past perspective projection. I did some research about matrix transformations and got caught up quite deeply in mathematical abstraction. It was the image below that really set my mind in motion. I decided to take a step back and use some simple high school trigonometry to solve the problem.

Leon Battista Alberti and Perspective Projection
I have spent approximately 13 hours on this project and the results so far are fantastic looking. This entire experiment has given me great insights into the way 3D geometry is rendered onto a 2D plane.

The Classic Utah Teapot :]
In this article I will show you the various steps that I have taken to render this image. I will focus on the mathematics behind perspective projection that I used to arrive at the teapot rendering above. The image is not perfect, but I am happy with the results.

Saturday, December 21, 2013

Dealing With a Stubborn Laptop Battery

I own an older model Panasonic Toughbook CF-28. I picked it up a couple of years ago for around a hundred dollars or so. It has a Pentium III 800MHz processor and 512MB of RAM, nothing to phone home about. What it lacks in performance it makes up for in its' rugged design. It is a military specification laptop that is capable of withstanding short drops, extreme temperatures and light water splashes. It also has a touchscreen. In other words, it is a fun toy.

This laptop was missing the battery when I acquired it. I decided to opt for a cheap replacement available on eBay for around fifty dollars. When the battery arrived, I was quite pleased with the quality and performance of the product. I was easily able to get more than 5 hours of battery runtime out of the laptop.

This laptop is far from my daily driver and I left it on the shelf for a few months. When I came back to it the battery was expectedly discharged completely. The interesting part is that it would not accept a charge despite the charge indicator being illuminated.

I decided to disassemble the battery to investigate and was able to bring it back to life!

Fixed Battery

Friday, December 6, 2013

A Graphical Introduction to Hash Functions with SHA-2

Bitcoin Logo
Cryptography is the glue that holds together our modern society of electronic banking, web authentication mechanisms and identity verification. It is also the basis for the radical shifts in the way we think about our money such as Bitcoin.

I have been fascinated by the concepts of cryptography lately and decided to implement a cryptographic hashing function to try and better understand them. I will present the knowledge that I have gained in an easy to understand fashion. I am by no means an expert on this subject but if you have a general interest this should be a good starting point.

I have decided to implement SHA-256 due to the widespread adoption and ubiquity of this particular function. This implementation is designed in LabVIEW which is a graphical programming language. Whether you are a seasoned programmer or just interested in cryptography, this gentle introduction will be beneficial to you.

Wednesday, December 4, 2013

A Testament to X11 Backwards Compatibility

I recently scored a Hewlett Packard 1670A Deep Memory Logic Analyzer and I finally had a chance to fire it up. This unit dates back to 1992 and is packed with all sorts of interesting options for connecting peripherals to it. One particular feature that caught my eye was the option to connect to an X Server.

HP 1670A Logic Analyzer
HP 1670A Logic Analyzer
Here is the interface of the logic analyzer running on a remote X connection. I enjoy the colour scheme.

HP 1670A user interface over an X connection :]
I will give you a quick explanation as to how I was able to set this up by modifying a couple of configuration files to enable remote X connections.

Saturday, November 30, 2013

YALEDD! 16x16 LED Display

I would like to present to you "Yet Another LED Display" (YALEDD!): a 16 by 16 LED Display. I am currently taking an engineering project management course and one of the objectives is to take a circuit from design to implementation while sticking to a schedule that we define.

The class was instructed to choose a simple circuit such as an LED flasher or a simple sequential state machine composed of discrete logic, capture the schematic, layout the PCB and have it made by the end of the term.

I decided that it would be boring to design a simple state machine. I also thought it might be pretty cool to have an electronic gizmo of my own design to show off on my desk at work.

Something Special :]
This display utilizes constant current LED drivers to regulate 10mA through each of the LEDs. I have not used multiplexing to drive this display. I've done multiplexing in the past, and the STP16CPC26 drivers looked like they would be fun to experiment with. The entire design uses surface mount technology (aside from a couple of connectors) and was hand assembled by yours truly.

PCB Back
A Sea of LEDs

Sunday, September 15, 2013

ARM Bare Metal Programming

Embedded systems programming has been a passion of mine for a couple of years now. I really enjoy bringing a processor online and making it dance to the beat of my drum. Over the past few days I have taken an interest in writing my own linker scripts, start code and a CRT0 (C Runtime). In this article I will give you some background as to why this is important. I will guide you through the steps that I have taken to bring an ARM processor from reset to main() and beyond.

I am using the SAM4E16E processor on a SAM4E-EK development board. I have the Atmel SAM-ICE debugging tool to facilitate loading code. The steps that I am taking in this article will be very similar for other ARM processors. I did some bare metal programming on the Raspberry Pi about a year ago and it was similar.  My development host is an up to date Linux Mint 15 system.

Debugger (front) and Evaluation Kit (back)
SAM-ICE and SAM4E-EK

Monday, September 2, 2013

Networking a Home from the 1950s

The year is 1957. The world is being taken storm by a wave of new technology. The first artificial satellite Sputnik 1 was launched and Elvis Presley's Jailhouse Rock was holding the number one spot on music charts around the world. All of this happened, of course, long before I was born.

Along with these exciting historical events, a small home was built in Stoney Creek, Ontario. My parents have recently purchased this home with the intention to renovate it into the 21st century.

The front of the tired old home (before new windows).
Date of Manufacture
I was tasked with networking the home and I decided to take some pictures along the way. I have retrofitted Cat6 and RG6 into each bedroom and living space to pave the way for Home Theater PCs (HTPCs) and "Smart TVs". We use Channel Master 4221 antennas to receive local terrestrial ATSC signals. The RG6 will distribute this signal into each room. I purchased most of the supplies from the local Nutech Electronics and Home Depot.

The Cat6 and RG6 lines departing from the electrical panel. Looks good :]
Read on to see more details!

Saturday, August 3, 2013

NI LabVIEW HD44780 Driver

I have always had a place for LabVIEW in my toolbox. My opinion of it varies from week to week but I am settling on the side of appreciating what it brings to the table. It is an intriguing software package that allows you to write programs using graphical block diagrams. It is targeted primarily for scientists and engineers (read: non-programmers). I am a seasoned programmer with experience in C, C#, Java and a whole pile of other languages so it is fun for me to use LabVIEW and think about it as if I am using C. I taught myself LabVIEW over the past year by working on increasingly complex projects.

I recently got my hands on a National Instruments USB-6009 Data Acquisition (DAQ) card and decided to write up a driver for the classic Hitachi HD44780 LCD controller. I used the object oriented features of LabVIEW to implement the driver. This allows multiple instances of the LCD to exist concurrently which means that I can have multiple displays interfaced to my PC simultaneously. The results were great!

The Initialized and Functional Display :]

I I released the code on NI Developer Zone. Read on to see how I did it!