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

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

## 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. My motivation for writing this is mainly to show different ways of doing something, in day to day life we might face simple issues like this and this type of workarounds can be very useful. I intend to keep on adding more and more ways.

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: Bluetooth Internet Connection Sharing.
Scenario 6: Wi-Fi Mobile Hotspot on Windows 10.
Scenario 7: Bluetooth Mobile Hotspot on Windows 10.

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.

Scenario 5: Share internet via Bluetooth.

Assume you are stuck in a position where your phone is connected via Wi-Fi and getting internet but your computer can't because it doesn't have Wi-Fi nor it can connect via Wired Ethernet. Furthermore you don't have USB cable to connect directly with your phone but your computer has Bluetooth so let's share phone's internet via Bluetooth.

Make sure your phone has internet connection and your PC has working Bluetooth.

Procedure:

1. Enable Bluetooth on your Phone and make sure the phone is connected to internet.

2. Go to Settings>More>Tethering

3. Enable Bluetooth Tethering.

4. Go to your Computer's Bluetooth settings and pair with the phone.

5. Go to Open Network and Sharing Center and go to change Adapter settings. From here right click on the Bluetooth and go to "View Bluetooth Network Devices".

6. From the View Bluetooth Network devices right click on the phone you want to connect to and Connect Using Access Point.

7. It should connect right away. But from the connection speed you can guess how much speed you can get out of it.

Note: If you want to use it on say another android device you can do that as well. Here is how to use it on a Nexus device. Go to the Bluetooth option of the said device and connect to the Phone that has internet.

Make sure on the Paired Device "Internet Access" is allowed.

Note: As I was mentioning earlier that speed might not be good, here is the possible speed you might get from Bluetooth Tethering.

Whereas direct connection can give you results like this

And do keep in mind that both hardware was Bluetooth 4.0. So not that good for activities that requires a lot of Bandwidth but if you are in need of doing something important and not Bandwidth hungry you can still do it.

Scenario 6: Mobile Hotspot on Windows 10

Windows 10 brings a lot to the table, not all of them are good but a lot of good things are included as well, for example a very easy way to start a Mobile Hotspot.

So if you have a machine running Windows 10 that has internet connectivity you can easily share it over Wi-Fi for other devices to connect. Essentially you can turn your computer into a Wi-Fi access point. This comes in handy in many different scenarios.

In this test configuration I have my machine connected to the Internet Via Ethernet port, I also have a TP-Link USB Wi-Fi dongle connected to it, I will simply share the Internet over Wi-Fi.

Step 1: Go to Windows Settings Menu.

Step 2: From here Go to Network and Internet

Step 3: Click the Mobile Hotspot option on the Left.

Step 4: You might see something slightly different here, like in my case I have Bluetooth adapter plugged in so that option is there as well. For my case I'm sharing Internet from the one Ethernet Adapter that my system have, if you have multiple one connected to multiple devices you might have to select that too.

From the Edit Menu you can change SSID name and Password that to be used.

Step 5: After setting everything up properly just Move the Toggle Button to the right to turn it on.

Now the Hotspot is on and you should be able to find it on your Wi-Fi enabled devices nearby. Simply connect it with the password that you have just set.

As you can see from my phone I can easily use it.

Step 6: Now if you look up you should see something like "Devices Connected" Option. From there you can actually see the number of Devices Connected and as you can see my phone is listed there with the same IP address.

So that was pretty simple and Easy.

Scenario 7: Bluetooth Internet connection sharing on Windows 10.

Now this might be even more niche scenario where you would want to use Bluetooth as the access point and like I showed in this post previously that the speed regression is so bad that you can not use any bandwidth hungry devices with it. I was particularly interested in the speed that I can manage and it was not good however sending some Email and browsing some light websites were fine.

Ease of understanding I'm dividing the procedure in two steps. First one is from the Host Computer.

I am not going to post same pictures again, so you have to reach the Step 4 of the Previous Scenario(#6) and just click the Radio button for Bluetooth instead of Wi-Fi.

In here you can also see the number of connected devices and also note that maximum number of devices now is 7 which was 8 for Wi-Fi.

This is all you need from your system except you might have to accept your mobile device to be paired with the system.

Now From the mobile device or any other Bluetooth enabled device. In the Bluetooth menu you should see your computer's name on the Available Devices, if not make sure your computer is visible on Bluetooth.

Next connect with it.

When pairing your system will see the matching pair code and allow it to pair.

Now that it is connected, tap the settings icon right next to it.

In here make sure the Internet Access option is enabled.

And you are good to go!

However the speed I was talking about, Here take a look.

Pretty much 1/100th of the speed of Wi-Fi that is onboard here, but sure it can be used in extreme cases.