At 18:31 07/03/97 EST, you wrote: >> From: Andrew Warren >> >> Tjaart van der Walt wrote: >> >> > Here's the easiest way. You can do it in hardware or software. >> > Although it is not *truly* random, it is quite good indeed : >> > >> > Take a shift register (the longer the better), and tap two or three >> > of the stages. Add the taps (discard the carry - it is the same as >> > XORing) and feed back into the input of the shift register. >> >> Tjaart: >> >> This only works well if you pick the CORRECT two or three taps... >> Just choosing an arbitrary pair is unlikely to give a reasonably-long >> sequence. >> >> There are a couple of linear-feedback shift-register routines on my >> web page... > >This is true, but getting off-track from the original request, which >was a way to determine a 'really random' seed value on power up. >With a deterministic machine such as a PIC, one must refer to some >'random' external event to initialise a shift register etc. otherwise >the machine will repeat the same sequence each time. > If you use a mathematical pseudo-random algorithm (as one of the other posters suggested) you simply store the seeds in EEPROM and update them after each use. That way each random number is simply the next in the sequence. A careful choice of original values should result in a sequence of good random numbers which are almost impossible to second-guess (unless you know both the algorithm and seeds). If you don't have EEPROM then the next best thing is waiting for a user interaction while counting microseconds mod 65536. This value is added to the seed for a pseudo-random number generator. If this is not suitable you might like to write some code which adds all the values of the RAM (mod 65536) and posts it to the PC, then triggers a power off circuit. Stuff the resulting data into a stats package (sorry I can't recommend one - not my speciality) and look for correlations. If you're _lucky_ this will be fairly random, but I don't know. When all else fails there's no substitute for trying it out and getting some real data. Keith. ========================================================== Keith Dowsett "Variables won't; constants aren't." E-mail: kdowsett@rpms.ac.uk WWW: http://kd.rpms.ac.uk/index.html