random animatronics servo driver. 1000-2000 & 450-2450 microsecond pulse width range, for the MG995 and 9g servos respectively. It has two simultaneously generated outputs for each one. So you could control 4 servos with one chip.
Comes in an 18-pin DIP chip with pin spacing of 0.1 inch between pins. I also will include a 6 MHz crystal, and 2 capacitors for it to use as a steady timebase. Click the "click to enlarge" picture to the right and use the arrow keys to scroll to the right and look at the second picture for the wiring pinout.
Click here to see a video demonstration of this device controlling 4 servos at once (be sure to have a pop-up blocker so mediafire doesn't load an ad with something nasty). All servos shown are in operation mode 4 (explained below). Eyeballs not included. Also circuit board and wiring not included. You get the microcontroller and the 6 MHz crystal and 2 15 pF capacitors and wiring diagram and that is all. But I really, really want to end this paragraph with the sentence "eyeballs not included" so I'll say it again. Eyeballs not included.
Generates 4 functionally independent outputs. 2 are designed for the MG995 servo with a pulse width range of 1 to 2 milliseconds, and 2 are designed for the 9g servo with a pulse width range of 450 to 2450 microseconds, all 4 are positive pulse type, and with 20 milliseconds between pulses (50 pulses per second - precisely 20 milliseconds from the start of one pulse to the start of the next - the end-times of the pulses are adjusted each cycle). All random numbers are generated internally using an 80-bit linear feedback shift register based on a degree-80 irreducible polynomial, and as it updates 50 times per second, it will take 766 trillion years to repeat (and even then the positions of the 4 servos will be different from their starting positions so it still won't repeat). But just to make it really random, it is also randomized any time you change the state of one of its input switches (the 8 inputs that control pause time and movement type). The output pulse widths are adjusted in increments of two-thirds of a microsecond. Thus for the MG995 servo, it having a range of 1000 microseconds, can generate 1501 possible discrete pulse widths on that range, and for the 9g servo, having a range of 2000 microseconds, can generate 3001 possible discrete pulse widths on that range. Each one of the 4 outputs can independently (or connect them all together) be set to 4 modes, and each one behaves as follows:
Mode 1, servo pause time toggle, movement type toggle grounded:
commands the servo to pause for a randomly chosen amount of time, by a symmetric triangular probability distribution between 0 and 5 seconds, with a peak probability density at 2.5 seconds. Then it generates two points at random within the valid range of position for the servo, selects the one that is farther away and steadily heads for it at the correct speed so that it gets there in another randomly chosen length of time, this one randomly chosen between 2 seconds and 4 seconds, again with a symmetric triangular probability distribution, and peak probability density at 3 seconds. And then it repeats the cycle, pausing again, moving again, each time, the pause time and motion time different. In summary, each of the servo outputs tell the servo to pause for an average of 2.5 seconds (but as low as 0 or as much as 5), then to move toward a valid preset destination for at such a speed that it takes an average of 3 seconds to get there (but as low as 2 or as much as 4), and the process repeats.
Mode 2, servo pause time toggle +5 volts, movement type toggle grounded:
The same as Mode 1, but the countdown timer for the pause time is slowed down by a factor of 3. Thus the average time it pauses is not 2.5 seconds (having been a symmetric probability distribution between 0 and 5 seconds) but 7.5 seconds.
Mode 3, servo pause time toggle grounded, movement type toggle +5 volts:
Every 0 to 5 seconds, determined by a symmetric triangular probability distribution, the servo movement is halted (its speed is brought to 0). Its speed then follows a random walk. It slowly accelerates and decelerates in a random direction. It is bound by the limits of the range of position of the servo and so it stops if it reaches the edge (the pulse width is prevented from going outside the allowed range). The standard deviation of the drift is 144.3 microseconds change in pulse width / second^2. This is regardless of which servo output you are using - the MG995 outputs which are bound between 1000 and 2000 microseconds have a range of 1000 microseconds for their whole range in position, while the 9g outputs which are bound between 450 and 2450 microseconds have a range of 2000 microseconds for their whole range in position, so 144.3 microseconds change in pulse width / second^2 is more substantial to the MG995 outputs than the 9g outputs. Note, this is an acceleration-type unit, which is why there are seconds^2 in the denominator. In other words, the speed itself is what is experiencing the random walk, not the position. The rate at which the pulse width will be changing at that moment, after 1 second, which will be proportional to the servo's speed, will be on average 144.3 microseconds per second. Of course, there are 50 pulses per second, so that is 2.886 microseconds per pulse. A random walk is the integral of continuously sampled independent random variables (or if you will, a sum of discrete but very closely spaced independent random variables); this is the integral of a random walk. It may start out in one direction, slow down, and change directions. It will not however do this in a jittery fashion, because the velocity is a continuous function and so the position is a nice, smooth function with no cusps, and in fact since it is not truly a random walk with self-similar properties on every scale but a discrete approximation to one, it is a smooth function with no cusps and a second derivative that is quite limited in magnitude (and because the walk itself has a time limit of 5 seconds, its first derivative i.e. speed is also limited in magnitude, although it can in fact end up going faster than the speed limit of modes 1 and 2, but only if it's very lucky).
Mode 4, servo pause time toggle, movement type toggle +5 volts:
The same as mode 3, but with a standard deviation of drift one third as high; 48.1 microseconds change in pulse width / second^2.