Thursday, March 28, 2013

Digital Logic Design - AND Gate

This post is about one of the three Basic Logic Gates, AND Gate. In this post I will try to be elaborate that as much possible.

What is an AND Gate?

AND Gate is such a Gate that implements Logical Conjunction that is it will only be true if and only if all of its operands are true. To put it simply an AND Gate will only put out a High output only when all the inputs are High. So the truth table for a two input and gate will look something like this.

Detailed Explanation:

Lets assume three things,
1. A is MOM, B is DAD.
2. You want to go outside to play.
3. You need permission from both of them to outside and play.

What is going to happen then?

You have four possible scenarios.

1. Your MOM Says NO, Your DAD says NO. Result: Can't go out.
2. Your MOM Says NO, Your DAD Says YES. Result: Can't go out.
3. Your MOM Says YES, Your DAD Says NO. Result: Can't go out.
4. Your MOM Says YES, Your DAD Says YES. Result: Can go out.

That's what an AND Gate is.

You can also consider AND Gate with a series of bridges. Again let's assume something.

1. Mr. RED wants to Meet Mr. BLACK.
2. They have two bridges in between them, A and B.
3. There is no other available path except for those bridges.

So what's gonna happen in this case?

They can only meet each other if both the bridges are in working condition. So we can say a High Output only when both Inputs are High.

So lets sum up what happened here.

Constructing AND Gate:

1. With Diode:

To make an AND gate with diode we need
Diodes (Equal to the number of Inputs, 3 for 3 Inputs)
Pair of Resistors.
SPDT switches (Equal to the number of Inputs, again 3 for 3 Inputs in this case)

The way it works is simple. If any of the switches are in the Ground position the current will pass through the 4.7K resistor via Diode to the Ground. So the LED won't light up. But if all the Switches are in +5V position no Diode is going to conduct any current so the current will find its way through the 470ohm resistor and through the LED which will light it up. So the LED will only light up if all the Inputs are high.

2. With Transistor: 

You can compare an AND gate with two series bridges. If you want to get to the other side you will be needing both of them. If any of them is out of order or not available you are not going to get to that desired place.

Assume that Mr. Black wants to meet Mr. Red! The only way is crossing bridges A & B. If one of them is not available then they wouldn't be able to meet!

Its the simplest form of AND gate!

How to make a three input AND gate?
Its also Easy!
Just Add another transistor. About truth table - only if all the Inputs are yes then its output will be yes rest will be no.

This is how a D400 transistor looks like. (sorry about the image quality, I don't have a macro lens)

Where to find transistor & other stuffs?

You can use any common NPN Transistor for this for example D400/2N2222 will be fine & you can find them in any hardware store!

Wednesday, March 20, 2013

Linear Voltage Regulator 1- Hobby Electronics

Good morning everyone.Today I'm going to write about linear voltage regulators.

In my previous post I have showed how easy it is to get a desired DC voltage from AC outlet but there is a problem which is that DC voltage is not regulated. What that mean is the DC voltage might fluctuate with time. Even after using smoothing capacitors the voltage that we get is not fully stable. So that voltage might not be ideal for operating many equipment where it is mandatory to keep the voltage stable.

What exactly a voltage regulator does?

A voltage regulator takes in unregulated input voltage that fluctuates with time and gives off regulated output voltage that doesn't change overtime.

Capacitors are used for maximizing stability of the circuit. When this regulator is under load the capacitors will help to minimize ripple.


Now more about Three Terminal fixed voltage Positive & Negative Regulators.

Positive Regulators are used for regulating positive voltage.
Negative Regulators are used for regulating negative voltage.

Positive voltage regulator starts with 78 & followed by two digits which provide information about voltage. Like a 7805 is a positive 5V regulator, a 7812 is a positive 12V regulator.
Negative voltage regulator starts with 79 & followed by two digits for  which provide information about voltage. Like a 7905 is a negative 5V regulator.

Common Specification of 78XX series:

1. Voltage : A 7812 has a typical 12V output but it could be as low as 11.5V & high as 12.5V.

2. Output Regulation : The output voltage regulation is seen to be typically around 4mV to a maximum of 100mV(depending on output current). It means output voltage can typically vary only 4mV from rated 12V.

3. Short-Circuit Current : Amount of short circuit current is typically 0.35A, if the output is accidentally shorted.

4. Peak Current : Rated maximum current is 1A-1.5A but its peak current is around 2.2A.

5. Dropout Voltage : Typically the dropout voltage for this ICs are 2V. This is the minimum amount of voltage difference across the input-output terminal. If it drops below 2V the IC will no longer provide regulation.

Important Note : 

Linear regulators can be really hot during operation as they burns a lot of power and higher the current is drawn from the regulator and higher the difference between input and output voltage bigger the loss is. So a moderately sized heat sink is needed if more than 500mA is drawn from them.

It wastes Power as follows : (Vin - Vout) * Current out

e.g. If I use a 5V regulator from a 12V unregulated source and I'm drawing around 500mA(.5A)

it will waste (12-5)*.5= 3.5W.

3.5W heat is a lot of heat for such tiny device. It will soon stop working as soon as thermal shutdown feature kicks in.

what if I use a 7V source?

(7-5)*.5 = 1W

which is much lower.

So, one more thing try to use a closer unregulated input voltage. & it IC gets hot use proper heat sink with proper thermal paste!

Where To Find :

This ICs are very familiar & can be found in most of the places. 

From left to right 7805, 7809, 7812 and 7815

To read my other posts, click here.

Saturday, March 16, 2013

Internet Connection Sharing

Good Afternoon!

This post will be about sharing Internet connection in many different scenarios which can come handy time to time.

Possible Scenarios:

1. Internet from USB based 3G/4G Modem shared over wired Ethernet from a Desktop or Laptop. 


1. Let's say you have two computers but only one USB internet modem and you want to use internet on both machines. You cant plug one USB modem in two different machines at any given time, here's how you can use the one internet on both systems.

Let's take a look what we need for this project.

1. Ethernet cable (can be CAT5/5E/6),
2. Working Ethernet port on both systems (you need to make sure that both of them have proper driver installed, enabled and working).


So how you are going to do this?

1. Plug your USB modem on your system. Connect to the internet.

2. Go to Network & Sharing Center  ( On the task-bar you can see this icon . Right click & Open Network and Sharing Center)

3. Now click the change adapter settings on the top left.

You will see your existing installed hardware.  Here in my system Ethernet 2 is USB WiMAX modem & Ethernet is GbE and I will be using this Ethernet port to connect to another system.

5. Now right click on the Ethernet 2 (or the one you want to share) click properties. Then select Sharing Tab.
6. Check both of them & click OK.
7. You can control services from "Settings".

8. After clicking OK,IP will be automatically assigned to your other network Adapter ( the one through you are going to share)
Ethernet > Properties > IPv4

As you can see has automatically been assigned.

9. Now get to your other machine & open up network & sharing center. Go to change adapter settings. Then go to the properties of your adapter that you are going to use. Set IPv4 & IPv6 to auto.

that means check the radio buttons "Obtain an IP address automatically" & "Obtain DNS server address automatically". Press OK.

10.  Now connect the cable & You are done!

2. [][]

Next let's say you have a phone that has 3G/4G connectivity but you need to use the same internet in any other phone, how can you do that? Well that's pretty simple too.

For this you won't actually need anything more then just two phones.

So assume you have a phone with internet connectivity via 3G/4G, in this case it's 3G.

So here it can be seen that this phone is connected to a HSDPA network, now I want to share this internet via WiFi. First I will get to the settings.

Next stop the More options.

Next I'm gonna go to Tethering.

As I was saying that I will be using WiFi so all I have to do is set up Wi-Fi hotspot, which is maybe give a proper name and password then just start the hotspot. 

Here you can see the security type and password is given to this SSID and in this particular phone when no device is connected it will automatically turn off the Wi-Fi hotspot so save battery, by default its 8 minutes. So after launching the hotspot you can see it in any other device.

Here the hotspot is being discovered by the other device. 

Like connecting to any other Wi-Fi router all I needed to do is to type in the password and as you can see it is connected and internet using is possible. 

Let's share some more internet!

Now let's say you have an internet connection, a broadband one via an Ethernet cat 5/5e/6 cable with RJ45 port and you have maybe a laptop or a desktop with a WiFi adapter and maybe a phone. You want to use internet in all of them at the same time but don't wanna get a router or you will just use for short time. Yes it can be done.

So like I was saying you will need an internet connection and at-least a wireless adapter, could be an USB dongle or could be the built-in WiFi of a laptop or desktop.

Now first thing's first you gonna have to make sure that hosted network feature is supported. For this you have to type in the following command in command prompt.

netsh wlan show drivers

Here we can see that hosted network is supported, if you find a No in here, make sure to install proper driver for your wireless dongle or adapter.  

Next stop will be starting an ad-hoc wireless network. To do so you have to type in

netsh wlan set hostednetwork mode=allow ssid=<Enter the network name> key=<Enter the password for this>

In this case you can see I have set it up the SSID as Internet and password is something.

Now you have to start this network, to do so type in the following command and press enter.

netsh wlan start hostednetwork

From My mobile phone I can see that the wireless network is available.

Now, you have to share the wired internet on this ad hoc network. To do so go to "Network and Sharing center", can be found in control panel. 

From there go to the "Change Adapter Settings" and figure out which one is your internet connection, for me it is the Ethernet 2. Now you have to share it over the ad-hoc network that was created. To do so you have to go to the "Properties" of Ethernet 2 and get into the "Sharing" tab. From there share it over the Local Area Connection*6(or whatever you have, look for microsoft hosted network).

After pressing okay you should see the network is shared.

Now connect your phone or tab or whatever you want to connect to and see if internet is on!

 And internet is available!

Although I have found something quite interesting here, the speed which I'm getting via this is actually slightly lower than directly connecting it to the router. Well I wasn't really expecting to saturate this, I have a slow internet connection so was expecting full speed, and the Wireless network is an Intel AC one so it should have performed better I guess. Maybe windows is the culprit here! Who knows.

The blue ones are the results when connecting the phone directly to the router and the red ones are via this method. Anyway If you want to turn it off, simply Turn off the sharing from the adapter settings. Then go to the command prompt and type in

netsh wlan stop hostednetwork

Here we can see it has stopped and also the connection 6 is no longer available.

Hope you have enjoyed the post! Have a nice day!