Friday, August 28, 2009

74hc163 counter has a bug?

I have been playing around with some 74hc163 chips that I have. These are 4-bit synchronous counters with a parallel load capability. When both counter-enable inputs are logic high, and a positive clock edge arrives, the counter value increases by 1.

Oddly, the 74hc163 chips that I have seem to have a bug! When the counter value is at 1111 (i.e., 15, the highest possible count), and a positive clock edge arrives, the count changes to 0001 rather than 0000. From all of the 74hc163 datasheets I have seen, the count should wrap-around back to 0.

I'm pretty sure I have wired the circuit correctly. There are no floating inputs, for example.

The chips are labeled "SP74HC163N", and the manufacturer seems to be "SPI".

Here's a picture of the circuit with the 74hc163:


The following two pictures show LEDs which follow the '163 output. The 4 LEDs to the left are bits 0 through 3 of the count. The two LEDs on the right are showing the values at the -LOAD and enable inputs. (Note that they are both high, meaning that the counter is in counting mode.)

Here's how things look when the count is at 1111:


And here's how things look after one positive clock edge:


That's clearly not zero!

Saturday, August 22, 2009

Neat logic synthesis freeware

I was trying to minimize a boolean circuit for a project I'm working on, and I found a really nice program called Simple Solver:

http://home.roadrunner.com/~ssolver/index.html

You type in a truth table, and it spits out a boolean equation and/or circuit that generates the correct output. You can constrain the part types, which of course is very useful if you're using discrete parts (e.g., 74HC gates).

For the problem I gave it, Simple Solver found a solution using 4 NAND gates, which exactly fits in a single 74HC00. Sweet.

Simple Solver can also generate circuits using flip-flops based on user-specified timing diagrams, which is a feature I'm planning to investigate at some point.

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.

Monday, July 13, 2009

AS1106/AS1107 LED display drivers

I've been using the max7219 to control 7-segment LED displays. They're nice, and easy to use, but they're expensive (around $10).

I discovered today that there is a cheap alternative: the AS1106 and AS1107 from Austria Micro Systems. They appear to be functionally identical to the max7219 and max7221, respectively. And, you can buy them from Newark for $4 in qty 1. Sweet.

I've ordered some samples, so we'll see how they work out...

Friday, June 26, 2009

Super-nifty perl script for cropping pdf files

I often need to include a PDF file in a LaTeX document. This works great if the PDF file has a reasonable bounding box, but most software exports PDFs as full-page.

I found a really great perl script that will crop a PDF by settings its bounding box to precisely enclose the PDF file's contents:

http://ctan.org/pkg/pdfcrop

I used it on a couple PDF tables produced by (gag) Microsoft Word 2007, and it worked great.

Thursday, June 25, 2009

Fun with 7-segment LED displays

Here's a circuit with an atmega8 hooked up to a max7219 7-segment display driver chip, with six 7-segment LED displays:


The max7219 is the chip hidden in the rats nest of wires :-)

There's a ds1305 RTC chip on the breadboard, but it's not connected to anything yet.

Cheap USB AVR programmer

I have been using a serial-port AVR programmer (the Olimex one you can buy from Sparkfun) to do AVR development, but my laptop doesn't have a serial port.

There are a number of USB-based AVR programmers, and they're not particularly expensive (e.g., the Atmel AVR-ISP mkII is $34 from Digikey), but being the cheapskate that I am I was looking for something really inexpensive.

I'm happy to report that I've found one that works very well, and is only $10:

http://alldav.com/index.php?main_page=product_info&cPath=5&products_id=24

I'm using it with Sparkfun's AVR breakout board to bring the programming signals onto a breadboard using a single-row 6-pin cable from Digilent. Here's a picture of the whole setup:


The programmer is the small green board on the left. The breakout board is the even smaller red board connected to the programmer at a right angle.

In the host OS, the programmer appears as a serial port (/dev/ttyUSB0 on my Debian laptop). The programmer type for avrdude is "stk500v2".

As an additional bonus, the programmer supplies 5V to your circuit, using the host USB port as the power source. I don't think it will source a lot of current, but it's certainly fine for a few ICs and LEDs. The circuit on the breadboard in the picture has an atmega8 and an LED.