Bob Ammerman wrote: > > > PS. The preferred way to generate good psuedo random > > numbers is to generate numbers between 0 and 255 (for > > eaxample) and place in a 256 unit lookup table where > > there is only ONE of each number, but the postions > > are random. Then you can read 256 random numbers > > in sequence and have perfect weighting. > > This is really unneeded. > > A well designed PRNG (say one based on a shift register with feedback) _ > will, _by its very design_, generate every possible code in its range. > > Bob Ammerman Hi Bob, maybe I misunderstand you, but I still think the point was valid. If you generate a random number every time you update the pwm and the number is TRULY random it could be a disaster. You could generate the same number every time for an unknown amount of times. This is the real problem with truly random numbers. A psuedo random system (like I suggested) cannot generate the same number twice, nor can it generate the same number at all until all possible numbers have been read. This gives an equal weighting to all numbers IN ANY GIVEN TIME PERIOD which is never achieved with a true random number. A truly random system could generate any number at any time, it could generate the same number X times in a row and then not again for millions of generations. Very bad if it is controlling your pwm. :o) -Roman -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.