Showing posts with label DIY. Show all posts
Showing posts with label DIY. Show all posts

Wednesday, July 6, 2011

How to make bitmaps for graphic LCD (glcd)?

Making bitmaps for graphic LCD is pretty easy. There is a lot of free tools available over Internet, but I think there is no need to download them if you have already installed an image editing software in your PC. Also it is interesting to know what's actually they do. In this quick tutorial,  an example using GIMP - a free image manipulation program is described. This is a general tutorial and can be applicable for almost all type of graphical LCDs.

Step1: Know the pixel size of your graphic LCD. For KS0108 (a general purpose glcd), it is 128x64.
Step2: Choose an image(any image) to be embedded on LCD.
Step3: Scale the image to 128x64. In GIMP, (menu)Image -> Scale Image. Change height to 64 and width to 128.
If your image is not an exact multiple of 128x64 and if you want to keep the aspect ratio, you need to do any of the following:
a) Crop the image to 128x64.From toolBox(dock in the left hand side most probably), choose Rectangle Select Tool and spcify the size to 128x64 in the bottom of toolbox and select a portion you want and crop it. (menu)Image -> Crop to Selection.
b) Resize the image to less than or equal to 128x64. Then start a new image by (menu)File -> New. Then from the dialog box choose size as 128x64. Copy the previous image to the new image.
c) If you want to just check and image is not matter, image search on Google specifying the size 128x64 ;-)
Step4: Before going to this step, I assume you have an image of the same size of your LCD. In this example, 128x64. Next is the conversion of your color image to monochrome image. For that, choose, (menu)Colors -> Threshold. Using the dialog box, you can change the threshold in realtime.
Step5: Change mode.(menu)Image -> Mode -> Indexed.From the dialog box, choose 'Use Black and White (1bit) palette'. Click 'Convert'
Step6: Save the image.(menu)File -> Save as. Choose extension .bmp (bitmap).

Now your image is ready for embedding to your LCD. For some programs like MikroC for PIC, there is a built in tool to convert the bitmap into array. If you don't have such advanced tools, don't worry, let's do it using open source tools.
Using Octave/Matlab for KS0108
Now you have a monochrome bitmap of only zeros and ones. Now it should be grouped and formatted to a format supported by glcd. I did the conversion using octave. The script shown below accepts the bitmap name as argument and convert it to the glcd compatible form. make appropriate changes to run the script in MATLAB. Also change yourself the program if your lcd size is different.
#This code input a monochrome bitmap of size 128x64 and convert it to a form compatible to ks0108 graphic lcd(glcd)
arg_list=argv();
x=imread(arg_list{1}); #accept argument
num=0;
printf("Controller 1 (left)\n\n");
page=0;
for offset = [1:8:64]
    printf("Page %d:\n",page);
    page+=1;
    for j=1:64
        for i=[offset:offset+7]
            num=num+x(i,j)*(2^(i-offset));
        endfor
        printf("%d ",255-num);
        num=0;
    endfor
    printf("\n\n");
endfor
printf("Controller 2 (right)\n\n");
page=0;
for offset = [1:8:64]
    printf("Page %d:\n",page);
    page+=1;
    for j=65:128
        for i=[offset:offset+7]
            num=num+x(i,j)*(2^(i-offset));
        endfor
        printf("%d ",255-num);
        num=0;
    endfor
    printf("\n\n");
endfor

Monday, July 4, 2011

ChaserDesigner - A professional approach for fancy light design

This project is published in July 2011 th issue of Electronics For You (EFY) magazine (Page no: 94 to 98) titled:"Microcontroller-Based Light Chaser". Thanks to EFY for publishing this. You can read full article from EFYmagonline or purchase one.

ChaserDesigner is a useful project for fancy light designer professionals  as well as enthusiast who want to make their own LED patterns while decorating home during festivals. It's hardware part is simple one which uses 8051(or any variants of 8051) and a handy software part based on Qt. In the GUI, you need to specify how the pattern appear on LEDs(or connected higher loads) and it will automatically generate the source code for 8051(in assembly language). Only you need to do is that, burn the program in to the micro and put it on the circuit. Then the LEDs start to glow in the designed pattern. This is very handy and there are some tools provided to easily make your own patterns. The software works in Linux, Windows, or MAC and hardware components chosen are almost ubiquitous. In case, if any component found unavailable, please comment, I will try to recommend any alternative if any. I have put source code,circuit diagram and all other associated diagrams free for download.

1. contents.zip - Article before published, circuit diagram, images etc.
http://www.4shared.com/file/MolWxWP_/content.html

2. chaserdesigner_src.zip - Software source code.
http://www.4shared.com/file/zY9fz6LF/chaserDesigner_src.html


3.chaserdesigner1.0.zip - Windows XP executable file
http://www.4shared.com/file/3WmVxoaF/ChaserDesiner10.html


4.videos.zip - videos describing, how to operate the software and hardware.
http://www.4shared.com/file/EagoltHS/videos.html


Note: Since it is published by EFY,  it is better to read this article in EFY to get more pretty article with PCB layout also.

Saturday, November 27, 2010

Just bought an Arduino, What's next?


This article briefly explain what is to be done just after purchasing an Arduino board. Even though the prerequisites of Arduino is less compared to other development boards, I think this article will be useful because Arduino is being popular among beginners. This article deals with the latest version of Arduino at the time of writing - it is Arduino UNO.
Setting up drivers
Connect Arduino to your computer via USB cable. It will power up from USB power. Now start Arduino IDE. If you have not Arduino IDE download from here. No need to install the software. Just extract using your favourite decompressing utility (my favourite is 7zip) and run the executable named 'Arduino'. Now you have to set up your IDE to work with your Arduino UNO. First select your hardware from Tools -> Board -> Arduino UNO (or your exact hardware name. If it is not listed, try to download the latest version). Next, select your serial port from Tools -> Serial Port. Selecting serial port is in different way different OS.
Linux
If the 'Serial Port' menu is not active, probably, your device is not connected properly. Try to reconnect. If more than one serial ports are shown in the menu, we need to find out which is the correct one. To do that, disconnect your arduino first. Then you probably need to restart the IDE. Then look at the 'Serial Port' menu and note down the listed COM ports. Then reconnect your device and track the newcomer. This is the easy way. Select it.
One of the problem I suffered while playing with arduino in my Ubuntu 10.04 LTS was that, the compilation of the program was a failure. It was a dependancy problem. So what I did is that, installed Arduino IDE as described here. But it was an older version and my device UNO is not listed in it. Then downloaded the newer version from the downloads page. That was really a tricky step!
MS Windows
In Windows, just after connecting your device to the PC, a device driver wizard appears and try to find the appropriate device driver for the device. It will take a while and at the end of the fight, it fails to find an appropriate driver. Close the wizard and go to 'Device Manger' (Either via Control Panel or by right clicking 'My Computer' then 'Manage'). Then you can find Aduino UNO as the unknown device. Right click on that and choose the option to manually install the driver. Then locate the directory where you have installed Arduino IDE. Then the system install the appropriate driver and now you can see your device on the list named 'Ports' in the Device Manger. In parenthesis, there will be the curresponding COM port number (eg: COM 4) . Then choose that COM port in the Arduino IDE.
Starting with 'Hello World'
The commonly accepted 'Hello World' in embedded devices is LED blinking. There is an example in the IDE itself. Open the file from File -> Examples -> Basics -> Blink
Look at the program. For an average C programmer, the program seems self-explanatory. To compile your program, choose Sketch -> verify/compile. Then to upload the executable to your device, choose,File -> upload to I/O board. If everything you have done is correct, you will get your Arduino programmed and starts working just after burning the program using the USB power. Disconnect it from USB and use in your standalone applications.
Read more..
Arduino Lanugage reference
Arduino Playground

Saturday, March 13, 2010

Inside the Mosquito killer


Nowadays, people widely uses mosquito killer bats because of their easy usage. The product is imported from China for very cheap price. There's some electronics inside it. If you understand the working principle of that circuit and if you are an owner of soldering iron, you can easily troubleshoot the problems and can use the product for a long time.
The power source of old products was dry cells, while now it is rechargable battery of 2.4V. There is bridge rectifier and a capacitor is used to get enough power to charge the battery. Transistor become ON, when switch is closed and the sudden change in current in the primary coil in the transformer forms a higher voltage. The voltage is coupled to the secondary coil. transformer winding is so that peak voltage will be about 2000V. The diode network only pass a fraction of the output voltage to the metal net.

Friday, March 12, 2010

Slider game using Qt


It is better to do simple things first in Qt before making hands dirty with complex programs. Now I just prepared a slider game using Qt.Hope all of you know how to play slider game. My code is simple and having a slider panel of 3x3 matrix. I know the code is not much pretty. But I just put my source code to download. It may be helpful for beginners. Of course, you can modify the code to satisfy your needs.
Enjoy!

Download slider.zip
Note: You need to recompile the code before using. I successfully compiled the code in Linux. Of course, you can compile it in other platforms without modification of code.

Wednesday, February 10, 2010

Let's have fun during festivals!

Festivals are not only for entertainment. You can do some cool things. I have just made a fire powered car using commonly available things during festivals. See how:

The things you required:Now, make the things done.
Unfortunately, I can't capture pictures and videos of running the car, because, my mobile phone did something wrong while capturing. Sorry. I don't have another sample to do once again. I will try it next year!

Car after launching.I got everything fine. Even though you think this type of stuffs are gibberish, people like me find entertainment by doing so.

Warning: use a metal or card board plate above toy car in order to avoid over burning. Don't do it in you room. Do it away from your home as well as from inflammable things. Don't launch while you stand behind the car.