CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Random ID identification with PIC

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

Random ID identification with PIC
PostPosted: Fri Jul 27, 2007 2:46 am     Reply with quote

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
Ttelmah
Guest







PostPosted: Fri Jul 27, 2007 3:23 am     Reply with quote

_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'
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Fri Jul 27, 2007 8:04 am     Reply with quote

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.
Fabri



Joined: 22 Aug 2005
Posts: 275

View user's profile Send private message

PostPosted: Fri Jul 27, 2007 8:54 am     Reply with quote

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
Ttelmah
Guest







PostPosted: Fri Jul 27, 2007 10:08 am     Reply with quote

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... Smile

Best Wishes
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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