"Un-initialized" does not mean random. It means the value is not defined by the spec. The value may be consistent for a production lot of chips though. Racing your own RC osc against the watchdog's RC should produce a good random number. Sherpa Doug > -----Original Message----- > From: Tony Pan [mailto:weidong.pan@VERIZON.NET] > Sent: Tuesday, August 21, 2001 10:51 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [PIC]: Generating a "truly" random number on the > application of power > > > Thanks Frank. > > >>>> Using TMR0 is ok when using RC oscillator. Don't use > TMR0 in crystal > operation. > > Why? > > In addition, some advised me to let the WDT time-out for the > first time > after power then get the TMR0. When I think about it, since > the TMR0 is > un-initialized upon powerup, is it really necessary to go > through the WDT > time-out? > > Tony > > ----- Original Message ----- > From: "Wollenberg, Frank" > To: > Sent: Tuesday, August 21, 2001 10:21 AM > Subject: Re: [PIC]: Generating a "truly" random number on the > application of > power > > > > Tony Pan wrote: > > > > > Our products are used in motel environments to control ACs. > > > The reason we > > > need to stagger the startup is that if we don't, in case of > > > power loss and > > > resume, all the AC will start at the same time and that > will cause a > > > problem. As you know each board is situated in its room > and working > > > independently so there is no way one board knows what the > > > other's doing. > > > > AC will start on power-resume AND power-on.. > > > > > In my hardware we use RC oscillator. Now I use the initial > > > TMR0 value upon > > > powerup to get a random number. I also add the initial values > > > of FSR, ADRES, > > > PORTB and some ADC reads of the board into the number. I > > > guess that would > > > give me nearly "unique" number for each board. I then use the > > > last few bits > > > of this number to determine the startup time. > > > > Using TMR0 is ok when using RC oscillator. Don't use TMR0 in crystal > > operation. > > FSR and ADRES are uninit on powerup, but i think they won't differ, > > especially if the PIC's are from the same silizium. > > PORTB must be input, but because of the identical hardware, > the values > > should be identical. > > Reading a voltage divider with ADC is OK. Use carbon > resistors (20%). Try > to > > not meet the acquisition time, the Chold is varying from > chip to chip. > Also > > you can use an external reference voltage from a voltage divider > (carbon!). > > > > Compute this value ONLY on first powerup and use it as a > initial seed > value > > of a random generator (hint: in C: persistent). Compute a > random number as > a > > delay time after power becomes OK. > > > > > I haven't got the chance to test it yet. For we have > other features to > > > implement at the moment. If you see any potential > problems with this > > > approach, please let me know. > > > > It is possible to compute identical delay times, but the > possibility is > very > > small. > > Another approach is to use a "digital ID chip" from DALLAS (DS2401 i > think). > > This number IS unique !!! > > > > Frank > > -------------------------------------- > > GSP Sprachtechnologie GmbH > > Frank Wollenberg > > HW-Entwicklung > > Tel.: +49 (0)30 769929-78 > > Fax: +49 (0)30 769929-12 > > eMail: f.wollenberg@gsp-berlin.de > > > > > > -- > > GSP Sprachtechnologie GmbH > > Teltowkanalstr.1, D-12247 Berlin > > Tel.: +49 (0)30 769929-0 > > Fax: +49 (0)30 769929-12 > > eMail: Info@gsp-berlin.de > > Web: http://www.gsp-berlin.de > > > > -- > > http://www.piclist.com hint: The list server can filter out > subtopics > > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > > > > -- > http://www.piclist.com hint: The list server can filter out subtopics > (like ads or off topics) for you. See http://www.piclist.com/#topics > > > -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics