Вы находитесь на странице: 1из 69

A VISION BASED ROBOT A vision based robot has an image acquisition device like a webcam as its eyes.

Then we need a processor that can make sense out of those captured images and actuators like dc motors for navigation. One key point to note is that Image Processing has huge computational requirements, and it is not possible to run an image processing code directly on a small microcontroller. Hence, for our purpose, the simplest approach would be to run the code on a computer, which has a webcam connected to it to take the images, and the robot is controlled by the computer via serial or parallel port. The code is written in software that provides the tools for acquiring images, analyzing the content in the images and deriving conclusions. This Project will introduce the complete knowledge of Image processing using Matlab and development of the hardware which can do desired task using a web cam. The take away will be the fundamental knowledge with best practices and design strategies to build a Robot based on Image processing. Basic Mathematical operation by Matlab. Making GUI (Graphical User Interface) with Matlab (For Practical uses). Type of data types used for Image Processing. Conversion between Data types. Type of Images. Theory of conversion between images. Conversion between images with Matlab. Practical uses of binary and gray scale images. Basic Features of images for Practical purpose. Extraction of Features of image by Matlab like:-

Objectives
1. Finding area of particular sized spot or particular shaped spot or particular color spot. 2. Finding circumference of Featured Areas 3. Finding Gravitational point of particular featured Area etc (Many others features are there which can be extracted for practical purposes) Making negatives of images by Matlab Making Binary image using cut off value. Basics of Communication b/w computer and Hardware. Features of Motor Driver IC. Handling Parallel Port.

Block Diagram

Webcam

Matlab codes

Parallel Port

Motor Driver

Motor

Project process
A vision based robot has an image acquisition device like a webcam as its eyes. Then we need a processor that can make sense out of those captured images and actuators like dc motors for navigation. One key point to note is that Image Processing has huge computational requirements, and it is not possible to run an image processing code directly on a small microcontroller. Hence, for our purpose, the simplest approach would be to run the code on a computer, which has a webcam connected to it to take the images, and the robot is controlled by the computer via serial or parallel port. The code is written in software that provides the tools for acquiring images, analyzing the content in the images and deriving conclusions. MATLAB is one of the much such software available which provide the platform for performing these tasks.

MATLAB What does MATLAB stand for?


MATLAB stands for MATrix LABoratory. Hence, as the name suggests, here you play around with matrices. Hence, an image (or any other data like sound, etc.) can be converted to a matrix and then various operations can be performed on it to get the desired results and values. Image processing is quite a vast field to deal with. We can identify colors, intensity, edges, texture or pattern in an image.

Getting acquainted with MATLAB environment

For those who have just finished installing MATLAB on their system and cant figure out from where to start, no need to worry! This tutorial will first make you well acquainted with its very basics and then move further.

So, a typical MATLAB 2009 window looks like:

There are 4 main windows: 1. Command window: This is the main window where you write the commands, as well as see the outputs. In other words, here is your interaction with the software. 2. Command History: As the name suggests, it shows the list of the commands recently used in chronological order. Hence, you can double click on a command to execute it again. 3. Current directory: It is the default directory (folder) for saving your files. All the files which you make (like m-files, as discussed later) are saved here and can be accessed from

here directly. The location of the current directory is shown in the toolbar at the top. You can change it by changing the address here.

4. Workspace: It displays the list of the variables defined by you in the current session of MATLAB.

The Menu bar and Toolbar:

The toolbar has buttons for common operations like cut, copy, paste, undo, redo. The most important button here is the HELP button. It opens the MATLAB help window which has looks somewhat like this:

You can get the details of any MATLAB command/function here and many demos of some commonly used applications. Locate the four tabs: Contents, Index, Search Results and Demos on the left. One of the best ways to learn by yourself is to look for demos of your interest and type the command/ function which you encounter there as the search term. You will then get the complete details of the function like its use, syntax, as well as few examples on how to use it. You can also have a look at some of the related functions at the end of page under the heading See Also. The demos related to Image Processing can be found under Image Processing Toolbox and Image Acquisition Toolbox. Now once we are done with knowing the essential features of MATLAB, lets start typing something in the command window, say: a=5 and press enter.

Yes as you can see that MATLAB creates a variable with name a, stores value 5 in it and displays it in the command window itself. Hence you can see how user-friendly MATLAB is. Variables are stored in the form of Matrices in MATLAB. Hence, a is a 1X1 matrix in the above example. Similarly, you can make one dimensional, two dimensional, etc. matrices as follows: >> a= [1 3 5 7 9] a= 13579 >> b= [1 2 3; 4 5 6; 7 8 9] b= 123 456 789

To avoid the display of the variable, we use semi-colon (;) at the end of instruction. >> b= [1 2 3; 4 5 6; 7 8 9]; The indices of matrices in MATLAB start from 1 (unlike C/C++ and Java where they start from 0). We refer to a particular element of the matrix by giving its indices in parenthesis (). >> b(2,1) Ans = 4 Now with the variables in hand, you can perform various mathematical operations on them directly. >> a= [1 2 3]; >> b= [6 7 8]; >> a+b Ans = 7 9 11 Ans is the default variable of MATLAB. You can also store the result in another variable as >> c=a+b c= 7 9 11

General functions/commands
clc: To clear the command window, giving you a clear screen. clear: To remove all variables from the workspace. This frees up system memory. Trigonometric functions For angle in radians>> sin(1) Ans = 0.8415 For angle in degrees>> sind(30) Ans = 0.5000 Inverse trigonometric>> asin(1) ans = 1.5708

>> asind(.5) Ans = 30.0000 Similarly we have cos(), cosd(), acos(), tan()etc.

The colon operator (:) The colon is one of the most useful
operators in MATLAB. It can create vectors, subscript arrays, and specify for iterations. In a very crude language, we can say that the colon (:) means throughout the range. j:k is the same as [j,j+1,...,k] j:i:k is the same as [j,j+i,j+2i, ...,k] A(:,j) is the jth column of A A(:,j:k) is A(:,j), A(:,j+1),...,A(:,k) A(:) is all the elements of A, regarded as a single column. Example, >> a= [1 2 3; 4 5 6; 7 8 9] a= 123 456 789 >> a(:,2:3) Ans = 23 56 89 Relational operators Description Operator == Equal to ~= Not equal to < Less than <= Less than or equal to > More than >= More than or equal to *Note: As a block is contained in braces {} in C/C++/Java, a block is terminated by the end statement in MATLAB. for: To create a loop, i.e., execute a block of code specified number of times.

Syntax: Statement ... Statement end Example, >>c=[1 2 3 4 5]; b=0; >>for i=1:5 b=b+c(i); end >> b b= 15 while: Again to create loop, that executes till a specified condition is true. Syntax: while condition statements end Example, >> c=2009; i=1; while c>1 b(i)=mod(c,10); c=c/10; i=i+1; end >> b b= 9.0000 0.9000 0.0900 2.0090 zeros(): Create array/matrix of all zeros. B = zeros(n) returns an n-by-n matrix of zeros. B = zeros(m,n) returns an m-by-n matrix of zeros. Example, >> z=zeros(2,4) z= 0000 0000 Similarly we have ones() function for all values 1.

size(): Returns matrix dimensions. Syntax: statement ... statement end Example, >>c=[1 2 3 4 5]; b=0; >>for i=1:5 b=b+c(i); end >> b b = 15 while: Again to create loop, that executes till a specified condition is true. Syntax: while condition statements end Example, >> c=2009; i=1; while c>1 b(i)=mod(c,10); c=c/10; i=i+1; end >> b b= 9.0000 0.9000 0.0900 2.0090 zeros(): Create array/matrix of all zeros. B = zeros(n) returns an n-by-n matrix of zeros. B = zeros(m,n) returns an m-by-n matrix of zeros. Example, >> z=zeros(2,4) z= 0000 0000 Similarly we have ones() function for all values 1. size(): Returns matrix dimensions.

A Binary Image

A Grayscale Image

Grayscale Image: It contains intensity values ranging from a


minimum (depicting absolute black) to a maximum (depicting absolute white) and in between varying shades of gray. Typically, this range is between 0 and 255. *Note- In daily language what we refer to as black-and-white (as in old photos) are actually grayscale. Hence avoid confusion here in technical terms.

Color Image: We all have seen this! Such an image is


composed of the three primary colors, Red, Green and Blue, hence also called an RGB image.

RGB value: All colors which we see around us can be made by


adding red, green and blue components in varying proportions. Hence, any color of the world can uniquely be described by its RGB value, which stands for Red, Green and Blue values. This triplet has each value ranging from 0 to 255, with 0 obviously meaning no component of that particular color and 255 meaning full component. For example, pure red color has RGB value [255 0 0], pure white has [255 255 255], pure black has [0 0 0] and has RGB value [55 162 170].

Representation of an Image in MATLAB


An image in MATLAB is stored as a 2D matrix (of size mxn) where each element of the matrix represents the intensity of light/color of that particular pixel. Hence, for a binary image, the value of each element of the matrix is either 0 or 1 and for a grayscale image each value lies between 0 and 255. A color image is stored as an mxnx3 matrix where each element is the RGB value of that particular pixel (hence its a 3D matrix). You can consider it as three 2D matrices for red, green and blue intensities.

Reading and displaying Images


imread(): To read an image and store in a matrix. Syntax: IM=imread(filename)

Where IM is a matrix. If the file is in the current directory (as described above), then you only need to write the filename, else you need to write the complete path. Filename should be with extension (.jpg, .bmp...). There are some default images of MATLAB like peppers.png, cameraman.tif, etc. You can try reading them as >>im=imread ('peppers.png'); It is always advised to use a semi-colon (;) at the end of the statement of reading an image, otherwise you can try yourself what happens! imshow(): Displays the image. Syntax: imshow(filename) or imshow(im) Example, >>imshow('cameraman.tif'); OK, now lets make our own image, try this: >>a(1,1)=0; >>for i=1:200; for j=1:200 a(i+1,j+1)=1-a(i,j); end end >>imshow(a);

Data cursor: To see the values of the colors in the figure


window, go to Tools>Data Cursor (or select from the toolbar), and click over any point in the image. You can see the RGB values of the pixel at location (X,Y).

A better option of data cursor is the function imtooli(). Type the following >>imtool(peppers.png); and see the pixel info on lower left corner as you move mouse pointer over different pixels. Making M-files and functions M-file It is a provision in MATLAB where you can execute multiple commands using a single statement. Here the group of commands is stored as a MATLAB file (extension .m). Go to File->New->Blank M-file MATLAB editor window opens where you can write the statements which you want to execute and save the file.

Here we have saved the m-file by the name test.m. Now as you type >>test in MATLAB command window, all the above commands will execute.

Comments: As we have comments in C/C++/ Java using double


slash (//), in MATLAB we use symbol % to write comments, i.e., statements that are not considered for execution. You can see comments in green in the snapshot above.

Functions
Functions, as some of you might know, are written to organize the code efficiently and make debugging easier. The set of statements within a function can be executed as and when required by just calling it, thereby avoiding repetitions. The data which is needed within the function can be passed as arguments and then the required values can be returned. You can return any no. of values and they can be matrices also. A function is saved as an m-file with the same name as the name if the function. For Example, the following function takes the input as a colored image and returns a binary image where the green pixels have been replaced as white, rest are black and also returns the total no. of green pixels. (This task is required frequently whose use is described later) function [bingreen, num]=green(im) [m,n,t]=size(im); bingreen=zeros(m,n); num=0; for i=1:m for j=1:n if(im(i,j,1)==0 && im(i,j,2)==255 && im(i,j,3)==0) %Red and Blue components must be zero and Green must be full bingreen(i,j)=1; num=num+1; end end end Now suppose the input image is 'shapes.bmp' (not a default image of MATLAB, hence you can save it in the working directory to perform the following operations or make yourself in paint)

So, you first read the image and then call the function by typing in the command window >> I=imread('shapes.bmp'); >>[img, n]=green(I); >> n n= 28753 >>imshow(img);

As you can see, this is a binary image with white pixels at those coordinates which were green in input image.

Now this was an ideal image where each color was perfect. But in practice, you dont have images with perfect colors. So, we give a range of RGB values to extract our required region of image. Suppose the image at hand is the following (again its not a default image) and we need to extract the red region.

So, we use the same function with the main conditional statement changed as function bw=red(im) [m,n,t]=size(im); bw=zeros(m,n); for i=1:m for j=1:n if(im(i,j,1)>150 && im(i,j,2)<50 && im(i,j,3)<50) %Specifying range for red bw(i,j)=1; end end end You can define more specific range as per your requirement. Now when we see the output image, it looks like

*Tip: To get an idea of what range of RGB values you must define, use imtool() function (or data cursor) with the original file, move the cursor over the region which you need to extract and note down the RGB values. Expand/ Contract the range as per your requirement by trying several times. This is actually how the calibration is done.

Removing Noise
As you can see, the binary image obtained above has quite a lot of noise. You need to smoothen the edges, remove the tiny dots scattered here and there so that at last you have some countable number of objects to work upon. There are several functions available in MATLAB to remove noise in an Image. Some of them are (bw is the above binary image): imclose(): Performs morphological closing operation. It fills in the gaps between two objects and smoothens the edges. The degree and type of smoothening and joining depend on the structuring element, i.e., the basic shape which is used to perform the operation. The structuring element can be a disk, a diamond, a line, etc. To create a structuring element, use strel() function. For example, >> se=strel('disk',5); % a disk of radius 5 >>bw=imclose(bw,se); original image itself >>imshow(bw); %Perform the closing operation on

imfill(): Remove holes from the image Holes are background pixels surrounded by foreground (image) pixels. >>bw=imfill(bw,'holes'); >>imshow(bw);

Now you need to remove the spatters. For that you can use the function imopen(). imopen(): Morphologically open the image. >>se=strel('disk',2); >>bw=imopen(bw,se); >>imshow(bw);

*Note: The purpose of these functions might not be clear at fist. Hence, it is strongly recommended that you explore these functions yourself by trying out on different images and have a look at these functions in MATLAB Help section also. The sequence of performing these operations is very significant, as the subsequent operation is performed on the converted image and not the original image. The sequence I have adopted is NOT necessary, and you must try yourself which sequence suits your requirement. The size and shape of structuring element is also to be determined experimentally, so that the number of objects you get in the binary image is same as what you require. This final image obtained in this example is still not workable, and you can try yourself to get a consolidated image. There are many other functions available for noise removal like imerode(), imdilate(), etc. Please refer to MATLAB Help section for details. An object is defined as a connected region in a binary image.

The use of making a binary file:


In most of problem statements of robotics based on image processing, we are required to find the centroid, area, and no. of objects of a particular color. MATLAB has in-built functions for these tasks which operate on binary images only. Hence we create binary images corresponding to different colors. For example, in the problem statement Brooklyn Builder of Techkriti10, the image from the top (overhead camera) looks somewhat like (again its an ideal image; the real one will be far different and full of noise)

Now we first take a sample image of arena, note down the RGB values (using imtool()) and then extract the regions of different color by making binary images. Then we can find the centre of different objects using the function bwboundaries() and regionprops(). The piers and decks can be differentiated on the basis of their area.

Getting the properties of different regions bwboundaries


It traces the exterior boundaries of objects in a binary image. B=bwboundaries(bw) bwboundaries returns B, a P-by-1 cell array, where P is the number of objects and holes.(A cell array is one where each element of the array is a matrix itself). Each cell in the array B contains a Q-by-2 matrix. Each row in the matrix contains the coordinates (row and column indices) of a boundary pixel. Q is the number of boundary pixels (perimeter) for the corresponding region. In other words, B contains the coordinates of pixels constituting the perimeter of each object and hole. For example, suppose there are four objects in a binary image.

Then the matrix B can be understood as shown in the diagram below

*Note: In the coordinate matrix, the first coordinate is the row number (y - coordinate) and second coordinate is the column number (x-coordinate) of the boundary pixel. Take this always into consideration as it can create a lot of confusion. bwboundaries(bw) will trace the hole boundaries too. So, a better option is to use bwboundaries(bw,'noholes')

Label Matrix (L)


A label matrix(L) corresponding to binary image is a 2D matrix of the same size as that of the image. Each object in the binary image is numbered 1,2,3,. and all the pixels of L corresponding to the objects in binary image have value respectively 1,2,3. The background pixels are 0 by default. In other words, the region in L corresponding to first object in the image is marked 1, corresponding to second object is marked 2 and so on. The label matrix corresponding to the above binary image would look somewhat like this (colors are just representative, the matrix will consist of values 0,1,2,3 and 4 only)

The label matrix(L) is can either be obtained from the function bwboundaries() as [B L]=bwboundaries(bw,'noholes'); or from function bwlabel() as

L=bwlabel(bw); Now why is this label matrix needed? It is required to use the following function

regionprops: It is used to measure properties of image


regions. Once we have an image consisting of all the objects labeled, we must now know the centroid, area, etc. of each. Syntax: STATS =regionprops(L,properties) Where STATS is a structure array with length equal to the number of labeled objects in L. The fields of the structure array denote different properties for each region, as specified by properties. properties are be a comma-separated list of strings. See the help section of MATLAB for all the properties available. We will use Centroid and Area. Example, >>stats=regionprops(L,'Area','Centroid'); The properties in the array stats are obtained by dot(.) operator. >>a=stats(3).Area; %to get area of 3rd object >>c=stats(2).Centroid; %to get centroid of 2nd object *Note: length(stats) = length(B) = max(L(:)) = no. of objects in bw

Working in Real Time Getting Hardware information


Till now we have been working on images already saved on our computer. But in actual practice, we need to work in real time, i.e., we need to take images continuously from the current environment using a webcam and then process them. Hence, the Image Acquisition toolbox of MATLAB provides support in this regard. To start with working in real time, you must have a functional USB webcam connected to your PC and its driver installed. MATLAB has built-in adaptors for accessing these devices. An adaptor is software that MATLAB uses to communicate with an image

acquisition device. You can check if the support is available for your camera in MATLAB by typing the following: >> imaqhwinfo % stands for image acquisition hardware info >> cam=imaqhwinfo; >> cam.InstalledAdaptors I tried this on my computer and I got the following information

To get more information about the device, type >>dev_info = imaqhwinfo('winvideo',1)

Most probably you would have 'winvideo' installed and use that. If it is not available, use whichever adapter is shown by imaqhwinfo. If you are using a laptop, you may also have a webcam in it. So note down the Device Name shown as above. If it is not the USB webcam, then probably DeviceID = 2 should work. Hence, type >>dev_info = imaqhwinfo('winvideo',2) *Note: From now onwards, I will refer Adapter by winvideo and DeviceID by 1. You must check yourself what is available on your system and change the commands described further accordingly. Note down the supported formats by your camera as >>dev_info = imaqhwinfo('winvideo',1); >>dev_info.SupportedFormats

As you can see, there are 5 supported formats in my camera. The numbers (160x120, 176x144.) denote the size of the image to be captured by the camera. Previewing video You can preview the video captured by the camera by defining an object (say by the name vid) and associate it with the device. >>vid=videoinput('winvideo',1, 'YUY2_160x120') or >>vid=videoinput('winvideo',1, 'RGB24_160x120') % depends on availability

It should give information somewhat like this

vid is has been declared as the video input object, and now the camera can be referenced by this name. To see a preview of the video through your camera, use preview command >> preview(vid)

You can check out the preview with different formats. You will see that the size of preview window changes. Use a format that suits your size requirement. A larger size gives greater clarity and is easier to work with, but consumes more memory and therefore is slow. But in a smaller image, it is difficult to differentiate between two objects.

Capturing Images
Now you have a video stream available and you need to capture still images from it. For that, use getsnapshot() command. >>im=getsnapshot(vid); % where vid is video input object Here im is the 3D matrix and you can see the image by the usual imshow() command >>imshow(im); If you get an unexpected image (with shade of violet/green/pink and low clarity), there is nothing to worry. You must be using a format starting with YUY2_... which means that your image is in YCbCr format and not RGB format. Therefore, you must convert it in RGB format by using >>im=ycbcr2rgb(im); >>imshow(im); If a format somewhat like RGB24_160x120 (anything starting with RGB24_....) is used, then you directly get the image in RGB format. If you want to store an image captured, so that you can view it later (like .jpg, .png, .bmp), you can use imwrite() >>imwrite(im,'myimage.jpg'); The file myimage.jpg is saved in the current working directory. *Note: It takes time for the camera to be active and sufficient light to enter it after giving preview() command. Hence, there should be a time gap of 2-3 seconds between preview() and getsnapshot(). If you are typing in command window, then you can maintain this time gap manually. But generally you will use these commands in an m-file, hence, the delay must be given using pause() command. Also in a vision based robot, the images have to be taken continuously, so use an infinite loop. vid=videoinput('winvideo',1, 'YUY2_160x120'); preview(vid); pause(3); while(1) img=getsnapshot(vid); % Do all image processing and analysis here end

Once you have the image matrix im, you can perform all the operations like extracting region of particular colors, finding their centroid and area, etc. by the methods described previously. SIGH! Now sufficient Image Processing has been learnt. Great! What next? Something apart from image processing must be known to make and run the robot. How to interface your computer with your robot via serial/parallel port? How can you send instructions from MATLAB to your robot and control it? The control of the robot is a dynamic process. You continuously take images using webcam, process them, find the required information like position of an object, orientation of robot (if there is an overhead camera) and finally the task to be performed (move robot left / right / forward / backward / pick object, etc.). According to the task at hand, some data is output on the serial/parallel port.

Interfacing via PC Ports


The Instrument Control toolbox of MATLAB provides support to access serial port (also called as COM port) and parallel port (also called as printer port or LPT port) of a PC. If you are using a desktop PC or an old laptop, you may have both, parallel and serial ports. However in newer laptops, none of them may be available and you will have to use USB to Serial Converter cable. Please note that USB to Parallel converter is not recognized as a virtual parallel port.

Parallel Port

A tutorial on Parallel port Interfacing


A tutorial on Parallel port interfacing and programming for beginners. This tutorial covers both hardware and software aspects about programming the parallel port. It also includes a sample schematic and test program in Visual C++. You can make your first parallel port application running straight away.

Parallel Port

Introduction
Parallel port is a simple and inexpensive tool for building computer controlled devices and projects. The simplicity and ease of programming makes parallel port popular in electronics hobbyist world. The parallel port is often used in Computer controlled robots, Atmel/PIC programmers, home automation, etc... Here a simple tutorial on parallel port interfacing and programming with some examples. The primary use of parallel port is to connect printers to computer and is specifically designed for this purpose. Thus it is often called as printer Port or Centronics port (this name came from a popular printer manufacturing company 'Centronics' who devised some standards for parallel port). You can see the parallel port connector in the rear panel of your PC. It is a 25 pin female (DB25) connector (to which printer is connected). On almost all

the PCs only one parallel port is present, but you can add more by buying and inserting ISA/PCI parallel port cards.

I don't have parallel port on my machine! What do I do?


Unfortunately, as of today parallel port is a completely deprecated interfacing standard. It is impossible finding a new laptop with parallel port these days. Even almost all branded PCs already shead Parallel Ports from their back panels. Other alternative available in market such as PCI parallel port expansion cards and USB to Parallel Port converters aren't good for anything other than connecting your old printer because of their architectural difference. As of now the only possible alternative is to use serial ports along with serial to parallel converters (Unfortunately serial ports aren't available on laptops these days) or use USB which is the most popular interface standard in the market as of today. But inherent complexities of implementing USB protocol and hardware requirements keep the hobbyists away for experimenting with USB. But there are great alternatives in market which uses USB but as easy as using parallel port. One such device is Numato Lab's 8 Channel USB GPIO Module. Though this is a USB based module, the user doesn't have to worry about the intricacies and complexities of USB protocol.

A Parallel Port Mode

The IEEE 1284 Standard which has been published in 1994 defines five modes of data transfer for parallel port. They are, 1) 2) 3) 4) 5) Compatibility Mode Nibble Mode Byte Mode EPP ECP

The programs, circuits and other information found in this tutorial are compatible to almost all types of parallel ports and can be used without any problems (Not tested, just because of confidence!).

Hardware
the pin outs of DB25 connector is shown in the picture below

The lines in DB25 connector are divided in to three groups, they are 1) Data lines (data bus) 2) Control lines 3) Status lines As the name refers, data is transferred over data lines, Control lines are used to control the peripheral and of course, the peripheral returns status signals back computer through Status lines. These lines are connected to Data, Control and Status registers internally. The details of parallel port signal lines are given below

Pin No Signal Directi Regist Invert (DB2 name on er - bit ed 5) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 nStrobe Out Data0 Data1 Data2 Data3 Data4 Data5 Data6 Data7 nAck Busy In/Out In/Out In/Out In/Out In/Out In/Out In/Out In/Out In In ControlYes 0 Data-0 No Data-1 No Data-2 No Data-3 No Data-4 No Data-5 No Data-6 No Data-7 No StatusNo 6 StatusYes 7 StatusNo 5 StatusNo 4 ControlYes 1 StatusNo 3 ControlNo 2 ControlYes 3 -

PaperIn Out Select In

Linefee Out d nError In

nInitiali Out ze nSelectOut Printer

18-25 Ground -

Parallel port registers


the Data, Control and status lines are connected to their corresponding registers inside the computer. So by manipulating

these registers in program , one can easily read or write to parallel port with programming languages like 'C' and BASIC. The registers found in standard parallel port are, 1) Data register 2) Status register 3) Control register As their names specifies, Data register is connected to Data lines, Control register is connected to control lines and Status register is connected to Status lines. (Here the word connection does not mean that there is some physical connection between data/control/status lines. The registers are virtually connected to the corresponding lines.). So whatever you write to these registers, will appear in corresponding lines as voltages, Of course, you can measure it with a multimeter. And whatever you give to Parallel port as voltages can be read from these registers (with some restrictions). For example, if we write '1' to Data register, the line Data0 will be driven to +5v. Just like this, we can programmatically turn on and off any of the data lines and Control lines.

Where these registers are?


In an IBM PC, these registers are IO mapped and will have unique address. We have to find these addresses to work with parallel port. For a typical PC, the base address of LPT1 is 0x378 and of LPT2 is 0x278. The data register resides at this base address , status register at baseaddress + 1 and the control register is at baseaddress + 2. So once we have the base address , we can calculate the address of each registers in this manner. The table below shows the register addresses of LPT1 and LPT2.

Register LPT1 LPT2 data registar(baseaddress 0x37 0x27 + 0) 8 8 status register 0x37 0x27 (baseaddress + 1) 9 9 control register 0x37 0x27 (baseaddress + 2) a a

Programming Concepts
almost all programming languages allow programmers to access parallel port using some library functions. For example , Borland C is providing "Inportb" and "Outportb" functions to read or write IO mapped peripherals. But the examples provided here in this tutorial is written VC++ and can be easily ported to other compilers like Borland C and Turbo C. Visual Basic does not have any functions or support to access parallel port directly, but it is possible to add such capabilities to your VB application by writing a dll in VC++ and calling its exported functions from VB. VC++ provides two functions to access IO mapped peripherals, '_inp' for reading and '_outp' for writing. These functions are declared in "conio.h".

Hardware for testing sample programs


The schematic diagram of the test circuit is shown below. It is recommended to build this circuit before testing the sample programs

Sample program in VC++


Writing a parallel port interfacing program in VC++ is very easy. Here are the steps to write your first parallel port interfacing application in VC++. Start VC++ IDE, Select 'New' from File menu. Then select Win32 Console Application from Projects tab (picture-3). Enter project name as partest1, then click OK button.

Picture-3 Now you can see a dialog box with caption Win32 Console Application - step 1 of 1 (picture-4).

Picture-4 Select a simple Application and click Finish. Now open example1.cpp from file view and replace the existing code with the code given below.

#include #include #include #include #include

"stdafx.h" "conio.h" "stdio.h" "string.h" "stdlib.h"

int main(int argc, char* argv[]) { short data; if(argc<2) { printf("Usage\n\n"); printf("partest1.exe ,,\n\n\n"); return 0; } if(!strcmp(argv[1],"read")) { data = _inp(atoi(argv[2])); printf("Data read from parallel port is "); printf("%d\n\n\n\n",data); } if(!strcmp(argv[1],"write")) { _outp(atoi(argv[2]),atoi(argv[3])); printf("Data written to parallel port is "); printf("%s\n\n\n\n\n",argv[3]); } return 0; }

Build the project and copy partest1.exe to "c:\".

How to Test the Program?


Connect the assembled hardware shown above to your PC's parallel port. Open DOS command window Move to "C:\" and type "partest1 write 888 255" and press enter. If everything is correct, LED1 to LED8 in the hardware will glow. You may be doubtful about the command line parameters passed to the program. Here 888(0x378) is the address of the parallel port data register and 255 is the data to be written to parallel port data register. If you enter "partest1 read 888" to command line, the program will read parallel port data register and display it. This will blindly read the contents of parallel port data register, but not the data present on data lines. To read the data from the data lines, we will have to

enable the bidirectional data transfer first. To enable Bidirectional data transfer just set the "Bidirectional" bit (bit 5) in control register. This is done by writing 32 to control register. The command "partest1 write 890 32" will do this. After entering this command you can read the status of switches in the hardware using the command "partest1 read 888" Tried the Inpout32.dll..? Then learn how Inpout32.dll does the things. This brief tutorial explains about the working of Inpout32.dll in simple steps, with the help of a flow chart. This could help you much if you want to modify the Inpout32 dll source code If you don't know what is Inpout32.dll, please read it here and then continue. How it works

The outstanding feature of Inpout32.dll is , it can work with all the windows versions without any modification in user code or the DLL itself. This tutorial describes how it is achieved, what programming methods used, what are the APIs used, etc.... The Dll will check the operating system version when functions are called, and if the operating system is WIN9X, the DLL will use _inp() and _outp functions for reading/writing the parallel port. On the other hand, if the operating system is WIN NT, 2000 or XP, it will install a kernel mode driver and talk to parallel port through that driver. The user code will not be aware of the OS version on which it is running. This DLL can be used in WIN NT clone operating systems as if it is WIN9X. The flow chart of the program is given below.

The two important building blocks of this program are 1)A kernel mode device driver embedded in the DLL in binary form 2)The DLL itself

Kernel mode driver Hwinterface.sys


The source code of Hwinterface.sys kernel mode driver is located in "kernel_mode_driver_source" directory. Where "hwinterfacedrv.c" is the main application source file. Three functions implemented in the driver are 1) DriverEntry() , Called when driver is loaded. Creates device object and symbolic links. 2) hwinterfaceUnload(), Called when driver is unloaded, performs clean up 3) hwinterfaceDeviceControl(), handles calls made through DeviceIOControl API. Performs reading writing to the parallel port according to the control code passed. The DLL Inpout32

The functions in the DLL are implemented in two source files, "inpout32drv.cpp" and "osversion.cpp". osversion.cpp checks the version of operating system. "inpout32drv.cpp" does installing the kernel mode driver, loading it , writing/ reading parallel port etc... The two functions exported from inpout32.dll are 1) Inp32(), reads data from a specified parallel port register. 2) Out32(), writes data to specified parallel port register. the other functions implemented in Inpout32.dll are 1) DllMain(), called when dll is loaded or unloaded. When the dll is loaded , it checks the OS version and loads hwinterface.sys if needed. 2) Closedriver(), close the opened driver handle. called before unloading the driver. 3) Opendriver(), open a handle to hwinterface driver. 4) inst() , Extract 'hwinterface.sys' from binary resource to 'systemroot\drivers' directory and creates a service. This function is called when 'Opendriver' function fails to open a valid handle to 'hwinterface' service. 5) start() , starts the hwinterface service using Service Control Manager APIs. 6) SystemVersion() Checks the OS version and returns appropriate code. What is hwinterface.ocx ActiveX control It is an activex control with same features of Inpout32.dll. It can be used either with VC++ or VB. But it gives great convenience when used with VB. Data can be written to parallel port using Outport method and can be read using Inport method.

MATLAB has an adaptor to access the parallel port (similar to adaptor for image acquisition). First you must check from the Device Manager of your system (My Computer->System Properties->Device Manager->Ports) that what is the name given to the parallel port of your computer. Lets say it is LPT1. To access the parallel port in MATLAB, define an object; lets say by the name parport >> parport = digitalio('parallel','LPT1'); You may obtain the port address using, >> get(parport,'PortAddress') >> daqhwinfo('parallel'); % To get data acquisition hardware information You have to define the pins 2-9 as output pins, by using addline() function

>> addline(parport,0:7,'out') Now put the data which you want to output (depends on motions of robot required) to the parallel port into a matrix (See function logical() in MATLAB Help); e.g. >> dataout = logical([1 1 0 1 0 1 0 1]); Now to output these values, use the putvalue() function >> putvalue(parport,dataout); Alternatively, you can write the decimal equivalent of the binary data and output it. >> data = 213; >> putvalue(parport,data); You can connect the pins of the parallel port to the driver IC for the left and right motors of your robot, and control the motion of the vehicle. You will need an H-bridge for driving the motor in both clockwise and anti-clockwise directions (like L293 or L298). L293D

Fig: A DC Motor DC Motor (Intermediate and Advance users can skip this) A DC motor is electromechanical device that converts electrical energy into mechanical energy that can be used to do many useful works. It can produce mechanical movement like moving the tray of CD/DVD drive in and out (you may like to try it out Go to My Computer, right click the drive icon and click "Eject"). This shows how software controls a motor. DC motors comes in

various ratings like 6V and 12V. It has two wires or pins. When connected with power supply the shaft rotates. You can reverse the direction of rotation by reversing the polarity of input. Control with MCUs As the MCUs PORT are not powerful enough to drive DC motors directly so we need some kind of drivers. A very easy and safe is to use popular L293D chips. It is a 16 PIN chip. The pin configuration is as follows.

L293D Dual DC Motor Controller. This chip is designed to control 2 DC motors. There are 2 INPUT and 2 OUTPUT PINs for each motors. The connections is as follows.

Fig: Motor Controller Using L293d chip. The behavior of motor for various input conditions are as follows A Stop Clockwise Anticlock wise Stop Low Low High B Low High Low

High High So you saw you just need to set appropriate levels at two PINs of the microcontroller to control the motor. Since this chip controls two DC motors there are two more output pins (output3 and output4) and two more input pins(input3 and input4). The INPUT3 and INPUT4 controls second motor in the same way as listed above for input A and B. There are also two ENABLE pins they must be high(+5v) for operation, if they are pulled low(GND)

motors will stop.The following program starts the motor runs it one direction for some time and then reverses the direction. #include <avr/io.h> #include <util/delay.h> void Wait() { char i; for (i=0;i<100;i++) _delay_loop_2(0);
}

void main() { //Setup port D pin 4,5 as output. DDRD=(1<<PD4)|(1<<PD5); while(1) { //Clock wise PORTD=0B00010000; Wait(); //Anti clock wise PORTD=0B00100000; Wait(); //Stop PORTD=0;
Wait(); } }

Assembling.

Insert the L293D chip into the breadboard. And connect as per the Items Required. circuit diagram. Now connect the DC motor. Then connect the 9V supply DC Motor 12V to the breadboard this supply is used to run he motor. Also connect L293D chip the 5V supply to the breadboard this Breadboard. is the logical supply i.e. it defines a HIGH or 1 is 5V. This 5V is Some wires available in the xBoard itself. Use a 2pin connector to access this. Then connect the PD4 and PD5 pins of the MCU to the breadboard. These will provide signals to control the motor. Use a 8 PIN connecter to get PD4 and PD5. Connect PD4 to A and PD5 to B Now burn the program into the MCU and power on the system. The motor will rotate and will change directions after some times.

CAPACITORS It is an electronic component whose function is to accumulate charges and then release it.

To concept of

understand capacitance,

the

consider a pair of metal plates which all are placed near to each other without touching. If a battery is connected to these plates the positive pole to one and the negative pole to the other, electrons from the battery will be attracted from the plate connected to the positive terminal of the battery. If the battery is then disconnected, one plate will be left with an excess of electrons, the other

with a shortage, and a potential or voltage difference will exists between them. These plates will be acting as capacitors. Capacitors are of two types: - (1) fixed type like ceramic, polyester, electrolytic capacitors-these names refer to the material they are made of aluminium foil. (2) Variable type like gang condenser in radio or trimmer. In fixed type capacitors, it has two leads and its value is written over its body and variable type has three leads. Unit of measurement of a capacitor is farad denoted by the symbol F. Small unit capacitor It is a very big unit of capacitance. are pico-farad denoted by pf

(Ipf=1/1000,000,000,000 f) Above all, in case of electrolytic capacitors, it's two terminal are marked as (-) and (+) so check it while using capacitors in the circuit in right direction. Mistake can destroy the capacitor or entire circuit in operational.

DIODE

The simplest semiconductor device is made up of a sandwich of P-type semiconducting material, with contacts provided to connect the p-and n-type layers to an external circuit. This is a

junction Diode. If the positive terminal of the battery is connected to the p-type material (cathode) and the negative terminal to the N-type material (Anode), a large current will flow. This is called forward current or forward biased.

If the connections are reversed, a very little current will flow. This is because under this condition, the p-type material will accept the electrons from the negative terminal of the battery and the N-type material will give up its free electrons to the battery, resulting in the state of electrical equilibrium since the Ntype material has no more electrons. Thus there will be a small current to flow and the diode is called Reverse biased.

Thus the Diode allows direct current to pass only in one direction while blocking it in the other direction. Power diodes are used in concerting AC into DC. In this, current will flow freely during the first half cycle (forward biased) and practically not at all during the other half cycle (reverse biased). This makes the diode an effective rectifier, which convert ac into pulsating dc. Signal diodes are used in radio circuits for detection. Zener diodes are used in the circuit to control the voltage.

Some common diodes are:-

1. Zener diode.

2. Photo diode.

3. Light Emitting diode.

1.

ZENER DIODE:-

A zener diode is specially designed junction diode, which can operate continuously without being damaged in the region of reverse break down voltage. One of the most important applications of zener diode is the design of constant voltage power supply. The zener diode is joined in reverse bias to d.c. through a resistance R of suitable value.

2.

PHOTO DIODE:-

A photo diode is a junction diode made from photo- sensitive semiconductor or material. In such a diode, there is a provision to allow the light of suitable frequency to fall on the p-n junction. It is reverse biased, but the voltage applied is less than the break down voltage. As the intensity of incident light is increased, current goes on increasing till it becomes maximum. The maximum current is called saturation current.

3.

LIGHT EMITTING DIODE (LED):-

When a junction diode is forward biased, energy is released at the junction diode is forward biased, energy is released at the junction due to recombination of electrons and holes. In case of silicon and germanium diodes, the energy released is in infrared region. In the junction diode made of gallium arsenate or indium phosphide, the energy is released in visible region. Such a junction diode is called a light emitting diode or LED. RESISTANCE

Resistance is the opposition of a material to the current. It is measured in Ohms (). All conductors represent a certain amount of resistance, since no conductor is 100% efficient. To control the electron flow (current) in a predictable manner, we use resistors. Electronic circuits use calibrated lumped resistance to control the flow of current. Broadly speaking, resistor can be divided into two groups viz. fixed & adjustable (variable) resistors. In fixed resistors, the value is fixed & cannot be varied. In variable resistors, the resistance value can be varied by an adjuster knob. It can be divided into (a) Carbon composition (b) Wire wound (c)

Special type. The most common type of resistors used in our projects is carbon type. The resistance value is normally indicated by colour bands. Each resistance has four colours, one of the band on either side will be gold or silver, this is called fourth band and indicates the tolerance, others three band will give the value of resistance (see table). For example if a resistor has the following marking on it say red, violet, gold. Comparing these coloured rings with the colour code, its value is 27000 ohms or 27 kilo ohms and its tolerance is 5%. Resistor comes in various sizes (Power rating). The bigger, the size, the more power rating of 1/4 watts. The four colour rings on its body tells us the value of resistor value as given below. COLOURS CODE

Black----------------------------------------0 Brown--------------------------------------1 Red------------------------------------------2 Orange-------------------------------------3 Yellow--------------------------------------4 Green---------------------------------------5 Blue-----------------------------------------6 Violet---------------------------------------7 Grey-----------------------------------------8 White---------------------------------------9

The first rings give the first digit. The second ring gives the second digit. The third ring indicates the number of zeroes to be placed after the digits. The fourth ring gives tolerance (gold 5%, silver 10%, No colour 20%).

In variable resistors, we have the dial type of resistance boxes. There is a knob with a metal pointer. This presses over brass pieces placed along a circle with some space b/w each of them.

Resistance coils of different values are connected b/w the gaps. When the knob is rotated, the pointer also moves over the brass pieces. If a gap is skipped over, its resistance is included in the circuit. If two gaps are skipped over, the resistances of both together are included in the circuit and so on.

A dial type of resistance box contains many dials depending upon the range, which it has to cover. If a resistance box has to read upto 10,000, it will have three dials each having ten gaps i.e. ten resistance coils each of resistance 10 . The third dial will have ten resistances each of 100

The dial type of resistance boxes is better because the contact resistance in this case is small & constant.

TRANSFORMER PRINCIPLE OF THE TRANSFORMER:Two coils are wound over a Core such that they are magnetically coupled. The two coils are known as the primary and secondary windings.

In a Transformer, an iron core is used. The coupling between the coils is source of making a path for the magnetic flux to link both the coils. A core as in fig.2 is used and the coils are wound on the limbs of the core. Because of high permeability of iron, the flux path for the flux is only in the iron and hence the flux links both windings. Hence there is very little leakage flux. This term leakage flux denotes the part of the flux, which does not link both the coils, i.e., when coupling is not perfect. In the high frequency transformers, ferrite core is used. The transformers may be step-up, step-down, frequency matching, sound output, amplifier driver etc. The basic principles of all the transformers are same.

MINIATURE TRANSFORMER

CONVENTIONAL POWER TRANSFORMER

POWER SUPPLY In flow in one direction only. When the anode of the diode is positive with respect to its cathode, it is forward biased, allowing current to flow. But when its anode is negative with alternating current the electron flow is alternate, i.e. the electron flow increases to maximum in one direction, decreases back to zero. It then increases in the other direction and then decreases to zero again. Direct current flows in one direction only. Rectifier converts alternating current to respect to the cathode, it is reverse biased and does not allow current to flow. This unidirectional property of the diode is useful for rectification. A single diode arranged backto-back might allow the electrons to flow during positive half cycles only and suppress the negative half cycles. Double diodes arranged back-to-back might act as full wave rectifiers as they may allow the electron flow during both positive and negative half cycles. Four diodes can be arranged to make a full wave bridge rectifier. Different types of filter circuits are used to smooth out

the pulsations in amplitude of the output voltage from a rectifier. The property of capacitor to oppose any change in the voltage applied across them by storing energy in the electric field of the capacitor and of inductors to oppose any change in the current flowing through them by storing energy in the magnetic field of coil may be utilized. To remove pulsation of the direct current obtained from the rectifier, different types of combination of capacitor, inductors and resistors may be also be used to increase to action of filtering. NEED OF POWER SUPPLY Perhaps all of you are aware that a power supply is a primary requirement for the Test Bench of a home experimenters mini lab. A battery eliminator can eliminate or replace the batteries of solid-state electronic equipment and the equipment thus can be operated by 230v A.C. mains instead of the batteries or dry cells. Nowadays, the use of commercial battery eliminator or power supply unit has become increasingly popular as power source for household appliances like transreceivers, record player, cassette players, digital clock etc.

THEORY USE OF DIODES IN RECTIFIERS: Electric energy is available in homes and industries in India, in the form of alternating voltage. The supply has a voltage of 220V (rms) at a frequency of 50 Hz. In the USA, it is 110V at 60 Hz. For the operation of most of the devices in electronic equipment, a dc voltage is needed. For instance, a transistor radio requires a dc supply for its operation. Usually, this supply is provided by dry cells. But sometime we use a battery eliminator in place of dry cells. The battery eliminator converts the ac voltage into dc voltage and thus eliminates the need for dry cells. Nowadays, almost all-electronic equipment includes a circuit that converts ac voltage of mains supply into dc voltage. This part of the equipment is called Power Supply. In general, at the input of the power supply, there is a power transformer. It is followed by a

diode circuit called Rectifier. The output of the rectifier goes to a smoothing filter, and then to a voltage regulator circuit. The rectifier circuit is the heart of a power supply. RECTIFICATION Rectification is a process of rendering an alternating current or voltage into a unidirectional one. The component used for rectification is called Rectifier. A rectifier permits current to flow only during the positive half cycles of the applied AC voltage by eliminating the negative half cycles or alternations of the applied AC voltage. Thus pulsating DC is obtained. To obtain smooth DC power, additional filter circuits are required. A diode can be used as rectifier. There are various types of diodes. But, semiconductor diodes are very popularly used as rectifiers. A semiconductor diode is a solid-state device consisting of two elements is being an electron emitter or cathode, the other an electron collector or anode. Since electrons in a semiconductor diode can flow in one direction only-from emitter to collector- the diode provides the unilateral conduction necessary for rectification. Out of the semiconductor diodes, copper oxide and selenium rectifier are also commonly used.

FULL WAVE RECTIFIER It is possible to rectify both alternations of the input voltage by using two diodes in the circuit arrangement. Assume 6.3 V rms (18 V p-p) is applied to the circuit. Assume further that two equalvalued series-connected resistors R are placed in parallel with the ac source. The 18 V p-p appears across the two resistors connected between points AC and CB, and point C is the electrical midpoint between A and B. Hence 9 V p-p appears across each resistor. At any moment during a cycle of v in, if point A is positive relative to C, point B is negative relative to C. When A is negative to C, point B is positive relative to C. The effective voltage in proper time phase which each diode "sees" is in Fig. The voltage

applied to the anode of each diode is equal but opposite in polarity at any given instant. When A is positive relative to C, the anode of D 1 is positive with respect to its cathode. Hence D 1 will conduct but D2 will not. During the second alternation, B is positive relative to C. The anode of D2 is therefore positive with respect to its cathode, and D2 conducts while D1 is cut off. There is conduction then by either D 1 or D2 during the entire input-voltage cycle. Since the two diodes have a common-cathode load resistor RL, the output voltage across RL will result from the alternate conduction of D1 and D2. The output waveform vout across RL, therefore has no gaps as in the case of the half-wave rectifier.

The output of a full-wave rectifier is also pulsating direct current. In the diagram, the two equal resistors R across the input voltage are necessary to provide a voltage midpoint C for circuit connection and zero reference. Note that the load resistor R L is connected from the cathodes to this center reference point C.

An interesting fact about the output waveform v out is that its peak amplitude is not 9 V as in the case of the half-wave rectifier using the same power source, but is less than 4 V. The reason, of course, is that the peak positive voltage of A relative to C is 4 V, not 9 V, and part of the 4 V is lost across R.

Though the full wave rectifier fills in the conduction gaps, it delivers less than half the peak output voltage that results from half-wave rectification.

BRIDGE RECTIFIER A more widely used full-wave rectifier circuit is the bridge rectifier. It requires four diodes instead of two, but avoids the need for a centre-tapped transformer. During the positive halfcycle of the secondary voltage, diodes D2 and D4 are conducting and diodes D1 and D3 are non-conducting. Therefore, current flows through the secondary winding, diode D2, load resistor RL and diode D4. During negative half-cycles of the secondary voltage, diodes D1 and D3 conduct, and the diodes D2 and D4 do not conduct. The current therefore flows through the secondary winding, diode D1, load resistor RL and diode D3. In both cases, the current passes through the load resistor in the same direction. Therefore, a fluctuating, unidirectional voltage is developed across the load.

Filtration The rectifier circuits we have discussed above deliver an output voltage that always has the same polarity: but however, this output is not suitable as DC power supply for solid-state circuits. This is due to the pulsation or ripples of the output voltage. This should be removed out before the output voltage can be supplied to any circuit. This smoothing is done by incorporating filter networks. The filter network consists of inductors and capacitors. The inductors or choke coils are generally connected in series with the rectifier output and the load. The inductors oppose any change in the magnitude of a current flowing through them by storing up energy in a magnetic field. An inductor offers very low resistance for DC whereas; it offers very high resistance to AC. Thus, a series connected choke coil in a rectifier circuit helps to reduce the pulsations or ripples to a great extent in the output voltage. The fitter capacitors are usually connected in parallel with the rectifier output and the load. As, AC can pass through a capacitor but DC cannot, the ripples are thus limited and the output becomes smoothed. When the voltage across its plates tends to rise, it stores up energy back into voltage and current. Thus, the fluctuations in the output

voltage are reduced considerable. Filter network circuits may be of two types in general: CHOKE INPUT FILTER If a choke coil or an inductor is used as the firstcomponents in the filter network, the filter is called choke input filter. The D.C. along with AC pulsation from the rectifier circuit at first passes through the choke (L). It opposes the AC pulsations but allows the DC to pass through it freely. Thus AC pulsations are largely reduced. The further ripples are by passed through the parallel capacitor C. But, however, a little nipple remains unaffected, which are considered negligible. This little ripple may be reduced by incorporating a series a choke input filters.

CAPACITOR INPUT FILTER If a capacitor is placed before the inductors of a choke-input filter network, the filter is called capacitor input filter. The D.C. along with AC ripples from the rectifier circuit starts charging the capacitor C. to about peak value. The AC ripples are then diminished slightly. Now the capacitor C, discharges through the inductor or choke coil, which opposes the AC ripples, except the DC. The second capacitor C by passes the further AC ripples. A small ripple is still present in the output of DC, which may be reduced by adding additional filter network in series.

CIRCUIT DIAGRAM

PROCEDURE FOR MAKING PROJECT

Building project in the proper manner is really an art, something which must be practiced and learned through trial and error, it is not all that difficult. The main thing is to remember to take each step slowly and carefully according to the instructions giving making since that everything at it should be before proceeding further.

TOOLS: The electronics workbench is an actual place of work with comfortably & conveniently & should be supplied with compliment of those tools must often use in project building. Probably the most important device is a soldering tool. Other tool which should be at the electronic work bench includes a pair of needle nose pliers, diagonal wire cutter, a small knife, an assortment of screw driver, nut driver, few nuts & bolts, electrical tape, plucker etc. Diagonal wire cutter will be used to cut away any excess lead length from copper side of P.C.B. 7 to cut section of the board after the circuit is complete. The needle nose pliers are most often using to bend wire leads & wrap them in order to form a strong mechanical connection.

MOUNTING & SOLDERING: Soldering is process of joining together two metallic parts. It is actually a process of function in which an alloy, the solder, with a comparatively low melting point penetrates the surface of the metal being joined & makes a firm joint between them on cooling & solidifying. THE SOLDERING KIT

1.

SOLDERING IRON:

As soldering is a process of joining together two metallic parts, the instrument, which is used, for doing this job is known as soldering Iron. Thus it is meant for melting the solder and to setup the metal parts being joined. Soldering Iron is rated according to their wattage, which varies from 10- 200 watts.

2.

SOLDER:

The raw material used for soldering is solder. It is composition of lead & tin. The good quality solder (a type of flexible naked wire) is 60% Tin +40% Lead which will melt between 180 degree to 200 degree C temperature.

3.

FLUXES OR SOLDERING PASTE: When the points to solder are heated, an oxide film forms.

This must be removed at once so that solder may get to the surface of the metal parts. This is done by applying chemical substance called Flux, which boils under the heat of the iron remove the oxide formation and enable the metal to receive the solder.

4.

BLADES OR KNIFE:

To clean the surface & leads of components to be soldered is done by this common instrument.

5.

SAND PAPER:

The oxide formation may attack at the tip of your soldering iron & create the problem. To prevent this, clean the tip with the help of sand paper time to time or you may use blade for doing this job. Apart from all these tools, the working bench for

soldering also includes desoldering pump, wink wire (used for desoldering purpose), file etc. HOW TO SOLDER? Mount components at their appropriate place; bend the leads slightly outwards to prevent them from falling out when the board is turned over for soldering. No cut the leads so that you may solder them easily. Apply a small amount of flux at these components leads with the help of a screwdriver. Now fix the bit or iron with a small amount of solder and flow freely at the point and the P.C.B copper track at the same time. A good solder joint will appear smooth & shiny. If all appear well, you may continue to the next solder connections. TIPS FOR GOOD SOLDERING

1. Use right type of soldering iron. A small efficient soldering iron (about 10-25 watts with 1/8 or 1/4 inch tip) is ideal for this work. 2. Keep the hot tip of the soldering iron on a piece of metal so that excess heat is dissipated. 3. Make sure that connection to the soldered is clean. Wax frayed insulation and other substances cause poor soldering connection. Clean the leads, wires, tags etc. before soldering. 4. Use just enough solder to cover the lead to be soldered. Excess solder can cause a short circuit. 5. Use sufficient heat. This is the essence of good soldering. Apply enough heat to the component lead. You are not using enough heat, if the solder barely melts and forms a round ball of rough flaky solder. A good solder joint will look smooth, shining and spread type. The difference between good & bad soldering is just a few seconds extra with a hot iron applied firmly.

PRECAUTIONS 1. Mount the components at the appropriate places before soldering. Follow the circuit description and components details, leads identification etc. Do not start soldering before making it confirm that all the components are mounted at the right place. 2. Do not use a spread solder on the board, it may cause short circuit. 3. Do not sit under the fan while soldering. 4. Position the board so that gravity tends to keep the solder where you want it. 5. Do not over heat the components at the board. Excess heat may damage the components or board. 6. The board should not vibrate while soldering otherwise you have a dry or a cold joint. 7. Do not put the kit under or over voltage source. Be sure about the voltage either dc or ac while operating the gadget. 8. Do spare the bare ends of the components leads otherwise it may short circuit with the other components. To prevent this use sleeves at the component leads or use sleeved wire for connections. 9. Do not use old dark color solder. It may give dry joint. Be sure that all the joints are clean and well shiny. 10. Do make loose wire connections especially with cell holder, speaker, probes etc. Put knots while connections to the circuit board, otherwise it may get loose. MAKING PRINTED CIRCUIT BOARD (P.C.B.) INTRODUCTION--

Making a Printed Circuit Board is the first step towards building electronic equipment by any electronic industry. A number of methods are available for making P.C.B., the simplest method is of drawing pattern on a copper clad board with acid resistant (etchants) ink or paint or simple nail polish on a copper clad board and do the etching process for dissolving the rest of copper pattern in acid liquid. MATERIAL REQUIRED The apparatus needs for making a P.C.B. is :*Copper Clad Sheet *Nail Polish or Paint *Ferric Chloride Powder. (FeCl) *Plastic Tray *Tap Water etc.

PROCEDURE The first and foremost in the process is to clean all dirt from copper sheet with say spirit or trichloro ethylene to remove traces grease or oil etc. and then wash the board under running tap water. Dry the surface with forced warm air or just leave the board to dry naturally for some time. Making of the P.C.B. drawing involves some preliminary

consideration such as thickness of lines/ holes according to the components. Now draw the sketch of P.C.B. design (tracks, rows, square) as per circuit diagram with the help of nail polish or enamel paint or any other acid resistant liquid. Dry the point surface in open air, when it is completely dried, the marked holes in P.C.B. may be drilled using 1Mm drill bits. In case there is any shorting of lines due to spilling of paint, these may be removed by scraping with a blade or a knife, after the paint has dried.

After drying, 22-30 grams of ferric chloride in 75 ml of water may be heated to about 60 degree and poured over the P.C.B.; placed with its copper side upwards in a plastic tray of about 15*20 cm. stirring the solution helps speedy etching. The dissolution of unwanted copper would take about 45 minutes. If etching takes longer, the solution may be heated again and the process repeated. The paint on the pattern can be removed P.C.B. may then be washed and dried. Put a coat of varnish to retain the shine. Your P.C.B. is ready. REACTION Fecl3 + Cu ----- CuCl3 + Fe Fecl3 + 3H2O --------- Fe (OH)3 + 3HCL

PRECAUTION 1. Add Ferric Chloride (Fecl3) carefully, without any splashing. Fecl3 is irritating to the skin and will stain the clothes. 2. 3. Place the board in solution with copper side up. Try not to breathe the vapors. Stir the solution by giving seesaw motion to the dish and solution in it. 4. Occasionally warm if the solution over a heater-not to boiling. After some time the unshaded parts change their color continue to etch. Gradually the base material will become visible. Etch for two minutes more to get a neat pattern. 5. Don't throw away the remaining FeCl3 solution. It can be used again for next Printed Circuit Board P.C.B.

USES Printed Circuit Board is used for housing components to make a circuit for compactness, simplicity of servicing and case of interconnection. Thus we can define the P.C.B. as : Printed Circuit Boards is actually a sheet of Bakelite (an insulating material) on the one side of which copper patterns are made with holes and from another side, leads of electronic components are inserted in the proper holes and soldered to the copper points on the back. Thus leads of electronic components terminals are joined to make electronic circuit. In the boards copper cladding is done by pasting thin copper foil on the boards during curing. The copper on the board is about 2 mm thick and weights an ounce per square foot.

The process of making a Printed Circuit for any application has the following steps (opted professionally):

* * *

Preparing the layout of the track. Transferring this layout photographically M the copper. Removing the copper in places which are not needed, by the process of etching (chemical process)

Drilling holes for components mounting.

PRINTED CIRCUIT BOARD

Printed circuit boards are used for housing components to make a circuit, for comactness, simplicity of servicing and ease of

interconnection. Single sided, double sided and double sided with plated-through-hold (PYH) types of p.c boards are common today.

Boards are of two types of material (1) phenolic paper based material (2) Glass epoxy material. Both materials are available as laminate sheets with copper cladding.

Printed circuit boards have a copper cladding on one or both sides. In both boards, pasting thin copper foil on the board during curing does this. Boards are prepared in sizes of 1 to 5 metre wide and upto 2 metres long. The thickness of the boards is 1.42 to 1.8mm. The copper on the boards is about 0.2 thick and weighs and ounce per square foot.

Вам также может понравиться