We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
MCBXC167-Net Evaluation Board with C166 Compiler: Does anyone know how to create random numbers (0-1023)?
hi there are a lot of algorhithms available to calculate random numbers. I recommend the book: "NUMERICAL RECIPES in C"; Press, Teukolsky, Vetterling, Flannery; Cambridge University Press; ISBN 0 521 43108 5 There are a lot of complete program examples included. CD is available too. A little bit theoretical book but for me a must have book. Bye ...Leo
"there are a lot of algorhithms available to calculate (sic) random numbers" Note that "calculate" and "random" are mutually exclusive! Software algorithms are inherently deterministic and therefore can only ever give you pseudo-random numbers - as Erik has already pointed out. Graham Cole recently posted an LFSR-based pseudo-random number generator for C51: http://www.keil.com/forum/docs/thread3202.asp (It seems that Keil have incorporated this concept in C51 v7.08: http://www.keil.com/update/_docs/releasenotes/c51v708.htm) If you want true randomness, you will need to use some external, truly-random process - such as electrical noise, or the user pressing a button.
You can find a more detailed version of my LFSR pseudo-random number generator here: http://www.programmersheaven.com/zone5/cat27/32219.htm It comes with some supporting notes and a couple of interesting links. Although my code is aimed at 8051 family processors, the principles are quite general.