This blog has permanently moved to

Contact Form | Email Address

© 2018 All rights reserved by Boseji

Thank you for all your support.

Thursday, December 30, 2010

MinGW: pexports for Windows DLLs

We were trying to extract the MinGW compatible library for FTDI driver DLL, this is part of the d2xx Project for PyUSB - Python Based FT232 Bit Banging Tutorial. This was part of upgrading the PyUSB package for Python 2.7 Compatibility.

Here are the steps to get the pexports working for MinGW:

[1] Download the pexports Package
The package pexports is available as an utility in the MinGW Sourceforge FRS. Here is a link:
In case you are unable to find it you can go to the Main FRS by clicking on "files" in the MinGW project page : http://sourceforge.net/projects/mingw
Then Files->MinGW->pexports->pexports-{Most Recent Version}

Download the peexports-0.44-1-mingw32-bin.tar.lzma file.

[2] Extracting the File
Now the downloaded file needs to be located in the MinGW directory.
Bassically the LZMA file contains an exe file called as pexports.exe which is to be placed in
/bin Directory.

To extract the LZMA file there are two ways
> You can can download the Tar for Windows utility located at : http://gnuwin32.sourceforge.net/packages/gtar.htm
> Use the msys system that comes with the MinGW auto installer.

After you have the tar.exe available either in "Windows Path" or directly in the same directory as the LZMA file. Execute the following commeand:
tar -x --lzma -f peexports-0.44-1-mingw32-bin.tar.lzma

This would unzip the pexports.exe file into ./bin directory.

[3] Generating the Verbose output from pexports.exe 
Just locate your "dll" file that you wish to see the Function Exports for and give the following command.
pexports -v <DLL FileName>.dll

Wednesday, December 29, 2010

Versaloon Platform: One Debugger for All Microcontrollers

Versaloon Platform is an Completely Open-source project which dedicates itself to USB to Anything protocol. It is a versatile device that can be used to program a verity of Microcontroller and also act as a Debug Host.
At present is support s the following Protocols: JTAG, SWD, SPI, IIC, C2DK, AVR-ISP, Cypress-ISSP, ISP and BDM protocols
The Chips it supports includes:
    * LPC1000_ISP/JTAG/SWD
    * STM8_SWIM
    * AT89S51_ISP
    * PSOC1_ISSP
    * MSP430_JTAG(without TEST pin)
    * C8051F_C2/JTAG
    * LPC900_ICP
    * HCS08_BDM
    * HCS12(X)_BDM
    * SVF_JTAG
Also its available in Several form factors and feature combination.
1. VersaloonNano -- Ultra small hardware with 10Pin connector

2. VersaloonMini - Small hardware with standard 20Pin JTAG connector

There are a few Advanced Versions also planned which would include LCD, MicroSD card and High Speed USB etc.
This project is completely designed using Kicad, the open source Professional Grade EDA suit in Making.
The Entire Source Tree as well as the Schematics are available in Google Code SVN:

It has support for the OpenOCD and UrJTAG.

Friday, December 24, 2010

Pro-Mboard: Development Board for Mbed Preview Pictures

Recently, We were able to Soldered and test the Pro-Mboard that we posted earlier. Here are a few Pics:
Top View
Bottom View
However we quickly noticed a problem that the Rev0.1 had a non connected ground in USB connector in the FT232 breakout section. We would be fixing this and also have planned a complete overhaul to help people develop their application transform into board and Pro-Mboard would help them do so.

Let us know your suggestions to make this board better.

Thursday, December 23, 2010

Nano Radio Receiver out of Graphene Sheet

Researchers Yuehang Xu and his team at Columbia University in New York has been able to make a nano scale Radio receiver using Graphene Sheet. They buit nanotrampoline out of graphene that can directly detect radio frequency signals, paving the way for a new generation of radios.
Graphene Sheet Radio Receiver
 Picture shows how the Graphene Sheet has been placed on top of a FET which induces DC current in Graphene when the Radio waves strike. They say the graphene sheet resonates when blasted with a voltage changing at radio frequency signals and that this can be easily measured by monitoring the capacitance between the sheet and the third electrode below the sheet.
That's a significant result. For some time now, physicists have been hoping to find ways of using nanoelectromechanical resonators to filter and generate radio signals directly. At present, this has to be done with various kinds of mixing techniques. The problem is that nanoelectromechanical devices all suffer from parasitic capacitance, which tends to drown out the signals that physicists are interested in at radio frequencies.
Graphene sheet device is immune from this because its design causes the effects of stray capacitance essentially to cancel out. And they prove it by using their device to pick out a radio frequency signal at 33.27 MHz.
Graphene sheets are two orders of magnitude less massive than similar devices made of silicon and so can measure signals at much higher frequency. Xu and Team say, they should be able to measure signals in the GHz range. The new device works at 77K so its operating temperature will need to be boosted before it can be used in consumer devices. Neither of those problems seem like showstoppers, however.
Physicists have known about the amazing properties of graphene for a decade or so now. They've even predicted that it will take the world of microelectronics by storm. What nobody really appreciated was how quickly this would happen. Now we're finding out.

Here is the Ref: arXiv:1012.4415

Sunday, December 12, 2010

Multi Threshold Voltage CPLD: Altera MAX V

The latest in Low Power CPLD design the Altera's Max V line of CPLDs. Now the Dynamic Power Consumption( P=F.C.V) can be brought down significantly.
These work on an single 1.8V supply and can support I/O logics of 3.3,1.2,1.8,2.5V. Also have a very low entry marker of under a USD of pricing.

Monday, November 29, 2010

Pro-Mboard: Development Board for Mbed

We designed a board to help us in prototyping the Mbed board out side the bread-boards.
When we started out prototyping using Mbed we realized that all the boards available for Mbed were either needed to shipped from outside or we costly from our budget perspective.

For this we designed our own Pro-Mboard. The board's intent was to serve the following objectives:

1. Need for additional access pins to the same SPI bus (For Multiple SPI nodes)
2. General Purpose area for riging up Custom Circuits
3. Access to SD Card slot, USB Device/Host connection
4. Ethernet connection with Magnetics and LED
5. Serial port on FT232 for easy debugging and monitoring apart from Mbed's Windows Serial Port
6. Selectable Powering Options
7. Enough Power Busses for connections to other Hardware.
8. Low Cost

Here is what we have:
Pro-Mboard Rev0.1

Schematics Rev0.1 PNG
Schematics Rev0.1 PDF

We have the First Revision of the PCB already available and right now the Component Assembly is in progress. Expect some pictures by 6-DEC-2010.

We would like to request your feedback on the design and also if there are furthere improvements that can be performed.

Tuesday, November 23, 2010

Chess Becomes Harder: Thanks to Quantum Physics

Adding a twist to the normal Chess game using the uncertainty of the Quantum Mechanics makes thing more difficult.Queen's University computer scientists have invented a new version of chess where its nearly impossible to predict the nature of a piece before hand. As soon as the player touches the piece it assumes is new behavior.

'You only know what a piece really is once you touch the piece,' researcher Ernesto Posse said after he tried the game. 'Basically, planning ahead is impossible.'

Quantum quirks
According to quantum physics, very small particles behave according to principles that give them characteristics very different from the behaviour of larger objects. Here are a few properties of those quantum objects:
> Quantum superposition: A quantum object may exist in multiple states at the same time.
> Wave function collapse: An observer's interaction with a quantum object in a superposition of states, such as an attempt to measure its position or momentum, will make it "collapse" into a single state.
> Quantum entanglement: Two or more quantum objects may be linked so that any change to one is immediately experienced by another, no matter how far apart they are from one another.
Read More : http://www.cbc.ca/technology/story/2010/09/02/quantum-chess-akl.html

Wednesday, November 17, 2010

Rainbow in Nano: Micro Carvings Make Metals Glisten In Any Colour

Optoelectronics engineers have discovered how to make gold of any colour by carving tiny shapes onto its surface. Then we may have some stickers directly printed on the metal surface.
Gold absorbs blue light and this produces its characteristic yellow colour. And copper absorbs blue and green light making it look a reddy orange.Other colours are hard to come by without coating the metal or carving a diffraction grating onto its surface to produce a characteristic interference pattern, like those from a compact disc.

But now there's another way thanks to some interesting work by Jianfa Zhang at the University of Southampton and a few pals. Their idea is to carve a different type of repeating pattern on to the surface of a metal.

These patterns are smaller than the wavelength of visible light. Instead of causing the light to interfere, they work by changing the properties of the sea of electrons in the metal--in particular its resonant frequency. This alters the frequency of light it absorbs and reflects.

Friday, November 12, 2010

Debounce a Button: A Common Problem

De-bouncing a button has been a challenge for any embedded engineer. Well not to say "challenging:, it is always a nagging stuff.

Some time you trade with time, code space or some other resource. Hack-A-Day organized an event to collect all the great De-bouncing code. Nice collection of code snippets to refer.

Thursday, November 11, 2010

Mini CNC out of PC Part

We cam across an recent innovation in building a small CNC from PC parts. Mike is a PCB designer with 3D modeling experience, cool.

He built it at the cost of only USD45. The website includes some basic building instructions. It also has the YouTube Video that demonstrates this CNC machines operation. We congratulate him on this build.

Wednesday, November 10, 2010

File Restore for NTFS & FAT

We recently came across an utility FreeUndelete from Office Recovery.com to recover the files on NTFS and FAT partitions. This is available for Free as personal use.

FreeUndelete restores deleted files, including those removed from Windows Recycle Bin. In case of accidental removal of files on a NTFS (1.0 and 2.0) (default for Windows Vista, XP, 2000 and NT), FAT32, FAT16 or FAT12 file systems this is the utility to help.
Supported file systems: 
NTFS 1.0, NTFS 2.0, FAT12, FAT16 and FAT32
The recovered files are saved into a new user-selected location to prevent overwriting the deleted files on the original media.There is no charge, direct or hidden, to download and use a fully functional copy of the program. The program does not install any spyware or adware along with it. It does not populate user's desktop with pop-up ads or forcefully subscribe user to mailing lists.

Additionally the is a Proper Usage Guide that suggest and describe the installation steps for this utility.
Here is the Direct Download link for the FreeUndelete. We have already successfully tested this by installing it into a Pen drive for portability and this also helps to recover the files on HDD where you cant install this software directly.

Friday, November 5, 2010

Geek Visiting Card - In Style

We came across Frank's innovation in making his own Business card using a ATtiny85 microcontroller running the AVR bit-bang V-USB stack.
When the Caps lock key is pressed thrice then this card prints out the complete contact information on Notepad. This device basically emulates a USB keyboard using the HID profile and senses the key presses on the system. Then after the valid key presses it starts to generate a stream of key presses to type in the information.
Impressive portray of what a geek can have as a style statement.
Complete Documentation along with schematics and code is available on Frank's Website. Check out his development for AVR based USB HID profile devices call : USnooBie. This is compatible to Arduino and can be directly plugged into the PC. Its also commercially available at Seeed Studio.

Testing What you Manufacture: The Pogo Pin Guide

There was a nice tutorial by Lady Ada on the Website. This demonstrates how to make test jigs for the Porto or Manufactured PCBs.
This site contains most of the explicit instructions on how to make your own jigs using the good old Arduino.

Saturday, October 16, 2010

Single Electron Reader : Next setep to Quantum Computing

Recently Australian scientists have made a major breakthrough in the study of quantum mechanics.They were able to read the spin of a single electron on a silicon wafer. From the University of New South Wales:
A team led by UNSW engineers and physicists has achieved a breakthrough that brings a super-fast quantum computer a step closer to reality by developing a “single electron reader” – a key building block in creating a silicon-based quantum machine.
Quantum computers promise exponential increases in processing speed over today’s computers through their use of the “spin”, or magnetic orientation, of individual electrons to represent data in their calculations.
In order to employ electron spin, the quantum computer needs both a way of changing the spin state (the “write” function) and of measuring that change (the “read” function) to form a qubit – the equivalent of the bits in a conventional computer.
Well we are closer to a full electronics logic and data manipulation using Quantum Phenomenon.

Spectrometer : In a Pocket

An interesting project that brings smart phones and chemistry together.
    University of Illinois chemistry professor Alexander Scheeline has developed software that turns a camera phone, an LED, and a few other cheap tools into a spectrometer. Armed with these, he thinks we can bring high-end analytic tools to high school chemistry labs all over the world.

    “The potential is here to make analytical chemistry a subject for the masses rather than something that is only done by specialists,” Scheeline said. “There’s no doubt that getting the cost of equipment down to the point where more people can afford them in the education system is a boon for everybody.”
In High School Chem Labs, Every Cameraphone Can Be a Spectrometer (Source: Wired.com)

Wednesday, October 13, 2010

OpenSource Hardware: The next revolution

Recently Open-source Hardware summit was held in NY when all the Open Source geeks and gurus met to discuss on the next big thing: Open Source Hardware. For ages, electronics had been formidably closed and only a handful of corporates and big players had access. With the growth of open source software, people had freedom from the propitiatory software. The similar revolution was started with the AVR microcontrollers from Atmel as they gave the complete tool chain for free(story of AVR). Now this idea has come to a much mature phase where a global standard for hardware would be adopted:
The standard definition says:
Open Source Hardware (OSHW) Statement of Principles (Draft)
Open source hardware is hardware whose design is made publicly available so that anyone can study, modify, distribute, make and sell the design or hardware based on that design. The hardware’s source, the design from which it is made, is available in the preferred format for making modifications to it. Ideally, open source hardware uses readily-available components and materials, standard processes, open infrastructure, unrestricted content, and open-source design tools to maximize the ability of individuals to make and use hardware. Open source hardware gives people the freedom to control their technology while sharing knowledge and encouraging commerce through the open exchange of designs.
This spec has already approached a 1.1 of release. Here is the 0.4 draft that it began with.
We wish all the OHS supporters best of luck and would try our level best to contribut this movement.

Tuesday, October 5, 2010

Sintel: Open Source Wonder Movie

Got to watch this:

“Sintel” is an independently produced short film, initiated by the Blender Foundation as a means to further improve and validate the free/open source 3D creation suite Blender. With initial funding provided by 1000s of donations via the internet community, it has again proven to be a viable development model for both open 3D technology as for independent animation film.
This 15 minute film has been realized in the studio of the Amsterdam Blender Institute, by an international team of artists and developers. In addition to that, several crucial technical and creative targets have been realized online, by developers and artists and teams all over the world.
This is a real nice creation and demostrates the Power of Opensource.
For more info Visit the Sintel Website.

Monday, September 27, 2010

Kosh Module: Update 4

Now the Schematics and the Eagle Files have been updated into Source Forge. A single non-Isolated 5V CAN Transceiver is used SN65HVD251 with a resistive Level conversion for the 3.3V circuit. Also included is a button for Reset and a dedicated button for the VSCP Init function.
Here is a picture of the current schematics:

Possibly the SD card connector that I use needs to be pictured.
As we can see from the picture only 7 pins are used. The Kosh module also gives provision for this connector only(8th pin in NC). Possibly in the future we can look for a real SD card connector on board. But this trick was real neat so I am following it.
The technique used here is taken from dharmanitech.com's SD card Article.

Let me know your suggestion to make this project Better.

Sunday, September 26, 2010

Low Power Series : Battery Life Calculation

Battery has become the key source of energy in the Emerging Low Power Devices. It's important to note that the capacity is a limitation for batteries, so they need to be used wisely.
To help in this regard we would like to share our Battery Life Calculation Technique that we have used successfully in many of our projects.

# First of all let's start with the basics of identifying some of the key characteristics of any system that is battery driven:

- Cycle Time: t(p)
This is a unit time between any two subsequent wake-up(or Active Mode) or sleep(or Low Power Mode) timings of any battery driven device. This is also known as Operation Cycle.

- Sleep Time: t(sleep)
This is the total time within one operation cycle time of a battery powered device, where it consumes the least amount of energy( in terms of electric current ).

- Active Time: t(act)
This is the total amount of time within one operation cycle time of the battery device where it consume energy
more than it does in Sleep Time t(sleep)

Hence, t(p) = t(act) + t(sleep)

# Next, would be to determine the Operation Cycle:
We know that for every specific operation the device performs some tasks and then go back to Low Power mode. The rate at which this switching is performed determines the battery life and is also required to determine the Cycle Time t(p).

Let's take an example of a thermometer that needs to perform temperature measurement every hour in a Day
and for rest of the time it remains in low power mode.

So, Rate of Therm. Operation (in days) = 1/24 day

Since, there are 24 hours in a day and it needs to perform the measurements on an hourly basis.
Also expressing of the rate can't be directly in days , as it makes things difficult for embedded guys who deals
with Milli-seconds. Let us now convert the above mentioned rate in terms of milliseconds.

Rate of Therm. Operation (in mS) = (1/24)*24*60*60*1000 mS = 3600000 mS

Now, if you closely observe this rate is nothing but the Operation Cycle since it's exactly the distance between the two subsequent Measurements.

Thus, have been able to find our first parameter Cycle Time t(p) = 3600000 mS

# Next job is to find the Active Time t(act):
This is the time taken by the battery device to do it's intended function. It is important to note that this
time can be subdivided into multiple tasks on the basis of device current consumption.
Shown below is the current verses time graph for a typical battery powered device.

The time and current values of all these tasks are used to find the Energy Time Product(express in mAmS ) which can then be multiplied to voltage to obtain Energy Capacity(expressed in mAH ). To explain this we would take two examples - one from our prior Thermometer example and, another from a more complex embedded device example.

Let us consider that our Hourly thermometer needs to operate for 10mS
and would consume an estimate of 10mA

Then, Active state time t(act) = 10mS
Active State Energy Time product for Thermometer = 10mA * 10mS = 100mAmS 

Let us consider the Active time graph of the more complex embedded device.

Here we would like to tabulate the values in order to find individual Energy Time Products and the total Active Time t(act) Shown below is the graph depicting the same.

Time(mS) Current(mA)
1 5
2 2
3 3
4 1
5 1
6 2
7 1
8 1
9 2
10 3
11 3
12 1
13 1
14 2
15 5
16 6
17 2
18 1
19 1
20 2

# Next would be the Sleep Time t(sleep):
This is the time in which the battery powered device consume the least amount of power in terms of current drawn. In general the device would try to remain in this state for the maximum of the Operating Cycle in order to minimize the power consumption. However the actual power consumed by the battery
powered device can't be zero unless batteries are taken out. So this small consumption is what would again contribute to battery life. To explain this let's see the above two examples.

Let us consider that our Hourly thermometer would consume 10uA of current in it's low power mode or sleep mode.

Thus, Sleep time t(sleep) = t(p) - t(act) = 3600000 - 10 = 3599990mS
Sleep Sate Energy Time Product for Thermometer = 0.01mA * 3599990mS = 35999.9 mAmS

For the complex embedded device we would modify the the table to grab the various consumption levels into different tasks. The new table with a column for the Energy Time Product added.

The Next parts would be covered Later, Hope that this would provide some useful information on the Low Power Calculations. Let me know your feedback on this.

Warm Regards,

Friday, September 24, 2010

Paper-thin supercapacitor has higher capacitance: Nano Energy Revolution

Emerging as a significant advancement in development of Super Capacitors, this is something ground breaking.

Paper thin Super Capacitor and bendable too. Makes the possibility of wearable energy storage in the near future. Catch more on this at PhyOrg.

Saturday, September 18, 2010

Save the Pen Drive from Infection (a.k.a USB Storage Protection)

Recently I found a trick to make my Pen Drives safe. This was to say that if you connect to an Infected PC you may be spared by warnings only. In fact as per study the majority of people who work on Windows XP operating systems are affected by this problems. I found an permanent solution to this, however this would block only the "Autorun" method of infection by the Virus. For Others you still need to be care full, as they might infect your other files.
Certain category of the Virus and Worms spread by hiding inside the "Recycle Bin" folder and installing executable code in the special file - "Autorun.inf". This file is responsible for both setting the Icons for the Pen Drive and also contains "Attach-time-Execution-instructions" for the drive. The Virus thus modifies this file to make sure that next time the pen drive is plugged into another PC the Virus can spread. My method here is simply to avoid this. In fact this has already been explained many times on the web, however I am publishing a compiled version of steps help get all in one place.

1. First we need to convert the Pen Drive file system to NTFS.
     All Widows versions after 2000 support this file system so
     there is not reason to worry.
     To proceed First Back Up all Data from the Pen Drive.
     To do this take the Uninfected Pen Drive!! in an Uninfected PC!!
     (This would work only before the Infection has happened)
     Plug it into the PC with Administrator Privileges
     (Logged in as Administrator) or the User has Admin rights.
    Open the Terminal Window by executing the "cmd" command
     from the Start Menu => Run.
     Now go to the Pen Drive " drive letter" by typing ":"
     in the Terminal.
     Suppose if my Pen Drive is connected as "H:" then I
     type "H:" and press enter

     In general the Pen Drives are formated by default as FAT32,
     but to make them safe we need to make them NTFS.
     Give the Command "convert : /FS:NTFS",
     It would warn you, give yes.
     Suppose the Drive is connected to H: then
      convert H: FS:/NTFS

      After this by keeping the Pen Drive attached, Reboot the System.
      When the Windows reboots it would configure the Pen Drive to NTFS.

2. Create the "Autorun.inf" file.
      This can be done by simply saving a Text file in Notepad in
       the Pen Drive as "Autorun.inf" .

3. Protecting the "Autorun.inf" file.
      Open a Terminal window in the way as stated earlier.
      Give the following commands in a Sequence:
       attrib -a Autorun.inf /S /D
       attrib +s +h +r Autorun.inf /S /D
       cacls Autorun.inf /c /d everyone
       Now it would ask for confirmation answer with 'y'

4. Creating Recycle Bin Folder.
      This can be performed in the same Terminal Window as above.
      Give the command: "md Recycler"

5. Protecting the Recycle Bin Folder.
      This can be performed in the same Terminal Window as above.
      Give the following commands in a Sequence:
      attrib +s +h +r Recycler /S /D
      cacls Recycler /c /d everyone
      This would ask for confirmation answer with 'y'

Now when the virus or the infected computer tries to access
this drive then there would be warning.

Hope that this helps to prevent further problems although not be full proof
but "prevention is better than cure".

The original article was taken from: Source 1 and Source 2

Warm Regards,

Wednesday, September 15, 2010

MinGW: Win32 Adventure Begins

MinGW, a contraction of "Minimalist GNU for Windows", is a minimalist development environment for native Microsoft Windows applications. I had know this for a long time. For many cross compilers I was using GNU gcc compiler. However my Win32 experience was mostly using the VC++ from Microsoft. I always wanted to do away the propitiatory stuff related to Visual Studio and all. The best way for hobbyists like me is to go for GNU alternatives.I tired my luck in installing and running my first program on the MinGW today.

So here goes what's we need to do:
Step1: Installation

> First we need to download the MinGW suit from Sourceforge. Fortunately unlike other GNU tools this has a good Installer feature. I downloaded the recent mingw-get-inst-20100909.exe, or which ever gets updated.

However for the installer to work an Internet connection is needed for it to download the complete packages.
Note that installation user need to be a Administrator user, or at least have Administrator rights on the PC, this is being installed. This is important since we need to also configure the path for the executable.

> After the download is complete, execute the the installer. It would ask for creation of the Software icons etc. Click next to continue

> Next it would ask for the Repository Catalogs - Select the Use pre-package repository catalogs.
Since its always better to trust the tested packages than the beta ones.

> Accept the GNU License to continue

>It would prompt to create the MinGW directory. Possibly like C:\MinGW. This can be set to another location or left as it is. We would consider it left as it is for this tutorial.

> Next comes the selection of the Program File group.

> Finally the important step the selection of the packages: Select the C++ Compiler and MSYS system if you like. However its better to install MSYS in case you need the feel of linux under windows.

> After this it opens a command prompt window to download the packages. There may be a case that the internet connection drops out. Don't worry, the install can be reinstated again and again it would start at the exact point of download it had stopped.

> If all the download is completed successfully you don't get a error message before Finish.

Now an Important step is to set the Path:
>Go to Start Menu in WinXP right click on the MyComputer and select Properties to open the "System Properties Dialog".
>Go to the Tab "Advanced" at the bottom would be button named "Environment Variables". Click this to open the "Environment variables" dialog
> In the "System Variables" list scroll for "Path" and click on Edit.
> It will already have some data, that would be default path of the system.
Concatenate to it ";" and click ok to set the path. 
Ensure that path is not accidentally over written or many things on the system would fail.
Best way it the copy it to notepad, add the required parameters and then paste it back to the Input box.

Now the PC is ready to execute the MinGW programs!!.

Step 2: First Dos Based (Terminal Based) Program

>First we need to open the Termial : Use "Start Menu" ==> "Run" Type "cmd" to open the command prompt.
> Go to the desired directory where the programs stored. For this tutorial its assumed to be at C:\MinGW\tut\ directory. So we give the command "cd c:\MinGW\tut" in the terminal
> Check the GCC version - give the command "gcc -v" it should display the version of the current GCC installed with MinGW.
> use Notepad to make you first program: For this tutorial we name it as "main.c" Below is the code:

#include <stdio.h>
#include <conio.h>
int main(void)
      printf("My GCC is working with MinGW");
      return 0;

> Now give the first compile command: "gcc -Wall -O2 main.c -o main.exe"
  Here the "gcc" is the compiler , "-Wall" says that we need to see all the warnings, "-O2" is the Optimization directive, we have the file name to be compiled and then "-o " specifies the final "exe" (on Windows) we want to generate.
> After this you can see the file has been created named "main.exe". Double click on this to execute.
> If everything is fine then you get a small terminal window displaying "My GCC is working with MinGW", press any key to continue.
This way the simple terminal based programs can easily be made using this excellent power open source compiler.

Step3: First Windows Program

> Here is the program named as "main1.cpp"

#include <windows.h>

  MessageBox(0,"Hello, Windows","MinGW Test Program",MB_OK);
  return 0;
} > To compile type : "gcc -Wall -O2 -mwindows main1.cpp -o main.exe"
Here the additional "-mwindows" instructs the compiler that this is a Windows application.

> Double click on the "main.exe" created. If everything works fine we would see a small message box:
> This is the basic Message Box api for Win32 applications.
Now lets do some advanced stuff:

Step 4: Advanced Windows based Program on Win32

> Here is the code for this named as "main2.cpp"

#include <windows.h>

char *AppTitle="Win1";
LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam);

  HWND hwnd;
  MSG msg;


  if (!RegisterClass(&wc))
    return 0;

  hwnd = CreateWindow(AppTitle,AppTitle,

  if (!hwnd)
    return 0;


  while (GetMessage(&msg,NULL,0,0) > 0)
  return 0;

LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
  switch (msg)
    case WM_PAINT:
      HDC dc;
      RECT r;
      DrawText(dc,"Hello World",-1,&r,DT_SINGLELINE|DT_CENTER|DT_VCENTER);

    case WM_DESTROY:

      return DefWindowProc(hwnd, msg, wparam, lparam);
  return 0;
> This program would be compiled using :"gcc -Wall -O2 -mwindows main2.cpp -o main.exe"
However you might see a depreciated warning since we have the "-Wall" option.
"main2.cpp:3:16: warning: deprecated conversion from string constant to 'char*'"
Dont worry its alright to have this warning.

> Now Double click on the "main.exe" created, If every thing goes fine we see:
> That's the first Windows program with callback implemented.

But we are still not doing the things in the GCC way, create the Makefile:

#gcc -Wall -mwindows -O2 main2.cpp -o main.exe

CC = gcc

# EXE Environment
# -mwindows for Windows Environment
# blank for DOS environment
EXE_ENV = -mwindows

# File optimization level
# O0 - Level 0
# O1 - Level 1
# O2 - Level 2
# O3 - Level 3
# Os - Optimize for Size

# GCC Options that help in debudding
# -Wall to show all the warnings


      $(CC) $(OPTIONS) $(OPTIMIZATION) $(EXE_ENV) main2.cpp -o $(OUTPUT)
      rm -f *.exe
      rm -f *.o

Now in the terminal just give the "make" command and the file magically compiles.
If you need to clean up the file just give "make clean"

I would be posting more advances soon.
Meanwhile let me know your feedback to make this article better.

Warm Regards,