Monday, December 22, 2008

Simple method to decompile (Microsoft HTML Help File) CHM files

Microsoft compiled HTML help files are now commonly used in software applications and generally these files are opened using hh.exe (HTML Help) file in windows folder. The most important thing is, hh.exe have custom chm decompilation command. To use this option simple provide following parameters to hh.exe,

hh.exe –decompile

for example :

hh.exe -decompile E:\test\output E:\test\help_demo.chm

That’s all. Check the output directory for all HTML topics, Images and other related files.

Friday, November 7, 2008

9 Pin dot matrix printer using PIC16F84A

In this project we design 9 pin Microsoft Windows NT compatible dot matrix printer using two PIC16F84A microcontrollers. Printer mechanism is based on old Commodore dot matrix printer. At the moment this device support for Microsoft Windows 2000 and XP operating systems.

Other most notable features of this implementation are,

  • Drive 18V - 9pin magnetic dot matrix head unit

  • Handle 12V paper feeder and head movement stepper motors

  • Support A4 and compatible page formats

  • System drives using 240V - 18V step-down transformer

  • Audible warning system

  • Low power consumption due to CMOS implementation

  • Works with Standard Printer Port

In this implementation we use Microsoft Windows Driver Development Kit (DDK) with Microsoft Visual C++ to create device driver for the system and use Delphi 7 to create front end application (printer maintenance – control panel applet). Both microcontrollers are programmed using MPLAB – ASM.

In this system we use 2 microcontrollers with 7MHz oscillators,

One PIC16F84A handles all incoming messages from LPT port and send status information to the port. This MCU also provide front end interface to the system (such as manual paper feeder switch, audible warning system, etc)

Second microcontroller handles printer head and paper feeder.

Other than PIC16F84s we use following semiconductors in this project,
  • Series of ULN2001 chips to interface system with printer head and stepper motors.

  • MC14066 as virtual switches

  • NE556 for audible warning system

  • LM317, LM7805, LM7812 power regulators

  • 18DB05 Bridge rectifier module
During the test runs this printer produces an excellent results and only most notable limitation is its slow speed in printing. In future we plan to implement USB and Ethernet interfaces to this project.

Friday, October 31, 2008

Essential USB Specifications and Develop embedded systems with USB

Universal Serial Bus (USB) allows peripherals and computers to interconnect using standard protocol and provide plug and play feature to the devices. At the moment there are 2 specifications available for USB they are,

USB 1.1 : In this specification data transfer rate is 12Mbps and 1.5Mbps.

USB 2.0 : Support data transfer rate up to 480Mbps.

Both these specifications support up to 127 devices and support for hot swapping (no need to power down to remove or connect the devices). In USB devices are categorized as a classes and each class represent the functionality that target device can provided to the host device. For example:

AUDIO : Audio and related systems

HID : Human Interface Devices. (E.g: Keyboard, Mouse, etc)

POWER: Devices related with the power such as UPS systems.

IrDA: Infrared devices.

There are 4 types of transfers take place over USB,

Control transfer : Used to configure the bus and devices on the bus.

Bulk transfer : Move data asynchronously over USB.

Isochronous transfer: Transfer time critical data and support for unidirectional transfers only.

Interrupt transfer: Used to retrieve data in regular intervals. (Generally from 1 to 255ms)

In a USB architecture data is transferred using packets and each packet contains synchronization byte, Packet ID (PID), contents and CRC (Cyclic redundancy check data) There are 4 packet types available in USB and they are,

Token Packets : 24bit packet that determine the type of a transfer that is take place over the bus.

Data Packet : Can transfer between 0 to 1023 bytes and also have 16bit CRC stage.

Handshaking Packet : Which is used to acknowledge the end to end data transfer.

Descriptor : Contain the device capabilities such as product identifier, manufacture code, class type, internal configuration, etc.

USB devices uses shielded four wires, cable to interconnect the devices. Data transfer is take place at D+ and D- (similar to RS422/485 specification) and other remaining 2 wires carrying power (+5V and 0V) to the device. D+ signal has a 15K pull-down resistor to the ground and D- has a 1.5K pull-up resistor to +3.6V power line.


In embedded systems there mainly two methods to implement USB interfaces,

Using standard bus interface: Most recommended devices are FT245, FT232 and USS820.

Using USB to SPI bridge: Most recommended device is ATMEL AT76C711 AVR microcontroller.

When designing embedded systems using USB we need to take special care about,

Noise : To prevent external noises designer need to add ferrite bead to the USB cable. Generally the value of the ferrite bead is depends on the total current required by the circuit.

Power Source : Need to provide well regulated power source to the device. Generally we use 7805 regulator to provide +5V to the USB interface and LM1086-3.3 to provide +3.3V power source to the system/device.

Double check the power lines (especially if you are working with FT245, FT232 and USS820 devices) and voltage ratings. Improper power connections and voltage levels may burn the chips and ports instantly.

Is Delphi for PHP successes ?

I’m trying Delphi for PHP 2.0 in few days back and I'm get very frustrated about it because of its pour implementation and technologies. Some key failures in Delphi for PHP 2.0 are,

- IDE is very buggy and most of the times it produces "Access Violation" errors and IDE get confused. (In my computer Delphi 7 tries to debug it.)

- Help is very pour and incomplete.

- JavaScript and PHP integration is very complex and buggy. Most of the time JavaScript codes may not work in client side and it is heavily depends on the web browser.

- Some times it is necessary to deploy entire "VCL" directory to the web server otherwise some of the VCL components produces invalid outputs. (specially RichEdit and TrackBar components)

- MySQL integration is pour and buggy.

- Build-in Apache web server crash several times and because of that reason we may not be able to debug/run web application using IDE.

- Some times XML file (xml.php) generated by Form Designer may not compatible with VCL for PHP framework.

- Some of the controls have missing properties.

Actually most of these problems are not very critical (we can fix most of them at the work) and hopefully Qadram Software will fix these problems in there next releases but at the moment Delphi for PHP is not a wise investment for PHP rapid application developments (RAD) and I’m personally recommended to use PRADO framework ( instead of Delphi for PHP. PRADO have same features as Delphi for PHP. The only thing is it does not have drag-and-drop style IDE.

Compared with other web application development systems (IDEs) the concept of "Delphi for PHP" is an excellent and it provide complete web application development solution to the PHP, Delphi/C++Builder users, only thing is it need more maturity.

According to my observations Delphi for PHP is not a tool developed by CodeGear (former – Borland), it is developed by Qadram Software and the core of the system – "VCL for PHP" framework is available in as an open source free software project, (same as PRADO) so anyone can modify, fix errors or add features to that framework. VCL for PHP is distributed under the terms and conditions of GNU – LGPL (GNU Lesser General Public License), and its competitive framework PRADO is distributed under the BSD Licenses.

Note : If you are a Delphi/C++Builder developer it is highly recommended to use PRADO because it’s naming standards and execution patterns are more similar to Delphi VCL.

Friday, October 3, 2008

Design USB Devices and interface them using Delphi

According to my experiences USB devices are bit complicated to design and writing software (drivers and support applications) for USB devices are time consuming and complex process.

Most recommended (and easiest) method to design hardware interface for USB port is using Future Device Technologies FT245 or FT232 chips. At the moment both these chips support for USB 2.0 and have excellent set of APIs.

To test the performance of this device I implement some experimental version of PC oscilloscope using FT245 USB Interface, AD7575 ADC, LF347 Op-amp, 4069 Hex Inverter and array of AM7205 FIFOs. Application program is design using Delphi 7 and it is totally based on FTDI Delphi APIs. This test system is worked perfectly in Windows XP and Windows 2003 systems during my test runs and produce excellent results.

I choose FT245 for this design because it has 8 parallel input interfaces and this is perfectly matched with AD7575 ADC. (AD7575 also have 8 parallel outputs) I use 2705 FIFOs to capture the maximum number of samples.

So implementing USB system is not a big problem now, we may use

  • FT245 Parallel USB FIFO or,
  • FT232 Serial USB FIFO

Both these chips have APIs in C++, Delphi, Visual Basic, etc. I’m choosing Delphi because of its performance, features and familiarity and I’m also use FT245 API with C++Builder 6, 2006 and Delphi 5, 6 and Delphi 2007 without any problem.

There are several interesting features available in FT245/232 chips which include,

  • Support for suspend mode

  • Several power configuration (USB self powered, external powered options)

  • Interface EEPROM with device descriptor.

  • Operate with standard +5V power supply

  • Higher data transfer rate (up to 15Mbps)

FT245/232 generally operates with +5V and all I/O ports support standard logic voltage levels so we can interface FT245/232 with any standard digital system easily and I’m also use FT245 with PIC and ATMEL microcontrollers without any problem.

Only problem in FT245/232 is its SMD package, because of this reason it is bit difficult to use this chip with standard project boards/prototype boards.

Tuesday, July 8, 2008

About Thoppigala 3D Computer Game

Thoppigala is a computer game developed by Vectronics and according to my observations it is developed using Game Creators FPS Creator. I have demonstration version of Thoppigala game and it is totally based on FPS Creator models and FPSC Model Pack 5. The vendor (Vectronics) do model’s texturing part only. Demonstration mission available in this release (file version is based on the FPSC sample mission and it’s level designing is in very poor stages.

In this game, player use Tommy Gun (Thompson Submachine Gun) for it’s operations, but the problem is according to my knowledge Sri Lanka Army may never use Tommy guns for there operations and it is widely used in World War II and currently it is not in use. FPSC model pack 5 contains good weapon collection and I don’t know why designers may not use them for these missions.

This game have lot of other problems, most notable problems are,

Enemy AI : During the attacks, and all the others just choose some random direction to run in, and doesn't stop at walls. This may be able to fix using script modification.

All the enemy entities are act in very artificial way. This is a main problem in FPSC, but it is possible to fix this using source code supplied by game creators.

Game may not work with some video drivers. (for example in nVidia FX5200 – version

Game voices are not very attractive and in poor quality.

Some of the debugging features may not disabled by the Vectronics, such as "Tab" key.

Game Creators release lots of model packs for this tool, (and lots of free models and scripts are available in web too) using these resources they may be able to shape up there product.

This game "Thoppigala" is become more attractive if developer choose a correct engine like "Reality Factory", "Jet3D" (this is also a non/less-programmable game engine) FPSC is good for guys who don’t know programming or 3D modeling. This is a commercial game, so developer need to think about its game engine again. Most people may not use FPSC for there games because of it’s poor quality (for more information check DevMasters – FPSC Page)

In this game author try to do something new (and I’m personally appreciate his/her vision in this game), but (s)he use wrong tools and technologies to implement this game.

Sunday, July 6, 2008

Simple Variable Zener Diode

There are several variable zener diodes available in IC market, but in Sri Lanka it is difficult to obtain variable zener diodes. (For example LM431) So I build this circuit to get the functionality of Variable Zener diode. This circuit is based on two transistors and for Q1 you can use any general purpose NPN transistor and for Q2 use any general purpose PNP transistor.

Using this circuit it is possible to get 3V to 25V (400mW) output. I use this circuit for one of my SMPS project (as a replacement for LM431) and it produces an excellent results.

Friday, June 20, 2008

Notable 3D Game Engines – Part1

This series contains list of game engines explore by me during the implementation of our STF game engine,

Panda3D – Open source game engine (use BSD license) mainly based on C++ and Python. Engine is smart and has narrow learning curve. We got most of the ideas to our project from this game engine.

Torque Game Engine – One of the best and full featured game engine. I try to select this engine for our game “Special Task Force” but it is not success because of the license problem. (STF is an open source game project, so we need to release all the source codes with it, but TGE license may not allow this.) Compared with other commercial game engines TGE is low cost 3D game engine (US$150 per programmer) but it had some wider learning curve.

FPS Creator – Product from “the game creators”. Using FPSC anyone can create FPS (First Person Shooter) game without any coding. FPSC have drag and drop environment to create games but I notice several bugs in the system. One of the Sri Lankan computer game “TOPIGALA” is build using this software package. FPSC is developed using Dark Basic and al the source codes are available in FPSC Home page. (But do not try to build this game engine using released source code, if you build FPSC from released source code then some of the features like bots collection detection may not work properly, to work them properly you need to install several add-ons to Dark Basic compiler)

Genesis3D – Another 3D Game engine for Windows platform, it similar to Doom Engine. There are several game titles are available with this game engine and most notable one is “Special Force from Lebanon based paramilitary group”. The engine is fairly OK but it had some wider learning curve. This game engine is free and source code is available to download.

Truevision 3D – TV3D is one of the excellent game engine I have seen. TV3D is easy to learn and support for Delphi, C++, VB, C# and VB.NET. TV3D SDK is available to download and the engine is well documented. PlanetX is a suitable world editor for this engine and it is released as a commercial product.

Saturday, June 14, 2008

Special Task Force Game – System Implementation

Implementation of our new 3D computer game “Special Task Force” has been started and all the development related news are available at Special Task Force Developers Center (STFDC) at

All the applications (including libraries) in this project are published according to the specifications of GNU GPL. All the documentations, guides and text files are protected using GNU FDL, and all the models, images, voice files and music files are protected using Creative Commons License.

Tuesday, June 10, 2008

Home-produced USB Sound Card

In this project I’m build USB sound card using single chip and it produce good audio output and compatible with Windows 9x operating systems and Windows NT family operating systems (I am not tested this circuit with Windows Vista and chip manufacturer say it is worked with Mac OS also) This is a plug and Play device and device driver is not required. Special feature of this sound card is its built-in HID controller. Using this HID controller user may be able to control Windows Volume control using 3 buttons located on the sound card. These buttons are used for Volume Up, Volume Down and for Audio Mute.

This device is based on Burr-Brown’s PCM2904 USB CODEC chip and it produces stereo output. PCM2904 operates using USB power (self powered) and external power adapter is not required.

I think this device is ideal for USB headphones or mini-speaker modules. My implementation is 10x9 cm. I spend Sri Lankan Rs. 1500 for this circuit.

Saturday, June 7, 2008

13W x 4 Audio Amplifier with Surround Sounds

This is my new audio power amplifier which is based on TDA8511 power amplifier IC. According to the datasheet this IC produces 13W per channel (with 2R load) and single TDA8511 chip contain 4 inputs and outputs.

Other than TDA8511 this amplifier use TA8184 for tone controls and LA2610 for surround sound processing.

To obtain the high sound quality and good separation I use separate amplifier module for each tweeter and woofer in both left and right channels. (That’s why I’m select TDA8511 for this project)

For the test run I couple this amplifier with my JVC DVD Player and it produces extreme high quality audio output.

Front Panel controls available in this amplifier are,

  • Volume
  • Bass
  • Treble
  • Balance
  • Surround Sound On/Off
  • Loudness Switch
  • Power On/Off

Some of the calculated technical specifications are,

  • Output Power : 13W x 4
  • Supply Voltage : 15V Single Rail
  • Total Harmonic Distortion : 1%
  • Bass Control Range : -12.5dB to +12.5dB
  • Treble Control Range : -12.5dB to +12.5dB

Friday, June 6, 2008

Open Source 3D First Person Shooter – Special Task Force

We start new open source game project known as “Special Task Force”. It is a FOSS project and hosted at At the moment project is in planning stages. Some of the finalized features of this game are,

  • Based on OpenGL 2.0 Graphic Technologies.
  • Support Python 2.3 Scripting
  • Use BASS sound system for audio
  • Use ODE (Open Dynamics Engine) for game physics
  • Support Multiple weapon configurations
  • Support for downloadable missions
  • Implement using Borland Delphi and C++Builder

Still we are collecting information and getting ready for the implementation, Source code implementations are planned to start at the mid of June 2008. For more information please checkout

My PIC16F73 base Digital Alarm Clock

In last two months I developed some electronic devices using Microchip microcontrollers. First device is an electronic alarm clock using PIC16F73 and 4060 timer chip. This clock has 2 programmable alarms and it is working successfully in last two months continually.

I design this alarm clock using CMOS chips; due to the fact that power consumption is very low and may be able to operate with 3 penlight batteries. At the moment this device is working with mains power (230V AC) and has battery backup facility.

Size of the entire device is 11x11x4 cm.

As shown by the photograph device have 3 push buttons and 1 SPDT slide switch. These push buttons are used for,

  • Alarm Mute / Mode Selection
  • Hour Set
  • Minutes Set
SPDT Slider is use to select “Clock Run” and “Alarm Setup” modes.

This system use following chips for its operation,

  • 4060 – Act as an oscillator and divider
  • 4027 – Toggle clock single and to control 1Hz clock pulse.
  • 4017 – Divide by 10 counter
  • PIC16F73 – Main control system
  • 7805 - +5V regulator

Microcontroller is programmed using MPASM and it is the most critical part of the implementation. (I spend 1 week for this)

I got seven segment display module from old satellite receiver and to build the entire system I spend Sri Lankan Rs. 500.00.

Welcome to My Web Log

Hello, welcome to my web log, in this web log I mostly discusses about technical subjects related to computer programming, digital electronic circuits (specially related with microcontrollers and control systems) and some mechanical implementations.

This is my personal web log, so some non-technical stuff are possible to appear in this space.