> I find the old lib from Wouter is better since it creates a > new start > random number each time the PIC is reset.
That's interesting, I have to have a look at it... For the PIC is a deterministic system, and it should therefore be impossible to generate real random numbers. You could, for example, count all the "1" bits in the ram space. The ram has no default values on startup, perhaps there are some bits that initialize sometimes to 0 and sometimes to 1. Or, there can be some data left from the last run. You could regularly save a random seed in flash memory. If the flash call wears off it's not too bad as it's random anyway, you *want* the bits to change... Otherwise, to get (almost) real random numbers, you'll have to use some "real world" parts. A cheap and easy thing could be a, say, 10uF electrolytic capacitor on a schmitt-trigger input. Output a "0" to the capacitor to discharge it, then activate the weak pullup, and count the instruction cycles until the input becomes a "1" again. It should take about 0.2 to 1.6 sec. Let the timer overflow a hundred times, the more the better. When you're stopping the timer once the pin reads "1", you'll have a nearly-random number in the counter. Use this number as random seed, and you'll have random numbers as good as the random function can give. There are books about how to judge the quality of random numbers... The procedure described above depends not only on the temperature, supply voltage magnitude and ripple, humidity, time since last use, age of the micro and the capacitor, surroundings of the circuit, radio interference... The charging time will always be similar for specific components, but it is unlikely that it will be the same to the millisecond (or the microsecond, if running at high speed). Other possible entropy sources: noise generators (a noisy op-amp may suffice) antennas internet packets radioactive decay single photons reflected (or not) by a beam-splitter Some are easy to use, others not... ;-) Greets, Kiste -- You received this message because you are subscribed to the Google Groups "jallib" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/jallib?hl=en.
