\ On Jan 8, 2011, at 1:39 PM, Chuck Hackett wrote: > This is mostly a "mind experiment" because I don't have a current need but, is there > a way to obtain a truly random (8-bit is good enough) number on an AVR? I'm not > talking "random" in the statistically pure sense, just non-deterministic. > > I'm only thinking of using it on startup. > > Sampling a "noisy diode" would be great but I want to do it without having to add > external hardware or dedicate an I/O pin to the effort. > > All I can think of is something like setting up one of the analog inputs as 'free > floating', turning the gain all the way up, and violating all the "how to avoid ADC > noise" rules and taking a sample. > > I don't think the timers would be helpful because these would tend to be > deterministic and, by nature, run in sync with any code that would be sampling them. > > I recently started a project to make electronic dice. I'm using the libc (pseudo) random number routine. I figured it would be could enough for my purposes provided I could come up with a random seed. I set up a timer to free run and I read it on the first press of the roll button and pass it as a seed to random number routine. A really fast counter with a human reaction time should provide a reasonably random seed. I can't use just the timer and button push for all my random numbers as I need several per roll (two die and multiple random die face appearances as they "roll"). A long time ago I setup a random number generator using three inverters in a loop. This makes for a very fast oscillator, as fast as the logic family can go pretty much. I fed this to an 8 bit counter connected to the CPU. It was not synchronized with the processor clock and was quite a bit faster. __ > > Clark Martin Redwood City, CA, USA Macintosh / Internet Consulting "I'm a designated driver on the Information Super Highway" [Non-text portions of this message have been removed]
Message
Re: [AVR-Chat] Random Number Generator
2011-01-08 by Clark Martin
Attachments
- No local attachments were found for this message.