The point of the next few entries will be to bring you up to speed on what exactly is meant by AC power versus DC power. We will cover what the terms mean, the tools of each, the real-world-implementation and fun facts. But where to start?

Let’s start simple and hands on with an experiment.

Supplies:

A 1.5v dry cell battery (standard AA will do just fine)

A magnet (you’ll want something with a little kick to it. I used a simple round magnet. Fridge magnets won’t work very well)

A voltmeter

about 1 foot of solid copper wire

A compass

An iron nail (something that can be picked up by magnetism)

Procedure:

1) Getting started

-Touch the probes to each end of the battery and see that there is a voltage difference. We are measuring the amount of potential energy in the battery. Much like a roller-coaster at the top of its climb, it has only so much energy to expel and therefore is bounded in a similar way.

2) Neat Tricks

-you will need the compass, wire and battery. Complete a circuit by touching the copper wire to both ends of the battery and moving the wire near the compass. You should see the compass needle become magnetically attracted to the wire. Much like normal magnets, the field in the wire is aligned, but is moving. Because of this movement it created a magnetic field.

3) Neater tricks: Creating electricity

-Attach each end of the copper wire to the volt meter probes. Once that is done take the free magnet and move it across the wire at varying speeds, do not stop. As you pass the magnet over the wire, the electrons inside should either be attracted or repelled and show some readings on the voltmeter. Electrical current is defined as the change in charge over time, or the rate of flow. This is where the “electricity is like water” analogy comes in. Because of the “flow” of electrons endued by the magnet, a current can be measured.

Lessons learned:

Voltage: Difference in potential. It is a way of defining how much “push” you have behind your circuit.

Current: Change in charge over time. The rate of “flow” inside your circuit. The more electrons you push through, the higher the current.

We will revisit the electricity/magnetism topic several times in the following articles, so don’t worry, more will be explained.

Tune in next time for learning about DC circuitry and its applications and forms.

]]>

For instance, if you were building a clock or counter, it would be incredibly useful to remember where you were last. A calculator would also be a good place so that you could “enter” each number and operation. Both applications require vastly different approaches. We’ll start with the calculator, since it’s easier.

To build a calculator, let’s use our imaginations for a second. On a traditional digital calculator you enter your first number then the operation then the next number, repeating the process over and over until you get to your final answer. Alright, let’s imagine a canal, each number is held in a dike and pushed forward through the canal one at a time. Then let us imagine that our operations are each a path this water can go through. Now, the problem is how to do we hold the number so we can continue to add/subtract as long as we see fit. Basically input-operation-hold-more input-operation-etc.

So we need a method of holding since we already created an adder/subtractor that works perfectly well. A “D” flip-flop does the trick very well, actually by definition. A D flip-flop takes in an entry at an instant (defined by a periodic clock usually) and only changes that input when the clock hits again. Usually you’d just program a regular frequency for a clock, but in this case, the clock operation is going to be the add or subtract queue. Like when you press + on a simple digital calculator and the screen changes, the “clock pulse” will be the + button.

Once we understand the underlying problem and solution, the design is exceedingly simple. We just need to plug the parts together, see the diagram:

Image source

With the following diagram it’s a matter of plug-and-chug to create the circuit. The user input (switches for binary numbers) is tied to one input of the full adder (see lab 3) while the output is fed into a D flip flop. The D’s output (read as D^{+}) is sent both to the Y input of the full adder (so initially it’s user’s input + 0, then all further operations are “previous number” + “user input”) and to the ROM we designed in lab 5/6. Same use, same setup. The ROM translates the final output to normal decimal.

Some important things to make note of:

-the number of flip flops depends on number of inputs. You would arrange them to cover all possible outcomes. So, if there are 2^{n} combinations, then you’d need N flip flops.

-There are many types of flip flops with their own usages. I will cover them further in another post.

-The XOR thing in the full schematic is to handle subtraction. This was covered in Lab 3-part b.

Full sized schematic can be found [HERE]

]]>

For numbers we will use a 7-Segment display, as seen below:

These readers can be found in all sorts of gadgets. Microwaves, calculators, watches, billboards, etc. They are easy to read and we are all very familiar with them.

__The Catch__: We need a way to translate from binary to a form that turns on/off the proper segments.

There are two ways we can tackle the problem. Both with widely different solutions.

Use BCD:

By using 4 bits to convey each digit, we can solve the problem with logic gates. For instance: 8 = 1000. We change that into 1111111 or 0000000 (depending on the device) and we get a usable output.

Pros:

-Can build with basic parts

-Can (if you had too much free time) count with other bases up to base 16

Cons:

-Hard to expand

-Can display errors

-Extra outcomes

By using some Boolean tricks we can minimize/eliminate much of the errors. The final outcome looks something like [LINK].

The other possibility is a full translator. A custom piece of machinery that just spews out an answer for whatever input provided. This tool is called a ROM.

For a ROM, you program all possible outputs so that it just “answers” the input automatically, regardless of “logic”.

Pros:

-Easily implemented

-Scalable (up to max size)

Cons:

-Must be programed (time consuming)

-Has MAX scale. Larger arrays will require larger ROMs

This comes in handy with large systems. For instance, we can logically solve a system with up to 6 inputs. Any larger than that requires a 4th dimension or powerful computing equipment. So, for a system of 8 inputs (in this case) a programed ROM saves a lot of time.

For this case, the programed ROM will handle numbers from 0->255. This way, we can have a reusable part (much like the Full Adder from lab 3) that we can implement in further labs.

For instance, much like the previous image, we can have a 8-bit translator that is much simpler to implement.

**NOTE** Quartis “simplifies” the inputs/outputs into busses. Those thick lines are technically several inputs in one. Also, it compresses inputs/outputs into one symbol that you assign for all “addresses”.

~Locke

*Writer’s Note: I will post images later tonight. I do not have access to all the parts on this machine, but the tags have already been added. Check back soon!*

]]>

Once again, before we start talking about any circuit logic or design, we need to figure out the mechanics of the problem. Multiplication, like addition, isn’t very difficult. We all know the rules, but once again, binary adds a new perspective.

Note 1: Multiplication consists of 2 parts. First the multiplication, then addition. Because we will need to multiply numbers larger than 1, such as 8 (1000), we are forced to do the addition step.

Note 2: With binary, 1×1 still equals 1, so no need to carry bits in the multiplication step.

So, starting with regular multiplication let’s take a look:

As you can see, there are some digits highlighted. As said by note 2, we will not have to carry numbers in the multiplication step, only the addition step. Therefore, the multiplication is easy.

0x0=0

0x1=0

1×0=0

1×1=1

Which by definition matches an AND gate (ironic, no?). The tough part is figuring out how to handle all the additions. As I said in both the adder posts, the adder can be expanded infinitely to add **TWO** sets of bits together. When you start having to add multiple lines of bits, things get sticky.

The layout of our math (to keep the notation straight) is gonna look like this:

A_{n} and B_{n} are the bits being multiplied. Design does depend on how many digits are being combined.

X_{n} = B_{n} x A_{0}

Y_{n} = B_{n} x A_{1}

Z_{n} = B_{n} x A_{2}

V_{n} = B_{n} x A_{3}

Also, in all this mess is carry bits. We will tackle that in the design stage.

So, we have the basic framework to build our multiplier, but how to put the pieces together? Let’s look at the image again.

F_{0} = X_{0} Easy!

F_{1} = Y_{0} + X_{1} also easy. No carry!

F_{2} = Z_{0} + Y_{1} + X_{2} Okay, problematic…

How to solve this? Well, simple design can be just as useful as talking about it.

The image may be hard to see in this blog, so try a LINK.

As you can see, the adders are in a similar orientation to our multiplication tables at the top. The addition is sandwiched between the bits. If you look across the top of the design, the A_{n} bits are taken care of vertically, while the B_{n} bits are added in horizontally (to make the design less of a rat-trap). All the layers are added together like VZYX_{0} + VZYZ_{1} THEN + VZYZ_{2} and so on. The design is easy to expand or condense and is convenient.

So, to expand the design, here are the equations:

Full adders: B across by (A-1) down (number of bits)

AND gates: B x A

F_{n} (outputs) = A + B

The real trouble of the design is making sure that all wires are connected properly. One foul connection and the system will not work.

~Locke

]]>

The task: Create a game of rock-paper-scissors to play against the computer.

For this, we need a random number generator so that it’s like playing the game against a dice. You don’t know what it’s outcome will be and the computer isn’t able to “cheat”. Luckily enough, java comes with a random number generator, so it’s just a matter of handling the outcomes.

I assembled my program in two halves. The first half, it’s own method, checked the user input and returns a number to correspond with the choice (1 for rock, 2 for paper, 3 for scissors, and 4 if the user doesn’t enter the right value). Then the computer generates a random number and compares it against the user input using a switch/catch tree with an if/else tree inside. So, it catches the computer input and tests it against the user input.

Thankfully, it worked on the first try and is rather clean and concise. The code.

~Locke

]]>

The idea is that you have a set of tools, namely AND, OR, NOT and XOR. With these four operators you can express just about any set of outcomes. In the case of lab 3, we are looking for a way of expressing addition and subtraction in a simple manner that can be infinitely expanded.

This may sound daunting, but it’s not; it’s only a puzzle. So, like a puzzle, we are looking for not only correct combination, but efficient ones. This usually requires stripping a problem into smaller chunks and analyzing what the exact parts.

Let’s start with normal addition, namely two numbers at a time. If you add just single digit numbers it may look like the following:

This is the simplest addition possible. No carry, only 1 digit numbers. We can also do larger numbers and carries, but how to look at them? Well, for instance, you will never carry a number larger than 1 in this kind of addition, even in the largest numbers we can muster.

So, it can stand to reason that you will never have to carry a number larger than 1 in any base. A valuable piece of information.

Next, we figure out that we will have up to 3 numbers being added, the “x” bit, the “y” bit and the “carry” bit. It also stands to reason that if all 3 were 1’s, the largest outcome is 1 with a carry of 1. So we split the system twice. X + Y + Carry (handled by using XOR gates) and then figuring out IF there is another carry. It stands to reason that if **ANY 2** of the 3 inputs are 1, then the carry will need to be one.

Great, so how do we implement that? Well, we construct a table of all possibilities, like so:

I unfortunately do not have the space to explain the methods to how I built the “carry” system in my adder, this is what the entire system looks like:

The next section we need is to be able to handle subtraction. Usually, in binary we use two’s compliment. To oversimplifiy, you express negative numbers by inverting the bits + 1. This also requires an extra bit. So +9 (01001) can be expressed as -9 (10110+1=11000). This may sound overly complicated, but it makes life very easy on the logic level. By tying one end of an XOR to a switch (creating 0 for addition and 1 for subtraction) then the other to the “y” input (in this case) it will flip the bits as so. This way with using our “full adder” we can also have a subtracter with the flip of a switch.

Next Lab: Multiplying

~Locke

]]>

So, as the previous entry talked about, everything will be handled in binary and therefore the math is gonna be a little funny, so let’s start there.

When handling any sort of math with binary, the only two answers possible are 0 and 1. So, same rules apply in binary as in decimal. Therefore, 0+0=0, 1+0=1, 1+1=10 (zero carry-the-one). Simple enough yes?

So, to add one “bit” to another, we need two parts. First ,the actual addition and then the carry. Without getting terribly technical the addition is handled by an XOR and the carry by an AND operator. The circuit looks like this:

But that only works for the first bit. Just with normal addition, the first digit is easy, but all further digits need to take into effect the carry digit from the previous addition. Now, just like with normal addition, you’ll never have to carry any number larger than 10 for instance, so in binary, same idea applies, your carry bit never is larger than 1… rather nice, no? Also, another fact, in this case, is if any 2 of the inputs is one, then there will be a carry. Therefore, behold the “full adder”.

Then, you don’t want to have to build that over and over and over again for each pair of bits added, so we simplify the setup to one custom part as seen below:

This particular part can be reused over and over again for as many bits need to be added and is particularly useful in a myriad of scenarios. Just connect the carry out and carry ins.

More to be covered later.

~Locke

]]>

Allow me, for a few minutes, to explain the very background of the engineering in these circuit labs.

In the mid 1800’s a man by the name of George Boole, who was fascinated by number theory, created what is now known as Boolean Logic. This system strives to translate all algebra and arithmetic into a two value system with simple operators. As is widely trivial knowledge today, all computers work in binary (a system of 0’s and 1’s), and therefore uses Boolean logic to actually function.

Why Boolean and why binary? Well, as Murphy’s Law dictates; the more moving parts, the more likely the system will fail. So why do operations in this crazy math system? With only two possible outcomes and further cooperation at the atomic level (with magnetism and “spin”) then Boolean algebra is the only real choice.

I will explain the processes further in other labs, but I will try to do a brief overview.

**Binary:**

There are a few theories in Binary that need to be covered before we continue. Mainly, translating numbers into and out of binary. Let us start with base 10 (decimal) which we are all familiar with. First, start with a number, like 425. When you say it aloud, it’s four hundred-twenty-five. This can also be construed as (4×100 + 2×10 + 5×1). Binary is much the same, but smaller. So, if your number is 110100111, then you just work down the line in powers of 2. So 110100111 is 1×1 + 1×2 + 1×4 + 0x8… and so on, returning 423.

Also in computer-speak, shorthand for binary comes in incredibly useful. The two most common are octal (base 8) and hexadecimal (base 16).

To convert from binary to octal, just group numbers by 3’s. So 110100111 becomes 110 100 111 and then translates to 6 4 7.

To convert from binary to hexadecimal, group numbers by 4’s. So 110100111 becomes 0011 1010 0111 which then is translated to 3 A(9+1=A) 7.

These shorthand translations come in incredibly useful when trying to simplify keystrokes for instance, seeing as they are all handled by ASCII code. There are other uses, but it comes down to hex or oct are just ways to shorten code.

**Boolean**

With Boolean algebra, there are 4 operators.

NOT: this inverts the input given. If input is 1, then output will be 0. This operation can be drawn as a prime mark (‘) or a bar over the input.

AND: This operator handles a situation that is true for both inputs. Usually this is modeled by “multiplication” or a V.

OR: This operator handles situations where ANY input is

true. Usually this is modeled by “addition” or an inverted V. This is, in general terms, like the opposite of AND.

XOR: The last combination required. This handles variables when you only care if ONE of them is 1. This is usually shown by a

circled plus sign.

This all may sound confusing… and I will agree. These are just the basics and raw facts. More info can be found on wikipedia and other online sources. I will be explaining their uses and implementations further in other lab reports, seeing as information without context is useless.

Until next time,

~Locke

]]>

Stay tuned for more stuff!

~Locke

]]>

So, as I stated in my previous entry, this week’s Java homework was to make a calculator that took user input like “3 + 4” or “3.7 / 6” kind of thing. I was having all sorts of trouble with it.

First try:

Tried to implement the program with a method that checked the sign and then passed the value and a true/false value that checked if the numbers were actually numbers.

Second try:

Could not get the program to recognize the signs I was putting in. Solution: figure out the ASCII value and use a SWITCH statement to handle the 5 different operations. Next, implement a TRY-CATCH statement to test if the numbers were numbers and life would be good? No. Asked for help from the professor about my program and he responded “No TRY-CATCH. Can’t use those, they haven’t been covered yet”.

Third try:

With some input from Karel, I used hasNextDouble() which returns boolean values. If TRUE, then go through the program, if FALSE, program quits before an error can occur. By then using the equals(char) method, I was able to get the whole program to work. Took a last hit of the crowbar to get it to compile correctly, but it works. Even had enough time to do a INT or DOUBLE checker to return even cleaner values.

Link to code

~Locke

]]>