![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Fabri
Joined: 22 Aug 2005 Posts: 275
|
Random ID identification with PIC |
Posted: Fri Jul 27, 2007 2:46 am |
|
|
Hi to all,
I need to generate an random 16 bit number at the first startup of pic micro. Does it possible ? What is the right way to generate it really random ?
Thanks for suggestion,
Regards,
Fabri |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Fri Jul 27, 2007 3:23 am |
|
|
_True_ 'random' numbers are hard!.... This is why most systems use 'psuedo random numbers'. The point of these, is that they are easier to generate, and have similar statistical behaviour to a 'random,' number.
True 'random number' generators, use things like particles being generated by a radiation source, and are large/expensive...
Question is, what hardware you have present other than the PIC?. The compiler has the ability to generate a pseudo random number sequence, starting with a 'seed' value. If the seed is nicely variable, these numbers will fit most applications. The problem is how to generate a 'nice' seed. A typical solution, would be to seed the generator, from an external clock chip. On a given 'power on', the value in this, will depend on just when in the count cycle the unit has woken. Predicting the final value, after this number has been used to seed the pseudopseudo random number generator, will be very hard, making this ideal as a 'random' value, for most applications.
Best Wishes
The 'seed' function, is 'srand', and the number generator, is 'rand' |
|
![](templates/subSilver/images/spacer.gif) |
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Fri Jul 27, 2007 8:04 am |
|
|
I have seen an article that talks about a switch and a floating AD channel to get the magic SEED.
The switch is pressed by a person, and that tells when to sample the "noise"
on the AD channel.
or perhaps simplify this to just reading the noise at start up. |
|
![](templates/subSilver/images/spacer.gif) |
Fabri
Joined: 22 Aug 2005 Posts: 275
|
|
Posted: Fri Jul 27, 2007 8:54 am |
|
|
Hi,
By the way, I don't necessary have an unique ID but quite difference from other. In any case, I can realize to do manually pressing a combination of pushbutton for some second and then have, from counting counter, the SEED.
What are you thinking about this last idea ?
Regards,
Fabri |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Fri Jul 27, 2007 10:08 am |
|
|
Unfortunately, just reading the ADC, is likely to be more deterministic than is perhaps wanted. On a 'cold' boot, most of the ADC's return pretty fixed values if allowed to float.
One other idea, is to read the level of a signal derived from the mains. Given the noise on this, and the timing of switch on, the value is very unpredictable...
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|