Random outcome on multiple devices


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166

    Default Random outcome on multiple devices

    Hi All,

    I have read most of the forum posts regarding Random Number generation but can't find one that answers my particular question.
    I understand the random number sequence will be highly repeatable and predictable if using the same seed but what is the likelihood of the same random number being generated on two or more stand alone PIC's?
    For example, four PIC12F508's all running the same code and all turn on at the same time - would the outcome of a "RANDOM MyNumber" command likely to be the same for all four PIC's?

    A bit of background - I need to build an array of 32 pairs of LED's and set each pair to toggle at a different frequency. Each pair of LED's will be driven by its own PIC. I was hoping to be able to introduce a degree of randomness to the whole scheme rather than having to program each PIC differently to achieve an overall variation in flash rates between individual pairs.

    Comments and suggestions would be greatly appreciated.

    Cheers
    Barry
    VK2XBP

  2. #2
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Hi Barry, Greetings from Australia

    If you run the same program on all four pics the result will be the same.
    There is no math formula to produce a random number
    PicBasic will cycle through a finite set of numbers.

    If you can choose a seed, you could load each pic with a different seed.

    If any action depends on a user pressing a button you can time the button
    push, or count contact bounce, and add that result to a seed for a different seed each launch.

    Without any external input, I think you'd be needing to at least write
    something different to each on-board EEPROM,
    unless you can do something really tricky to detect noise in a power supply or some such thing.
    Cheers, Art.

  3. #3
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Hi Art,

    In what part of the "Land Down-Under" do you reside?
    I am in Sydney's southern suburbs.

    Thanks for the quick reply.
    Noise detection systems are overkill for this project. I was hoping that the power up sequence for individual devices would have provided some degree of variation.
    What if I used a timer based system to generate the seed and then de-tuned the internal oscillator between various devices to get some spread of variation - do you think that would work?
    Alternately, I could cascade a pulse from PIC to PIC and emulate a button push... just thinking out aloud here.

    Cheers
    Barry
    VK2XBP

  4. #4
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Close to Brisbane here

    There are always things you can try. Maybe PicBASIC's POT command.
    only instead of using a potentiometer, try a fixed value resistor,
    and maybe a reading with POT will vary enough with temperature
    (if you had to produce multiple units and keep firmware identical).

    Once with the Sony PSP I got random numbers by looking at the audio input

  5. #5
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,521


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Hi,
    It all depends on where you want to introduce the variation.... If you by "detune" the oscillator mean to tweak the OSCTUNE register slightly between devices then you might as well program in a different seed from the get-go - there will be a unique program in each device either way.

    Perhaps you can use something like the RCTime command with an external RC (duh...) network to generate the seed and rely on the tolerance of the R and the C to get the needed variance.

    /Henrik.

    EDIT: Art beat me to it while I was typing and doing some other things.

  6. #6
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    166


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Great suggestions guys - thank you.

    I will look at the POT/RCTime commands and choose wide tolerance components or random values to achieve the desired variation.

    Cheers
    Barry
    VK2XBP

  7. #7
    Join Date
    Aug 2003
    Posts
    985


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    I can't help thinking there would be some noise on the power you'd see with ADC.
    Interference between ADC pins has always been a problem...

Similar Threads

  1. Programming multiple pics with multiple programs
    By Luckyborg in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 3rd April 2013, 17:47
  2. Multiple I2c Devices
    By alphaengr in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th January 2012, 04:37
  3. Multiple serial devices to one pic
    By rshaver in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th October 2011, 15:34
  4. 12F683 ADcin = binary outcome!
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 5th March 2010, 04:42
  5. Self update of devices
    By Ioannis in forum General
    Replies: 17
    Last Post: - 24th December 2009, 17:49

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts