Posts Tagged ‘LEDs’

My Latest Big Project

16 April 2020
open side of pattern generator and serializer

I have been working on my latest project for about a week straight now. It’s finally in a usable form.

This project has several purposes behind it. First, I needed a pattern generator to test LED arrays that would output very ordinary patterns, nothing fancy, just so I could tell if the display was working. Second, I needed the output to be serialized to simplify connection of the display to the signal source. Third, I wanted to use as many old boards as I could, rather than junk them.

This project incorporates about a dozen old boards that were taken out of “dead” projects and gathering dust on my bench. They all had to be re-worked for this project. It also incorporates some older pattern generation circuits as a way of preserving a technology I have not been using recently.

Here is another shot of the project:

new project showing front panel

Here we can see the front panel which has four main knobs, DIN connectors for the serial signal output, and some other controls.

Added Control Systems

This was an ambitious project for me basically because of the additional front panel controls that I would not put on equipment unless it was being used to test other equipment.

Besides the four voltage-controlled oscillators (VCOs) that have been fairly standard in my eArt projects, there is a pattern selector that is implemented by a rotating “click” knob that I got off an old mobile radio. This gives me about 64 different possible combinations using just one knob.

The other thing I wanted to implement was the ability to isolate just one section of a pattern and show only that on the display. For this I used an old 4-bit binary rotary switch that I had laying around (making 16 possible choices) and some comparison logic using the infamous “XOR” (exclusive OR) gate, also known as a binary adder. This gate, basically, has one output (“0”) if the two inputs match and another output (“1”) if the two inputs are different. AND the outputs together (after inverting them), and you see if two binary numbers match for as many bits as you need or want.

As a geeky aside, I made use of the fact that binary AND and OR are complementary functions. Thus, you can accomplish a binary AND on the outputs of the XOR gates without inverting them first (to make a match = “1” instead of “0”) using an OR gate, which then gives you a “0” output only when there is a match (when all inputs are “0”). Invert that, and you get a “1” for a match. In my case I needed the “0” to show a match!

I also wanted to choose between the “legacy” patterns that I built into this project and the “simple” patterns used for test purposes. For this I used a 4-bit selector IC. One can make a “tree” of these ICs and select from as many different inputs as one wants.

I don’t build these sort of control circuits that much, so I had to do a bit of head-scratching along the way.

My bench and a few closeups

The project on my work bench

I don’t photograph my bench that often because it looks so messy. But here we see my current setup with the project and one of my displays on it.

To the left is a small oscilloscope and you can see its two test leads hanging down from little hooks. In the center is one of my numerous parts cabinets. Behind the project is a work light and a soldering iron. Above the light is a digital meter I bought used (highly recommended for an electronics bench) and above that a rack chassis full of power supplies. The supply with the panel lit up is the one I use the most.

my bench power supply

It produces four different voltages, 5, 7.5, 9 and 12. I use 5 volts the most. The panel had room for two meters (eBay specials!) so I can monitor more than one output at a time if I need to. Here it shows my five volt connection switched on and drawing 38 milliamps. With CMOS logic, most of the circuitry draws close to zero power. Most of this current draw is from the oscillators.

The 12 volt meter shows 18 mA current draw. This is from the panel meters themselves. It was easier to power them from one of the four supplies, rather than adding another just for them.

pattern generator set up in demonstration area

Here we see the pattern generator installed in its case and running the same display. This is in the “demonstration” area of my room.

closeup of the panel

There is room for another panel section above the one I used. You can also see the binary rotary switch set to “A” which is ten in hexadecimal.

8 spirals display

Here is “8 spirals,” one of my more colorful displays. All the lights should be lit in this pattern, but you can see that there are two lights having problems.

Arduino Drives 7-segment LED Display

23 March 2018

7-segment LED display

A standard 4-digit display. I fiddled with the image to make it look lit up.

7-segment Displays

This type of LED (Light Emitting Diode) display has been around for a long time, and you can still find them in many devices. For most applications they have been replaced with LCDs which use less power and are more versatile. But if all you need to do is display numbers, and you have some old parts around that you want to use, then you might be interested in putting one of these things into a “modern” project, such as one using an Arduino (programmable microcontroller).

Pin Count

The simplest Arduino has only 20 pins that can be used for digital I/O (inputs/outputs). A 7-segment display requires 8 pins to drive the segments (if you want to use the decimal point) and a pin for every digit. For 4 digits, that’s 12 pins. For 8 digits, that’s 16 pins. That doesn’t leave many pins for other functions in your project. But, you might not need many other pins.

There are ways to reduce pin count. One way is to use ICs (integrated circuits) that will take a binary number at the input, say from 0 (B0000) to 9 (B1001) and output the appropriate pattern to the segments to display those numerals. You can also use a simpler encoder to run the digits; 3 (binary) lines in, 8 lines (or digits) out. That means you could operate an 8-digit display using only 7 Arduino pins.

Drive Current

An older LED, like you find in these displays, requires at least 5ma (milli-amps) of current to look reasonably bright. Most are rated for 20ma. These arrays are actually scanned (only one digit on at a time), so it helps to make them look brighter if you drive them with more current than the LEDs would need if they stayed on all the time. However, unless you can find a special IC to do your decoding, one specifically designed to drive LED arrays at those current levels, most ICs won’t be able to do the job. The average CMOS (complementary metal oxide semiconductor) IC that hobbyists use is only rated for about 2ma output current.

However, the Arduino itself is rated for about 20mA output. So the Arduino pins can run the LED segments unassisted. I use transistor arrays to run the digits. They take about 1ma in and can output up to 500ma or so. However, these drive transistors invert the input signal (in high, out low), so to drive the digits requires a signal of opposite polarity to what you would use if you weren’t using the transistors.

Existing Solutions

Most – but not all – of these factors are taken into account by an Arduino code add-on (called a library) named “SevSeg” (for “seven segments”). What it does not take into account is using encoder ICs to lower the pin count. My design uses an encoder to select the digits, but runs the segments directly from the Arduino. So, I could not use the library that had already been written for this purpose.

My Own Solution

I am writing this because I thought I could come up with something relatively simple that would do the job, but I wasn’t sure.

The basic cycle of action is fairly straightforward:

  1. Set up the 8 segment drivers to be high or low depending which segments you need on or off to display the desired numeral (or other pattern) for the first digit.
  2. Select that digit by outputting the binary number corresponding to that digit’s hardware position. (Say, B000, three low lines for binary zero, “digit zero.”)
  3. Keep that pattern on for a little while (a milli-second maybe), then switch to the pattern for the next digit.
  4. Repeat this process for each digit, until all have been lit, then repeat the entire cycle as long as you want the display to show something.

I used what is sometimes referred to as a “brute force” method to select the digits. For each digit, I just tell the Arduino which lines to make high and which lines to make low. It’s only 3 lines, so not that hard to do it that way. Those lines will stay that way until I tell the Arduino to change them, so it’s just three commands for each digit. Pretty easy.

I could have done the same for the segments, but I was hoping for a simpler solution. I found one by using a built-in Arduino function (built into the code writing system, not the microcontroller!). This function is one of several that treat a number as a string of binary bits. They are called the “bit functions.” The one I used is called “bitRead().” You give this function almost any number and it can tell you whether there is a “1” or a “0” in any of the places in its binary form. For example, the number 255 is binary “11111111.” All its places are ones. The number 254, one less, is B11111110. There’s a zero at the end instead of a one. So bitRead(254,0) would return zero, while bitRead(254,1) would return 1. As is customary in most of these programming languages, lists of things usually start with “item 0” instead of “item 1” as most of us would assume. So, if you want the first item in the list you have to ask for “0” and if you want the 8th item you ask for “7”. Seems weird but you get used to it after a while.

For the eight segments on an LED display (including the decimal point) there are 256 possible different patterns, each represented by a number from 0 to 255. So I just had to figure out which numbers would produce the correct patterns to display numerals 0 to 9 on the display, then put those numbers in a list, with their position in the list corresponding to the numeral they represented. Then to display that numeral, I would just have to use bitRead() on the number selected from the list, going through each of the 8 binary places, and matching up each place with the pin I used for that segment (another list) and I would have the entire pattern properly outputted.

For my hardware, I wasn’t using the decimal point, and the list I came up with was: {63,6,91,79,102,109,125,7,127,111} for numerals 0 to 9. The numeral 8 has all seven segments on, so would be 127 (B1111111) in almost any system using this idea. The other numbers could change if the wiring of pins to segments was different than the one I used.

Note on touch screen styluses

I’ve been playing around with my touch screen devices, an iPod Touch and an HP Stream tablet. They both have “capacitive” screens and therefore require a conductive rubber stylus if you don’t want to use your fingers. I found a nice ballpoint pen downtown that uses the “eraser” as a stylus tip, and two children’s styluses at Walmart. I like to use the styluses instead of fingers, and hope to locate a drawing program for my tablet before too long.

styluses for touch screens

Voltage indicator

4 April 2014

This post is an experiment for me.
I don’t usually describe how I do my design work.
The objects, generally speaking, are not that photogenic, and electronics is a bit of a dry subject. But some people just aren’t familiar with it, and they should be. This is the age of electronics on earth.

most of my patch bay

My patch bay – right side.

Design opportunity and goal

While some electronics designers work within the framework of marketable consumer or industrial products, I don’t. It’s strictly “for fun” you might say. But any designer requires opportunities to do his or her work. After all, you can always buy OTS (off the shelf) if the item you want has already been designed.

I had made a “patch bay” – a kind of interconnection panel where lots of signal connections come together at the same place – for signals used to control my displays. I had purchased a blank piece of aluminum from a local welding shop, cut a slot down the middle (don’t ask me how) and drilled a bunch of holes in it for switches and connectors, then started loading it up with circuit boards.

But on the far left end I had four holes where nothing really seemed to fit: A design opportunity! I decided I wanted a voltage indicator that used four LEDs that got brighter as the monitored voltage got closer to each one’s center setting. The usual bar graph, of which I had made many using a commonly available part, uses ten LEDs that just go on when the input voltage goes above their set point, and off when it goes below. There is also a “dot mode,” which I like to use because it uses less power, where the LED whose set point is closest to the input voltage is the only one that goes on.

I didn’t want to use ten LEDs in the usual way. I wanted to use only four and have them get brighter and dimmer, the way my light panels are designed to do. I wanted each one a different color, but I only had three colors on hand, so the middle two are green, the top is white and the bottom is red. The red LEDs I have are a good deal less bright than the other colors, so I had to try to compensate for that, too.

patch bay left side

My patch bay, left side.

Dot display IC (integrated circuit)

I decided to use the dot display IC as the central component in this project. The two bottom outputs would go to the red LED. The next three to the lower green. The next three to the upper green, and the top two outputs to the white LED. You can set up the IC for so much current per output. Old LEDs required 20mA (milliamperes) to be bright. But modern LEDs only need 2. I tried limiting the current through the LEDs using series resistors. The brightest LED (white) would get a big series resistor (7K – kilohms) the green ones would get smaller ones (I think I used 1.5K) and the red would get the smallest series resistor, something like 100 ohms. These values were arrived at experimentally, and weren’t perfect, but good enough for this project.

How do you get an LED to get brighter and dimmer? You can simply drive it with more or less current. But almost exactly the same effect can be achieved by turning it on and off rapidly using a technique called “pulse width modulation” (PWM). This works because the body only takes a picture of its environment about 100 times a second. So any light flashing at about that rate or faster will appear constantly on. In technology, this is most commonly experienced when watching video monitors (or films). The picture on them only changes 30 to 70 times a second, but the motion appears continuous.

To do this with my dot display IC, I would have to make the input move back and forth through the set points of each of the dot outputs. I decided to use a “triangle wave” for this, and here it is:

triangle wave

This image is from my USB oscilloscope. There is a grid with the vertical and horizontal scales shown by the knobs. The period of this waveform is about 10mSec (milliseconds) and the amplitude is about 800mV (millivolts) peak-to-peak. So it’s oscillating at about 100 Hz (Hertz, cycles per second) and it’s about a volt high. The entire scale of my meter is 2.5 volts, so this signal should activate about 4 outputs at one time, with the one at the center of the oscillation the brightest.

I coupled this signal to an amplifier through a capacitor, then made the DC (direct current – not oscillating, or changing very slowly) level of the amplifier equal to half the input signal (0 to 5 volts). This created an input signal to the dot display IC of a triangle waveform going up or down depending on the slowly-changing DC level being measured, centered at zero to 2.5 volts, the input range of the dot display IC.

Does it work?

With the input set lower (see knob) the red LED is brighter than the lower green (by a little).

low input display

With the input set higher, the white LED is brighter than the top green.

high input display

The effect is quite noticeable, particularly to the eye (less to a camera). I was pretty happy with the outcome.

Limitations of measuring instruments

The range of voltages I use for my analog projects is zero to five volts, so that’s the only range my indicator needed to have. Since the electronics run on +7V and -5V, they can’t put out much more than 5 volts anyway.

But I noticed a funny thing happening with my USB oscilloscope when I didn’t connect it to my signal through a capacitor (to block the DC component of the signal).

clipped triangle wave

It was “clipping” off the top of the waveform! My cheap little USB oscilloscope only has a display range of plus and minus 5 volts! (at least at the settings I was using). This is a very small DC range for a professional oscilloscope, where more like plus and minus 50 volts is what is expected. This little scope had no DC offset built into the front end (all good scopes do) so if the signal goes beyond certain limits, it just disappears.

Here is a trace of the 12volt square wave that creates the triangle wave. Notice that it stops at a little under 5 volts. This means I will have to build a more compliant front end onto my scope if I want to see the entire waveforms in my 8-12volt projects.

clipped square wave

Comments?

I hope this post gives some small insight into the electronic design process. I kept it conceptual. The hardware details are VERY dry. You just look up the data sheets of the parts you decide to use and figure out how to connect the correct pins together. There are certain real-world considerations to take into account, such as using bypass capacitors on the supply pins so signals don’t get into the circuit in unexpected ways. And you have to know how to solder if you want to make a permanent circuit board. Solder is hot metal and it has stuff inside that smells pretty bad when it burns, so a lot of people don’t like it and I don’t blame them. It’s a great technology for military equipment, but hobbyists could probably get by with conductive glue.

Anyway, I rarely get real comments on this blog and would appreciate some. They don’t appear immediately; I have to go through them and approve or disapprove them.

Bye for now.