TIL311 replacement

Back in the day, when men were men and computers were programmed in hexadecimal, Texas Instruments produced a nifty little display chip called a TIL311. This chip took a 4-bit nibble as input, and produced a single hex digit on a built-in LED display. As if that weren’t cool enough, TI packaged it in translucent red; you could almost convince yourself that you saw the electrons moving through the traces as the display digits changed. This wasn’t a consumer-oriented BCD display for use in calculators and clock radios (though it would work nicely for that) — this was an actual hexadecimal display, capable of displaying numbers beyond zero-through-nine.

To paraphrase This Is Spinal Tap, “these went to fifteen!”

A TIL311 hex decoder and display (click for larger)

 

A TIL311 displaying hex digit "C": 1100, or decimal twelve. (Click for larger)

 

Unfortunately, although they’re still as useful as ever, TIL311s are extremely scarce today. The best price I could find online was $19.95 apiece. (For comparison, you could get several backlit 32-character LCD displays for the same cost.)

For Drexel’s EET325 Microprocessors class this term, we wanted to capture the essence of programming a vintage 8-bit CPU like the Z80. A modern LCD display would be simpler to implement, but somehow it just wouldn’t be the same. Hex displays like the TIL311 worked beautifully: one hex digit exactly covers four bits. Two digits cover one byte (for the data bus) and four cover a 16-bit word (for the full address bus on the Z80). The most recent versions of the DrACo/Z80 are true 8-bit machines, though: the address bus is 8 bits wide (although expandable to 16). Because of this, only four hex digits are needed; two for the address and two for the data.

Even so, four TIL311s per board would add $80 to the bill of materials — roughly doubling the cost. This, we figured, was an opportunity to put our LPKF PCB plotter to use creating some modern TIL311 replacements. A PIC16F1825 microcontroller, a common-anode seven-segment LED display, and seven resistors take the place of TI’s slick one-chip solution. It isn’t nearly as pretty, but it gets the job done for a bit less money.

The displays in action, and a view of the single-layer traces. (Click for larger.)

A few design revisions and squashed bugs later, the first of the new boards are up and running. The PIC runs in a continuous loop, monitoring the four data pins and updating the seven-segment output based on data in a lookup table. (The code is easily converted to a common-cathode design by inverting the display bits; the board would have to be modified to support this. It would have been nice to be able to do this in software by using an I/O pin as a switchable common, but unfortunately there were no spare pins left.)

Here is the zipped PIC project to reproduce this display for yourself, along with the layout file used to create the board layout in FreePCB. The design is completely single-layer for ease of soldering, although if using double-sided copper-clad boards like we did, the holes on the top layer must be insulated. The PIC actually runs at its slowest self-clocked speed of about 31kHz; since the monitor-lookup-and-update loop only takes 36 cycles, the display can still be updated at several hundred Hz — fast enough to be a blur if the Z80 is running that fast. (The design should work at any speed, since no timing at all is used; the PIC is simply emulating combinatorial logic as fast as possible/necessary.)

Some details on construction: All resistors are 470 ohm, although any similar value should work OK. The connector is a standard 0.1″ row connector, with the plastic insulator pressed all the way to one side. This way, the connector can be inserted through the top of the board, soldered to the bottom side like all of the other components, and have enough pin length left to comfortably fit into a solderless breadboard. Since these boards will be used in a classroom lab setting, I opted to socket the PIC. That way, if one accidentally gets its power reversed and/or is introduced to 12V instead of 5V, we can easily replace it.

Since the LED display is driven by the PIC, it is less likely to be damaged due to incorrect connections; the PIC is unlikely to pass enough current to it to cause damage. The LED is keyed, and will only go in one way. (Yes, it’s supposed to be upside-down; these boards don’t use the decimal point, and the circuit layout worked much better that way.)

I’m still working on refining the parameters for producing boards on the LPKF plotter (not to mention dealing with some persistent alignment issues) — but it’s definitely getting there.

If you decide to make one of these for yourself and have questions, please email me (“Eric” at this domain); I’ll be happy to help.

 

Posted in Assembly, Coding, Components, Digital, DrACo/Z80, Drexel, EET325, Electronics, Level 3, Nostalgia, PIC Microcontrollers, Projects | Tagged , , , , , | 5 Comments

Musical Witchcraft

Several years back, I bought a “The Very Best of Tom Paxton” CD. Among several other really good songs, it had a new version of “Jennifer’s Rabbit” — one of my favorite songs from childhood. (There’s not nearly enough good fantasy in the world.) I especially liked what he’d done with the intro to the song in this version: a single note, in a minor key, which set a mysterious, exciting mood for the song.

It wasn’t until I learned a bit more about music theory, though, that I sensed that something was up. Single notes, by themselves, are never major or minor. “Also Sprach Zarathustra” is a great example of this — a tonic, a dominant, then a tonic one octave up, followed by a major chord and a minor chord in quick succession. It’s a neat effect which relies on the fact that with the first three slow notes, the major-vs-minor question hasn’t been resolved yet (no third, major or minor, has appeared yet.)

The opening note of “Jennifer’s Rabbit” seemed to have been crafted by resorting to dark magic: setting a minor-key tone with a single note just isn’t possible. (In fact, that note turns out to be the tonic — present in any key, major or minor.)

How did he do it?!? This was a job for Audacity!

The waveforms for the opening notes. (Click for larger.)

The song opens with the single guitar note — at about 147Hz, probably the D below middle C. About 400 milliseconds later, though, the pattern changes subtly. If you listen, a minor third has been introduced, not quite loud enough to really be obvious. Sneaky!

…but Tom Paxton, after all, is the guy who wrote “The Marvelous Toy.” I’ve known for many years that he’s a musical genius. I just wondered if he’d found a way to rewrite a thousand years of Western musical theory!

 

Posted in Analog, Music, Nostalgia, Science | Tagged , , , , | 1 Comment

Thoughts on LabVIEW

NI LabVIEW is a graphical “programming language” oriented toward experiment and data acquisition automation. It’s useful in a lot of situations, and fairly easy to pick up. I’ll even give LabVIEW a pass for being a proprietary vendor-specific tool (and not an open-standard language like C). Proprietary tools are often useful, and even with the best of intentions, open-source communities don’t always have the resources to provide slick, easy-to-use tools.

For certain tasks, mostly involving data capture and analysis, LabVIEW is a very useful and intuitive way to create software for laboratory automation. If an experiment required the capture of a signal, outputting a snapshot of a Fourier transform whenever certain parameters were met, LabVIEW would be a good choice of software tool.

However, LabVIEW, by its nature, is unbelievably bad at certain other tasks. Specifically, basic arithmetic operations are generally done by wiring numbers to mathematical operators. To add two and four, you create “constant” objects for “2” and “4”, then run wires from each of these into an “addition” module (which looks like a miniature op-amp symbol.) This makes wonderful sense when routing signals and control lines; not so much when performing basic arithmetic.

The true nightmare, though, doesn’t appear until complex program-flow logic gets into the mix. Once an application becomes more than moderately complex, the LabVIEW schematic quickly starts to look like a psychedelic plate of alien spaghetti. One image in particular that I found on The Daily WTF illustrates the point beautifully.

*Literal* spaghetti code! (Click to see it in all its high-def glory...)

When your “program” looks like this, the language is trying desperately to tell you something. Pain, after all, is Nature’s way of saying “DON’T DO THAT!” Here, LabVIEW is doing its best to tell the programmer that it just doesn’t naturally bend in that direction. It’s like trying to implement linked lists in BASIC or writing a flight simulator in LISP. It might be possible, but that doesn’t mean it’s a good idea.

A while back, I buttonholed a NI rep at one of their local “hands-on” seminars. (One thing NI does very well is customer relations and training.) I eventually got him to admit that yes, there is an actual language behind the scenes that all these graphical connections are eventually compiled into. He mumbled something about it being for NI developers only right now and not-really-ready-for-prime-time and so on.

Even if that’s so, having the option to code in actual code would be very helpful. LabVIEW could retain the graphical interface for signal-flow applications, while offering a C-like text interface for applications that work better with more complex control structures. There are even ways to do concurrency (one of LabVIEW’s selling points) in textual languages — and in fact, this has probably already been solved in NI’s behind-the-scenes language.

Why not let the man behind the curtain out to meet the customers? I’m sure a lot of good would come from it. I know a lot of LabVIEW applications would become a lot easier to understand if this could happen.

 

Posted in Coding, Electronics, Tools | Tagged , | 2 Comments

Diamagnetic Levitation

Earnshaw’s Theorem states that “a collection of point charges cannot be maintained in a stable stationary equilibrium solely by electromagnetic interaction of the charges.” In other words, no arrangement of permanent magnets, no matter what their polarity, strength, or arrangement, can result in magnetic levitation (unless tricks like gyroscopic stabilization, geometric restriction along one axis, and/or closed-loop electronic control are used.)

Earnshaw was a spoilsport!

Fortunately, it turns out that there’s a loophole — diamagnetism. Certain materials repel all magnetic fields (albeit very weakly), and this effect can indeed be used to produce continuous magnetic levitation, with no electronics or power sources needed.

Bismuth is generally used for experiments like this. It’s one of the most diamagnetic materials around, fairly easily worked (it melts at 271 degrees C, which can be achieved over a kitchen stove), and is nontoxic enough that it’s the active ingredient in Pepto-Bismol. At about $70/kg on eBay, it’s not dirt-cheap, but neither is it as expensive as gold or platinum, so it’s within reach of most amateur scientists. With the proper setup, the diamagnetic properties of bismuth can be used to make magnets levitate — permanently — with no power supply or PID controller in sight.

A neodymium magnet floating in midair! (Click for larger.)

Having seen an interesting article online on how to make diamagnetic levitation work, I bought a pound (about 450g) of fairly pure bismuth on eBay and stopped by Lowe’s and Radio Shack for a few parts I didn’t have. (I really need to get a house, where I can have a properly-equipped lab. Not having bismuth is understandable, but not having ring magnets or 10-24 threaded rod stock on hand is embarrassing.) Here’s what’s needed for the levitation project:

  • About 300g of fairly pure bismuth metal (the chunk I bought was claimed to be 99% pure, and worked fine);
  • A small, lightweight neodymium magnet. (I used one of the “small discs” in a neodymium magnet set from ThinkGeek);
  • Several ceramic ring magnets (I used two 5-packs from Radio Shack);
  • A length (maybe 30cm or so) of 10-24 threaded rod;
  • Two hex nuts, three washers, and a wing nut for the threaded rod;
  • A project box or other enclosure (to hold the ring magnets over the bismuth);
  • Something to hold the bismuth discs apart (I used two stacks of three dimes each).
  • Three clean, empty aluminum cans
  • A furnace capable of 300 degrees C or so. (Bismuth melts at about 271.5 degrees C, but I found that using 450C made it melt more easily. Aluminum is good up to 660 degrees C, so stay well below that. You can use a kitchen stovetop if you don’t have a furnace available.)
  • Metalworking tongs, if using a furnace.
  • A milling machine, or at least a file / Dremel tool / sandpaper, to flatten out the cast bismuth discs.

First, prepare two empty aluminum cans; remove the pop-tops and turn them upside-down. (The molten bismuth will be poured into the indentations.)

Next, cut the bottom part of the third can off (leave about half to 2/3 of the can attached to the bottom; you’ll use this as the crucible.)

Place the bismuth ingot in the can bottom and use the furnace to heat it until it’s nicely melted. (Unlike most things except water, solid bismuth is less dense than the liquid, and should float, so it should be easy to see when it has all melted.)

Ready to melt the bismuth. (Click for larger.)

Using the tongs, carefully remove the can from the furnace and pour the molten bismuth into the indentations in the two other aluminum cans. Allow them to cool (make sure to set the can crucible on a heatproof surface while it cools, as well.)

The cast bismuth, solidifying in the aluminum-can molds. (Click for larger.)

Once the bismuth and cans have cooled to room temperature, pry the bismuth out. Bismuth is brittle, so take care not to chip it too badly. (I found it necessary to cut the cans apart and tear them open enough to release the bismuth.)

Mill, sand, file, or otherwise flatten the discs, without making them too thin. They will work better to repel the magnetic field if they are flat. The ones I made initially had a peak near the center that had to be flattened out with a Dremel tool. I plan to mill them flat next week.)

Next, it’s time to assemble the project. Here’s an overview picture, to give an idea of what you’re making:

The whole setup, magnets and all. (Click for larger.)

Thread the ring magnets onto the threaded rod, and secure them with hex nuts and washers at each end. They should go nearly at one end of the rod, leaving just enough rod left over to ensure that the nut doesn’t come off. (This isn’t very critical; you can leave a few mm and still have it work fine.)

Thread another hex nut, then a washer, onto the rod from the top. Lower these to near where the magnets are. Cut a hole in the top of the box or enclosure large enough for the rod. Using the wing nut and another washer, suspend the rod about 20cm above the bottom of the box.

At this point, take the small neodymium magnet and note which side is attracted to the end of the magnet rod; this end will need to point upwards. (Try not to let it jump onto the rod; neodymium discs are brittle.)

Place one bismuth disc, flattest side up, in the bottom of the box, centered under the magnet stack. Place the dimes or other spacers around the edges of the disc, leaving enough room in the center for the disc magnet to float freely.

Place the neodymium magnet onto the bismuth disc. Carefully lower the second bismuth disc, flattest side down, onto the spacers.

Now to adjust it. At this point, the magnet should be resting on the bottom bismuth disc (gravity pulling it downwards with more force than the magnetic force from the ring magnets plus the diamagnetic repulsion from the bottom disc are exerting upwards.) Very gently, start rotating the threaded rod to slowly lower the magnet stack towards the bismuth discs. You should see the disc magnet start to “dance” around a bit, then lift up on one end, then eventually leave the bottom disc altogether and float in the air. If you overdo it, or if the bismuth discs are too far apart, the disc may skip the “floating” phase and bump into the top disc. If this is the case, back off on the magnets a bit to get the disc to float lower. If you can’t find a setting where the disc floats, decrease the distance between the bismuth plates.

Here’s a video of the completed project doing its thing, even while being subjected to gentle puffs of compressed air and being poked at with a (nonmagnetic!) stick…

Have fun! Send me an email (“eric” at this domain) if you have questions.

Posted in Bismuth, HOW-TO, Level 3, Metalworking, Projects, Science | Tagged , , , , , , | Leave a comment