About Me

Monday, December 29, 2008

Nios II, C++, Quartus II

Spent about a week on porting my x86 Frogger game onto an Altera DE2 development board. The port was guided by an existing implementation of Frogger on the DE2 board by a PhD student called Willie but the game was written to use a Real-Time Operating System (RTOS) called MicroC/OS II. The software was written in C. That implementation runs at about 1 frame per second though I think there are some self-imposed delay statements. My implementation of the game, as a single threaded progamme, runs at about 14.6 frames per second which is a significant speed up. I removed a lot of hardware blocks from the synthesised system that I knew I wouldn't use. This was done mainly to decrease the time needed to compile and synthesis the SOPC for the DE2 board. This should help when I have to recompile the system when I develop my reactive unit.

System on Programmable Chip (SOPC) components:

  • SDRAM (8 Megabytes; 4 MB for programme memory and 4MB for exception instructions)
  • SRAM (512 Kilobytes) for VGA frame buffer
  • DMA controller for SDRAM and SRAM components
  • On-chip memory (32 Bytes)
  • On-chip memory (10 Kilobytes)
  • DMA controller for both on-chip memories
  • Nios II CPU (Fast configuration with I/D cache)
  • EPCS Serial Flash Controller (FPGA configuration)
  • JTAG UART (Downloading programme data and debugging)
  • Timer (100 MHz) for system clock
  • Timer (100 MHz) for time stamping
  • Push buttons (4) for player inputs
  • Slide switches (18) for changing player number
  • Red LED (18) for displaying player number
  • LCD (16 x 2) for displaying game information
  • Seven-segment LED (8) for displaying the number of DMA interrupts
  • VGA (80 x 60 pixel mode)
  • VGA Controller (640 x 480 extended by Willie)
  • ISP 1362 for USB
It took around 2 days just to reduce the list of components to this. Most of the time when I removed a component, the DMA interrupts would stop occurring. It's probably the symptom of something else. Maybe the Nios II processor stopped working. Not sure.

The right most push button on the board, KEY0, seems dodgy. If you move the top of the button from side to side while it's depressed, the voltage level from the button changes from high to low. Trying to de-bounce that would be futile considering the button is already depressed when the voltage changes from high to low.

Improving VGA performance
Understanding the use of the DMA controller and memories to get a VGA output took a bit of time. However, porting the code from C to C++ was easy. The method of drawing to the VGA goes like this: Pixel information is written to a one-dimensional array equal in size to videoWidth x video Height and exists in SDRAM; this array is then copied to SRAM; then the VGA controller is told to read from SRAM via a FIFO channel.

I have tried removing the second step (copying to SRAM) but this cause major glitching for the video drawing as the video becomes hazy. I'm not sure what is causing it and don't have the time to investigate. I haven't found the register informatino for the VGA controller so there's no way for me to determine how fast the picture is being redrawn. I think DMA counting is the way for me to go right now.
  1. The method of transferring the frame buffer from SDRAM to SRAM was improved so that it occurred as one DMA transaction. Before it was happening as 300 transactions of 600 bytes (600 x 300 pixel video size). This was possible as the memory required is just 175.8 Kilobytes.

  2. The transfer mode used by the DMA controller was set to bytes (8-bits) but half words (2 bytes or 16-bits) could be used instead. Changing the mode to half words improved performance quite a bit. The DMA controller supports up to quad words but because the SRAM is only 16-bits wide, half words is the realistic maximum for transfer mode.

  3. The functions used to draw to the background and foreground were optimised as well. This involved pre-calculating the starting base addresses for each line of the frame buffer and block. The frame buffer is an array of size videoWidth x videoHeight that exists in SDRAM while the block is an array containing pixel information of a game asset. Hence, the pre-calculated base addresses are basically offsets into the frame buffer and block arrays. Also, simple changes to the initial value for the for-loop counters was made to further simplify the arithmetic used.

  4. The function for redrawing the background (which seldom happens when compared to drawing frogs, logs and tokens) was improved by the simple fact that the videoWidth was conveniently divisible by 4. This meant I could transfer 4 pixels to the frame buffer in SDRAM rather than 1 pixel at a time. This optimisation was tried out with the functions used to draw to the background and foreground but the benefits were offset by an increase in the overhead required to determine whether there was still enough pixels left in one line to be transferred as a group of 4 pixels or 2 pixels or just 1 pixel.

  5. Finally the C code was ported to C++ by packaging the functions and variables required into a Render class.

The resulting Render class header file is listed below:

#ifndef RENDER

#define RENDER

#include "constants.h"

#include "frog.h"

#include "logRow.h"

#include "token.h"

#include "Game/assets.h"

#include "altera_avalon_pio_regs.h"

#include <sys/alt_irq.h>

#include <sys/alt_dma.h>

// Link as C. Avoids undefined function references during linking stage.

extern "C" {

#include "vga_controller_ext.h"


class Render {


// Public variables

volatile bool dmaCompleted;

vga_controller_dev* vga;

// Public functions


Render(void (*)(void*, alt_u32));

void (*handleDmaInterrupt)(void *, alt_u32);

void repaint(void);

void drawToForeground(const short int x,

const short int y,

const unsigned short int width,

const unsigned short int height,

const unsigned char *block);

void drawToBackground(const short int x,

const short int y,

const unsigned short int width,

const unsigned short int height,

const unsigned char *block);

void drawChar(const short int horiz_offset,

const short int vert_offset,

const int colour,

const char character,

const char *font);

void drawString(const short int horiz_offset,

const short int vert_offset,

const int colour,

const char *font, const char string[]);

void redrawBackground(void);

void game(Frog frog[], const LogRow logRow[], Token& tokens);

void restart(void);

void won(int, int);


// Private variables

unsigned short int SCREEN_WIDTH;

unsigned short int SCREEN_HEIGHT;

unsigned int PIXEL_COUNT;

vga_frame_buffer_struct* vgaFrameBuffer;

unsigned int frameAddress;

unsigned char *bufferImage;

// Location of current pixel of the block to draw

const unsigned char *blockPixel;

// Start address of the current video line (frame buffer in sdram)

const unsigned char *currentFrameBaseDelta;

// Start address of the current block line

const unsigned char *currentBlockBaseDelta;

Assets assets;

// Private functions

void removeFrogElements(const Frog& frog);

void frogElements(Frog& frog);

void logRowElements(const LogRow logRow[]);

void tokenElements(Token& tokens);


#endif /*RENDER*/

Everything is working so now it's time start working on the reactive unit to the Nios II processor. Time to learn about closely-coupled memory and custom instructions!!

Thursday, December 18, 2008

Computer Systems Engineering with First Class Honours

Compaq Presario replacement

Finally ordered and assembled our replacement computer for the old and dead Compaq Presario. The motherboard has a good selection of legacy ports that may be useful later on for some random FPGA projects. Got a 500 GB hard disk so that should last until the next motherboard melt down. Integrated graphics is working just fine with Vista Home Premium. Also an Intel Celeron E1400 (dual core) with 2 Gigs of RAM should be enough for internet surfing. Managed to hack in remote desktop so I can now administer it from my room! Monitor is the only thing that might need upgrading now. Scanner software is a bit old as well but the scanner itself still works fine.

Wednesday, December 10, 2008

Python, CherryPy and Verilog

Decided to try and upgrade Python from 2.52 to 3.0 on my Xubuntu partition.  I decided to try and install all the packages in a bid to try and get rid of all the module warnings.  I did succeed in the end but I probably installed a lot useless sources.  Took ages trying to find the right sources to install as well.  Anyway, got Python 3.0 to compile and install so that was good.

Now I know that CherryPy 3.1.1 is incompatible with Python 3.0 so I was prepared to manually "update"/hack the source files of CherryPy so that it would run.  I was quite successful in updating the syntax and finding replacement modules to use in place of the depreciations.  A lot of the changes were just guesses though because some of the Python 2.x syntax looked quite "loose"; especially the the except and raise expressions.  However, the new module "socket" that replaces "Socket" had changed quite a lot so I was unable to find the updated method calls.  Namely, I couldn't find an equivalent to socket._fileobject(None)._rbuf in Python 3.0 so that was when I gave up on "updating" CherryPy.  I *think* I found something similar called makefile() but the resulting object doesn't have an _rbuf attribute.  Not entirely sure what _rbuf stands for.  Could be "receive buffer".  I think the point of the line is to get a file object expected by the socket in its receive buffer and try and find out what type of object it is.  Guess I'll just have to wait for the official implementation.  Could be a few years . . .

Tried some more Verilog.  Stuck on how you should statically define an array.  Right now I've only got the array *initialised* within the "always" block which to me is clearly the wrong place; but it works okay for now.  There's also the distinction of packed and unpacked arrays which concerns the layout of memory.  Also, I'm not sure how you specify the range for an integer.

Saturday, December 6, 2008


A list of languages I've touched on so far during the holidays:
  • Python
  • Ruby
  • C / C++
  • Java
  • JavaScript
  • ActionScript 3, MXML
  • LaTeX
  • Bash
  • Simulink
  • Verilog

I went to the Microsoft Imagine Cup seminar session yesterday.  It was a fairly good session.  They talked about getting an idea through imagining and then realising the idea.  Tiny bit of talk about commercialisation but not enough to give the audience an impression of the business side of things.  no talk of writing up a venture summary, business plan or having an elevator pitch for investors to look at.  They then went through how you should do the presentation to the judges including demonstrations.  Lastly they went through the submission dates for the different competitions.  There was also something about an eBOX.

(Tag-less entry)

Tuesday, December 2, 2008

Flex 3, ActionScript 3, LaTeX

Spent the last two days working on some Adobe Flex 3 and ActionScript 3 goodness. Been porting the BlueMesh GUI that I had made for my Part Four Project from pure ActionScript 2 to ActionScript 3 and MXML. The use of MXML has definitely cut down on development time for the font end stuff (GUI). It has taken only two days to get the GUI ported from work that had taken at least 5 months to sort out. If only were able to use Adobe Flash Player 9 then maybe we would have had a kick arse relational editor (BlueMesh). The port has quite a bit of ActionScript but it's mainly for testing out popups and alert boxes. No more need for JavaScript calls! Everything is nicely contained in the MXML file. Still haven't tried passing in external variable values into the Flash application though. It should follow similarly to ActionScript 2. You use FlashVars to pass values in the application.

Also installed TexLive on my Xubuntu installation so I could have a play around with LaTeX. Will have to use it to create future reports. I guess you wouldn't call LaTeX a "document programming language". Rather it's more like a "document description language" (DDL) because you describe the structure of your intended document but the actual implementation of the document (in DVI, PS or PDF) is at the mercy of the LaTeX compiler you choose to use.

Hmm shouldn't be long before I can try some VHDL or Verilog and play around with FPGAs. Hopefully Xilinx ones. Still want to try and play around with Simulink on MatLAB. Wonder how the function block idea will be like compared to other "function block" design languages say, FBDK.

Saturday, November 29, 2008

Open Flash Chart

Finally got around to implementing Shapes and shape_point in the Open Flash Chart Python library. You can now finally draw polygons on to the charts! It didn't take too long to implement which was good. I did get stuck on writing the demo though. I couldn't follow my use of arrays in my code and I had a "null" value problem in the JSON ><. I've now updated the code.google.com page for the library with a new uploaded zip file of the library and a new Wiki page for the change log.

Thursday, November 27, 2008


Been trying to come up with a good desktop background from my computers.  Haven't had much luck coming up with an idea.  Been playing around with black and white . . .

Tuesday, November 25, 2008

Dumb ATmega8 project

Finally finished the ATmega8 library.  Has API to use a 7-segment LED, pins, PWM, 2-bit flip flop, timers and some other random stuff.  The code size is pretty big though.  Not sure how to optimise the size away without losing the abstraction.  So for the final Alkali programme, it's able to detect light pulses with a reverse biased LED.  Depending on the length of the pulse, it will generate one of three events.  These three events will be "reacted" on by setting the speed of the fan and writing one data bit to the 2-bit flip flop.  The fan has three speeds; maximum, medium and off.  There's an LED that blinks on and off at close to 1 second intervals.  There is an LED that indicates the persistence of a light pulse and its indication will also persist.  The output of the tachometer of the fan is connected to a couple of external interrupt pins and these are used to turn the decimal point of the 7-segment LED on and off.

So yeah, a pretty dumb project . . .

Monday, November 24, 2008

Dumb ATmega8 project, Open Flash Chart

Had some problems with reading in the tachometer output through a couple of external interrupt pins.  It seemed that every time the fan turned on, the "latency" light would turn on.  If it wasn't doing that, it the fan would turn off after a while.  I couldn't really figure out why it was doing this because the timers must have stopped working or the wireless sensor was being triggered automatically.  Eventually I found a remedy.  It was to increase the prescaler for the PWM timer.  I was using a prescale of 1 which may have been too fast and caused the interrupts to fight over each other.  I tried to get some meaningful output written to the 7-segment display but because of the distortion of the tachometer by the PWM, the numbers didn't really make sense.

I finally made changes to the Python library for Open Flash Chart.  Each graph variety class has its own "set" functions to properties that are fairly unique to other graphs.  This means you can change the properties after creating the graph dictionary.

Sunday, November 23, 2008

Dumb ATmega8 project, Open Flash Chart

I've got the tachometer fan being driven by an n-channel MOSFET.  Was done pretty easily.  Vcc is around 7V and the input voltage is either 5V or 0V.  The MOSFET seems to be fully forward conducting at 5V so that's good.  Right now, I have the fan turning on and off every time the wireless / light sensor detects a light event.  So, that's pretty dumb so it fits with the whole theme of the project.  I'm going to try and work on this tachometer thing.  The third year electronic design paper involved using a three pinned tachometer fan so I'm basically going to be doing their project.  Hopefully it'll be easy.

Going to work a little more on the Open Flash Chart Python API as well.

Thursday, November 20, 2008

|-| @< |< ! |\| 7 0 5 |-|, ATmega8, Photoshopping

Managed to update to the 5th release.  Was easier than I expected because last time I borked the installation.  Just had to make sure a file was deleted and to change one line of the start up script.  Still stuck with VESA 3.0 video.  Still can't get it past the max resolution.  Got wireless so that's good enough for me.  One thing that does bother me is that I have to reduce the allocation of shared graphics memory (Intel 3100 GMA) for it to boot through.  But if I do that, then Vista falls back to the "basic" window manager.  Meh.

I did some more improvements to my ATmega8 library.  The wireless / light sensor now reacts to any pulses of light.  Whenever the light is de-asserted the counter will increment.  Basically I have a function / method for detecting positive edges (sensor is active low).  I also added a reaction to the length of time that the wireless sensor is asserted.  When the period exceeds a threshold, a status light is asserted and remains asserted until the wireless sensor does not detect the light anymore.  I managed salvage the Intel Pentium !!! CPU from the old Compaq desktop.  It's a Coppermine revision.  I also took the fan and heat sink used to cool the CPU and I've now attached it to my dumb ATmega8 project.  It's got three inputs; ground, Vcc and a tachometer output.  Since it's only a three terminal fan, the tachometer output is distorted for any PWM input signal.  Basically the ideal tachometer output is AND-ed with the input PWM since the tachometer will output a low whenever the PWM is low regardless of whether the tachometer should be outputting a high or low; Tachometer output = (Ideal tachometer output) AND (PWM).  I have yet to write a library for abstracting the tachometer output and PWM output and control.

Started photoshopping some cards today.  Got a birthday card and two good-bye cards to make.  I'm having a photoshopping block.  I've run out of ideas for making good-bye cards.  Getting harder and harder each year because you can't exactly give someone a card they've seen before . . .

Tuesday, November 18, 2008

|-| @< |< ! |\| 7 0 5 |-|

Wow, I finally did it again.  Though with a different DVD.  Frustrates me how I couldn't use my hacked version to make it work.  I had to change the order of my SATA HDD and DVD drives so that the DVD drive had "higher priority" over the hard drive.  I was amazed when I got to the set up screen.  Hit a small issue when the installation finished.  I had forgotten to bless the partition.  That fixed the blank / black screen that I had.  Got internet working but no video acceleration.  Back on old VESA 3.0 so I'm maxed out at a resolution of 1280 x 1024.  Looks pretty damn ugly on a widescreen monitor.  But any way, good enough for me right now.  Going to try installing on a virtual machine.  See what happens.

Sunday, November 16, 2008

Google Code, Compaq, Blog, Parallels

Made a few improvements to the Python repository for Open Flash Chart.  Added in a Wiki page showing a quick overview of how to make the data strings.  It gives a superficial comparison between the Python method and PHP method.

Pretty much finished doing maintenance work on the Compaq laptop and another desktop.  Frustrating how particular "users" complain of running out of disk space without thinking about where they're putting all their crap.  Perfectly fine partitions for "programs" and "documents" yet they're ignored.  It amazes me how people manage to screw things up.  Well I guess, not everyone's born as a computer user.  I wouldn't be surprised if the wireless adapter gets KO-ed within the next couple of weeks.

Finally decided to re-link the images I use for this blog.  The webhost I've been using has lately been very unreliable.  Hopefully my crusty geocities account will be better.

Decided to install Parallels Desktop 4.  As unlikely as I had hoped, the hard disk conversion to the new format screwed itself over.  So now I'm left with a truly POS installation of Windows.  Yet another reinstall that I have to do . . .

Saturday, November 15, 2008

Open Flash Chart 2 - Python API

Made my first code repository.  It was for the Python library I wrote for Open Flash Chart 1 and 2.  It's on Google Code.  Look.  Download.  Use.  Enjoy.  Improve.

Compaq Presario 2116AH + Wireless

Managed to fix an old DSE wireless 802.11g adapter.  Basically two contacts of the USB port lost contact with the pads on the PCB boards.  Probably due to too the port being bent up and down too many times.  I basically did a hacked job at re-soldering the pins with an absolute shocker of a soldering iron.  The tip doesn't even exist.  It's shaped like a flat head screw driver.  If you've done any soldering on PCBs made for IC you'd understand that a lot of the pads are tiny, thin or clustered very close to each other.  I must have immersed a few components in globs of solder before I managed to make a "connection".  As an Engineer, I feel the responsibility to self-regulate my work and declare the work of poor quality and lacking professionalism!!!!  But the wireless adapter works and that's all I care.

I decided to reinstall the Windows on the Presario laptop since everything was running slowly and Internet Explorer was having issues connecting to the internet.  The internet settings must have screwed themselves up because the an IP address was being allocated to a hidden device; Yay!  Reinstall went well.  Legitimate copy.  No activation issues.  Yet.  Got Service Pack 3 installed with IE7 and WMP 11.  Running out of disk space though which ain't too good...  Hmm have yet to order parts for a new desktop.

Thursday, November 13, 2008


After taking a break from my dumb ATmega8 project by looking at some stuff to buy for a gaming project, I decided to start looking at Ruby and ultimately Ruby on Rails today. Just did an apt-get for the packages and what not. Everything seems to be going well apart from needing to install minor prerequisites.

Ruby seems easy enough. Just went through a tutorial that demonstrated some of the basics. Behaves similarly to Python and shares a structure like any other scripting language though everything is an object in one way or another. This is different to the languages which have integers, characters and booleans as primitives. Getting Rails to run was easy. Rails has a tool that allows you to create a ready-to-go skeleton of a website. The Model-View-Controller organisational thing is something I'll need to understand properly. I'll probably need to spend some time on my website to make it easier to manage and maintain. Right now it's a few folders with a lot of files in each.

A new version of Cherrypy is out and seems to be compatible with Python 2.6 which is nice.

Wednesday, November 12, 2008

The start of a dumb ATmega8 project

I've continued to extend my C code for my ATmega8. It now does more than count from 0x00 to 0x0F. Every time it counting overflows, the speed of the counting gets changed. All this is done using my fancy time struct and functions. I've implemented "optical wireless communication" using a single LED as the receiver. It's very crude but works. I've got it to reset the counting every time light is shone on it. Hopefully I'll be able to make an "event based" controller. So I'll have it recognise light patterns and act on them. Wonder if I can use some sort of software exceptions (interrupts produced by running code). Code size is getting too big though for what seems to be a small amount of functionality. I shall document my System library later on.

Tuesday, November 11, 2008

AVR ATmega8 madness

Now that I've finished writing the Python API for Open Flash Chart 2, I decided to start working on some ATmega8 coding.  Got a free ATmega8 a while back so I decided to put it into use.  I found a seven segment LED display so I ended up making a simple one digit hex counter. I should really use a 3-bit decoder to address my LED display.  Taking too many ports up.  I'm using the decimal point as a blinking indicator so show that my timer is actually ticking.  I'm writing in C and I've started making my own "System" libraries.  I've got a timer struct and a single digit seven segment driver.  I also have an 2-bit Flip-Flop but I haven't got any plans to use it right now.  Might use it as a 2-bit memory storage device?  That would be silly though.

Sunday, November 9, 2008

Open Flash Chart 2 - Python API

Finally finished the (re)writing of the Open Flash Chart API library for Python.  Only too three whole days to understand what was going on with the JSON.  I think the hardest thing to understand was the use of x_axis_labels and x_axis_label objects to store the labels of the x-axis labels which is then assigned to the label variable in set_x_axis.  It feels a little convoluted because in the JSON, you have an entry called "label" and inside that you have an entry which is also called "label".  With the rewrite, some of the objects/functions are different places and they don't have the same interface as the PHP implementation.  The fact that the axes do not come together at (0, 0) bothers me because when the axes have significant thickness it looks like one giant pixel has been taken out of it.  Anyway, onto the actual changes.

  • Filename ofc2.py changed to openFlashChart.py
  • Filename ofc2_element.py changed to openFlashChart_varieties.py
  • New file created called openFlashChart_elements.py
The original names were confusing and contradictory in my view.  This was due to the way the key word element was used on the Open Flash Chart website and in the JSON strings.  On the website, Chart Elements is used to describe elements or properties of the charts that are independent of the chart type being drawn.  However in the JSON string, the entry elements contains a list of charts to draw.  Hence, ofc2_element.py was changed to openFlashChart_varieties.py to better reflect the purpose of the file to create different chart types.  Classes describing the properties of the chart were taken from ofc2.py and placed into a new file called openFlashChart_elements.py.

Accordingly, openFlashChart.py imports the chart elements defined in openFlashChart_elements.py.  The only files required to use Open Flash Chart is openFlashChart.py and openFlashChart_varieties.py.  The only inconsistency with this is that x_axis_labels and x_axis_label are defined in openFlashChart_varieties.py when they should really be defined in openFlashChart_elements.py.  Having them defined in openFlashChart_elements.py was not ideal as the file should be hidden from the programmer.

Example of importing all the required classes to make charts:

import openFlashChart

from openFlashChart_varieties import (

















from openFlashChart_varieties import (












So what exactly has been implemented?  Well below is a list of features that have been implemented.  Those already existing in the Python library are denoted by a ( - ).  Those that have been added by myself are denoted by a ( + ).  This list has been compiled by taking the menu lists from the Open Flash Chart website.

Chart types/varieties:

-  Line

+ Line Dot

+ Line Hollow

-  Bar

+ Bar Filled

+ Bar Glass

+ Bar 3D

+ Bar Sketch

+ Bar Horizontal

-  Bar Stack

+ Area

+ Area Hollow

+ Pie

+ Scatter

+ Scatter Line

+ Radar

Chart elements:

-  Title

-  X axis legend

-  Y axis legend

-  X axis

-  Y axis

+ Y axis (right)

+ X axis labels

-  Background colour

+ Click events

+ Floating bars

-  Tooltip

To elaborate a bit more, individual data points can be customised for all charts.  The same goes for tooltips.  This was achieved through the creation of data value objects like bar_value, hbar_value, bar_stack_value, etc.  Some of the existing classes were also modified.  For example in tooltips, specifying the behaviour of the tooltip with mouse location was added in. Some bugs were spotted in the process.  For example, in some functions that accepted boolean values, the conditional evaluation for setting a dictionary value was incorrect.  The original test was for the truth of a value rather than the existence of a value.  This meant None and False were treated as the same which meant some settings were unable to be set as false.  As mentioned before, the interface for adding x axis labels is in the "wrong" place.

I also wrote my own demo.py programme to show off the additions I made.  I also got some of the javascript features going as well.  Like the calling of a javascript function using on_click and loading new JSON data using load() defined in the ActionScript.  (Uses cherrypy)


  • Instead of using separate functions (set_hover and set_proximity) set the same "mouse" value for tooltip, only one function is implemented that takes in the mouse behaviour as a string. This function is called set_behaviour() and is found in the tooltip class.
  • Because the element classes were written to allow the necessary JSON strings to be created, little attention was drawn to make the elements as objects.  So an element is defined in one go on creation and adjustments to its properties after creation cannot be made.
  • Write classes and functions to implement the shape and shape_point objects to allow shapes to be drawn onto the chart canvas.  These will probably be written into openFlashChart_varieties.py even thought it's more suited for openFlashChart_elements.py given its independence of the chart type being drawn.
  • Make the API more elegant to use.  Particularly the exposure of chart elements to the programmer so that it works more like the PHP implementation.

I'm pretty happy with what I've been able to achieve in the last 3 days.  Apart from the first to-do item, I think I have implemented all the functionality that Open Flash Chart 2 offers.  I've set myself up well to upgrade my use of Open Flash Chart from version 1 to 2 for StockShaping.  The only other complaints I'd make (in addition to axes intersection) is the loss of the reload() function defined in ActionScript which would make its own call to fetch new data.  Instead, you have to fetch the data yourself and then pass it into Open Flash Chart through the load() function. Also, the file size of Open Flash Chart has ballooned up to about 256 kb from 64 kb which may be of concern for those wanting to view charts on a slow connection.  It's just the first request for Open Flash Chart that is important.  Subsequent calls should be a lot faster with caching turned on.  The last thing is the use of "val" and "value" in the JSON as keywords to mean the same thing.  Entries for both keywords are values to plot on the chart.  This discrepancy is unnecessary and added to the implementation time and increase in code usage to cater for it.

Friday, November 7, 2008

openSUSE and Open Flash Chart

Finally reinstalled openSUSE and yet again, the UUlD changed.  The boot loader manager in openSUSE is pretty infuriating because it overwrites the menu.lst file with its own crap even if you use it to modify it.  For example, changing the location of the root device will get changed back to the original value.  Dumb manager.  In the end I updated menu.lst through the shell.  Managed to get all the fstab entries working so all my drives across all the Linux operating systems automount.

I started on using the Open Flash Chart 2 API.  Not much has changed with the html business. Still have to specify flashvars but the name of the variable that points to the data has changed to either ofc or data-file.  OFC2 now expects data formatted as JSON so that's where most of the work is going to be.  The included python library isn't in the style I want it to be so I'll be basically doing a rewrite.  Since not a lot of features have been implemented by the library, a rewrite should be fine.  Hopefully it'll be as easy as the work I did for adding to the Python library of OFC1.

Wednesday, November 5, 2008

Operating systems

Spent the day finding non-Linux operating systems to try out.  Found AROS and FreeBSD. Unfortunately, I couldn't install AROS because I didn't have a CD that could fit a 750 MB image... Do CDs greater than 700 MB even exist?  Couldn't install FreeBSD because it couldn't detect the repositories on the CD.  I didn't bother finding out why.  Probably because of the SATA connection or that I was so stupid I downloaded the wrong image?  Oh yeah, openSUSE is broken once again.  Complains of not finding the root device (/dev/root) when booting up.  I may try reinstalling grub but I think I'll just end up doing a clean reinstall.  I decided to try a new window manager so I settled with XFce since it's different and thus, I installed Xubuntu 8.10 on the old Compaq PATA 40 GB drive.  I want to try and get the dock going.  I have to say, all the major window managers all look the same.  I really want to try something that is built on a totally different philosophy; well excluding command line!  In between all the partition, installing, sudo-ing, I managed to read more on Python.  Going through the pdf describing the Python library.

I've decided to fix my fstab as well so that they'll be auto-mounted on boot.


Spent the whole night trying to get back my hackintosh on my PC rig but keeps failing.  Either because it's waiting for the root device or it's just hanging before waiting for the root device.  I've basically given up now.  I've changed as many of the drive settings as I can.  IDE/AHCI, boot order, flagging my PATA drive as boot and active ...  I have no idea how I did it the first time.  I remember having the same problems but it worked after changing the hard drive to AHCI and flagging the primary partition as boot.  Meh ...

I think I'll just find some obscure OSes to install.

Tuesday, November 4, 2008

Compaq Presario 5BW472

Started salvaging the parts to the Compaq and noticed the different headers coming from the motherboard.  Quite a few looked proprietary like ones for the status lights, front panel usb ports, and power button connector.  So I decided to check out the motherboard layouts from the one I might buy and the one of my current rig and found out that the connectors were proprietary and the Compaq power supply was missing the 2x2 pin power connector.  So, that basically means I can't reuse the case or the power supply.  I know have a few choices.  One is to find a new Micro ATX case.  Second is find a new ATX case and/or find a new ATX sized motherboard.  Third is to just get a stock standard base unit so we can get the standard shop warranty that my parents like so much.  Fourth is that we just get a laptop.  Hmmm

Vista Ultimate virtualisation; openSUSE 11.0; Open Flash Chart; Down Across and Up

While searching for an answer to my reactivation issue with Windows Vista Ultimate after a BIOS upgrade, I found a nice *thing* to allow me to use Vista without having to authenticate with Microsoft's web servers.  It does a nice job to trick the operating system in thinking the BIOS of the computer is from an eligible company for pre-activation.  So now I have a copy of Vista running in virtualisation.  Not sure what I'd want to do with it though...

While looking for computer parts to retrofit into the now deceased Compaq, I noticed that the prices of parts I used to build my PC rig (hackintosh) have increased quite a bit.  It now costs more to buy the parts now than a year ago.  Just shows how fast the online stores change their prices based on the FOREX.

With the help of a friend, I managed to get openSUSE 11.0 up and running with wi-fi.  After upgrading Ubuntu from 8.04LTS to 8.10, the UUID of the openSUSE partition changed or something about the partition changed and the bootloader couldn't find the root device.  I ended up reinstalling openSUSE because I didn't know better and I had already wasted 1 day changing the menu.lst file and grub.  After getting openSUSE booting, I had the same wi-fi problem.  I couldn't get it to make a connection to the wireless access point.  In the end, my friend found a link that basically told me to extract the firmware (rt73.bin) of the wireless adapter (ASUS WL-167g) into /lib/firmware/ and then restart the wireless module.  After that, I was able to connect to the access point but I only had intranet access.  Couldn't access the internet.  The problem I found was that the DNS server wasn't resolving the namespace correctly.  Retardly, this was probably because of my fetish for static addresses.  Once I started using DCHP, I could access the internet and pull down some updates for openSUSE!

I looked at Open Flash Chart (OFC) for a brief period.  Pulled down version 2 and had a little play around with the Python library and demo.  It seems to work quite well and feels more light weight than version 1.  I noticed that the point where the x and y axis come together is missing.  It's almost as if it's a bug in how the origin is drawn and just looks wrong.  Version 2 requires an ActionScript 3 compatible interpreter so that's basically version 9 and above of Adobe Flash Player.  So the consequence of upgrading StockShaping to use OFC is that people need to have one of the latest Flash Players from Adobe.  I guess it won't be too much of a problem since the ubiquity of version 9 is quite high given the popularity of youtube and the like which require Flash Player.

Just came back from a private screening of a movie made by a couple who are my sister's friends.  The movie was called "Down, Across & Up" and documents the couple's trek around New Zealand on horse back.  It was made possible by sponsorship, family and friends who supported them throughout their journey using horses.  Unfortunately it was shown that the phrase "Animals were not hurt during the production of this movie" couldn't be used but all the animals used seemed to have come out fine in the end.  They had a nice journey around farmland and lots of random people coming out to help them along the way; even if they had never met them.  All in all, it was quite a fun movie and they did a good job of taking us around New Zealand, quasi-horse back style!  Hmm also my first movie premiere XD

Monday, November 3, 2008

Compaq Presario 5BW472

Further to yesterday's achievements of borking the Compaq, I decided to turn it on this morning and to my surprise it POSTed and started booting Windows ME.  I decided to restart the comptuer and I was able to get into the BIOS and change some settings around.  I restarted the computer, placed the Windows ME setup CD into it but it fuxored again.  Took the CD out and restarted but remained fuxored at POST.  So in conclusion, it's still fuxored.  I'm going to wait a few hours before I try booting it back up.  If it fuxors after a few restarts then there's probably some hardware component with a half-life of a mayfly.

Sunday, November 2, 2008

Compaq Presario 5BW472

Looks like the end of the road for our *trusty* Compaq Presario 5BW472.  Ever since Windows ME was reinstalled on it, the mouse went crazy.  Every time you'd move the mouse pointer it would move off in a different direction.  It was like moving the mouse over a slippery terrain and never knowing what the terrain was like.  Other times the mouse pointer would just freeze into place and the only way to navigate around Windows was through keyboard shortcuts.  Well today I decided to take a look at it and unfortunately I broke it even more.  I repeat, I broke it even more.  The machine won't even get past POST.  Stuck at the Compaq boot up screen.  Tried clearing the CMOS BIOS using jumpers and taking out the backup battery.  That made it worse as it now has to count up the RAM before fuxoring.  Tried unplugging all the I/Os but still fuxoring so it's nothing to do with the devices stopping the POST.  Trying to do a BIOS recovery flash but Compaq seems to have cleverly disabled that feature ...

Yay for 4 years of Computer Systems Engineering!

Python / Cherrypy goodness

Got stuck into some python and cherrypy madness.  Been looking back over my code for my peer-to-peer project for CompSys 302.  Made quite a few improvements to it but I think I can still make some more if I finish reading the Python manuals.  There's a few fundamental things I'd like to change as well but I'm not going to make those changes yet.  I'd like to change the way the server and user information gets handled.  The classes right now for them are quite repetitive and not very "object orientated".  Worked a bit more on StockShaping as well.  Since I wrote the code for that a year after learning Python, the code base is a bit more solid and more "pythonic".  It would be good to experiment with generators and iterators.  Templating is also another issue I should sort out since I've basically made my own that does basic string substitutions.  Works all right but not every extendable.  Wonder when Cherrypy will be written to be Python 3k compliant... Might play around with Ruby on Rails; another pair of scripting tools for use in web development.

Saturday, November 1, 2008

The end of lectures

Well, no more lectures for me ... ever ... well unless I'm the one taking the lecture XD.  Since this blog has mainly been about lectures for the last semester of Engineering at the University of Auckland its use as a scratch pad for random thoughts during lectures and note taking are all but gone.  So, I'm basically going to convert it into a *real* blog where I just blog about things beyond academia, if that makes sense.

Friday, October 24, 2008


<quote name="Caring person">
    Kinda gay..he finished the lect..and now talking about the exam stuff

Thursday, October 23, 2008

EngGen403 tutorial

Q1) Communication, argument and logic.  Arts person marking.
Q2) Professionalism and ethics.  Why do we have ethics?
Q3) Indigenous knowledge and consultation.  Think about the Marae visit.  How do you apply your knowledge.  Study up on the RMA.  My tutor marking.
Q4) The role of the engineer in society.  Today's society.  Appropriate use of technology.
Q5 & Q6) Sustainability.  Probably one question on each topic the lecturer gave.  The world that we live in.  What can be done to the world.

20 min for each question.

A lot of them are common sense.  If you were in my tutorial and listening to all what my tutor had to say, then you'd do well.  Sustainability is probably going to have the hardest questions. Have good essay structure but not strictly enforced.  Have good handwriting.

Tuesday, October 21, 2008


Last lecture by the dean of Engineering.  Talking about the GDP of New Zealand.  Seems like yesterday's lecture all over again.  We're inefficient workers.  Landscape of NZ.  Knowledge economy.  OECD indicators.  But you also need places in industry that are able to take in an influx of engineers.  Probably not enough companies / opportunities where such industries can develop in such an agriculturally based country.  Overview of engineering market.


Came to lecture late because I was at a friend's ChemMat presentation.  15 min of new ChemMat knowledge of aluminium cover.  Lecture did not start when I came in because a survey was being held.

Going through the deterministic properties of a boolean mealy machine that are free running in parallel.  Encapsulation/Hiding for forcing synchronisation.  Scope.  Local criterion: 1) A hidden input must also appear in the output; 2) A negative input must not appear in the output.  Defining the automata that results from port hiding.

Monday, October 20, 2008


Lecturer today is a fire engineering consultant. Talking about why engineering is so good and so on. Talking about money and trying to squeeze in sustainability in all places possible. Slides look like a repeat of a PD1 lecture.

Comparing New Zealand with other countries. Your typical accountant and lawyer graphs to compare. More propaganda about engineers joining politics. Still the feeling that engineers are being portrayed as special people who don't fit very well with society. Too many reassurances that there's a shortage of "weird people".

Composed and transmitted from my iPod Touch

Thursday, October 16, 2008


Argos is a concurrent model of computation. Operators: refinement/hierachial product, synchronous product, hiding/encapsulation.

Composed and transmitted from my iPod Touch

EngGen403 tutorial

Substitute tutor. He's Canadian. Started talking about politics. Going through Monday's lecture which was on appropriate use of technology in third world places. Then onto Tuesday's lecture which was on believing what people say. Going through the exam structure.

Five topics in the exam. There may be some topics with multiple questions. Arguments and persuasive writing. Professionalism and ethics. The use of being in a professional body. Engineer's role in work safety. Change designs so they cannot be abused. Contracts you can be entered to by giving a simple consultation. E-mail can be used for legal purposes. Indigenous issues and consultation. Don't present a solution from the get-go as that does not show your willingness to listen to their needs and concerns. Objections in discussions. Resource Management Act. Sustainability issues and how they will affect our future jobs. Sustainable management and resources. Life cycle analysis of products. Appropriate technology. Engineers in society. We're an outcast or just plain special in a weird way?

Composed and transmitted from my iPod Touch

Tuesday, October 14, 2008


ESR presentation. Lecturer is the same from occupational risks. Has a whole lot of questions and wants us to read his slides. Inertia, aspiration and implementation.

Composed and transmitted from my iPod Touch


ReMIC is not an esterel compliant processor. There is no concept of clock tick because only clock cycles are available. This is because a ReMIC is a pipelines processor. Reactive code "substituted" with pseudo code. Scheduling support unit allows the ability to create interleaved concurrency and basic context switching.

Composed and transmitted from my iPod Touch

Monday, October 13, 2008


Lecture from an unqualified engineer from Watercare. Taking us on a journey to a micro-hydro project to a remote location; Papua New Guinea. Everything has to be done by yourself. Showing use the innovations required to use the natural resources around to get a dam, turbine and power on the village.

Composed and transmitted from my iPod Touch

Saturday, October 11, 2008

MikesBikes MCC Competition Final Results

MikesBikes MCC Competition Final Results‏
From: help@smartsims.com
Sent: Saturday, 11 October 2008 9:38:41 a.m.

MikesBikes MCC Competition Final Results:

As I am sure many of you will know, last night the final rollover for MikesBikes was processed. Attached in a following email is the Scoreboard report showing all Firms final placings ranked by Shareholder Value (SHV). Well done to all teams, the performance overall was exceptional.

Congratulations to the teams below who placed in the top 3 spots for SHV:

1st: iBike $62.39
2nd: Winston says NO $60.60
3rd: mini EMPERORS $58.16

1. Full credit to 'iBike' who were able to recover from a stage where their performance was dropping in comparison to competitors, evaluate strategy and proceed to creep back up the ladder to take first place!

2. The same goes for 'Winston says No' who were actually 3rd to last after the first rollover. After battling 'iBike' throughout the simulation were only just pipped at the post.

3. There are quite few teams that didn't rank in the Top 3 but performed very well in the latter half of the Simulation, well done! Of particular note are:
Johnny Boy
Friendly Bikes
25th Gear
Marvel Wonders

On behalf of Smartsims I would like to congratulate all those who competed in this years competition and I wish you well in your future endeavors.

Kind Regards,

Ian McPherson
Sales & Marketing Manager
Smartsims International

PeriodIndustryFirmSHVProfitSales Revenue
2014World 2iBike$62.39$7,842,113$25,629,256
2014World 2Winston says NO$60.60$8,477,912$32,663,008
2014World 3mini EMPERORS$58.16$5,781,363$22,961,479
2014World 1Synergy$47.51$4,457,112$16,111,456
2014World 2Johnny Boy$40.97$4,824,846$17,846,952
2014World 3Michaels Cycles$35.90$2,905,742$19,034,941
2014World 3Friendly Bikes$35.63$5,522,863$25,105,564
2014World 2JKPD Corp$33.85$3,072,660$17,856,842
2014World 1Dandelions$30.83$4,686,135$22,433,862
2014World 325th Gear$30.42$3,088,905$18,507,616
2014World 3Juggernaut$23.32$1,043,114$15,811,631
2014World 1Marvel Wonders$23.04$2,651,807$13,904,203
2014World 1CK Bikes$22.37$2,007,827$18,431,841
2014World 1Tropard$19.86$7,138,292$27,127,968
2014World 2RadRydes$17.55$2,070,223$16,270,599
2014World 1Team Campeon$9.08$81,522$9,229,610
2014World 2BULLET$0.01($5,290,455)$859,200

Friday, October 10, 2008


Use all combinations for firing rule. In the time transition diagram, the long periods relate to transitions with time delays while short ones are instantaneous. There are already some controllers made to test each mechatronic object. Remove the sequencer and the sensor signals. Create change event on plant. Should use the tools on Wibdows XP.

Composed and transmitted from my iPod Touch


Lecturer went through a question that had a beta term. Not sure because I got to the lecture late again. Not that it really matters. Tax shield.

Karen would like to announce that it's her hubby (chunnie's) 29th birthday today!!!!!!!! YAY~~~~!!!!!!

Eugene asks, who is hubby?!

Karen says 'hubby' is the love of my life ^^ LOL

Eugene says, that doesn't mean much ...

Karen says ............................hehe

Eugene asks, Why is he so old anyway? He was 8 when you were born. Gross!! :-p

Karen says: have you even seen photos of him????he looks younger than you!!!! Wahahahahaha!!!!! AND! I bet you were like 8 when I was born....minutes that is ^o^

Eugene says no. But does he look fugly? :-p. Also you're being very discrete with your food!

*Karen gobbles her chocolate & almond crossaint* well I'm hungry....back to talking about my hubby ^^ how could you think for even one second that he maybe fugly!????!???!

Eugene replies: just wondering what Jay and Edison are up against. Hope you wipe your fingers before you start typing on this keyboard -_-

*wipes fingers on eugene's jacket*..well Edison is in the past but should Edison not be in the past he still loses.....however..no one really beats jay - music-wise that is....in looks hubby beats all ^^

Eugene says he's run out of random things to say. Decided to draw : ) on the crossaint. Arsset substitution.

"YAY!!!!! I WIN!!!!" Karen says, also please stop drawing on my bag for the crossaint....I bet that red pen is toxic and it will kill me... ><

Eugene asks if any milk powder was used to make that crossaint? I bet the recycled paper holding it is more toxic :p. Imagine all the newspapers that went into making the recycled bag.

Karen replies....yes I think milk powder was used I'm going to develop kidney stones


Anyway, back to finance. Talking about imputation credits to counter double taxation on dividends. Onto gaming of company equity.

Composed and transmitted from my iPod Touch

Blog Archive