On Wed, 14 May 1997, John Payson wrote: > > At 17:17 13/05/97 +0000, you wrote: > > >I need a routine that returns a random number to implement something similar > > >to CSDMA/CD. I need it to make a random wait time after a collision, i've > > >seem some routines but how do i get different seeds to inicialize the > > >routine ? > > > > Hello, > > I've found that performing a XOR operation with all the un-inisialized > > values of the user RAM at startup (in the PIC16C84), you get a good random > > seed. > > Yes, but if two PICs happen to XOR to the same value you're sunk. Even > using a 2-byte XOR of user RAM is no guarantee of safety; depending upon > the characteristics of the chips you may find that certain chips tend > toward the same stuff. For a CSDMA/CD application, that would be a > killer. > I think i found a solution to make a random seed generator, at least one to solve this problem. It's something like this: Vdd | - -------- The function will work like this: | | | PIC | | | 1. Pin R (output) = 0 - | 2. Pin R (input) | | 3. Start counter +--------| R 4. While R == 0 increment counter | | 5. Stop counter ----- | 6. Return counter ----- | | We only need to use some very cheap components ----- (with big tolerances) to get a fair random seed generator :-). Antonio Almeida