Society of Robots - Robot Forum

Software => Software => Topic started by: khurlan on January 10, 2008, 01:24:15 PM

Title: pseudo-random no. generator
Post 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?
Title: Re: pseudo-random no. generator
Post by: Dr_Worm on January 10, 2008, 02:51:02 PM
I'm not sure this will help you but its in C++ and is a PRNG -  http://www.bedaux.net/mtrand/
Title: Re: pseudo-random no. generator
Post by: Admin on January 10, 2008, 03:07:53 PM
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.
Title: Re: pseudo-random no. generator
Post by: hazzer123 on January 10, 2008, 04:25:51 PM
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)
Title: Re: pseudo-random no. generator
Post by: paulstreats on January 10, 2008, 06:57:34 PM
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.....