go_away

Author Topic: pseudo-random no. generator  (Read 1973 times)

0 Members and 1 Guest are viewing this topic.

Offline khurlanTopic starter

  • Beginner
  • *
  • Posts: 1
  • Helpful? 0
pseudo-random no. generator
« 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?

Offline Dr_Worm

  • Jr. Member
  • **
  • Posts: 19
  • Helpful? 0
Re: pseudo-random no. generator
« Reply #1 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/

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,659
  • Helpful? 169
    • Society of Robots
Re: pseudo-random no. generator
« Reply #2 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.

Offline hazzer123

  • Supreme Robot
  • *****
  • Posts: 460
  • Helpful? 3
Re: pseudo-random no. generator
« Reply #3 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
Imperial College Robotics Society
www.icrobotics.co.uk

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: pseudo-random no. generator
« Reply #4 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.....

 


Get Your Ad Here