The post A Closer Look Inside the Arduino Uno, Part 2: Powering the Arduino appeared first on Circuit Crush.

]]>The post also gives a brief history lesson on the board, goes over the layout and some of the main components, discusses the Arduino pin out, and finally, talks about a few nuances of the Arduino Uno which may cause some seemingly weird errors to occur.

In that post, I made the promise to go into more detail on some of the often overlooked, but important nuances of the Uno.

This time around, we’ll delve a bit deeper into powering the Arduino Uno and talk about some of its limitations and best practices for doing so.

Let’s get started!

Powering the Arduino is something many of us put little thought into. Most of us simply grab our wall wart, jam it into the Arduino’s DC jack and go to town on what ever it is we’re working on.

The Arduino Uno’s built-in power supply is one of the least appreciated, but most important parts of the board.

In fact, if your Arduino-based creation is giving you weird or spurious errors and you can’t figure out why, there’s a good chance the power supply may be the culprit.

Figure 1 shows the power supply section of the Arduino Uno board.

As we can see, the input power can come from a few different sources:

- The DC jack (center positive)
- USB connector
- Vin header socket
- 5 V header socket

*Figure 1: the power supply portion of the Arduino board.*

* *

If you plug in both a DC power adapter (like a wall wart) and a USB cable, the board automatically draws power from the source with the higher voltage. There is a small FET (field effect transistor) to the left of the crystal that isolates the USB power from the DC jack to prevent it from back feeding into your PC’s USB port.

Also, there is a series diode that prevents reverse polarity from the DC jack. Inadvertently reversing the polarity can destroy the board.

The Arduino headers include three power outputs:

- Vin raw DC
- 5 V regulated
- 3 V regulated

The Vin socket connects to the 5 V regulator which powers the 5 V header socket and the rest of the board.

A word of caution is in order here. Vin is NOT protected by the series diode we mentioned earlier (it connects downstream of it). This means swapping ground (GND) and Vin will ruin the board.

When powering the Arduino, there is more than meets the eye, at least at first glance.

You’ll notice two capacitors near the DC jack in figure 1.

The one on the right stores energy for power arriving through the DC jack.

The specifications on the Uno say that you can use up to 20 V to power the board. The problem is these capacitors are only rated for 16 V. As you may have already discovered, electrolytic capacitors can fail rather catastrophically when polarity is reversed or when pushed beyond their voltage limit.

Low quality wall warts often have unregulated outputs that can exceed the ratings on the case — especially at lower currents, so be careful here.

One possible hack would be to replace the Uno’s capacitors with ones that boast a higher rating, say, 25 V. The caps are 47 µF electrolytic capacitors. This could be a good beginner’s Arduino project and also a good insurance policy on your board. Note that some boards, like the SMD version of the Uno I have, already come with higher rated capacitors.

Or you can just use a decent quality wall wart within the voltage specs of the capacitors the board comes with.

Just above the DC power jack lies the Arduino’s 5 V regulator. This device has a dropout voltage of around 1 V – 1.2 V depending on the current load. This requires a DC input of at least 6.5 V to ensure 5 V comes out, even though the Arduino specs on the voltage limits say 6 V (on the low end) is ok. Note, however, that the recommended voltage range starts at 7 V.

The power related specs (from the Arduino website) for the Uno are shown in figure 2.

*Figure 2: Arduino Uno power specs.*

The Arduino specs don’t say a lot about it, but if you use more than 12 V to power the device the regulator could overheat, damaging the board.

The voltage regulator does have its own internal over-temperature protection. This will shut it down when the temperature goes above 350° F (175° C).

Once the temperature drops, the regulator will automatically resume operation. This means that powering the board improperly can not only damage it, but cause strange errors and failures as the ATMega328P microcontroller restarts.

For most of us, when we put a finger on an object of about 150° F (65° C), we will only be able to keep our finger on it for a few seconds before the pain sets in. This is a good rule of thumb for hobbyist electronics in general: if you can’t touch it for more than a few seconds, it’s too hot.

The rules may be different if you’re designing a commercial or industrial widget, which often have to stand up to harsher environments, like under the hood of your car.

The Arduino, being a low-cost open-source platform aimed at hobbyists, is not meant to stand up to temperatures much greater than that for very long.

For a 12 V input, the maximum regulator current (using the rule above) is only about 70 mA.

How did I come up with that number?

I won’t bore you here, but if you read the data sheet for the regulator and do a bit of math (making a few rough assumptions) you should get something close.

With a 12 V supply, the max current (using our rule) isn’t much. The microcontroller itself draws about 10 mA at 16 MHz, the USB interface takes another 15 mA, and the rest of circuitry on the board (like the LEDs etc.) eat up another 10 mA or so. Not much room for anything else here.

The take-away: use a power supply less than 12 V.

For example, using the same thinking that gave us a limit of 70 mA for a 12 V power supply, we can raise that to about 250 mA if we use a 7 V power supply. Don’t have a 7 V supply? Grab the closest thing to it.

This type of precaution not only protects the 5 V regulator, it also protects the 3.3 V regulator.

Another word of caution is in order: watch your sources.

Since Arduino boards are open-source, anyone can copy the design and alter it as they see fit. For example, some Arduino look-alikes don’t have thermal vias (little copper-lined holes to conduct heat between the layers. You can see a lot of them in figure 1.) so the regulator is likely to run hotter.

One trick some people employ is to add a heatsink to the regulator. While this can help a bit, the case is made of plastic and doesn’t conduct heat away very well.

A minute ago, we talked about using a 7 V (or something close) power supply. But what if your project requires 12 V or more?

One way around this is to use a separate power supply for the project. You could also feed another voltage regulator that produces a lower voltage with that 12 V supply (with a heatsink, if needed) and feed the Arduino with its output. For example, a LM317 regulator with a few resistors would produce 7 V.

Here’s another good rule of thumb for those wishing to venture into this territory: when your power supply becomes more expensive than your Arduino board, it’s time to rethink things.

Going back to figure 2, we can see that the DC current limit for any digital pin is 20 mA. This is barely enough to drive one LED.

This is important because the microcontroller’s output pin drivers have no current limiters. We’ll talk more about I/O pin specs and characteristics in another post.

It’s been said that too much power often corrupts people. Too much power can also corrupt your project and ruin your board, as we have seen.

There is definitely more than meets the eye to powering the Arduino.

You may be able to bend or even break some of the rules and guidelines we’ve discussed a few times, but if done often enough, it will catch up to you. You’ll know it when the magic smoke appears or the board simply ceases to work.

We’d love to know what your favorite trick is when it comes to powering the Arduino. Leave a comment and tell us. Who knows, maybe your way works even better than the ones mentioned here!

The post A Closer Look Inside the Arduino Uno, Part 2: Powering the Arduino appeared first on Circuit Crush.

]]>The post Practical Electronics: Resurrecting My Electronics Workbench, Part 2 appeared first on Circuit Crush.

]]>I also showed you the “before” version of the bench, went over a quick (and cheap) computer upgrade for running simulations and programming, and did some “house cleaning.” Finally, I laid out some of the plan for the newly remodeled workspace.

The first post was more about planning, but this one is where the action is. This is where you’ll see the “after” version of the workbench.

I’m going to wrap up redesigning my electronics workbench and show you the finished (for now) product. And yes, I’ve added a lot more pictures to document the steps I took along the way.

You’ll also see a silly mistake I made.

If you haven’t read part 1, please read that first as it may help you understand some of my decisions and gives a bit of background on why I’m doing this.

Even if you’ve had an electronics workspace set up for a while now, I urge you to read the relatively short post as you may get some ideas for your own bench.

Let’s dive in.

I once was a renter who lived in a condo. The kitchen was small and narrow and there was a coat closet by the door where the kitchen met the one-car attached garage.

Shortly after moving in, I removed the door to this closet and decided to convert it into a pantry due to the small amount of cabinet space in the kitchen.

After a trip to the hardware store, I got to work on the pantry using three rails to support the shelf brackets (which I attached to the wall with toggle bolts), the brackets which fit in the slots in the rails, and the shelves themselves which rested on the brackets. It was great and served its purpose well.

Then I bought my own house and decided to bring the shelves and the brackets with me just in case. The rails remained screwed to the closet wall of the condo.

In my basement they sat for four years, but now it was time to repurpose them (while saving money) and use them for my electronics workbench.

Since I only would need a few shelves, I was able to obtain one 70.5” mounting rail at the hardware store. This rail would be cut into thirds.

Though the shelves are only about 3’ wide, the power supply has some weight to it and sagging shelves just don’t look that great. Plus, I’d hate for gravity to pull the shelves (with all my stuff) off the wall.

Hence the three rails for extra support.

At first, I tried cutting the rails with my Sawzall. This was a bit of an over-kill and led to a very crooked cut. Luckily, I was able to file the end down and make it a straight cut. No more power tools though. The rest would be cut by hand with a hack saw. The cut ends of the rails were then filed down to remove any errors in my cutting. This also made them safer by removing any burs and sharp metal edges.

After chopping the rail into three equal pieces, drilling a few additional mounting holes in the pieces (I wanted three screws in each section for added strength) and filing the ends, it was time to mount them to the wall.

I would need to be able to reach things on the lower shelf from the chair without getting up, but I also would need enough room under the bottom shelf for my clients’ desktop computers (for my business).

Grabbing my trusty electronic stud finder, I went to work.

I meticulously proceeded with the layout, drawing lines on the wall to ensure all three rails would be mounted to studs and that the rails were level. It’s hard to see, but figure 1 below shows the layout lines on the wall if you look closely.

Figure 2 shows the three cut rails with the mounting hardware.

*Figure 1: if you look closely you’ll see the pencil marks on the wall. A 2’ level was a great help in drawing the lines. The hole locations were also marked so I could drill pilot holes, which made screwing the rails to the wall easier and more accurate.*

*Figure 2: the three rails with the mounting screws and washers. The screws are 2 ¼” long. The clear plastic pieces on the upper left are dividers for the drawers in my small parts/hardware cabinet. They decided to photo-bomb the picture.*

Now it was time to mark the holes and drill pilot holes in the wall so mounting the rails with the screws would be easier and more accurate.

After that, I would screw the three rails to the wall.

The bottom ends of the rails would touch the horizontal line on the wall in figure 1 and the rails would lie between the vertical lines, so they could be fastened to studs rather than employing toggle bolts for extra strength.

Figure 3 shows the three rails on the wall.

*Figure 3: the three rails mounted to the wall.*

* *

The moment of truth was here. I checked each rail with a magnetic torpedo level to see if they were level.

Check.

The shelf supports came next. The shelves themselves simply rest on top of the support brackets.

But, there was a problem. The shelves were wobbly and weren’t making complete contact with all three brackets. Something was wrong.

But what could it be? The rails were level. The shelves were reasonably flat. All three rails were at the same height from the floor. WTF???

Then it hit me. The middle piece in figure 3 was cut from the middle of the 70.5” rail. The other two rails were from the ends of it.

The shelves were wobbly and didn’t rest on all three support brackets because I’d forgotten to compensate for the slots in the rails.

In other words, the slots in the middle rail did not line up with the slots on the two end rails so the support brackets weren’t all at the same height!

Close inspection of the picture will reveal this oversight and help explain what I mean.

I removed the brackets from the middle rail and set the shelves on the remaining brackets to confirm my belief.

Yep, I was right. The slots in the middle rail were slightly higher than the slots on the end rails.

*Figure 4: the shelves without middle support brackets.*

The thing is, I really wanted to use that middle rail and give the shelves extra support.

Back to the hardware store to purchase another (shorter) rail.

I brought the new rail home and cut it to the proper length of about 23”. Then, the old middle rail was removed. I fastened the new one to the wall and attached the shelf brackets.

It was now the moment of truth — take 2. I laid each of the two shelves across their respective shelf brackets. The taste of success was swelling in my mouth — no wobbling, everything level. Figure 5 shows the finished product.

*Figure 5: shelves, take 2. Notice the support bracket in the middle. You can’t see it, but the bottom shelf also has three supports.*

As you can see from figure 5, the bulletin board had to move to make room for the shelves.

Figure 6 below shows most of the set-up. There are still a few little odds and ends that need attention, but I’ll get there eventually. The most important parts are complete. Of course, this set-up is not cast in stone and may change. The electronics workbench should be a living, breathing organism that adapts to your needs.

*Figure 6: the complete work area set-up.*

There are a few additional details to note from the picture above.

The small whiteboard on the left comes in handy for quickly jotting down ideas and notes. Barely visible in the left bottom corner, we can see part of an old, long wooden dresser (next to the trash can behind the chair). This serves as extra storage.

Also note the book shelves. The one on the right contains all my engineering text books and other technical books. The other (with the plywood and parts bins on top) contains volumes of electronics related magazines I subscribe to. These serve as great references for both the theoretical and the practical. And they’re right at arm’s length if I need them.

On the left at the top we can see my EE degree next to a diploma from an electronics tech school I attended before college.

I used to keep these downstairs by my front door, so my customers would see them when they picked up their computers. This would position me as an authority. Since business has declined, I decided to move them upstairs by the bench. These and the other awards and certificates near the top are my badges of honor. When stuck on something, I often look at them for a quick jolt of inspiration and confidence.

Though not technically an “electronics” project in the sense there was no soldering, programming, or circuit design, planning and setting up my workbench was both fun and fulfilling. Now I just need to decide what my next build or hack is going to be to christen the re-born bench.

What project, hack, or build are you currently working on or recently completed? Comment and tell us about it!

The post Practical Electronics: Resurrecting My Electronics Workbench, Part 2 appeared first on Circuit Crush.

]]>The post Practical Electronics: Resurrecting My Electronics Workbench, Part 1 appeared first on Circuit Crush.

]]>Let me explain what I mean.

For those who don’t already know, I’ve been running my own computer repair and consulting business in my area since 2007.

To save money, cut overhead, and pass some savings onto my clients, I’ve always worked from home.

That being the case, my workbench had to change roles shortly after starting the business as I needed room to do repairs for my clients (it wasn’t unusual to have several desktop and laptop computers sitting on my bench at once).

First, it was a workbench for the business, second it was an electronics workbench.

As the business grew, I found myself shorter on time, so naturally the number of electronics projects started to dwindle as I spent more time on the business (and my other businesses, too).

But the past year or so business has been slow.

Don’t worry — this was expected. My focus shifted from my computer consulting business to another business that came my way in late 2011.

Of course, I kept getting calls for computer jobs for quite a while and continued to take them when they came. I simply just cannot resist an opportunity to fix a technical gadget, plus the extra money was nice.

Now the calls are only a few a month. I still take them, but decided to flip the script and make my bench an electronics workbench first, and use it for my business second.

This post covers the “resurrection” of my electronics workbench — the ideas, the trials, and even some errors.

If you’re new to electronics, this may help you get ideas for your own workspace and help you set it up.

If you’re not new, you may find that breathing some new life into your workspace can be helpful.

I’ve included pictures in an effort to visually document the process as I went along.

As often happens, this one grew into a nearly 3,000-word monster.

Originally, it was to be a single article. However, I wanted to fully document the whole process. So, rather than create one huge long post, I broke it into two smaller posts.

Also, this post isn’t like the others.

I don’t cover any sort of electrical theory or go into detail about a certain type of component.

Nor is it an “electronics” project in the sense that there was no soldering, wiring, circuit design, or programming.

However, for the enthusiast, proper workbench planning, design, and layout can be critical to your success. Therefore, the post fits right in with the mantra of this blog.

And breathing new life into my workspace was mega fun, so I wanted to share it.

Let’s get started!

The location of your electronics workbench will depend on several factors. One is how much space you have. Another is the type of projects you’ll be working on.

Whatever you pick, try to locate it in a relatively dry, quiet place free from wild temperature swings.

I have a house in which the second biggest bedroom is devoted to my businesses. There are two desks: one for clerical pencil pushing work, the other for computer repairs.

The room meets the above requirements.

I also have a basement with another workbench. This one sports a large vice and shares space with various power tools. If I need to cut or drill large pieces of wood, metal, or plastic for a project this is where I go.

You may have several choices for a location, or you may not.

If you’re 15 years old living with mom, your space will likely be your bedroom. If you’re lucky, you may be able to talk the parents into giving you some space in the basement, garage, or shed (if you own one). In that case, your bedroom can be the place you do the “light” work like design, soldering, etc. and the other spot can be for cutting and drilling.

Or, if you’re lucky enough to have a sufficiently large spot in the basement, you may be able to do all your work there.

Lucky for me, the room and the actual bench/work surface itself were already in place.

Now I had to put my thinking cap on and decide what I wanted and what would be appropriate for the room.

As alluded to before, I wouldn’t want to cut metal stock with my Sawzall for a combat robot in one of the bedrooms of my home.

The room would be reserved for design, simulation, soldering, light drilling and cutting, breadboarding, programming and the like. Any heavy-duty work would occur in the basement, if needed.

Below is a “before” picture of my bench and work area.

*Figure 1: “before” picture of my electronics work bench.*

* *

There are a few important things to note about it. First, on the far left are some bins for small parts sitting atop a short metal book shelf.

Second there is a desktop PC on the left (tower is under the desk on a wheeled carrier).

Third, the spare monitor next to the book shelf on the right is one I use for working on my clients’ desktop computers.

Fourth, there is an old-fashioned bulletin board above the desk with random crap on it.

And finally, the desk has 3 drawers: the 2 on the right and a shallow one in the middle between the keyboard and the other 2 drawers.

Also, you can’t see it in the picture, but there is a closet on the right which contains a metal cabinet with drawers. Several years ago, a Block Buster video store in my area went out of business and I snatched it up there for a small price.

The closet also has a shelf in it, along with a dead Robosapien V2.

Why is it dead?

A stupid manufacturing defect – the insulation on the wiring easily cracks off leading to all kinds of shorts. That’s a BAD design WowWee, and I was very sad when my Robosapien died (but too lazy to rewire the whole thing) so I thought I’d give you a shout-out.

Equally invisible in the picture (on the left) is an old, rather long wooden dresser which makes great storage space.

With my thinking cap atop my head, I went to work planning the design and layout of the bench.

First thing on my list was cleaning up that desktop PC and adding more RAM to boost speed for simulations, etc.

At the time, it had 6 GB of ECC RAM. Given the age of the PC and the fact that ECC RAM is not as common as the non-ECC type, adding more was harder than I thought it would be.

I went to eBay and found two 4 GB sticks for a decent price. They arrived in a small (and electrically unsafe) zip lock-type plastic bag.

Uh oh.

Upon powering the PC up after insertion, it was clear the memory was defective. The BIOS beeps screaming at me, the monitor blank. Don’t put static sensitive electronic components in a run-of-the-mill plastic bag. They make special bags for that.

Back to eBay where I was able to find two 2 GB sticks. Though not as much as the previous upgrade plan, this would still bring me up to 8 GB total RAM with 2 GB of RAM in each of the four slots. Packaged and shipped correctly, they arrived and worked when inserted into the PC.

Next on the list was to rearrange things and clean out some stuff I didn’t need any more.

With my end goal in mind, I went through all the drawers (including the metal cabinet in my closet), the desk drawers, the parts bins, and other areas disposing of old computer components and junk I was sure I didn’t need. Some things were moved to different locations in the house.

By doing this I was able to free up more space, therefore creating additional space for the important stuff, like spare parts, tools, cables for my scope and power supply, etc.

The next plan was to add some shelves above the desk. These would make a great home for my power supply, scope, and other odds and ends. To do this the bulletin board would have to move.

The small parts bins on top of the book shelf in figure 1 were always wobbly. Cramming various objects underneath them as shims to try to level them up gave a modest improvement, but still didn’t solve the problem completely. This is because the thin metal top of the shelf isn’t perfectly flat. It’s also a second-hand item which has taken its share of bumps and bruises.

A piece of left over ½” plywood in my basement (cut to the right size) would make a great topper for the shelf and stabilize things. This worked remarkably well and looks a lot cleaner.

Right now, MS Word is telling me I have almost 1500 words written, so I’m going to stop here. I’ll pick it up next post (promise!). There, I’ll delve into the meat of the series — my experience hanging the shelves and finally the finished workspace. And I’ll provide many more pictures to show the process as it evolved.

This should give you time to plan your workspace if you’re interested in creating one or changing your current set-up.

Stay tuned!

Until then, leave a comment and tell us where your workbench and workspace(s) are located.

**Update: part 2 is here!**

The post Practical Electronics: Resurrecting My Electronics Workbench, Part 1 appeared first on Circuit Crush.

]]>The post Breaking the Hex: Understanding Hexadecimal Numbers appeared first on Circuit Crush.

]]>In it, you’ll learn why binary numbers are used in digital systems. This will help you understand why hex numbers also often appear in digital systems. You’ll also get a quick review of the decimal system (and number systems in general). Finally, you’ll learn how to read binary, which will help you understand how to translate from binary to hex.

As I said before, if you’re new to digital electronics, it’s a must read.

And if you’re not so new it’s a good review.

Let’s break the hex and learn about hexadecimal numbers!

After binary numbers, hex numbers or base 16 numbers are the most important in digital applications.

The word hexadecimal comes from the Greek root *hex* – which means six, and the Latin root *deci* – meaning ten. Hence, the word hexadecimal refers to sixteen.

Hexadecimal numbers use a base 16 system which means that the positional multipliers in the hex system are powers of 16: 16^{0} = 1, 16^{1} = 16, 16^{2} = 256 and so on. This is just like the decimal system were all familiar with, only instead of powers of 10 we’re dealing with powers of 16.

The chart below will come in handy for figuring out various powers of 16. My, how quickly they grow!

Note that MSD stands for most significant digit and LSD stands for least significant digit. Sorry for the disappointment, LSD is not a drug — at least not in this post.

*Figure 1: various powers of 16.*

The first 9 digits in the hexadecimal system are the same digits 0-9 that you’re familiar with. However, the next 6 are represent by the first few letters of the alphabet: A, B, C, D, E, and F.

The first 16 digits on the hex system are given in the chart below along with their decimal and binary equivalents.

*Figure 2: hex numbers and their decimal and binary equivalents.*

If you’re not too familiar with the hexadecimal system, the use of letters to represent numbers may seem odd at first. Keep in mind though that any number system is only a set of sequential symbols. The form of the symbols is unimportant if you understand what they mean.

Remember also, that regardless of the number system, each digit must be represented by a single symbol.

If we were to use the symbols that make the number ten in decimal (rather than A) when writing numbers in hex, it would be hard to tell whether we were referring to 10 in decimal, or 10 in hex which equals 16 in decimal.

There is also perhaps an even more important reason for this, which we’ll disclose in the next section.

Right now, it may be easy to think something like *why bother with hex numbers? Base 16 is weird and seems complicated…*

Or maybe you’ve already figured out the virtues of using hexadecimal numbers. If not, you will in a minute.

The translation from hex to binary in figure 2 suggest a very important reason hex numbers are popular.

Hexadecimal numbers are ** way** more compact than binary and more compact than decimal numbers. Hex numbers pack more information into fewer digits.

Also, binary numbers are difficult to read and write because it is easy to drop or transpose a bit.

Because of this, hexadecimal is widely used in computer and microprocessor applications.

You’ve undoubtedly been faced with a blue screen on your computer after a crash. In addition, you’ll often see a cryptic message along with some hex numbers like 0xa56b170f.

The hex numbers refer to memory locations and data. If the PC was to spit it out in binary, the whole screen would be filled with 1’s and 0’s.

The prefix 0x tells us that the number is a hex number. The programming languages C and Java use this notation, but you may also see a hex number with the prefix 0h.

Almost all computer data sizes are multiples of 4. Since base 16 is a power of 2 (like 4), converting from binary to hex and vice versa is trivial, as we’ll see in a minute.

As usual, the easiest way to convert a binary number to a hex number or vice versa is to use a calculator. However, you should be able to do it almost as fast after reading this section.

You should know all the hexadecimal numbers from 0 to F (0 to 15).

Figure 2 shows us that for every possible 4-bit binary number, there is a hex equivalent.

To convert a binary number to a hex number, simply break the binary number into 4-bit groups, starting with the LSB (right-most bit). Then replace each 4-bit group with its hexadecimal equivalent.

As you move to the left, you may notice that you have less than 4 binary digits left in the last group.

No sweat. Just pad the last group with enough leading zeros to reach 4 bits, then convert to hex.

Let’s do a couple examples to illustrate this.

__Ex.1 __

Convert 1100101001010111 to hexadecimal.

**Solution:**

First, we break the binary number into groups of 4 bits:

1100 1010 0101 0111

Next, we simply find the hex equivalents of each of the groups of 4 binary digits, starting at the left:

1100 1010 0101 0111

** | | | |**

** C A 5 7**

1100 = 12 in decimal which is C in hex. Following a similar approach, we get A for the next group, 5 for the next and finally 7 for the last group.

Now we write CA57 or 0xCA57 so we know it’s a hex number. Wham, bam, thank you ma’am.

__Ex. 2__

Convert 11100010100110 to hex.

**Solution:**

Starting from the right (LSB), we break the binary number into groups of 4 bits:

11 1000 1010 0110

Since the group on the far left only has 2 digits, we pad it with 2 zeros:

0011 1000 1010 0110

Now, we take the hex equivalent of each of the 4 groups:

0011 1000 1010 0110

** | | | |**

** 3 8 A 6**

Now, we write 0x38A6.

Note that while it’s obvious that if a string of digits contains any of the letters A through F the string is a hex number, not all hex numbers will contain letters. Therefore, to avoid confusion, especially in this case, it’s a good idea to use the 0x prefix when writing or typing hex numbers.

The general algorithm for converting a binary number to a hexadecimal number is as follows:

- Group the digits of the binary number into sets of 4 digits (or bits). Add leading zeros to last group of 4 on left if necessary.
- Convert the binary numbers in each set of 4 into the equivalent hex digits.

The examples above suggest that this is also easy and trivial.

By simply doing the algorithm in reverse, we can convert a hexadecimal number to a binary number.

Let’s do a quick example.

__Ex. 3__

Convert 0xFF09 to binary.

**Solution:**

Starting at the far left, we write each hex digit in its equivalent binary format:

F = 1111, F = 1111, 0 = 0000, 9 = 1001

Stringing it all together, we get: 1111111100001001 or 1111 1111 0000 1001 if we break in up for easier reading.

The general algorithm for converting a binary number to a hexadecimal number is as follows:

- Write each hex digit as a 4-bit binary number
- Remember that 0 in hex is 0000 in binary!

Going from decimal to hex is a bit more complicated than going from binary to hex, but as we’ll see it’s similar to converting decimal to binary and not that hard to do.

There are two ways to convert decimal numbers to hexadecimal: sum of powers of 16 and repeated division by 16. Let’s talk about both.

Also called sum of weighted hex digits method, this method is good for simpler conversions (up to about 3 hex digits).

For example, let’s convert 35 to hexadecimal using this method.

Upon inspection, we note that 35 = 32 + 3

We also note that (2 x 16) = 32 and that (3 x 1) = 3.

So, we have 2 sixteens (or 2 sixteens raised to the first power) and 3 ones (or 3 sixteens raised to the zeroth power).

Therefore 32 in decimal = 0x23.

Remember that any number raised to the zeroth power is one.

The method above can become unwieldy for larger numbers.

Divide the decimal number by 16 and note the remainder. Be sure to write the remainder as a hexadecimal digit.

Repeat this process until the quotient is 0. The last remainder is the most significant digit of the hex number.

__Ex. 4__

Suppose we want to convert 31,581 to hexadecimal.

31,581 / 16 = 1973, remainder 13 (least significant digit, or LSD).

1,973 / 16 = 123, remainder 5

123 / 16 = 7, remainder 11

7 / 16 = 0, remainder 7 (most significant digit, or MSD)

Now we write all the remainders as hex digits: 13 = 0xD, 5 = 0x5, 11 = 0xB, 7 = 0x7

Listing them in proper order (MSD on far left; LSD on far right) gives us:

31,581 = 0x7B5D

One way to do this is to first convert the hex number into binary, then convert into decimal.

Another way to do this conversion is to multiply each digit by its power of 16 positional multiplier and add the products together.

The example below helps illustrate this.

__Ex. 5__

Convert 0x7C6 to decimal.

**Solution:**

First, we note each hex digit’s positional weight starting with the LSD: 6 has a weight of 16^{0}, C has a weight of 16^{1}, and 7 has a weight of 16^{2}.

Now we multiply each digit by its positional weight. We’ll start with the MSD:

7 x 16^{2} = 7 x 256 = 1792

C x 16^{1} = 12 x 16 = 192

6 x 16^{0} = 6 x 1 = 6

Next, we’ll add up our results: 1792 + 192+ 6 = 1990

So now we know how hexadecimal numbers relate to digital circuits and how to convert hex to binary and vice versa. We also know how to convert hexadecimal numbers to decimal numbers and the reverse.

Since hex numbers are quite common in the world of computers and electronics, I’m sure they’ll come up again.

Only now you’ll know how to deal with them. And as a bonus, next time you experience the blue screen of death, you’ll be able to translate those hex digits into the memory address(es) where the error(s) occurred.

Comment and tell us what you prefer working with: hex or binary?

Or you can comment and let me know what other topics you’d like to hear about.

Until next time,

Keep geekin’

The post Breaking the Hex: Understanding Hexadecimal Numbers appeared first on Circuit Crush.

]]>The post Another Powerful Post: A Primer on Electric Power Part 2 appeared first on Circuit Crush.

]]>If you missed it, please read it before you read this one. Here it is: One Powerful Post: A Primer on Electric Power Part 1.

Let’s kick things off by going over some electric power related terms and concepts dealing with reactive circuits.

For now, we won’t really differentiate between reactive circuits that are primarily inductive (RL), capacitive (RC) or both (RLC). We’ll delve into more detail on that stuff in another post.

Important terms are in **bold**.

If we apply the generalized electric power law

P = I x V (eq. 1)

to AC power, we can rewrite it as

p(t) = v(t)i(t) (eq. 2).

This is the **instantaneous power**, where t represents a particular point in time. In AC circuits, this usually involves some nasty looking trig with cosines all over the place due to AC power’s sinusoidal nature.

This quantity is difficult to measure, but the **average power** is a bit easier to measure. In fact, the wattmeter, (you guessed it — it measures power), responds to average power.

To get the average power, the instantaneous power is averaged over one cycle. The equation for average power is given below.

P_{avg} = ½ V_{p} I_{p} cos (ϴ_{v} – ϴ_{i}) (eq. 3).

The subscript p in equation 3 is the **peak value** of the sinusoid, which for a 120 V circuit is 170 V. The trig part is simply the cosine of the phase difference between the voltage and current. Reactive elements like inductors and capacitors cause this phase shift.

Another, even more useful measurement is the **RMS** value, or **root mean square**, also called the **effective value**. The RMS values of AC voltage and current are based upon equating the values of AC and DC power one would need to heat a resistor to the same temperature. In other words, a direct current whose values of I and V equal the RMS values of I and V for an alternating current will produce the same power.

The nice thing about RMS measurements is that they’re independent of time and frequency. The equation below is for 120 VAC circuits.

V_{RMS} = V_{p} x 0.707 (eq. 4).

Equation 4 gives us the RMS voltage where V_{p} is again the peak voltage. The formula for the RMS value of the current is similar – simply substitute peak voltage with peak current.

The actual formula for calculating the RMS value of other waveforms is kind of messy and involves calculus. We’ll save that for another post. Right now, you’ll have to trust me that equation 4 is right *if it’s a 120 VAC circuit*.

The formula for average power and power absorbed by a resistor can be rewritten in terms of the RMS voltage and currents.

P_{avg} = V_{rms}I_{rms} cos(ϴ_{v} – ϴ_{i}) (eq. 6)

P = I^{2}_{rms }R (eq. 7)

The **power factor** is the cosine of the phase difference between voltage and current. A lot can be said about power factor and power factor correction, but for now all we need are the basics. We can also regard the power factor as the ratio of the **real power** (resistive power) dissipated to the apparent power (more on that in a minute).

Purely resistive circuits have a power factor of 1, which is the best you can get. Purely reactive circuits have a power factor of 0. Most practical circuits fall somewhere between the two values.

Power factor can be **leading** or **lagging**. If it is leading, the current leads the voltage by some phase difference. If it’s lagging, the voltage leads the current by some phase difference. Power factor can affect your electric bill, so it’s important.

The real power is the only useful power and is the power the load actually dissipates. The **reactive power** (a.k.a. wattless power) is a measure of the energy exchanged between reactive elements and the load. The **VAR** (for volt-amp reactive) is the unit of measurement.

Purely reactive circuits dissipate no real power. They instead store energy either in a magnetic field or electric field and swap the energy back and forth with the rest of the circuit. Of course, in real life inductors have some resistance and capacitors aren’t perfect either.

The impedance these components show isn’t a real resistance and is instead a reactance. To calculate reactive power, we use a formula similar to equation 1 in that it is straight from Ohm’s Law and easy to apply.

P_{X} = I^{2} x X_{M} (eq. 8)

The subscript X in P_{X} means the power is reactive. The subscript M in X_{M} is either the capacitive reactance or inductive reactance and is measured in ohms just like resistance. The letter X itself is the reactance, be it capacitive or inductive.

The formula for calculating **inductive reactance** is given in equation 9.

X_{L} = 2πfL (eq. 9)

Where f is the frequency in Hertz and L is the inductance or value of the inductor in Henrys.

The formula for calculating **capacitive reactance** is given in equation 10.

X_{C} = 1/(2πfC) (eq. 10)

Where f is again the frequency and C is the capacitance or value of the capacitor in Farads.

The **apparent power** is so called because it seems apparent that the power should be the voltage-current product, as compared to a DC circuit. It is measured in **VA**s (**volt-amps**) and not watts (unless it’s purely resistive). It is the product of the RMS values of voltage and current.

Think of it as the power that appears to be supplied by the load. It includes both real power and reactive power.

An electronics newbie may think that apparent power is simply the sum of the real power and the reactive power.

This is not true. The problem lies in the fact that simple arithmetic on reactive variables can’t be done without considering phase.

If you’re an electrical engineer (or EE student) you take this into account using phasors and imaginary/complex numbers. For the average hobbyist, this can seem daunting and complicated.

Lucky for those who haven’t taken any engineering level circuit analysis classes, there is an easier way to get the apparent power.

To illustrate this, we can use a simple diagram known as the power triangle, which we can see in the figure below.

*Figure 1: the power triangle and how it relates to electric power
*

Understanding the following discussion and examples requires some (very) basic knowledge of trigonometry.

Using a right triangle, the relationship between real power (watts), reactive power (VARs), and apparent power (VAs) can be more easily understood.

You probably already know that in any right triangle the hypotenuse (apparent power in the above figure) is always the longest side. Here we can graphically see that the apparent power is greater than either the real power or reactive power and is the total power used by the circuit.

The cosine of 0 is 1; if we make the power factor angle small (ideally 0), then the triangle collapses on itself and the real power equals the apparent power. This gives us a power factor of 1 and is an ideal situation that only occurs in DC and purely resistive AC circuits.

Looking at the triangle, it is easy to see the amount of reactive power the circuit uses is what determines its efficiency. The more reactive power the greater the power factor angle, which lowers the power factor.

But is reactive power really all a big waste?

Sure, ideally, we should try to keep it to a minimum (especially if we pay for it!) but it turns out we need it. For example, inductive reactive power in electric motors forms the magnetic fields to spin the rotor. Without it the motor would not work.

For most households, employing power factor correction (we’ll talk more about this in a future post) might be a waste and too expensive to justify.

But, for large commercial and industrial facilities who pay tens of thousands per month for electricity, a significant savings can be realized.

Imagine figure 1 sitting in a Cartesian (X-Y) coordinate system with the left point of the triangle sitting at the origin. The real power runs along the x-axis, and the reactive power follows the y-axis. Figure 2 illustrates this.

*Figure 2: the power triangle in Cartesian coordinates.*

One important thing to note is that if the hypotenuse lies in the first quadrant of the coordinate system, the load is inductive with a lagging power factor.

If we were to flip the triangle along the x-axis so the hypotenuse now lies fourth quadrant, the load is capacitive with a leading power factor.

Believe it or not, it is possible for the hypotenuse to also lie in the second or third quadrant. This means that the load impedance has a negative resistance, which is possible in some circuits.

The power triangle is nice because it gives us a more intuitive understanding of electric power, but how do we actually calculate the different types of electric power?

You may have heard of the Pythagorean theorem. Using that and/or some simple trigonometry, we can easily calculate any value if we know any other two values.

The Pythagorean theorem states that in any right triangle:

A^{2} + B^{2} = C^{2} (eq. 11)

Where C is the hypotenuse or long side of the triangle and A and B are the other sides.

Using simple algebra, we can take the square root of both sides which gives us:

C = √A^{2} + B^{2} (eq. 12)

Note that the square root sign covers the whole right side of the equation.

To put it another way:

VA = √P^{2} + VAR^{2} (eq. 13)

Where VA is the apparent power, P is the real power, and VAR is the reactive power.

Here we don’t have to worry about phase angles – the Pythagorean theorem takes care of that for us.

From simple trigonometry, we can also note that:

cos (ϴ) = A/H (eq. 14)

where ϴ is the power factor angle, A the side adjacent to it (the bottom of the triangle in figures 1 and 2), and H is the hypotenuse.

If we re-write this using power as the variables we get:

cos (ϴ) = real power / apparent power

or

cos (ϴ) = P/VA (eq. 15)

This means that if we know the power factor or the power factor angle, we can get any of the three powers (sides of the triangle) as long as we know one of the sides.

Let’s do a few easy examples to illustrate the information given above.

__Ex 1:__

We know our circuit consumes 10 W or real power and 3 VAR of reactive power. How much apparent power does our contraption suck down?

Solution:

From the Pythagorean theorem we get equation 12 and use it here.

VA = √10^{2} + 3^{2 }= √100 + 9 = √109

Apparent power = 10.44 VA

__Ex 2:__

My circuit consumes 5 W of real power, but the apparent power is found to be 6.3 VA. How much reactive power does my creation use?

Solution:

Here we know the reactive power and the real power. All we need to do is algebraically rearrange equation 12 a bit to obtain:

VAR = √VA^{2} – P^{2} or VAR = √6.3^{2} – 5^{2}

Which gives us VAR = √39.69 – 25 = √14.69

Giving us a VAR of about 3.83.

__Ex 3: __

A circuit has a power factor of 0.85 and draws 3 W of real power. How much apparent power does this thing consume?

Solution:

We know that power factor = cos (ϴ) and that the cosine is the adjacent side of the triangle over the hypotenuse. Using this information, we can write:

0.85 = 3 W / some amount of VAs

Rearranging algebraically, we can write:

0.85 x (some amount of VAs) = 3 W

Dividing both sides by 0.85, we see that the apparent power is equal to roughly 3.53 VA.

Note that if we want the phase angle for some reason, we can simply grab a calculator and take the inverse cosine of 0.85, which gives us about 31.79⁰. This means the voltage and current are 31.79⁰ out of phase with each other.

By now we have a reasonable understanding of the difference between power and energy, purely resistive power, and calculating power in AC circuits, both resistive and reactive.

If some of the terms used in this post are unfamiliar, don’t worry. You should still be able to make power calculations using the information presented here.

In another post, we’ll delve into more detail about things we didn’t quite have room for in the two posts.

Things like the concept of impedance are important to understand, but right now you should be able to easily calculate the power your toaster uses or the power rating of the resistor needed in many of your circuits.

We’ll also take a closer look at power (and impedance) in RL, RC, and RLC circuits, since we now know that most AC circuits are not purely resistive.

Until then, drop us a comment and share any tips you have on saving power or choosing components for your circuits with the correct power rating.

*Like this post? You’ll love the electronics Facebook Group. Request to join today!*

The post Another Powerful Post: A Primer on Electric Power Part 2 appeared first on Circuit Crush.

]]>The post One Powerful Post: A Primer on Electric Power Part 1 appeared first on Circuit Crush.

]]>Understanding electric power and the associated concepts is a very important part of circuit design. If a component tries to dissipate too much power, the magic smoke comes out. We’ve all had this happen at one time or another.

At first, I was going to make this one post. It soon grew into a monster as I went on to explain all (ok, some) of the concepts surrounding electric power.

Electric power includes concepts like real power, apparent power, power factor and more.

The first part of this series will start by tackling one of the most confusing, yet fundamental aspects of it – power vs energy. Then, we’ll take a look at power in DC circuits and purely resistive AC circuits. After that, the series will delve into power in circuits that contain reactive components like inductors and capacitors.

If knowledge is power, then knowledge of power is power squared!

This concept is one that seems to confuse a lot of people. The terms power and energy are often used interchangeably, as if they’re the exact same thing, but there is a difference.

Power is the rate at which work is performed. Its unit is the watt, for which joules per second is the measurement. Joules are the unit of measure for energy.

The total energy in any process neither increases or decreases during that process (conservation of energy), it just transforms from one form to another.

So, if I slide a book across the table, I’m not making any “new” energy or destroying it. The kinetic energy of the moving book transforms into thermal energy due to friction, making the book and table slightly warmer.

The amount of energy transformed from one form to another is known as work.

Here’s an intuitive example that illustrates the difference between power and energy:

Suppose 2 people, each weighing the same, circle a track. One person takes their time and walks around the track in 3 minutes, while the other person sprints and circles it in 40 seconds.

Both people use the same amount of energy since they did same amount of work. However, the runner used his energy in a shorter amount of time while the walker spaced it out. Although both used the same amount of energy, the runner used more power since his energy was used up quicker.

Whether we talk about the motor in your car, an electric motor, the runner, or your latest electronic project, the output power is measured in watts, which describes the number of joules of energy used every second.

You may be thinking something like *but* *the motor in my car is rated in horsepower*. That’s right, but 1 horsepower is equal to 746 watts — the base unit is still watts.

For our purpose, we’re going to worry about electric power. Therefore, power, in connection to electronics, is the rate at which electric energy converts into some other form.

Because of this, the formula for power given below holds true.

P = W/t (eq. 1)

Where W is energy in joules, and t is time.

Energy can be given by equation 2 below:

W = Q x V (eq. 2)

Where Q is coulombs of charge and V is voltage (if you want to know more about coulombs, check out the post on batteries).

Substituting the formula for energy (eq. 2) into the formula for power (eq. 1) gives:

P = (Q x V)/t (eq. 3)

Since coulombs of charge Q equals the amount of current times time t, we get, by substituting I x t into eq. 3, the final and familiar equation for power below.

P = I x V (eq. 4)

Where I is current and V is voltage.

Don’t let all the substitution and simple equations above scare you. If you work through it, you’ll see that’s it’s pretty intuitive and easy.

Some books refer to equation 4 as the generalized power law. It is general in the sense that it tells us how much power a circuit uses, but does not tell us how the circuit uses it.

Regardless of what you call it, equation 4 is part of Ohm’s Law and is useful for determining power, current and/or voltage (depending on which ones you already know) in DC circuits and purely resistive AC circuits.

As an example, suppose your flashlight uses 2 D cell batteries, each at 1.5 V. The total voltage is obviously 3 V. Let’s assume the circuit draws 0.2 A of current. How much power does the flashlight consume?

To answer this, we simply multiply the voltage by the current:

3 x 0.2 = 0.6 W or 600 mW.

What if we knew the power and voltage of the flashlight but not the current?

Simply divide the power by the voltage:

0.6/3 = 0.2 A or 200 mA.

Piece of cake.

The same holds true for purely resistive AC circuits. Let’s say your toaster is purely resistive and runs off 120 V from your wall.

The label on the toaster tells us that it draws 1,000 W of power. How much current does it draw?

To answer this, we do as we did before and divide power by voltage:

1,000/120 = 8.33 A.

Easy peasy.

Unfortunately, in the real world, few AC circuits are purely resistive. This complicates things a bit.

So now we know that most AC circuits aren’t purely resistive. Now what?

Things like inductors and capacitors add a reactive component to the total power.

Think you can avoid this just because your appliance or widget doesn’t contain any inductors or capacitors?

Wrong.

The heating element in your hair dryer might be mostly resistive, but if it’s a coil there will also be some parasitic inductance. Then there’s the blower motor on that hair dryer which is made up of – you guessed it — coils of wire.

Electric motors in general cause a lot of unwanted inductance. This includes the compressor in your refrigerator, the motors in your washer and dryer, your blender – you get the idea.

And we didn’t even mention parasitic capacitance yet. All we need for that is two or more wires that are close enough together.

Imagine two wires inside some appliance right next to each other. There’s the conductor on one wire with its insulation, the insulation on the second wire, then the conductor in the second wire. That’s two conductors separated by an insulator (or dielectric) which makes a capacitor.

The figure below is an example to help illustrate this.

*Figure 1: though usually smaller, there are junction boxes like this all over your house. They lurk behind your plugs, switches, light fixtures and other locations.*

It’s not uncommon to open a junction box in your home, an appliance, or even the project you just finished building and see a mess of wires like figure 1. It’s safe to say that this scenario introduces both stray capacitance and inductance.

Once upon a time I was an electrician’s apprentice and was working on wiring a garbage disposal in a new hotel. The disposal had a small junction box where the AC wiring joins the wiring in the unit. Even though the breaker was off, I got a nice spark when I stuck my screw driver in this junction box. Stuffing all the wires into the box created a capacitive effect. I somehow shorted the “capacitor” out with my screw driver.

For the discussion that follows in the rest of the series, I’m going to make several assumptions. First, you’ve heard of capacitive reactance and inductive reactance and have at least some idea what they mean. Next, you’re at least somewhat familiar with the concept of impedance.

Explaining all these concepts would take several posts, so if you’re not sure about some of these things keep checking back. They’ll appear on the blog sooner or later.

By now you should know the difference between power and energy and how to calculate power in DC and purely resistive AC circuits.

You also know that most AC circuits aren’t purely restive and suspect that this can complicate things.

It does a bit, but it’s nothing that’s too difficult to wrap your mind around.

In the next part of this series, we’ll start by going over some common terms associated with electric power.

Then, we’ll go over a helpful little friend that resembles a simple geometric shape that we’re all familiar with and how he can help us.

After that, we’ll delve into calculating electric power in AC circuits that sport a phenomenon known as reactance.

Stay tuned!

Meanwhile, comment and tell us what your biggest questions about power are and maybe I’ll answer them in this series!

The post One Powerful Post: A Primer on Electric Power Part 1 appeared first on Circuit Crush.

]]>The post Test Your Electronics Knowledge With This Quiz appeared first on Circuit Crush.

]]>This post isn’t a post in the sense that it’s a tutorial on a certain topic.

This post is a short electronics quiz to assess your knowledge, maybe learn something along the way, and most of all, have some fun.

The questions in this set aren’t engineering level questions (in other words, they’re not terribly difficult) but some of them may be a little challenging depending on your knowledge and experience.

Don’t worry if this particular quiz didn’t contain a question about a certain topic. There are a myriad of questions one can ask concerning electronics, programming, circuit design, and much more. Rather, keep visiting the blog or subscribe via RSS as I’ll be posting more quizzes like this in the future.

First, you’ll see the questions.

After the last question, I’ll post the answers to each question with an explanation (or I’ll work the problem out, if appropriate).

No peeking!

Now let’s test your electrical knowledge…

1) Imagine an infinite grid of 1 Ohm resistors connected together (like the one in the picture below). If you were able to measure the total resistance of this grid, what would it be?

2) True or false: it takes more heat to melt lead-free solder than regular solder.

3) What is the difference between a primary and a secondary battery?

4) Name this component:

5) What is the value of the resistor below?

6) Five amps flow through a 10 Ohm resistor. How much power is dissipated by the resistor?

7) Your hair dryer draws 500 W of power. The electric company is charging you 11 cents per kilowatt-hour. You use the hair dryer for half an hour. How much did that dry head of hair cost you?

8) How many time constants does it take to charge/discharge a capacitor?

9) The sum of currents entering a node (or point in a circuit) is equal to the sum leaving the node. This is referred to as ___________________________.

10) Find V_{x} in the circuit below.

Space below left intentionally, scroll down for answers.

*

*

*

*

*

*

*

**1) Answer: 0.**

This is because the resistors are connected in parallel. We know that in any group of resistors connected in parallel, the total resistance is always less than the lowest resistance in the group. Since there is an infinite amount of one Ohm resistors in parallel, the total goes to zero.

**2) Answer: true.**

**3) Answer: primary batteries cannot be recharged.**

I wrote two posts on batteries, one covering primary batteries and another about secondary (rechargeable) batteries.

**4) Answer: photoresistor (a.k.a. photocell, light dependent resistor)**

Photoresistors vary their resistance according to the amount of light that hits them.

**5) Answer: 572 Ohms, 2% tolerance.**

It’s a 5 band resistor with bands colored (left to right) green, violet, red, black, red. The first three bands give the first three digits of the resistor’s value. The fourth (black) is the multiplier and is 0 in this case, so we’re not going to tack on any zeros to our answer of 572 Ohms. The last band is the tolerance which, in this case, is 2%. Check out my post on resistor color code if you need help with this.

**6) Answer: 250 W.**

Ohm’s Law is back to haunt us again. The easiest way to answer this problem is to remember that P = I^{2}R. So, we have 5^{2} x 10 = 250 W. Make sure you use a power resistor if you build a circuit like this!

**7) Answer: 2.75 cents.**

Power companies charge by the kilowatt-hour, so we need to convert watts into kilowatts first. 500 W is equal to 0.5 kW. Since we’re only using the device for half an hour, we need to multiply 0.5 kW by 0.5 hours, then multiply by our cost of 0.11 (11 cents):

0.5 x 0.5 x 0.11 = $0.0275 or 2.75 cents.

**8) Answer: 5.**

The exact reason for this involves differential equations and is somewhat complicated. Maybe I’ll tackle it (and try to simplify it) in a future post. For now just take my word for it

**9) Answer: Kirchhoff’s Current Law (a.k.a. KCL).**

KCL is one of the basic tools for analyzing circuits.

**10) Answer: 95 V.**

This was probably the hardest question here. Using another one of Kirchhoff’s laws (KVL or Kirchhoff’s Voltage Law) to solve for V_{x}, we can write the following equation:

20 + 15(5) – V_{x} = 0

Solving algebraically for V_{x}, we get V_{x} = 95 V.

I’ve booked Mr. Kirchhoff and his laws to make a future appearance on the blog

Since there are only ten questions, I decided to use a different grading scale than the one you’re familiar with from school.

You remember that one. If you scored a 90% or better you got an A. Less than 60% and you failed. And getting a D wasn’t considered great, even though it was a passing grade. That would mean you could only miss three questions and still get a decent score. For some of you, that may be child’s play, for others, maybe not.

Here’s the breakdown I decided to use:

- 1-4 correct: Beginner
- 5-7 correct: Intermediate
- 8-10 correct: uber-geek

Now I just have a few more questions for you…

How did you like this? Were the questions too easy? Were they too hard? Should I have 15 questions instead of 10?

Let me know your thoughts in the comments below.

*Like this post? You’ll love the Facebook group. You’ll also love our bi-monthly newsletter & free gift (see below).*

The post Test Your Electronics Knowledge With This Quiz appeared first on Circuit Crush.

]]>The post Types of Capacitors: Pros, Cons, & Applications appeared first on Circuit Crush.

]]>A while ago, I published a post about several common resistor types you’re likely to run into.

This post will be similar in that we’ll take a quick look at the common types of capacitors. Topics like the theory behind capacitors or deciphering their markings will appear in future posts.

The post will give a quick over-view of some of the applications for each type of capacitor, but will not go into great detail about the applications (again, this type of info will appear in future posts).

It will also give the reader an idea of the various common capacitors out there, their strengths and weaknesses, and a quick look at their applications. More exotic capacitor types (such as ultracapacitors and supercapacitors) or rare types will probably pop up in a future article.

This should enable one who’s not totally familiar with the various types of capacitors and their uses to hopefully pick the right one for their application.

Also, I suggest bookmarking this post (and the resistor one) as it will serve as a quick reference for the future.

After all, unless you work for a capacitor manufacturer or have a memory like a steel trap, you may find yourself asking questions like …*which capacitor has the tolerance I need?* Or *what’s the voltage range of this type of capacitor?*

And trust me; you WILL need to use capacitors in your circuits and creations.

Enough said, let’s dive right into the different types of capacitors.

Like resistors, capacitors come in two basic flavors: fixed and variable.

Both operate on the same basic principles.

A **fixed capacitor** is just like it sounds – its value is fixed and cannot be changed.

Of course, the capacitance of a **variable capacitor** *can* be changed.

The type of dielectric (insulating material between the plates) used in the capacitor classifies it.

For variable caps, we have air, mica, ceramic, and plastic.

Fixed value capacitors come in mica, ceramic, plastic, metal film, electrolytic, and more types.

Let’s start by taking a look at two interesting variable capacitors.

If you’re into working on old radios and other older equipment, you’ve likely run into variable capacitors that use air as the dielectric. These are also known as **air core capacitors**.

These work by keeping one set of plates fixed while the other set connects to a rotating shaft. Rotating the shaft varies the effective area of the plates, thus changing the capacitance. The plates are usually made of aluminum to prevent corrosion. Figure 1 shows this type of capacitor.

*Figure 1: old style variable capacitor.*

On top, we see the real deal, an actual picture of a variable air core capacitor. The bottom shows a somewhat simplified diagram of how the device works.

These capacitors are very stable over a wide range of temperatures and leakage losses are low. The downside is that they’re big and bulky. Other types of capacitors can achieve the same capacitance in a much smaller package (though they may not be as stable).

Unfortunately, these types of capacitors are showing up less and less these days due to newer technology and the ever increasing demand to shrink electronics. If you come across one, be sure to grab it, even if just for nostalgia’s sake.

The second common type of variable capacitor often finds its home on circuit boards and is the **trimmer capacitor**.

These usually adjust via a small screw which varies the distance between the plates. They’re good for fine-tuning circuits. Use only a non-metallic tool to adjust these types of capacitors because a metal tool can affect the capacitance making it very difficult to get the right value.

Figure 2 sports a picture of a typical trimmer cap. Note that these capacitors can use several different dielectrics, depending on the application. We’ll go into more detail on specific types of dielectrics when we discuss fixed capacitors.

*Figure2: typical PCB trimmer capacitor.*

On top, we can see what it looks like. Note that they are usually smaller than it appears in the picture. The bottom gives you a good idea on how the trimmer works.

Trimmer capacitors usually have values in the picofarad range.

Mica capacitors are composed of thin foil plates (usually aluminum or silver) that are alternately stacked to form the two plates of the cap. A thin layer of mica isolates the plates from each other. The whole shebang is sealed inside a protective casing.

The figure below depicts some typical silver mica capacitors.

These caps are very stable and have a good temperature coefficient. The cons are that they usually don’t come in high capacitance values and can be more costly than other types (silver is expensive, ya know).

You’ll find them in high frequency filters, resonance circuits, and even high voltage circuits. They have good insulation, and therefore are able to operate at higher voltages.

Capacitance values range from 1 ρF to about 0.1 µF.

Voltage ratings range from 50 V to 500 V.

*Figure 3: silver mica capacitors.*

These types of capacitors come in two main varieties: single layer and multilayer.

Ceramic caps (along with electrolytic caps) are the most widely available and popular capacitors.

You might be familiar with the small, round, disc-like capacitors found on many PCBs. These are **single layer ceramic capacitors** which consist of two plates with a ceramic dielectric in between.

They sport low inductance, so they can find use in high frequency applications.

Using different types of ceramics varies the dielectric constant resulting in several different types of ceramic capacitors.

Therefore, they also have varieties (ultrastable or temperature compensating) that are very stable across a range of temperatures. These can last many years.

The semistable single layer ceramic cap isn’t as temperature stable as the above, but it does have a higher capacitance.

Finally, the HiK ceramic capacitor has a high dielectric constant (and capacitance), but lacks stability and suffers from a phenomenon known as dielectric absorption.

Single layer ceramic caps have a capacitance range of 1 ρF to 0.1 µF.

Voltage ratings range from 50 V to 10,000 V.

Figure 4 shows a typical single layer ceramic capacitor.

*Figure 4: single layer ceramic capacitors.*

Like mica caps, many ceramic capacitors consist of several alternating layers of ceramic and metal plates. These are the **multilayer ceramic capacitors**.

They meet the demand for high density ceramic caps, and, like the mica caps, have many layers to boost the total capacitance.

They are also compact and have better temperature characteristics than the single layer variety.

Just like the single layer type of capacitor, they come in ultrastable, stable, and HiK varieties.

Their capacitance ranges from 0.25 ρF to 22 µF depending on the type.

Voltage ratings range from 25 V to 200 V, again depending on the type.

Many surface mount capacitors are multilayer, as we can see in figure 5.

*Figure 5: an example of multilayer ceramic capacitors.*

There are two main types of electrolytic capacitors: aluminum and tantalum.

**Aluminum electrolytics** have a chemical paste (the electrolyte) filling the space between their foil plates. When voltage is applied, a chemical reaction forms a layer of insulating material on the positive plate. Because this film is very thin, they can pack a good amount of capacitance in a small package.

The film and the plates are then rolled into a cylindrical shape before being placed in a protective case.

The chemical reaction also gives these capacitors a polarity that should be carefully observed. They can explode if the rated voltage is exceeded or the polarity is reversed, therefore do not connect an AC source to an electrolytic cap.

Don’t try this at home, but if you hook an aluminum electrolytic cap to a 120 VAC source, it will explode. Of course, if you do this and injure yourself I take no responsibility.

Both aluminum and tantalum electrolytic capacitors will be marked with either a “+” or a “-“ to indicate which plate is which.

These capacitors are popular due to their low cost and ability to provide a relatively high capacitance in a small package.

Aluminum electrolytics also leak badly, have bad tolerances, and have a high inductance. Because of this, they are good for low frequency applications and not so good for high frequency ones.

They should also not be used if the DC potential is well below the capacitor’s rated voltage.

These capacitors also have a limited life, even if they’re just sitting in your parts bin. When grabbing one that’s more than a few years old, be sure to check to see if it’s still in spec.

Typical values range from 0.1 µF to 500,000 µF or more.

Applications include power supply ripple filters, audio coupling, and bypassing.

A typical aluminum electrolytic capacitor appears in figure 6.

*Figure 6: an aluminum electrolytic capacitor. Notice the stripe on the side that marks the negative plate.*

**Tantalum electrolytic capacitors** are made with tantalum pentoxide and are polarized like their aluminum cousins.

They’re also smaller and more stable. They leak less and have less inductance than aluminum electrolytics. They sport a longer lifespan. The downside is that they’re more expensive and have a lower maximum voltage and capacitance.

Like aluminum electrolytics, tantalum caps can explode and/or burst into flames if the polarity reverses.

They often take up residence in analog signal systems that lack high current spike noise (spikes can damage them). Other applications include blocking, bypassing, decoupling, and filtering.

Tantalum caps are not good for high frequency applications. Like the aluminum versions, they should not be used if the DC potential is far below the rated voltage.

Figure 7 depicts a tantalum capacitor. Notice that they look different than the aluminum versions.

*Figure 7: a tantalum capacitor. Notice the + sign which marks the positive lead.*

These types of capacitors have replaced paper capacitors, which we will not discuss since they’re obsolete.

There are a few varieties of plastic film caps that are common, including polyester film and polypropylene film.

**Polyester film capacitors **(a.k.a. Mylar capacitors) use a thin polyester film as their dielectric (as any logical person may guess). Their tolerance (typically 5-10 percent) is not as good as polypropylene capacitors but they have good temperature stability and are cheap.

Polyester film caps are good for coupling and storage purposes. They often find use in audio and oscillator circuits and moderately high frequency circuits.

Capacitance values range from 0.001 µF to 10 µF.

Voltage ratings range from 50 V to 600 V.

*Figure 8: a typical polyester film (Mylar) capacitor.*

**Polypropylene film capacitors **have a higher tolerance than polyester film caps, so use them in place of polyester for applications that require a tighter tolerance.

Like polyester, they’re good for coupling and storage purposes, but also come in handy for noise suppression, blocking, bypassing, filtering, and timing.

Capacitance values range from 0.001 µF to about 0.47 µF.

Voltage ratings range from 100 V to 600 V.

*Figure 9: a polypropylene film capacitor. Notice the similarity in appearance to the polyester film version.*

**Polystyrene capacitors **aren’t film capacitors, but I lumped them here anyway.

These have a high inductance so they’re not good for high frequency applications. Exposure to temperatures above 160⁰ F (about 70⁰ C) will permanently damage them. Polystyrene is similar to Styrofoam (there is a slight difference; Styrofoam is a brand name, hence the capitalization), and Styrofoam melts. So does polystyrene.

Due to the high inductance, they are good for filtering and timing circuits running at a few hundred kilohertz or less. They’re also cheap with good stability.

Capacitance values range from 100 ρF to 0.027 µF.

Voltage ratings range from 30 V to 600 V.

*Figure 10: various polystyrene capacitors.*

Like the plastic film variety, these also come in both polyester and polypropylene. Since they both exhibit similar traits, we’re not going to treat them separately as we did with the plastic film caps.

Metalized film capacitors are made by using a vacuum deposition process that laminates a film substrate with an extremely thin (literally several atoms thick) aluminum coating.

They take up residence in circuits that use small signal levels (think low current and high impedance) where small physical size is a priority.

They’re not good for large signal AC applications.

One unique trait they possess is their self-healing ability. While shorts permanently destroy other capacitor types, these caps can heal themselves. Metalized film capacitors are also temperature stable with low drift.

You’ll find them in switching power supplies, audio circuits where sound quality is important, noise suppression circuit, snubbers and more.

Capacitance values range from 47 ρF to 22 µF, depending on the type.

Voltage ratings range from 63 V to 1250 V, again depending on the type.

*Figure 11: various metalized film capacitors. I’m not sure what the dots on the side are for, but notice that they can look similar to their plastic film relatives.*

Now we know something about the most common types of capacitors and what they’re good for and not good for.

Don’t forget to bookmark this post. It’ll come in handy.

Below is a nifty little chart that summarizes some of the characteristics of some of the capacitors we talked about.

We didn’t discuss it, but ESR stands for equivalent series resistance. ESR is a measure of the capacitor’s internal resistance and in series with it. Maybe ESR and other capacitor specs we didn’t discuss here will make an appearance in another article.

*Figure 12: a quick run-down of several common capacitor types.*

Until next time, comment and tell us: what types of capacitors do you use the most? Also, why do you pick that particular type?

*References:*

- Cook, Nigel P.
*Introductory DC/AC Electronics, 4th Ed.*Prentice Hall, 1999. Print. - Scherz, Paul & Monk, Simon.
*Practical Electronics for Inventors, 4th Ed.*McGraw Hill, 2016. Print. - Byers, TJ. “Bypass Caps Demystified [the chart].”
*Nuts and Volts*January 2007: 18-19. Print.

The post Types of Capacitors: Pros, Cons, & Applications appeared first on Circuit Crush.

]]>The post AC vs DC: What’s the Difference? appeared first on Circuit Crush.

]]>No, we’re not talking about a hard rock band, we’re talking AC vs DC with regards to electricity.

Some of you may already know this. Even if you’ve been dabbling in electronics for a while and think you have this figured out, I highly recommend reading this whole post as there are some things that may surprise you.

One of the easiest ways to explain the differences between AC vs DC is to treat each one separately and delve into some details about each.

Toward that end, we’ll start with DC first because it’s a bit simpler to explain and most of your creations will use it.

Electric current (or a voltage, as voltage and current are proportional) can be classified as direct current (DC) or alternating current (AC).

Direct current flows in one direction only, while alternating current changes direction periodically.

In the land of electricity, another word for direction is polarity.

But what do we really mean by this?

If we were to plot the voltage of an ideal battery versus time, we’d have a flat line, as you probably already know. With a given DC source, this line can either lie on the positive end of the y-axis or the negative end, but not both.

To see what I mean, take a gander at the simple pictures below.

*Figure 1: positive and negative DC voltages*

The red horizontal lines represent a DC voltage. On the left, we see a positive DC voltage (it could also represent a current if we labeled the y-axis current instead of voltage).

Notice how the line lies above the x-axis (which represents time) and how it will never dip below the x-axis — if we assume a steady-state voltage – even if we drag the x-axis out to infinity.

However, part (*b*) of the figure shows the voltage lying below the x-axis, which makes it a negative DC voltage.

In both parts, the line either dwells above or below the x-axis, but never actually crosses the x-axis, even if we watch this very exciting “waveform” for an infinite amount of time.

To most of us, it’s plainly obvious that a flat horizontal line on a graph represents a DC voltage.

But what about the figure below? Is this AC or is it DC?

*Figure 2: AC vs DC: is it AC or DC?*

* *

If you said DC, you’re right.

Even though this graph does not depict a flat horizontal line, it does not go negative at any point (assuming it remains steady-state and periodic).

Figure 2 depicts what’s known as pulsating DC.

Pulsating DC varies periodically from some minimal voltage (zero in this case) to some maximum voltage, back to minimum and then repeats.

By periodic, we mean that the waveform repeats itself at regular, predictable intervals. I’ll spare you the mathematical definition of periodic.

Remember, pulsating DC does *not* vary from a positive to a negative voltage or vice versa. It stays either positive or negative along the whole x-axis, regardless of the amplitude or wave shape.

This type of voltage/current occurs at the output of certain battery chargers and also at the output of a full-wave bridge rectifier which is part of a circuit that converts AC into DC.

Remember, whether pulsating or steady (like the flat line) direct current is current that flows in only one direction. Figure 3 below shows this concept in a simple circuit.

*Figure 3: a simple circuit*

Using electron flow (for more about electron flow vs conventional current flow see the post), current would flow from the negative terminal of the battery through the resistance to the positive terminal.

This direction does not change unless we change the polarity of the source. If we reverse the polarity of the battery by flipping it around (negative end now on top), current flows the opposite direction of the arrow.

Either way, the current (and voltage) is DC because it will never alternate directions back and forth.

Alternating current, or AC, is electric current first in one direction for a period of time and then in the reverse direction for a period of time.

Direct current can only change in magnitude, but alternating current can change in both magnitude and polarity.

Most of us are familiar with the AC power supplied to our homes.

Some of us may be familiar with the alternator in our vehicle that produces power. An alternator produces AC power (hence the name) before it is rectified and put to use to charge the battery and power the vehicle’s accessories.

The power at the receptacle in your home as well as the power created by the alternator in your vehicle (before rectification) comes in the form of a sine wave.

Sine is short for sinusoidal which, as we can see from a graph of the mathematical/trigonometric sine function, describes the shape of the wave.

The figure below depicts a typical sine wave you’d find at the receptacle in your home.

*Figure 4: a typical AC sine wave*

The AC power in your home is sinusoidal in nature because it is generated by rotating conductors in a magnetic field. If we take one cycle of the sine wave above and fold the negative half over to the left, we see that the resulting shape is somewhat circular in nature.

By cycle, we mean one alternation from zero, up to some maximum positive value, back to zero where it crosses the x-axis, then down to some minimum negative, then back to zero again where the cycle ends.

In figure 4, there is a small “x” where the first cycle ends and the second cycle begins.

Since we are rotating something in a circular motion (with a generator) to produce AC power, it should be no surprise that the sine wave is shaped the way it is. And, since there are 360 degrees in a circle, each cycle of the sine wave also goes through 360 degrees.

We know that alternating current gets its name because it alternates from positive to negative, but what does that really mean?

During one half-cycle electrons flow in one direction. Then, they switch and flow the opposite direction during the other half-cycle.

Figure 5 from Introductory DC/AC Electronics illustrates this.

*Figure 5: how alternating current moves*

In part (b) of the figure, we can see a typical sine wave. Part (C) shows how electrons move during the positive alteration and part (d) shows how they move during the negative alteration.

So, electrons in an AC circuit will move back and forth about a fixed point.

To clarify, consider the simple circuit in figure 3, only there is an AC source there instead of a battery.

Now, imaging that you’re very small and can “sit” in the middle of the resistor and see electrons flowing by.

For one instant, they pass you in one direction, in another instant, the opposite direction.

In fact, if you counted the number of electrons that slip by you during each alteration, you’d see that not only is it the same number each direction, but if you could tell each individual one apart from others, the same electrons would keep passing you — first in one direction, then the other.

Still want more clarification? This fantastic video from Khurram Tanvir should do the trick.

The video shows the basics on how an AC generator works.

It also shows how electrons move back and forth about a fixed point. Notice the needle on the voltmeter moving back and forth (with 0 as the fixed point) as the generator spins creating the sine wave.

One important fact about alternating current is that it doesn’t have to be sinusoidal.

Figure 6 depicts 3 other types of AC waveforms along with a sine wave.

*Figure 6: other types of AC waveforms*

The square wave should look familiar; you’ll see similar waves in digital circuits. Triangular waves are good for testing certain types of devices, like some amplifiers. Complex waves often crop up, too. They may or may not be desirable, depending on the circumstances.

For example, a sine wave with noise injected into it may look like the complex wave in the figure above. Or, an AM radio signal may take on a similar form. One is desirable while the other is not.

Regardless of their shape, they all have one thing in common: they’re positive for some period of time, then negative for some period of time.

I know the m-word is making some of you groan right now while others are rejoicing, but I promise – it won’t be that bad.

The mathematical description of a typical (non-pulsating) DC waveform is stupid-easy:

V (t) = V

Where t is time.

In other words, it’s a flat horizontal line and V is the voltage that remains constant throughout time (that’s why it’s graph is a horizontal line).

The description of a typical AC waveform depends on the shape, but for simplicity’s sake we’re going to assume a sinusoid.

Mathematically, an AC sinewave is technically described by the equation below.

v (t) = V sin (ωt + φ)

Where ω = 2πf.

That equation may be more familiar if you’re an engineer or electronics tech.

The lower-case omega (ω) is the frequency in radians rather than Hertz. Since most hobbyists aren’t super familiar with radians, the equation can be changed to a more familiar form.

v (t) = V sin (2πft + φ)

What follows is a break-down of what each part of this equation means.

*t** represents time.*

*v (t)** is a function of how the voltage varies or changes with time. In other words, v (t) changes as time changes. The stuff on the right of the equal sign describes how this change looks.*

*V **is the amplitude of the sinewave.*

*2**π** is a constant used to convert radians, which is an angular frequency (radians per second) to Hertz, the unit you’re probably more familiar with.*

*f** is the frequency in Hertz, or cycles per second. In a 60 Hz circuit, one cycle takes 1/60 of a second (this is the period of the wave which describes how long one cycle lasts. In general, the period T = 1/f, so one cycle of 60 Hz power lasts for about 17 ms). Conversely, there are 60 cycles in one second in a 60 Hz circuit.*

*Φ **is the phase of the wave. This is a measure of how far the wave is shifted with respect to time and is somewhere between 0 and 360 degrees. Once a sinusoid is shifted 360 degrees, it’s as if the shift never happened. The wave is the same because there are 360 degrees in a circle. In other words, if I were to draw a circle with a compass, once I rotated it 360 degrees the circle would close and start again at 0 degrees.*

You may be wondering how this fits in with the 120 V coming from a receptacle in your home.

In the U.S., AC power has a peak amplitude of 170 V (120 V is the RMS value) and the frequency is 60 Hz. We’ll assume no phase shift.

With this information, we can write

v (t) = 170 sin (2π60t)

to mathematically describe the voltage coming from the wall.

Don’t try this, but if you were to view the AC power in your home on an oscilloscope, you’d see a 60 Hz sine wave with a peak amplitude of 170 V.

If we graph this equation on a graphing calculator or computer, the same thing would show — no scope required.

If you have some experience in electronics, you likely know the answer. If you’re new, it may not be obvious.

Most things that plug into the outlets in your home convert the AC feeding it into DC. This includes your TV, computer, DVD player, Wi-Fi router and more.

There are a few good reasons why the power company supplies AC power rather than DC power.

- With AC power, you can easily step the voltage up or down with a transformer. Doing the same with DC is more complex. This allows the utility to use high voltage and lower current, which is more efficient. Wires have a resistance, which becomes significant if they’re miles long. Remember, Power = I
^{2}More current means more heat lost in the resistance of all those wires. That’s money wasted. So instead of high current they use high voltage (while keeping the current low), which can easily be reduced later. - It is much easier to convert AC to DC than it is to convert DC to AC.
- The generators the power company uses work by spinning conductors in a magnetic field. This naturally give rise to an AC sinusoidal output, as we already know. Some generators can output DC, but they are more expensive and more complex. Also, AC generators are usually larger, meaning they can generate more power.

As an interesting side note, the battle between AC vs DC power distribution settled in the 1890’s with AC as winner. This is why we use it today.

However, new technology has made a DC grid more feasible and efficient. There are a few small areas around the world that are testing this idea. Suffice it to say, it’ll be a while before the whole grid converts to DC, if it ever does.

There is so much more to the world of AC and even DC than we can cover in one post.

For example, we did not talk about transients (DC), nor discuss AC related things like RMS (root mean square), peak value, peak-to-peak value, or phasors in much (or any) detail.

Looks like a job for a future blog post!

Until then, comment and share what topic you would like to see covered in a future post. It might just show up

Like this article? then you’ll love the Facebook group for electronics & computer enthusiasts! Request to join today.

*References:*

- Cook, Nigel P.
*Introductory DC/AC Electronics, 4th Ed.*Prentice Hall, 1999. Print. - Alexander, Charles K. & Mathew, Sadiku N.O.
*Fundamentals of Electric Circuits, 2nd Ed.*Mc Graw Hill, 2004. Print.

The post AC vs DC: What’s the Difference? appeared first on Circuit Crush.

]]>The post A Closer Look Inside the Arduino Uno appeared first on Circuit Crush.

]]>Of all the different incarnations, the Uno remains one of the most popular.

In fact, if you’ve been dabbling in electronics for more than a few minutes or have worked with microcontrollers, chances are you’ve used it before or have at least heard of it.

A while ago, I wrote an article about using the Arduino vs a stand-alone microcontroller (like the ATmega328 that powers the Uno or a PIC).

They both have their pros and cons, so if you’re interested check out Getting Naked: Working With Naked Microcontrollers vs Trainers Like Arduino.

Though many of us have used the Arduino Uno, most of us seldom think of how it works or what’s under the hood. We’re going to take a closer look inside the Uno and see what makes it tick.

Actually, this will likely be the first of a series of posts about the inner workings of the Uno and the nuances of working with it. I may not write them in order (I may write about other topics before posting part 2), but they’ll eventually come.

*If you’re looking for the Arduino Uno and ATmega328 pin-out, see figures 1 and 2. *

Now, let’s have a closer look inside the Arduino Uno.

Made in Italy, the Arduino showed up on the scene in 2005. Since then, there have been various incarnations of the board including the Duemilanove (2009 in Italian), the Diecimial (which means 10,000 in Italian to celebrate the making of the 10,000^{th} one), the Mega 2560, and more.

The boards are very versatile and can handle most common things microcontrollers can do, and the price is low.

Then there’s the fact that the software to program it is free and can be used on Windows, Mac, or even Linux.

The hardware and the software are both open source, so others can take the designs and improve them without worrying about licensing fees.

There are many *shields* that are available which easily attach to the board adding functionality.

And finally, they’re great for experimenting and prototyping projects (though my Getting Naked post explains why you may want to go for a stand-alone micro instead).

Refer to figure 1, which shows the Arduino Uno.

*Figure 1: the Arduino Uno board*

Obviously, the rectangular thing in the lower right is the brains of the Uno, the ATmega328.

The power jack on the lower left is a 2.1mm center positive barrel connector. Above that, we can see a USB Type B jack for connecting the Arduino to a PC.

A series of 28 female pin headers allow you to connect other things to the Arduino and are at the top and bottom. These headers are separated into three groups. The digital pins are at the top. On the bottom left we have the power pins, and the analog pins dwell on the lower right (notice the small gap between them). Out of the 28 pins, 20 are for I/O.

The six analog pins can also serve as general purpose digital I/O. Out of the 14-total digital I/O pins, six can be used to generate PWM (pulse width modulation) signals.

The Arduino Uno also supports basic communications standards like TTL serial, SPI, I2C, and 1-wire.

Two of the inputs support hardware interrupts. They trigger on either a LOW, a rising edge or falling edge, or a change in value via software.

The oval-shaped silver object in the middle left is the 16 MHz crystal.

To the right of the power jack are two 47 µF capacitors. We’ll take a closer look at these in a future post.

Directly above the jack lies a 5 V low dropout voltage regulator. Directly above the capacitors closest to the microcontroller we can see a 3.3 V low dropout regulator. It lies near two surface mount capacitors.

Powering the Arduino is an often overlooked, but a very important part in the effective use of the device. Many spurious errors are actually power issues. We’ll go into more detail on properly powering the Arduino in a different post.

An Arduino Uno board measures 2 1/8” x 2 ¾”. The SMD version is *slightly* different but most people want the ability to easily replace the ATmega328 microcontroller if they accidentally kill it. If you’re new to Arduino, electronics, microcontrollers, or some combination of the above I’d skip the SMD version and grab the one in figure 1.

The operating voltage of the Arduino Uno is 5 V which can come from either a USB cable and your PC or some external source.

The recommended input voltage range is 7 – 12 V. You should try to keep that number closer to 7 V if you can as the small regulator will dissipate any excess energy as heat and can become very hot. We’ll go into more detail on this issue in another post.

The Arduino Uno contains two regulators. The 5 V regulator can theoretically provide up to 800 mA and the 3.3 V version can source 50 mA.

Aside from the microcontroller, the Uno has a few other main points of interest.

There is an integrated USB-to-serial communications chip for downloading programs or “sketches” from your PC and for serial communications back to the PC for debugging and monitoring.

This chip is the small black box above the 16MHz crystal in figure 1.

The USB link sports a 500 mA resettable fuse to guard against any possible damage to your PC. When you plug your Arduino into a USB port, the board takes its power from that port. In USB 2.0, the current a port is capable of sourcing is usually 500mA. USB 3.0 ports can source anywhere from 900 mA to 3 A depending on the type of port.

The analog pins connect to an internal 10-bit analog-to-digital converter (ADC). All the I/O pins can function as digital outputs and can sink/source up to 40 mA.

Next to the analog pins lie the power pins which provide access to both the regulated and unregulated power supplies.

The ATmega328 chip on the Arduino isn’t empty, it comes pre-loaded with a small bootloader for use with the Arduino integrated development environment (IDE).

One nice thing about the Arduino is that you can use it to program other ATmega328 chips if you were to build a project with the stand-alone microcontroller.

To do this, you’d program the chip, remove it and then insert it into your own circuit. All it needs is 5 V, a 16 MHz crystal, and two 22 pF capacitors.

There are a few more minor details on this and it’s something that I personally have not done, but I know its possible. Perhaps we’ll revisit the topic in another post once I get a chance to play with it.

*Figure 2: ATmega328 pin-out and Arduino I/O pin mapping*

Feast your eyes upon figure 2, which shows a pin-out diagram of the ATmega328.

One of the first things to note is that the ATmega328 pin numbers are different from the Arduino Uno pin numbers. This is important!

The labels inside the chip are the primary function names for each of the pins, while the parenthetical labels on the outside are any alternative uses for the pin, if any are available. The writing in blue shows the ATmega328-to-Arduino pin mapping.

Figure 3 shows a simplified block diagram of the ATmega328 microcontroller.

The I/O block is the 20 analog and digital pins. The six analog pins go to the ADC, which has a resolution of 4.9 mV because there are 1024 steps (remember, the ADC is 10-bits and that 2^{10} = 1024) and when we divide 5 V by 1024, we get 4.9 mV per step.

*Figure 3: ATmega328 simplified block diagram*

The two external interrupts that the chip supports map to Arduino digital pins D2 and D3.

There was a time when the analog comparator was not accessible through the Arduino IDE.

Personally, I have not tried to use this feature myself, but some quick searching seemed to suggest that there are now ways to use the comparator with the Arduino IDE.

The analog comparator will trigger an interrupt when voltage on one input equals or exceeds the voltage on another input. This could come in handy for certain projects. For example, say you want a fan to come on when the air reaches a certain temperature.

As of this writing, the current version of the Arduino IDE is version 1.8.3.

The Arduino comes with a Java-based IDE with a fully featured text editor. Once you write a sketch, it needs to be compiled which is referred to as *verifying* in the Arduino ecosystem.

Sketches are written in a language similar to C, though a sketch itself is not completely compatible with C.

There’s no *main()* function for one thing, at least not one that’s visible. It’s hidden from view and added for you when you compile or verify your sketch.

The sketch downloads to your Arduino via a USB cable. This process is automatic as the bootloader that resides in ATmega328 detects when a sketch is arriving.

The sketch takes residence in the 32 Kb of flash memory inside the ATmega chip. This memory can endure at least 10,000 read/write cycles, so you’re unlikely to wear it out any time soon. The Arduino also sports 1 Kb of electrically erasable programmable read only memory (EEPROM) which is non-volatile. Finally, there is also 2 Kb of RAM available which *is* volatile.

All Arduino sketches need two parts at a minimum: the *setup()* and *loop() *functions. These two functions take no arguments — so the parentheses are empty — but they still need to be there.

They appear as follows:

Void setup() { any code would go here

}

Void loop() { any code would go here

}

If you’re familiar with C, you know that *void* in front of the functions simply means that the function does not return a value when it’s done processing.

These two functions are a requirement and the Arduino IDE will report an error during compile if any of the two are missing.

Often, the makers of the board will release updated versions of the IDE. When they do, it’s a good idea to download them and install them. You can keep multiple versions of the Arduino IDE on your PC and switch between them if you want, but this isn’t something you should need to do often. If you do install the latest IDE, be sure to take a gander at the readme file for the latest changes.

Many of you have used the Uno in your projects and experiments, but now you have a little more detail on how the board and the brains (the ATmega328) work.

Future installments of this series will go into more detail about powering the board, a very important but often overlooked issue. We’ll also take a closer look at the digital and analog I/O pins, as there are some “gotchas” hiding there.

Meanwhile, comment and let us know about your latest Arduino experiments, projects, and endeavors!

*Like this post? You’ll love the electronics Facebook Group. Request to join today!*

The post A Closer Look Inside the Arduino Uno appeared first on Circuit Crush.

]]>