Wednesday, May 2, 2012

Electronics Project: Basics for doing it yourself - 2

Hi,

In this post I will be going through a regulated power supply. It is necessary to create your own power supply circuit for the projects you will be doing. Now lets discuss about the components that are used to make a regulated power supply unit.

Transformer:
A transformer is a device that transfers electrical energy from one circuit to another through inductively coupled conductors. It consists of two windings primary and secondary. When alternating current is applied to primary winding, a varying magnetic flux is created in transformer's core and thus a varying magnetic field through secondary winding. This varying magnetic field induces varying electromotive force (EMF) in secondary winding. If a load is connected to secondary, current will flow in the secondary winding, and electrical energy will be transferred from the primary circuit through the transformer to the load. This effect is called inductive coupling and well known transformer equation has been established:

Here, voltage in secondary coil (Vs) is in proportion to the primary voltage (Vp) and is given by the ratio of number of turns in the secondary (Ns) to the number of turns in the primary (Np). Thus, we can use transformer to step up or step down the AC voltage. While purchasing a transformer its cost depends on how much voltage and current it can couple on secondary coil. For our application, we will use a 500mA transformer that is rated 12V. This transformer when connected to 220V AC line will produce 12V at secondary coil. So, if the source AC voltage fluctuates the output voltage at secondary coil also fluctuates accordingly. 
It is very essential to distinguish primary and secondary coils of transformer when you want to use it. The primary coil in general has only two wires and the secondary coil has three wires coming out of the coil as shown in the figure. To check a transformer whether it is working or not we simply connect its primary wires to AC line. Then using a voltmeter, we have to measure voltage at secondary coil. Among the three wires from secondary coil, the wire that is coming from centre is common wire and the two wires coming from edge gives rated output voltage of the transformer. We connect common wire to common probe of multimeter and touch one of the edge wire. Place the multimeter in AC Voltmeter mode and measure the voltage. Then touch other wire and measure the voltage. Generally, the voltages are equal however, in some cases it might be different. Mostly, we can find the output voltage marked on the transformer such as 12-0-12, 12-0-9, 9-0-9 etc. which means at secondary coil the output is 12V at each edge wires and 0V at centre wire. 

Voltage Regulator IC:

As we know that, the AC source voltage fluctuates a lot and transformer also produces fluctuated AC output. For the proper operation of circuit, a constant DC voltage is always required. This constant DC voltage is obtained with the help of voltage regulator IC. Mostly we use 78xx series voltage regulator IC such as 7805, 7809, 7812 etc. The 79xx series voltage regulator IC are used for obtaining negative voltage level for application that requires negative voltage levels such as an audio amplifier. The 78xx series IC has three terminals named IN, GND and OUT. At IN terminal we apply input DC voltage which must be greater than required output voltage. The GND terminal is connected to ground of the circuit. The OUT terminal gives output voltage as specified by that IC. For 7805, 7809, 7812 IC we obtain +5V, +9V, +12V as output respectively. The voltage regulator IC also has a hole to connect heat sink with it. The heat sink is used to absorb heat dissipated by the IC which ensures its good performance and longer life. The heat sink is always connected to grounding of the circuit. 

Circuit Diagram:
This is the circuit diagram for 3-way regulated power supply. Where you can obtain three different voltage levels from same circuit. Here I have used 5V, 9V and 12V for output. The full-wave bridge rectifier is made up of four diodes where, we connect it as shown in diagram. This gives us two pair of terminals one pair for connecting AC source voltage and the other pair for obtaining corresponding DC voltage. The terminals can be distinguished as AC terminals are formed by junction of P and N side of each diode and DC terminals are formed by junction of P-P or N-N. 

Working:
When we connect the primary wires of transformer to AC line, the transformer steps-down the source voltage of 220V to 12V AC. Then this AC voltage is applied to AC terminals of full-wave bridge rectifier. When 12V AC is applied to it corresponding 12V DC is obtained at DC terminals. The polarity of this DC voltage can be determined since at P-P junction we always obtain negative half cycle of AC and at N-N junction we obtain positive half cycle of the AC. Thus N-N junction is positive and P-P junction is negative terminals of DC output. Since, AC voltage is a function of sine we obtain ripples at output DC voltage. To eliminate these ripples we have to use a capacitor as a filter. The capacitor charges slowly and discharges quickly hence, it do not allow ripple formation and smooth DC voltage is obtained after filtering by the capacitor. The positive terminal of the capacitor is connected to positive terminal of the rectifier and negative terminal is connected to negative terminal of the rectifier. Here we have used 1000uF/25V capacitor for our purpose. This 12V DC voltage is now applied to input terminal of different voltage regulator IC. The 3-way selector switch selects, each of the input terminals of the IC at different position. At one time only one of the three voltage regulator IC is given the input DC voltage. When the switch is changed to different position different output is obtained at output terminals of the circuit. The LED is used to indicate which voltage level is appearing at the output terminals.

Variable Voltage Regulated Power Supply:
The circuit we discussed earlier can be used for obtaining discrete voltage levels such as +5V, 9V and 12V. But, sometimes we are required 7.5V in this case the above circuit is not useful. Here, I would like to show a simulation of variable voltage power supply in which output varies from 1.2V to 12V. The main component in this circuit is LM317 variable voltage regulator IC. 
In the figure you can see the pin names of the IC and a typical circuit for connecting LM317. There is also a formula to calculate output voltage Vout of the IC. The variable resistor R2 is varied and corresponding voltage is obtained at output. In the circuit simulation shown in the video you can see when the resistance of variable resistor is varied it causes output voltage to vary from 1.2V to 12V. 



I hope you would like the circuit and give it a try. Please comment and post your suggestions.
Thank you.

Saturday, April 28, 2012

Electronics Project: Basics for doing it yourself - 1

Hi,
In this post I will discuss about some essential things you need in order to do electronics project. Electronics has always been my hobby and I spent most of my college time doing electronics projects. At the beginning of my college I learnt how to use bread-boards and knew about resistor, capacitors, diodes and transistors. When I learnt digital electronics and micro-controllers I was fascinated by them and kept on playing with them. I was regular subscriber of EFY magazine and I used to try DIY circuits in my home. Now, the time has come; I have to share my experience with you.

An electronic circuit is composed of individual electronic components, such as resistors, transistors, capacitors, inductors and diodes, connected by conductive wires through which electric current can flow. The different combination of these components when done properly is used to perform different operations such as signal amplification, computation of data, and so many things. The motherboard of your computer itself is an example of a complex electronic circuit which consists of different ICs. Whereas, inside your battery charger you can find a simple electronic circuit. So, the complexity is based on the application of the circuit. To be able to make an electronic circuit you must first know behaviour of each components when current flows through them. The components such as resistor, capacitor and inductors are passive components; meaning that the current flowing through them is directly governed by voltage applied to them. The other components such as diodes and transistors are active components. I would like to briefly introduce you about these components. You can go through your course book or find more information in the Internet about these component so, I will be more focused on their application in electronics projects.

Resistor:

Resistors offers a resistance to the flow of current. It is characterized by  resistance values measured in ohms and their power ratings measured in Watts.   Resistance is the ratio of potential difference (V) between the two terminals and the current (I) flowing through it i.e. Resistance (R)= V/I ohms. Resistances range from 10 ohm to 56Mohm(or more) and power ratings from 1/8W to 20W. We mostly use resistance in this range even though more power rating high value resistors are available. So, when you select a resistor its value and power rating should be the deciding parameter. Normally available resistors are 1/8W, you can see this type of resistors in the resistance box which contain resistances from 10 ohm to around 56Mohm, costs around Rs.30. But this resistor leads are flexible such that it will get bend easily. These 1/8W resistors are used in low power devices. The one which available in shops are of 1/4W which we mainly use. P= (I^2) * R, heat dissipation on resistor depends on the current flowing through it. Therefore for high current operations we use resistance of higher current ratings. The size of the resistor determines its power rating. Suppose if you put a resistor series with a motor which have a rating of 250mA(DC motor) -600mA(Stepper motor), then you can see that P= (I^2)*R = 0.25^2*R= 0.0625R. Assume R=10 ohm then P= 0.625W>1/2W. In this case you have to use a resistor of about 1W or more.There are two types of resistors - fixed and variable.




Now let's see how you can measure the resistance of a resistor. This is done by color coding over the resistor or you can use multimeter to measure resistance. As a beginner you should use color coding. See the following diagrams carefully, you can see that 4-band code, 5--band code and 6--band code (see next diagram). But we mainly get resistors of 4-band code.You can get a 1/4W resistor for Ps.20 irrespective of the value of its resistance. Due to the aging and other temperature effects, value of a resistor will change. That change is indicated using tolerance. The following figure show how to bend a resistor so that you can insert it in a breadboard. Don't bend too much close to the body of the resistor because it will leads to the breaking of the leads. So bend carefully. Sometimes you have to cut the leads of the resistor by some amount so that it can easily inserted properly.



Remember that all the values of fixed resistances are not available. Suppose if you want a 2Kohm resistor in your circuit, you can use a variable resistor (potentiometer) or two 1Kohm resistor in series. 

If you are interested in programming then I can send you the link to download a program with source code that calculates resistance of a resistor according to its colour code or by a value. This program was written using C#.NET with Framework  version of 3.5 so, you need .NET Framework 3.5 installed in your OS to run this program. If you are using Windows Vista or later you can enjoy using it as .NET Framework is pre-installed. Screenshot of this program is shown here. You have to be follower of this blog if want to get download link. I hope you will  do this by clicking follow at right sidebar of this blog.


Variable Resistor (Potentiometer):
Potentiometer is a variable resistor which is used to vary the resistance by rotating the shaft. Potentiometers are available from 100 ohm to 470Kohm (or more). Cost depends on the size of potentiometer, vary from Rs. 4 onwards. It is sometimes used as a voltage divider. If we connect  Lead A to Vcc and Lead B to ground then you can get voltages from 0 to Vcc by taking voltage at Lead A and Lead B.
 


Above figure shows different types of potentiometers available in market. Second and third potentiometers are mainly used when you want to change the value of resistance rarely and first one used when you had to vary resistance frequently. Second and third one are easy to be inserted in breadboard and they remain fixed. Resistance is varied by rotating the shaft in the body of the potentiometer.

Capacitor:
A capacitor is a passive component that is used to store energy in an electric field. It is characterized its capacitance, measured in Farads (F). This is the ratio of electric charge (E), measured in Coulombs (C) on each conductor to the potential difference (V) between them i.e. Capacitance (C)= E/V Farad. Like resistor there is fixed as well as variable capacitor also. But, we mostly use fixed capacitor and variable capacitor is used in application such as radio frequency tuning. The capacitor may or may not have polarity. Ceramic and Mica capacitors available in the market have no polarity, but electrolytic capacitors have polarity. The capacitors have different symbols.
In the above figure, we can see that different symbols are used for capacitors. The non-polar capacitor can be placed in a circuit in either way but, when polarized (electrolytic) capacitor is to be placed we have to be careful in placing them in the circuit. We can differentiate negative and positive leads of electrolytic capacitor by their length however, it is best to differentiate them by looking at capacitor itself. The negative lead is indicated by black band imprinted in the body of capacitor, which contains - sign as you can see in the above figure. Also, the electrolytic capacitors have voltage ratings; which indicates the maximum potential difference the capacitor can tolerate between its terminals. It is a very important factor in choosing the capacitor for you circuit. If your circuit is operating in say 25V and you are placing 16V capacitor then you may damage the capacitor. So, you have to be very careful when choosing the capacitor in your circuit.

Ceramic capacitors in general have the rated values in pico-Farad (pF) and electrolytic capacitors have the values in micro-Farad (uF). Ceramic capacitors have many marking specification. Capacitance, tolerance, working voltage and temperature coefficient may be seen imprinted on the capacitor with black colour text. Capacitance values are found to be written as whole numbers without any identification as to units (uF, nF, pF). Whole numbers usually indicate pF and decimal numbers such as 0.1 or 0.47 are micro-farads. Larger whole numbers (>100) such as 473 means 47*10^3 pF = 0.047 uF.

Here, the capacitor rated as 22 has a capacitance of 22pF. The capacitance of capacitor rated 104 can be found as; the first two digit are significant digits and last digit indicate number of zeros after the significant digits. So, 104 means capacitance(C)= 10*10^4 pF= 100000 pF= 100nF= 0.1uF. Similarly, 103 means C= 10*10^3 pF= 10nF= 0.01uF. You may also find values such as 104K, 103M, 102J etc. where the last alphabet denotes tolerance of the capacitor i.e. how much the capacitance is varied from rated value. K indicates 10%, M indicates 20% and J indicates 5%.

Capacitors are widely used in electronic circuits for blocking direct current while allowing alternating current to pass, in filter networks, for smoothing the output of power supplies, in the resonant circuits that tune radios to particular frequencies and for many other purpose.

Diode:
A diode is a two terminal semi-conductor device used for conducting current flowing through it only in one direction called forward direction. It has asymmetrical transfer characteristic, with low resistance to current flow in one direction, and high resistance in the other. A semiconductor diode is a crystalline piece of semiconductor material with P-N junction connected to the terminals. The unidirectional behaviour of diode is used to convert alternating current (AC) to direct current (DC), including extraction of  modulation from radio signals in radio receivers. There are different types of diode which has specific purpose such as; Zener diode is used for voltage regulation, Avalanche diode are used to protect the circuit from high voltage surges, Varactor diode is used to electronically tune radio and TV receivers, Tunnel diode is used to generate radio frequency oscillations and Light Emitting Diode (LED) is used to produce light. You can find more information about these diodes in the Internet so, we will only  focus on generic semiconductor diode and LED which are the most used diodes.

You can see a white ring close to one of the terminal which indicates N terminal of the diode and the other  is P terminal. You can see white text in black background in the form of 1Nxxxx, this represents model number of the diode that has charactersitics defined in its datasheet. You can Google the part number and find out its power rating, threshold voltage, and other required parameters. To determine whether a diode is working or not we need a multimeter with diode checking function. Then, we determine its forward voltage by connecting positive terminal and  negative terminal  of multimeter to the P-terminal and N-terminal (Forward Bias) of the diode  respectively. For 1N4001, it is about 1.2V and for 1N4007 it is about 1.4V. You can go through datasheet of the diode and find out their forward threshold parameter to check any diode. In the figure alongside, you can also see LED and from there you can determine P terminal and N terminal of a LED. The length of terminals as well as the shape of bottom view is used to determine them. The method to check a LED is similar to diode; we have to forward bias it and check to see whether it glows or not. Also, you have to note the voltage reading shown in multimeter because it is used to determine a series resistor connected to it's one of the terminals. Generally, you need to connect a series resistor to prevent excessive current flow in the LED otherwise, that current could damage the LED. The resistance is usually between 200 ohm to 2.2Kohm according to current being applied in the circuit.

Now, you can connect the circuit as shown below and use it as AC line indicator. Plug the P-terminal of diode to one of the terminal of AC line and plug one of the terminal of resistor in other terminal of AC line. This works because the diode rectifies positive half cycles of AC to DC and 100K ohm resistor is used here as series resistance to drop excessive voltage and block excessive current flow to LED. When positive half cycles reach P-terminal of LED the negative half cycles appear at N-terminal and the LED is forward biased and turns on and, when negative half cycles of AC appear at P-terminal of diode, it gets blocked (reverse biased) allowing no current to pass through it and the LED turns off. So, there is turning on and off of LED at every 0.02 second however, we cannot notice it. Thus, this circuit can be used as AC line indicator.

I hope this post has helped you understand as well as review some of the important terms you encounter while doing projects. If you like this post or you have comments please do not forget to write it. I like to hear from you.

Thank you.

Thursday, April 26, 2012

Card games made using VB.NET

Hi,
In this post I will be introducing you some of the card games that I have made using VB.NET and C#.NET. You might have played some of the card games that came with Windows OS like Solitaire, Freecell, Hearts etc. These are well enough to seize your free times. I have made some other type of card games such as Solitaire 11, TenKiller etc. to introduce some other card games that are not available in Windows OS. Now, let me introduce Solitaire 11 card game.

Background:
Solitaire 11 is a single player card game for Windows OS. It is one of my first card game (Complete) that is bug free and works in Windows XP, Vista and 7. I have created it using Visual Studio 2005 with .NET Framework 2.0. The idea came to my mind when I first played the card game in my vacation with my friends. I planned to develop it using VB.NET as I was just moving from VB6 to .NET. As I am not an artist, I worried how could I draw the card faces. Then I captured all the card faces and deck designs from existing Windows card games so it becomes familiar to the player. I have not used windows title and border to make it more like game.

Game play:
A single pack of well shuffled card is distributed in twelve places without seeing them.  If the sum of two cards are 11 then they are covered by top cards in the pack. You can not put cards if it contains face cards like Jack, Queen and King. However, if they appeared at very first deal, and they are not overlapping any cards you can bring them back to bottom of the pack and replace them by placing a card from top of the pack.
In this game you need to click Deal at top-left corner. As soon as you click this button you will get twelve cards distributed from the pack. Then you have to click any two cards that have sum 11 like, 7 and 4, 6 and 5, 10 and Ace, etc. You can also replace Jack, Queen and King that appeared at first deal by clicking them. The more they appear at first deal the more there is chance to win. The game is won if you finished all the pack of cards and you loose if there is no any valid sum of 11 is left. The timer runs as soon as you click the deal and determines how fast you won the game which will be used to calculate your score (fate). To start a new game just click Deal again. You can click Help on/off to guide you. Its so cool.

Video:
See it in action. Please comment after watching the video.



Hope you enjoyed reading this post. I will post more games on my next post.

Thank you.



Some cool C# console applications

Hi,
If you are new to C# and want to explore some cool features of this programming language, just mail with your short introduction and your purpose to me and  I will give you the link to download. The first three console application would demonstrate the object oriented programming in C#. If you want to explore more there is a Hangman game made using console application. Game description and screen-shots of the game is below:

Description of Hangman game:
I have always been interested in making games using different programming language such as C, C++, QBasic, Java, and Visual Basic. This time I decided to make this popular game using C# language to explore and face challenges in C#. I have tested this game many times and hopefully its bug free.  

Main Menu:
The main menu for this game is similar in operation as old DOS programs. It is entirely created using ASCII characters used for drawing box. Unfortunately, C# console application does not allow mouse events, so you cannot use mouse to select or click the menu items. The main menu consists of five items. You can view the description of each item on bottom-left corner of the screen. You can change category of words to guess using Categories menu. Also, you can turn sound on or off using Sound menu. These settings are saved and retained next time you open the game.















Game Play:
This is game play screen. Here you can see the chosen category in yellow colour. The words that you have to guess is from the particular category. You can also see how many words you have correctly guessed and how many of them are incorrect. You need to guess the word by pressing the alphabets in your keyboard. If your guess is correct it will appear there replacing - (dash) and if it is incorrect the body of a man appears at the base of the pole. You have ten chances, after that the man is suspended on the rope with pretty animation.














About:
This is the about dialogue box. The game name is flashed with different colours; a kind of simple animation. Can you notice the shadows of the box, it is also present in Main Menu and Game screen. There is an amazing trick to display shadows in application like these. 














I hope after reading this you are interested in trying the game once and see the source code for the game. I have well documented the source code and its so easy to understand. You need Visual Studio 2010 to open the project files. Also, you need .NET Framework 3.5 or higher to run this game in your PC. If your PC meets the requirement just mail me I will send you the link.


Video:
See it in actions. Please comment after viewing this video.