Random outcome on multiple devices


Closed Thread
Results 1 to 23 of 23

Hybrid View

  1. #1
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,612


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    As long as we stick to 8-bit PICs (which is what PBP supports) there's a quite a selection devices with 12bit ADC and two devices with 16bit ADC (18F8xJ72). All of them are enhanced 16F1xxx or 18F parts though, the smallest I could find thru a quick look is 28pin.

    /Henrik.

  2. #2
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Hi All,

    So much has happened in the last week or so...
    In typical fashion, the customer (my company on this occasion) has requested "additional functions" to be included which are above and beyond the original scope of work. The degree of modification has required a complete re-design.
    I won't bore you with the trivial details but the system now requires three separate LED flash sequences AND an auto function to scroll through the three stand-alone sequences.
    No - problems, just more time and code...

    I have now moved to a PIC16F1503. I would still like to use some sort of random number generation routine to achieve a random display flash rate between the thirty two individual PIC's without having to separately programming them. I could take the easy way out and do it manually but I like the idea of coming up with something eloquent

    Here is my thought:
    I can use my MeLabs programmer to generate a unique serial number for each PIC that I program. I understand this is a straight forward process. I would like to my program to read this unique serial number and use it as the seed for the random number generation source.

    Here is my question:
    Can is this concept be taken to a reality or am I barking up the wrong tree?

    Comments and suggestions greatly appreciated.

    Cheers
    Barry
    VK2XBP

  3. #3
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Well, the short answer is YES.

    The programmer can auto increment a serial number that gets programmed into Flash Memory.
    That value can be read back with READCODE.
    DT

  4. #4
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Quote Originally Posted by Aussie Barry View Post
    Here is my thought:
    I can use my MeLabs programmer to generate a unique serial number for each PIC that I program. I understand this is a straight forward process. I would like to my program to read this unique serial number and use it as the seed for the random number generation source.
    I think this would be the same as giving the PIC a fixed seed in the code. You might try a subprogram to save the last number used and then shutting it down. At startup have it read that value from eeprom.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  5. #5
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Quote Originally Posted by Archangel View Post
    I think this would be the same as giving the PIC a fixed seed in the code.
    Exactly!
    Using the U2's incrementing serial number ... Each PIC has a "Fixed Seed".
    But each of the 32 PICs are guaranteed to have a different seed, therefore a different blink pattern on power-up.

    They are all running the same sequence of 65535 pseudo random numbers, but they all start at a different point in that sequence.
    DT

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


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Thanks for the sanity check guys
    Glad to know I am on the right track.

    I should be able to sort out the serial number start and incremental values but I am curious to know the best place to store the information in flash memory.
    I will be totally honest - I am now working well beyond the limits of my knowledge base. A simple recommendation would be appreciated. A recommendation along with an explanation as to why would superb. I revel in every opportunity to learn something along the way.

    Please note: I have RTFM. Reading is one thing, comprehending is something altogether different.

    Cheers
    Barry
    VK2XBP

  7. #7
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    I would suggest putting it at the end of Program Memory.

    The 1503 has 2K words of flash, so two locations starting at 07FEh.
    It will store the lowbyte and highbyte separately.



    Code:
    Temp   VAR WORD
    Seed   VAR WORD
    
    READCODE $7FE, Temp
    Seed.LowByte = Temp.LowByte
    READCODE $7FF, Temp
    Seed.HighByte = Temp.LowByte
    I don't have access to a 1503 today, but I think it should work.
    DT

  8. #8
    Join Date
    Jan 2011
    Location
    Sydney, Australia
    Posts
    172


    Did you find this post helpful? Yes | No

    Default Re: Random outcome on multiple devices

    Legendary response Darrel - thank you!

    I will keep you posted with project milestones as they are reached.

    Cheers
    Barry
    VK2XBP

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 : 0

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