Currently the code has been simulated but not tested in hardware.
This project is based around the Atmel ATtiny13 8-bit AVR microcontroller. Digital noise circuits commonly are built using a shift register and a few gates which, together make up what is known as a Linear Feedback Shift Register (LFSR). A LFSR uses feedback in such a way that its binary value hits every possible combination except all 0’s or all 1’s depending on the type of LFSR. An example using the CD4006 shift-register is Ken Stone’s digital noise circuit. The CD4006 is not so easy to find and also has a large footprint. Using the tiny13, a simple and reliable white noise source, or an externally clocked digital noise source can be obtained. The following designs both use a 32-bit shift register and a microcontroller cpu clock of 4.8MHz.
- Self Clocked White Noise
- Externally Clocked LFSR
Self Clocked White Noise
A while back, I built a white noise source using the noisy characteristics of certain BJTs and a high gain amplifier (Opamp). While this works, I found that the voltage distribution was normally biased towards one side. I tried hundreds of transistors and none of them had a very uniform output. Another problem is that this type of noise does not provide a good control of the minimum and maximum output voltages. This became an issue when trying to use the noise source for a ‘chance’ control on another module. This need led me to a digital noise source, but most digital noise sources require several components.
The ATtiny13 digital noise source runs a loop consisting of 25 assembly instructions that make up the LFSR. Using a cpu clock of 4.8MHz, a new output is available at a rate of 192KHz. The repeat rate of the LFSR is a little over 6 hours. The output is taken from bit of the shift register and passed through a 2nd order low-pass filter. The filter also adds an offset and scales the ouput to +-5V. This design is well suited to drop into another circuit where a noise source is needed.
AVR Assembly: avr_lfsr-self_clocked.zip
Externally Clocked LFSR
The above design can be converted to an externally clocked design to fit in a modular system. The tiny13’s external interrupt pin becomes the shift clock and the LFSR algorithm is moved into the interrupt service routine. With the extra code required to handle the interrupt, maximum shift rate becomes 145KHz. By changing the cpu clock to 9.8MHz, the shift rate can reach 290KHz which will also reduce the shift clock -> output update latency from about 7us to about 3.5us.
The full digital noise module has an on-board VCO which acts as the default shift clock. An external input is also provided to allow clocks generated by other modules. Just as in Ken Stone’s design, I have added a few digital outputs tapped from the shift register and the feedback path. These digital outputs are useful for random events when the LFSR is run with a low shift clock.
AVR Assembly: avr_lfsr-external_clock.zip