how
do you make a machine unpredictable?
this is a good question because anyone who's worked with electronics
knows that the devices are generally designed to produce precise intervals.
there's more to dancing than just counting.
this machine has a circle of 16 leds driven by a one-of-sixteen
decoder, fed by a four bit binary up/down counter. when the counter is
clocked, the lighted led appears to move around the circle in the direction
determined by the state of the up/down line:
i wanted the led to appear to 'search' the perimeter of the
jar, in an unpredictable, arhythmic, back-and-forth motion. what i needed
was a 4-bit binary number that could be pre-loaded into the counter
to give a visually random count each time the led reversed direction (count
up 6, count down three,count up 14,...etc.). the answer was a circuit described
in don lancaster's cmos
cookbook. it's a psuedorandom sequence generator:
this is simply a four-stage shift register with a data input
that is an xor function of the two most significant bits. note that
an all-zero state is disallowed. it produces a sequence of fifteen
numbers that are visually unpredictable, even though they repeat every
fifteen clock cycles. i enhanced the effect by including an audio pickup
and circuitry to change the starting point.
this was 1977, and my home made cp/m computer was running
well enough to tempt me to test the feedback connections in software. the
xor function in the above diagram looked like a parity check on those two
bits, so i guessed that the following z80 assembly language routine would
generate some interesting sequences:
ld a,(mask) ;load the accumulator with a mask
variable
or (hl) ;logical or the
mask with the virtual shift register
jp pe,noset ;if the parity of the result is even
scf
;shift a zero into the register
noset: rr (hl)
;else shift a one
ret
;return with the new number in (hl)
the routine was used in many loops over the next few days
and became really rich when i found that any logical operation would produce
weird sequences. it became richer yet when the routine was put into a loop
that would print out the results in various ways.
this printout, for example, shows that a seed (hl) of 10000000b
and a mask of 0000001b will produce a sequence that is eight bytes long
before it begins to repeat. the whole printout is 256 lines and tests all
combinations of seeds and masks to give a maximal length for each combination.
other printouts sorted the lines by maximal length and satisfied my need
to know that i had a source for interesting visual sequences. it is important
to remember that every configuration of the routine will have one disallowed
state.
this circuit is a hard-wired version of the routine. it continuously
plots sequences, at various plotting speeds, changing the mask upon sensing
a sound. in this case, an and logical operation is used. click on it to
zoom.
if you've got it in you to wire up a 16x16 matrix of leds,
the following circuitry will display its output.
i am aware that this is probably the re-invention of some wheel. if
you have seen anything similar in the literature, please send me a note.