Digital Electronics Fundamentals 2: Basic Logic Ports

Let’s talk a little bit of logic ports, how they can be made with discrete components, and how to use the premade one available as integrated circuits.

All of this, while learning a thing or two about Boolean Algebra, which is very useful both for designing and analyzing digital circuits.

The NOT Gate

Let’s start with the NOT gate, the simplest form of logical port.

The little circle on the right is the actual symbol for the not operator. The rest of the symbol represents just an active component, an amplifier in particular.

And, in fact, the NOT gate is made of a simple transistor polarized in such a way that it works in only two possible states: OFF, where it does not conduct any current, and ON, where it does conduct enough current to be in saturation. And to obtain this behavior, we just need a couple of resistors: one on the collector, to limit the maximum amount of current, and one on the base, to limit the current that goes through the base-emitter junction when the base is positively polarized.

Let’s now figure out how it works.

If we put a positive voltage in A, basically the +Vcc, the transistor will be ON and a current will flow between collector and emitter, limited only by the resistor on the collector. Because of that, the output U will be at about the ground level.

If we connect A to ground, instead, the transistor will be OFF, or open, and there will be no current flowing through it. As a result, U will find itself at the positive voltage +Vcc.

Remeber now that we associate the +Vcc to TRUE, or the number 1, and we associate the ground level to FALSE, or the number 0.

With such information, we can build what is called a truth table, which is a table that represents how a logic circuit works. In this case the NOT gate.

To build this table, we list all the input symbols on the left side, and all the output symbols on the right side.

In this case, we have only one input, A, and one output, U.

Then, we write on the left side of the table all the possible combinations of ones and zeros on the inputs. In this case, since there is only one input, we will have only a 0 and a 1.

Last, on the right side, we write the output values corresponding to the inputs on the same line. Again, in this case there will be only a 1 and a 0.

This table, now tells that every time the input is at 0, the output is at 1 and, viceversa, every time the input is at 1, the output is at 0.

This logic function, therefore, does just one simple thing, it generates an output that equals the inverse of the input. And, for this reason, the NOT gate is also called Inverter.

Using the boolean algebra, we can define for each basic logic function a specific symbol. For the NOT function, or inverter, the symbol is simply a dash on top of the name of the input or output.

So, using the boolean algebra notation, the NOT function is represented like this:

This notation doesn’t seem to be important, right now, but you’ll see later how important it becomes when we need to design logic circuits.

For the everyday use, NOT gates are usually available in the form of integrated circuits that contain a number of them.

This IC needs a power supply of +5V, since it belongs to the TTL family, and it contains six NOT gates.

The NAND Gate

The symbol of the NAND gate is made of two parts: the NOT gate, which is the circle at the output of the symbol, on the right, and the AND gate, which we will talk about later.

Let’s see how we can make one with discrete components, which will help us understand how it works.

In this case we have two inputs and one output.

If both inputs are at 0, both transistors will be OFF and no current will flow through them. As a result, we will have a 1 at the output.

If one of the inputs is at 1 and the other one is at 0, one transistor will be ON and the other one will be OFF. And since they are connected in series, there will still be no current flowing through them. The output will still be at 1.

But now, if both inputs are at 1, both transistors will be ON and the current will be able to flow through them. And this will bring the output level toward ground, or a logic 0.

Here is the corresponding representation with a truth table:

And here is a typical IC carrying 4 NAND ports:

The AND Gate

And now let’s see why we have talked first about the NAND gate instead of the AND. Look at how it is made with discrete components:

Yes, you can see now that although logically the NAND gate is made with an AND and a NOT gate, building such gate works exactly the opposite. With discrete components, we need the NAND gate and a NOT gate to make an AND gate!

This is because a transistor is intrinsically an inverting amplifier and, therefore, it’s natural use is the NOT gate. Whenever we try to build a port with transistors, it will come out with inverted logic, and so building a NAND is actually more straightforward than building an AND.

And now that we have seen how to build the truth table for the NAND gate, it seems natural to obtain the truth table for the AND gate just by inverting the output. And you can easily verify that following the signals on the previous circuit.

Look closely at the table now. The AND function actually resembles the well known multiplication function. In fact, the boolean AND is identical to the classic arithmetic multiplication, but in an extremely simplified way, because there are only two digits in boolean arithmetic.

Given the resemblance, we usually represent the AND operation in the same way as we do with the arithmetic multiplication:

And now that we have a boolean representation of the AND operation, we can define the representation of the NAND, just by recalling that the output is the inverse of the AND:

Another interesting thing is that building a NAND gate is easier than building an AND gate also for TTL integrated circuits. It is not by chance that the first in the list of the TTL ICs is the NAND gate itself.

Regardless, here is the pinout of a TTL IC providing 4 AND gates with 2 inputs:

The NOR Gate

Let’s now examine another kind of port. With the NAND gate, we connected the two transistors in series. Let’s see now what happens when we connect them in parallel.

So we have the first transistor with its two resistors.

Then we add another transistor, but we connect its collector directly to the one of the first transistor.

And then this second transistor has its own input.

The output is taken on the two collectors.

Let’s see how it works.

With a zero on both A and B, both transistors will be OFF, and therefore will not draw current from the resistor at the collectors. The result is that the voltage at the two ends of the resistor is the same, which means that the voltage at the collectors is +Vcc, or a logical 1.

Putting now a 0 on A and a 1 on B, the transistor on the left will be OFF, while the transistor on the right will be ON, so it will behave like a closed switch.

This transistor will then drain current from the resistor on top, causing the output to go low, which is the logic 0.

Putting a 1 on A and a 0 on B will sort a similar effect. But now the transistor ON is the one on the left, and the transistor OFF is the one on the right.

So, this time, the current will flow through the transistor on the left and the output will still be a 0.

Finally, a 1 on both inputs causes both transistors to be ON and, therefore, the output U will once again provide a 0.

The behavior presented by this circuit is called NOR function, and the device is a NOR gate which has this representation made with 3 arcs and the circle that represents the NOT.

This is instead its truth table:

And here is the pinout of a typical IC providing 4 NOR gates with two inputs each:

In boolean algebra, we represent this function as:

And yes, it looks like the inverse of the addition. But note that in boolean algebra, the value of 1+1 is still a 1. And this is something important to remember. We are talking about logic operations here, not arithmetic operations. If one thing is true and another one is also true, if we put them together we still have a true.

The numbers 0 and 1 are used for convenience, but they do not represent actual numbers, just logic states.

The OR Gate

Let’s now make the OR port.

Similarly to what we did with the AND gate, we will make first a NOR port, and then we will attach at its output a NOT gate.

And now that you are good at it, try to verify on your own that this is the truth table for the OR function:

Here is the symbol of the OR gate:

And here is an IC with 4 ports inside:

Finally, the boolean representation of the OR function:

And remember: this is a logical expression, not an arithmetic one. Therefore: 1+1 = 1.

Conclusion

So, today we have seen 5 different logic gates, or ports: The NOT, the NAND, the AND, the NOR, and the OR.

We have also seen how it is easier to build inverting gates, because of the way transistors actually work.

And we have seen that obtaining in practice non-inverting ports requires more components, so we reach the paradox where simpler logic ports have a more complex implementation.

Now that we have the basics, next time we will start looking at something more complex, obtained as a combination of 2 or more ports of the kind we have seen today.

This series of tutorials is also backed up by a corresponding video series available on YouTube. The following page provides the links to the YouTube Videos, as well as the link for the whole series, and the links to all the files involved in the tutorials, with schematics and anything else that might be needed:

Advertisement

How To Make A PCB Using A Laser Printer

When working with electronic circuits, sooner or later we feel the need to make our own PCBs to get a more functional and better looking circuit board.

I already made a video in the past to show how that could be done, for simple circuits, by drawing the circuit manually on the copper clad with a special kind of pen that uses an ink impervious to the chemicals needed to etch the PCB.

This time, I am presenting you a different technique, that allows you to draw the traces, and also the silk layer, with any of the design tools of your choice available on the Internet and the market in general. All you need to have is a laser printer. You can refer to this newer video for a demonstration of the process.

The whole process works on the concept that the printouts of the laser printers are made with a toner that has the characteristic of being able to protect the copper from the etching chemicals, like the ink from the pen in the original video. This is because the toner is made with a sort of plastic material.

Unfortunately, we cannot use a laser printer to print the masks directly on the copper clad, because the PCB boards are too thick for the printer. Therefore, we need to find a way to print on paper and then tranfer the printed ink to the copper afterwords.

This is made possible by a certain quality of glossy paper that do not allow the toner to stick permanently on its surface when exposed to heat. Even paper from magazines that are printed on glossy paper works relatively well for this to happen. However, there are specialized papers, that are designed specifically for this, which are called Thermal Transfer Paper For PCBs. A quick search on-line will give you plenty of places where you can buy it at a relatively modest price.

Once you have your PCB design ready and printed on such paper, the process to create PCBs becomes really straightforward.

First step is the transfer of the traces drawing to the copper. The copper needs to be perfectly clean, so it is always better to use a piece of steel wool to scrape away copper oxide and other dirt from the copper surface. Just move the wool in a circular fashion to remove all the particles of oxide from the copper clad and make sure to use gloves, otherwise the contact with the skin of your hands will soon oxidize again the copper.

Once all the oxide is removed, you need to deep clean the copper to remove any particle of dust from it. To do so, you can use some alcohol. Once done, let the board stand for a a while to make sure it is completely dry.

Then lay the board on the printout, making sure the copper is in contact with the drawing. Wrap the paper all around the board to make sure it will not move during the transfer process.

Once the PCB is wrapped with the paper, put it on the table copper-side up and use an iron at the max temperature, with no steam, to heat uniformly the whole surface of the paper and the pcb wrapped in it. Be careful not to burn yourself in the process, of course. You do not need to press hardly, the weight of the iron is just enough. Just make sure you keep moving the iron so that the whole surface is heated uniformly. Do that for a while, until the copper clad becomes almost as hot as the iron. Don’t worry about burning the paper. it is not going to happen. Paper burns at 451 F while the iron, even at the hottest temperature, doesn’t normally go over 400F.

Once the paper and the clad are well heated, put aside the iron and unwrap the board, making sure that when you remove the paper from the copper side you do that slowly and uniformly. The ink from the printout will now have moved from the paper to the copper.

Second step is the actual etching. Use a plastic container, fill it with some ferric chloride solution, enough to cover the whole pcb, then dump the board in the solution. Once the board is in the solution, you’ll notice that the ferric chloride starts changing color. From the initial brown color, it starts becoming darker and darker. This happens because of the copper on the board that starts dissolving in the solution.

While the etching process continues, try to agitate the solution periodically, which will speed up the reaction. A warmer room will also help. Every now and then, check the status of the board and remove it from the solution as soon as you don’t see any more copper on the surface of it.

Once the etching is completed, remove the PCB from the solution and start rinsing it immediately, to stop the reaction that would continue to attack the remaining copper on the surface.

You now need to remove the toner film from the copper traces, otherwise you will not be able to solder the components on it. To do so, use a Lacquer thinner on a piece f paper or cotton and work slowly a little bit at a time. Do this in a well ventilated area. Solvent vapors are both unpleasant to breath and harmful.

Third step is to drill the holes. It is only necessary if you use pass through components, of course. If you use surface mounted components, this step is not necessary, unless you need holes to hold in place the board.

Finally, the fourth and last step is to do another transfer, on the components side of the board, to transfer the drawing for the silk layer. The procedure is exactly the same, but this time the toner will be lay down directly on the board support, not on the copper.

You can see how this process allows you to quickly repeat the whole procedure on as many boards as you like. You just need to print multiple copies of the layouts on the thermal paper and go through the previous four steps.

Hope yo liked this procedure, and don’t forget to go watch the corresponding video, so you will see exactly how this procedure works.

Electromagnetic Interference and Shielding

Whenever a current flows through a wire, it creates a magnetic field surrounding it and, if the current is variable, so will be the magnetic field.

Conversely, if we put a wire in a variable magnetic field, an electromotive force will be generated in the wire, in other words: a voltage. This voltage, in turn, produces a current in the wire when it forms a closed circuit, like a loop.

Another way to describe this phenomenon is this: if we have a variable magnetic field in a volume of space, a variable electric field will be automatically generated in that same space. It is that electric field that generates the voltage on the wire and causes current to flow through it. Again, this concept presents a duality. If I generate a variable current in a wire, a variable electric field will be present on the wire and its surroundings. As a result, a variable magnetic field will be generated in the same volume of space.

In fact, whenever there is a variable electric field, there is also a corresponding variable magnetic field and viceversa. Each of the two variable fields cannot exist without the other. They always both exist at the same time. It is for this reason, that we usually refer to them as a single field called Electromagnetic field.

And because the electromagnetic field changes over time, it also affects its surrounding space and the space surrounding that space, and so forth. Basically, the effects of the electromagnetic field is visible over long distances and so we say that electromagnetic fields propagate in space. We call this an electromagnetic wave.

https://upload.wikimedia.org/wikipedia/commons/9/99/EM-Wave.gif
(Attribution: And1mu / CC BY-SA (https://creativecommons.org/licenses/by-sa/4.0)

Light, for example, is an electromagnetic wave and propagates in space at what we call the speed of light.

A physicist named James C. Maxwell, back in 1861, put together all the knowledge of the time and elaborated a set of 4 equations that completely describe how electromagnetic fields work and how electromagnetic waves propagate. These equations are known today as the Maxwell’s Equations.

Remembering James C. Maxwell – Station HYPO

The concept of electromagnetic waves is widely used in electronics to make devices that can receive and transmit information using this physical property. You know very well these devices. They are called radios, and they can be used on their own or inside a wide variety of more complex devices, like TV sets and cellphones.

Without the electromagnetic waves, the global telecommunications system we enjoy today would not exist.

However, there is a negative side of the electromagnetic fields and waves. Electromagnetic waves are continuously transferred from one circuit to another, or from one part of the same circuit to another as long as variable currents is produced. The problem is that, most often than not, we do not want these kind of interactions.

Whenever an unwanted signal is generated in a circuit because of the electromagnetic fields that surrounds it, we call it a noise, and we try our best to remove it.

Noise (electronics) - Wikipedia

The generation of these unwanted signals is generally called Electromagnetic Interference or, in short, EMI.

The action we take to avoid and prevent EMI is called Electromagnetic Shielding, or EMS.

Basically, it works by putting a shield in between the area where the source of the Electromagnetic field is located, and the circuit that is negatively affected.

There are several sources of EMI, some occur in nature, others are created by humans, as a by-product of the machines and devices we use daily.

Since the production of EMI is a bad thing, the governments all over the world provide guidelines to help reduce the generation and the effects of EMI. They also define rules that specify the maximum amount of EMI that any device can generate.

This helps manufacturers in creating compatible devices that do not influence each other.

If we had to make a list of all possible sources of EMI, that list would be incredibly long.

Here are just some examples.

Some natural occurring EMI:

– solar magnetic storms, that occur from time to time on the surface of the sun and may cause huge electromagnetic waves that can propagate toward Earth and cause a disruption of electric and electronic devices.

See Explanation.  Clicking on the picture will download
 the highest resolution version available.

– lightning, especially during thunderstorms.

– Earth’s magnetic field flux, which is caused by moving an electric device across the magnetic field generated by the Earth, thus creating unwanted electric fields and currents inside the device.

And here are some human-created sources of EMI:

– TV sets

– Radios

– cell phones

– brush motors

– fluorescent bulbs

– computers

– tablets

– microwave ovens

– power generators

illustration of industrial and home immovable power generator

– internal combustion car engines

– arc welders

– brownouts and blackouts in the power grid

– electrical power lines, causing the well known humming that can be even heard when getting close to a high voltage power line.

– voltage sags and spikes in circuits

… and the list goes on and on. And each item in this list is potentially a noise generator that can affect and even totally disrupt the functionality of an electronic circuit.

That’s why, all the electronics equipment that is sensitive to EMI needs to be protected with shields. We call this protection “ElectroMagnetic Shielding” or “RF Shielding”.

Whenever we have an electronic device that is sensitive to electrical noise, we need to provide it with some sort of electromagnetic shielding, or EMS, to make sure that the electrical noise generated by the EMI is reduced below a value, or threshold, that the device can safely handle. Sometimes, very sophisticated and sensitive instruments have really low thresholds, a condition that is very difficult to achieve but, nonetheless, necessary.

Examples of electronic devices that need EMS are:

– electric wires used to transport audio, video and radio frequency signals: to protect them we usually do things like surrounding them with a metallic shield. Such cables are called coaxial cables.

– RF equipment: radios, cellphones, TV sets, and so forth, need to be shielded from unwanted noise. In fact, EMI can make sounds difficult to understand, or it can distort pictures and videos, for example.

– Audio equipment: again we don’t want to hear noise when we are listening to our preferred song or band.

– medical equipment: EKG machines, diagnostic equipment and the sort affect human life and we don’t want that the wrong noise at the wrong time causes somebody to die.

– Avionics: what if the airplane instruments stop working during landing because some EMI was generated by the unshielded device of a passenger? That’s why they don’t want you to use any sort of electronic devices during take off and landing.

– certain lab tools, like oscilloscopes: we want them to measure the signals of our circuits under test, not the noise produced by electromagnetic fields in the room where the instrument is located.

And again, the list goes on and on.

Whenever we create a new device, we always need to make sure, first, that it will not cause EMI that can affect other devices; and, second, that it will not receive too much EMI from the surroundings.

The ability of creating Electromagnetic shielding depends on two different properties of the materials: the conductivity, which is the capability of allow the movement of electric charges, and the magnetic permeability, which is the capability of a substance to facilitate the flow of a magnetic field through it. In other words, the permeability works for the magnetism like the conductivity works for the electricity.

The conductivity property allows to shield from electric fields and the permeability property allows to shield from magnetic fields.

Unfortunately, there are no materials that have simultaneously a good conduction and a good permeability. So, we choose one material or another depending on what aspect we need to give priority.

Shielding due to conductivity is achieved by the property of what is called the Faraday Cage.

Michael Faraday was a British scientist that invented the device in 1836. The cage was capable of shielding people from electric strikes and from electrostatic discharges. That device is today known with his name, the Faraday’s cage, and its principle is extensively used to provide electric shielding of all sorts.

It is basically a cage made of conductive material and is capable of shielding whatever is inside of it against electrostatic and electric fields.

It works because an external electric field causes modifications in the distribution of the charges in the conductor. Once the charges are redistributed, they produce on their own another electric field that cancels out the original field and prevents it to enter inside the cage. The better is the conductor of which the cage is made of, the better the cage works.

Note, however, that the cage is supposed to be a continuous covering of conductive material, without holes. Only that way it can prevent electric fields from going inside. In practice, we do need openings in the cage, otherwise it would not be possible to put anything inside of it. But, as long as the openings have a size much smaller than the length of the electric waves that we want to shield, the Faraday’s cage will work as if it was a continuous covering.

So, for lower frequencies we can have bigger openings, but for higher frequencies we need to make them smaller and smaller, up to the point that for very high frequencies we really need a continuous covering.

Another aspect of the Faraday’s cage is its bad efficiency at the higher frequencies due to what is called the skin effect.

When a constant current flows inside a conductor, all the movable charges inside the conductor participate in creating the current.

But, when we have an alternate current, the center of the conductor is used less and less with the increase of the frequency. So, at the highest frequencies, if we don’t have a very good conductor, since the current will only move in a thin outer layer of the whole conductor, or the skin, the resistivity will be so high that the electrons inside will not move fast enough to counterbalance the electric field and so the shield will not be effective.

That’s why at the highest frequencies shields are usually made with an external layer of copper or even silver, which is the best known conductor.

When we need to create a shield for a magnetic field, a good conductor doesn’t do any good. For magnetic fields, we need to use materials with high permeability to magnetic fields which, conversely, are poor conductors.

The big difference with magnetism is that we cannot separate north and south poles like we do with the positive and negative charges, Therefore, the lines of a magnetic field always go from the north pole to the south and cannot be interrupted.

What we can do is to merely deviate the field lines and force them to go through a high permeable material, away from the device that we want to protect.

https://www.kjmagnetics.com/images/blog/article2010.01.pic1-640.png
Courtesy: https://www.kjmagnetics.com/images/blog/article2010.01.pic1-640.png

This is a totally different approach from the electric fields, where we actually cut the field lines and prevent them to go inside the Faraday’s cage.

Materials

As we already said, there are two kind of shielding: those that work better against electric fields, and those that work better against magnetic fields.

Different materials have been adopted over time to achieve these two goals.

To shield from electric fields, we need to use good conductors. The best conductors, however, like silver and copper, are very expensive. So, whenever possible, the tendency is to use slightly less conductive metals that are still very efficient at the particular frequencies where the shield is supposed to work.

And so you can see shields that are made of aluminum, steel or nickel, and only when strictly necessary copper or even silver is used.

Shields for electric fields can then be shaped as a solid box, or as a mesh, or a metallic foil, depending on the mechanical and electrical needs. To protect plastic boxes, there are even certain conductive paints that can be used to coat the plastic and obtain a relatively good shielding.

To shield from magnetic fields, we need to use a material that is permeable to magnetic fields.

Iron and steel are the obvious examples, but there are some alloys that are particularly good for magnetic shielding, like silicon-iron and mu-metal.

Just to give you an idea, the relative permeability of the air is defined as 1.

Iron with 0.2% impurities has a relative permeability of 5000.

Silicon-iron has a permeability of 7000.

And mu-metal has a permeability of 100,000.

Depending on how thick we can make the shield and the amount of magnetic energy that we want to stop, we will need to choose one solution or the other.

For electronic circuits, however, we deal most of the time with electromagnetic waves and not with constant or quasi-constant fields.

Since electromagnetic waves have both an electric and a magnetic component, and since one cannot exist without the other, it is enough to shield from one of the two component to block the whole wave.

That is why, electronic devices are usually only shielded against the electric fields, which are the easiest shields we can obtain. Doing so, we can stop or reduce the electric component of the waves and, therefore, the whole waves, since the magnetic component will go away as well, just because the electric component is not there anymore.

When creating an EMS, or an electromagnetic shielding device, we need to be careful to make it in such a way that it will actually shield our electronic circuit, rather than actually collect even more noise. Unfortunately, it is very easy to obtain the opposite effect.

For example, if the shielding of a device is not connected to ground, the current that flows in the shield will non be able to be discharged anywhere. As a result, all the energy will be reflected in the surrounding space, thus defeating the purpose of having a shield or, even worst, causing some resonating effect that could create even more noise.

Another cause of trouble is when the shielding is done in such a way that the internal currents move around in a loop. If that happen, the loop will actually cause a concentration of the eletromagnetic waves, thus causing more trouble than not having a shielding at all.

The last issue I would like to mention is the one of the gaps in the shielding which, if too large compared to the wave length of the noise, will not be able to prevent the noise itself to go through. We therefore need to be very careful when making holes in the shielding, for example, to allow wires to go through. Or to allow us to see the display of an instrument. If the opening is too large, compared to the wavelength, the noise will no through and the shielding will be ineffective.

EMS is always a hot topic in electronic devices, whether they are low or high frequencies. We need to spend a lot of thoughts when designing the case of a device and, in case of radio frequency, even the design of the PCB deserves a lot of attention to prevent unwanted coupling of the signals from one section of the PCB to another, which is basically noise that is generated and distributed internally to the circuit itself.

It is also important to distinguish cases where the device is supposed to deal with very low signals versus those cases where the signal is higher.

When dealing with low signals, we may end up with noise that has the same magnitude of the signal being treated, and so we have to put a particular attention to the suppression of the noise, which could otherwise overwhelm the wanted signal.

When dealing with higher level signals, the surrounding noise could sometimes be considered negligible and, in such a case, the EMS becomes less of an issue.

It is important, therefore, to address each case individually. There is no common solution that can be adopted for everything.

%d bloggers like this: