Friday, August 21, 2009

Electronics stuff

I've been having a lot of fun playing with electronics this summer. I completed my AVR microcontroller project, which involved designing a custom circuit board and having it manufactured. More details soon.

Since I feel like I have a reasonable handle on working with AVRs, I'm currently taking a step back, and learning about low-level digital circuits - gates, flip-flops, etc.

Several important issues arise when building digital circuits:
  1. You need to have a power-on reset to get all of the stateful circuit elements into a well-defined initial state
  2. You need a clock source
  3. To understand what is going on in the circuit, you need a way of visualizing the logic levels at important points
I solved the first two problems by constructing a small circuit with six pushbuttons, using a switch debouncing circuit I found in the Microcontroller Idea Book. Each button controls a single output pin. A button press causes the output pin to go low, and a button release causes the output pin to return high. Since a 74HC14 Schmitt-trigger hex inverter IC is used, there are six buttons/outputs. A picture:


The thing at the lower-right with the two wires sticking out of it is a single-row header socket, which is very handy for allowing wires to be plugged into a circuit on the fly. I will spare you a picture of the underside, where you can see how bad I am at soldering things. In any case, the thing works, and is useful for generating both reset and clock signals.

I addressed problem number 3 (visualizing logic levels) using a pair of 74HC04 (hex inverter) ICs to control 6 LEDs. Each input is fed through a pair of inverters, where the output of the second inverter controls the LED. So, the LED is lit if the input is high, and is dark when the input is low. Basically, each input is a really simple logic probe. (I found out by experience that you can't use a 74HC output to both light an LED and also drive an input.) The only minor hassle is that you have to tie the unused inputs to ground, but that's not a big deal. A picture:


Here, the LEDs are showing the output of (one half of) a 74HC139 2-to-4 decoder driven by a 74HC74 dual D-type flip-flop used as a 2-bit counter. When the clock button is pressed, the dark LED (the '139 decoder has active-low outputs) cycles through positions 0 (left) through 3 (third LED from the right). The last two LEDs are unused.

No comments: