Binary Count

time

0001 0011 0101 0111 0001 0011 0101 0111

Bit 0

0 1 00 1 00 1

Bit 1

0 0 11 0 01 1

Bit 2

0 0 00 1 11 1

Bit 3

0 0 00 0 00 0

Figure 3: Controlling frequency with a binary counter.

This effect is evident if you look at the numbers 0 through 7 written out in binary, as illustrated above in Figure 3.

Notice how the frequency of the binary pattern reduces by ½ as you go from the top row to the bottom row. In other words, the digits in the top row toggle between one and zero; the digits in the second row toggle half as frequently as in the first; and so on. This shows how a binary counter inherently performs a divide-by-two in frequency function. The second interesting property of a binary counter, which is not so remarkable, is that when a binary counter gets to its highest count, it wraps around to zero again.

Thus, when driving the address bits of the sprite ROM, what we are really interested in is the frequency at which the bits are sequenced. Going through all the bits at a rate equal to the base rate of the ring oscillator is too fast; at 16kHz, the pattern will be very tight, and in fact, it’s unlikely that a viewer will see any pattern at all. Recall that we really want an update rate equal to roughly 30Hz.

In other words, we want a sprite to be fully “displayed” around 30 times a second. Going back to the frequency divider property of a binary counter, we see that bit 9 on a counter clocked at 16kHz will have a toggle rate roughly equal to 15 times a second. So, we wire bits 5 through 9 of the counter to drive the “sprite count” address input of the ROM. If I wanted an update rate of strictly 30 times a second, I would have used bit 8 of the counter. But in perceptual tests of the circuit that I conducted, I found that the pattern looked best at a rate of 15Hz, slightly below the threshold of persistence of vision.

etc....

Each period is
twice as long as
the one above,
so the effective
frequency is halved.

Recall that one of the goals was to provide a 32x16-bit sprite pattern. This means that a 5-bit (e.g. 25 = 32) counter was all I needed for the sprite pattern counter. Bits 16 through 19 are used to drive the “frame count” input for the ROM. These four bits are used to choose which sprite is looped into the LEDs, up to a total of 16 different patterns. Again, recall that the binary counter also serves as

continued on page 186

Ring Around the Rosy

To visualize how a ring oscillator works, imagine you have some people standing in a circle holding hands. Each person will try to raise his or her left hand if the right hand is lowered, and vice versa. If you have two people holding hands, then one person will raise one hand and the other will lower one hand; after this point, the system stops (this is actually how many basic memory cells are built, using a pair of inverters tied together in a loop).

However, if you had three people in such a ring, and each of them were to try and raise their hands in opposing polarities, you would find that there is no steady state: hands will go up and down at roughly three times the rate it takes for a single person to raise or lower his or her hand. Thus, for every loop with an odd number of people, you will encounter a resonance or oscillatory effect, and the period of the oscillation around the loop increases as you add more people to the ring.

In circuits, we build such rings out of long chains of inverters to make a quick and dirty frequency source. Such frequency sources are far from stable or ideal because the rate at which an inverter can switch depends upon the temperature, voltage, and particular structural defects within that inverter.

Make: 37

References:

Archives