- Published: Saturday, 04 April 2009
- Written by Digital DIY
- Hits: 5503
Download the module: RandGen
This module implements a simple modulo-based PSEUDO Random Number Generator for Swordfish Basic. It's difficult to generate true random numbers from a deterministic machine like PIC. Hopefully, some mathematical methods let us have a series of numbers that seems really random, although they have all a fixed cycle upon which they restart to give the same series of values. this is why they are all called Pseudo random number generators. The cycling behaviour has the advantage to give you the possibility to repeat the same experience despite the fact that it's based on (pseudo) random numbers.
Call the RandGen.Initialize(pInitialValue) one time with the initial value (value read from an analogue floating PIC pin for example).
Call the RandGen.Rand() function to get a new random value.
The following program gives an example on how to use the pseudo-random number generator;
Written by Ahmed Lazreg (octal). A simple Pseudo Random Number Generator module (modulo based).