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.
LED.
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.

Types:

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!

Internet connection can be shared between devices in numerous ways and this post will cover some of them. Methods shown here might not be the best or the most elegant but they are workarounds which might come in handy in different scenarios.

Index:

Scenario 1: Using single USB Modem on Two machine.
Scenario 2: Mobile Phone's 3G/4G internet on other devices.
Scenario 3: Turn Your Computer into Wi-Fi Access Point(Without any extra Software).
Scenario 4: Turn Your Computer into Wi-Fi Access Point with Xiaomi Mi USB Router(Link).
Scenario 5: Internet Sharing Using Bluetooth.

Scenario 1:USB 3G/4G Modem shared over wired Ethernet from a Desktop or Laptop to another one. 


A bit more Details:

Let's say you have two computers but only one USB 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 that one connection on both systems.


Extra accessory needed:

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).


Procedure:



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

2. Go to Network and 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.
4. You will see your existing installed network hardware.  Here in my system Ethernet 2 is USB WiMAX modem and Ethernet is Gigabit wired connection. This wired port will be used for connecting to other system.






5. Now right click on the Ethernet 2 (or the one you want to share) click properties. Then select Sharing Tab. Check both of them and click OK.



6. You can control services from "Settings".




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



As you can see 192.168.137.1 has automatically been assigned.

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




10.  Now connect the cable and You are done! 

Note: For the second machine you don't have to use windows, any other machine would do but you have to keep the IP and DNS to auto.


Scenario 2: Sharing 3G/4G internet connection of android device to other device.

For this type of sharing you don't need any other accessory.

Procedure: 

1. Connect to internet via 3G/4G with your phone.

2. Go to Settings



3. Go to More options.

4. Now go to Tethering


5. Enable Wi-Fi hotspot. You can change password and SSID from the Set up Wi-Fi hotspot. It is mandatory to use WPA2-PSK and a good password if you want it secured.


6. Go to the Wi-Fi of other device that you want to use this shared connection.


7. Connect to the right SSID with the password set earlier.


8. Done. You can use internet on both devices now.


Note: You can use this shared Network on any device that has Wi-Fi. Phone, tablet or any type of computer. Though be careful, 3G/4G internet can be costly.


Scenario 3: Turn your Computer into a Wi-Fi Access Point


Let's say you don't have a Wi-Fi access point, your computer is connected to internet via Wired Ethernet. You want to share this internet connection through Wi-Fi.

For this you have to make sure that your computer has Wi-Fi capability.

Procedure:

1. First thing that you gonna have to make sure is 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 device.  


2. 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.

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


netsh wlan start hostednetwork



4. Now go to the device from where you want to use this shared connection. From my phone I can see that the SSID "Internet" is available. But don't connect to it yet.



5. From host system 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. 



6. From there go to the "Change Adapter Settings" and figure out which one is your internet connection, for me it is the Ethernet 2. We want to share this connection over the ad-hoc network that we created. To do so 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).


7. After pressing okay you should see the network is shared.


8. Now connect your phone/computer to use this internet.


 9. And internet is available on other device as well!


Note: 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. I wasn't really expecting to saturate as  I have a slow internet connection so was expecting full speed. Moreover the Wireless network is question is an Intel AC so it should have performed better. 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. 

Turn off: 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.