[sdiy] AVR/ARDUINO psuedo random noise?
Magnus Danielson
magnus at rubidium.dyndns.org
Wed Feb 16 17:46:50 CET 2011
On 02/16/2011 04:18 PM, dan snazelle wrote:
> I am looking for advice or example code on how one might use the Arduino/AVR32 as really long shift register for digital noise.?
>
> i would think it could be done, using one input for clock and another input for data and using software XORS?
No input, but an output.
Here is a quick-hack which compiles but I haven't tested it:
#define NOISE 13
long state;
void setup ()
{
// Enable the noise output pin
pinMode (NOISE, OUTPUT);
// Init noise state
state = 1;
}
void loop ()
{
if (state >> 31)
{
state ^= 0x400003;
digitalWrite(NOISE, HIGH);
}
else
digitalWrite(NOISE, LOW);
state <<= 1;
}
Using the table entry for 32 bits in
http://home1.gte.net/res0658s/electronics/LFSRtaps.html
The trick here is to xor the output but backwards, which is an
alternative approach that can be used. I could have fluked the feedback
vector, so that may require trimming, but at least I show the code
principle.
Cheers,
Magnus
More information about the Synth-diy
mailing list