[sdiy] LFSR digital noise source

Jay Schwichtenberg jschwich53 at comcast.net
Mon Nov 11 21:16:57 CET 2019


Very true while most transistors will work there can be a big difference 
between types (2N3904, 2N2222) and some difference between transistors 
of the same type. Some working better than others.

One thing on the CD4006 is that it is an 18 bit shift register so you 
will probably be getting a noticeable repeating pattern depending on the 
clock rate. Using a number of CD4015s to get a larger shift register and 
clocking it faster will give better results.

As far as taps go for different lengths of shift registers this is a 
good reference. Keep in mind these are XNOR gates.

https://www.xilinx.com/support/documentation/application_notes/xapp052.pdf

If you want to do reading on noise one of our gurus Bernie Hutchins has 
a lot of great information on his web site. Check out EN76 and AN402 for 
sure but if you want more info AN378, AN384, AN412 and AN415.

http://electronotes.netfirms.com/free.htm

If you want to implement a micro based LFSR it does not take much of a 
processor. All you need is a unit that has a timer to clock the LFSR , a 
bit or RAM, some flash memory and a 32 bit processor is nice but not 
mandatory. If you want to add options like filtering or DACs then you 
might need some more memory and peripherals.

Here's my go to code for a 32 bit LFSR which I run on 32 bit processors. 
If you have an 8 bit processor you may not need any changes, it depends 
on the compiler and libraries that are available for the chip. Think of 
the XOR option as being a form of even/odd parity and it makes things 
easier. For just a noise source I setup a timer interrupt that goes off 
at a fairly high rate (20KHz -> 100KHz) which outputs a bit and then 
calculates the next cycle. Notice that I output the bit first. That will 
give you more consistent timing then calculating which timing may very a 
small bit and then outputting. After that there is some form of analog 
filtering, typically F/5.

#define LFSR_BIT_32 (((uint32_t) 0x00000001) << 31)
#define LFSR_BIT_22 (((uint32_t) 0x00000001) << 21)
#define LFSR_BIT_02 (((uint32_t) 0x00000001) << 1)
#define LFSR_BIT_01 ((uint32_t) 0x00000001)

uint32_t lfsrCalcSum(
     uint32_t        lfsrValue
)
{
     register uint32_t   lfsrReturn;
     register uint32_t   sum;

     lfsrReturn = lfsrValue;

     sum = 0;

     if ( LFSR_BIT_32 & lfsrReturn ) sum++;
     if ( LFSR_BIT_22 & lfsrReturn ) sum++;
     if ( LFSR_BIT_02 & lfsrReturn ) sum++;
     if ( LFSR_BIT_01 & lfsrReturn ) sum++;

     lfsrReturn = (lfsrReturn << 1) | (sum & (uint32_t) 0x0000001);

     return( lfsrReturn );
}

Best wishes.
Jay S

On 11/11/2019 3:54 AM, René Schmitz wrote:
> Hi David,
>
> On 11.11.2019 08:38, David G Dixon wrote:
>> I've built quite a few analog white noise sources, and I've never 
>> selected
>> transistors, and they've always worked perfectly.  Not sure why.  Have I
>> just been lucky, or is it actually pretty idiot-proof?
>
> I would say, try out a few different transistors in the same circuit, 
> and see and hear for yourself. Yes, they will work. The definition of 
> "perfectly" may vary though. :)
>
> Best,
>  René
>
> -- 
> synth at schmitzbits.de
> http://schmitzbits.de
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at synth-diy.org
> http://synth-diy.org/mailman/listinfo/synth-diy



More information about the Synth-diy mailing list