Random number seed


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Jan 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Random number seed

    Actually the if statements work fine, but I like adding the "Else" statements and "EndIf"s to clean up the code (Thank you Sazer). and comments to clarify the logic behind my code. My real issue is the way the code is now, my code always provides the same sequence of numbers on start up. I need it to be different each time at startup as well as any other time it basically is supposed to randomly flash 1 of 5 different LEDs - 5 times and then stop and wait for B.7 to go high and then star again. So how can I randomly add a seed to the very first iteration of this process. I read some where that you can pull a value from TMRO, so it will give you an initial seed of 0 to 255. Any thoughts?
    Last edited by kwelna; - 24th January 2007 at 04:08.

  2. #2
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Default

    Hi, Kwelna

    Just keep the last value before switching off in EEPROM ... as a new seed !!!

    Alain
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  3. #3
    Join Date
    Jan 2007
    Posts
    8


    Did you find this post helpful? Yes | No

    Default Random seed

    Duh!!! So simple I never would have thought of it.........well maybe in a week or two.... I am alwqys looking for a more complicated method. that is what happens when you get old!

    Thanks again

    Kevin

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by kwelna
    that is what happens when you get old!
    Imagine when you'll be as old as i am

    You could still use an hardware solution... count pulses at the output of a white (even pink) noise generator... now it's going to be really random. Always a long debate around this....
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,653


    Did you find this post helpful? Yes | No

    Talking Stone age survivors ???

    Hi, Steve

    You were talking about the MM 5837 ... I suppose ???

    The only one corresponding to your age LOL !!!


    Hi, Kevin

    << I am alwqys looking for a more complicated method. that is what happens when you get old! >>

    Here, you're only talking about yourself ...

    Ah, Will you have a look here ???

    http://www.manhattancontrols.com/for...932b79b20ee1c5



    Alain
    Last edited by Acetronics2; - 1st February 2007 at 11:38.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  6. #6
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Acetronics View Post
    Hi, Steve

    You were talking about the MM 5837 ... I suppose ???

    The only one corresponding to your age LOL !!!
    LMAO! well could also be a simple op-amp (maybe dual), cmos gate etc etc. no need for a dedicated IC. Maybe PBP SOUND could do the job.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Random Numbers
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 18th December 2008, 09:47
  2. Random seed using the ds1307 RTC
    By rookie11 in forum General
    Replies: 7
    Last Post: - 25th November 2007, 21:31
  3. Working with the random number generator
    By kwelna in forum mel PIC BASIC
    Replies: 9
    Last Post: - 16th January 2007, 18:50
  4. Random number results
    By bartman in forum mel PIC BASIC
    Replies: 3
    Last Post: - 9th March 2005, 18:39
  5. more random number questions
    By bartman in forum mel PIC BASIC
    Replies: 1
    Last Post: - 14th November 2004, 18:55

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