[sdiy] AVR/ARDUINO psuedo random noise?
dan snazelle
subjectivity at hotmail.com
Wed Feb 16 18:35:12 CET 2011
On Feb 16, 2011, at 11:46 AM, Magnus Danielson wrote:
> 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
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at dropmix.xs4all.nl
> http://dropmix.xs4all.nl/mailman/listinfo/synth-diy
>
XOR The output but backwards? not quite sure what you mean. I will go try this out!
thanks
More information about the Synth-diy
mailing list