Society of Robots - Robot Forum
Software => Software => Topic started by: khurlan on January 10, 2008, 01:24:15 PM
-
i'm a noob in PICs andi need to create a pseudo-random number generator using PICmicrocontroller. It actually works just like an LFSR.
I'm using PIC16F877A and MPLab IDE sofware. I'm also using the PICClite compiler. I nid a program in C .
Can anybody helpme with the source code?
-
I'm not sure this will help you but its in C++ and is a PRNG - http://www.bedaux.net/mtrand/
-
What about reading from a list of "random" numbers? this is the old fashion way of doing it . . .
You can also poll from the timer, analog port . . .
Or say multiply a number from the 'random list' by the timer, then divide by the analog port value, etc. to get a pseudo-random number.
If its on a robot that only needs a random number with response to an external event (button pushed, sensor detects something, etc), then using the timer value would be best.
-
Heres a tutorial with an idea for generating random numbers using the ADCs -
http://www.sparkfun.com/commerce/present.php?p=Sinister7 (http://www.sparkfun.com/commerce/present.php?p=Sinister7)
-
most systems on modern computers still just use the timer. They use the nano seconds at the capture time as a root.....
Random numbers exist as just random, you have to take a reading randomly from somewhere. Take the reading from a timer in ms us or ns and divide by an a/d reading etc.....