random problem


Closed Thread
Results 1 to 6 of 6

Thread: random problem

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Location
    USA, CA
    Posts
    271


    Did you find this post helpful? Yes | No

    Default

    If you read the section on Random, you will see that your output variable is also used as the seed. Try to use Random Time instead of Random Temp. That way your seed is changed after each use. In your code Temp is unnecessary anyway.

  2. #2
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    I'm not so sure about that, if I use time as my seed it will always be smaller then 2730, (time / 24) Will this not affect the output of the random generator?
    i.e. does the seed need to be a 16 bit number or not?

  3. #3
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    Okay, I did a little test:
    If I try this code:

    Code:
    loop:
         random temp
         toggle LED
         pause temp >> 8
    goto loop
    My LED flashes in a very nicely random way.

    If I try this code:

    Code:
    loop:
         random temp
         temp = temp >> 8
         toggle LED
         pause temp
    goto loop
    Then it does not flash in a nicely random way.
    So... the seed must not be modified.
    But anyway this still does not explain why my morse code flasher doesn't work. Unfortunately I do not have the circuit at hand (it's in Paris now) so have to probably build a second one to really test.
    Last edited by eggman; - 21st May 2009 at 20:27.

  4. #4
    Join Date
    Dec 2005
    Location
    So Cal and loving it
    Posts
    40


    Did you find this post helpful? Yes | No

    Default

    What about using your adcin 'audio' value as the seed - it seems like it should give you some randomness.
    +-------------------------------------------------------------------+
    | PBP 2.47/2.50 | MCS+ 3.0.0.5 | U2 Prog | Vista x64 | NO SLEEP!!!!!!! |
    +-------------------------------------------------------------------+

  5. #5
    Join Date
    Oct 2007
    Location
    The Netherlands
    Posts
    45


    Did you find this post helpful? Yes | No

    Default

    Hmm that's a good idea, will try, thanks

Similar Threads

  1. Random Numbers
    By BobEdge in forum mel PIC BASIC Pro
    Replies: 12
    Last Post: - 18th December 2008, 08:47
  2. USART Problem , but don't know where, in pc? or in PIC?
    By precision in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 15th July 2007, 08:12
  3. Another Serin/Serout Problem!
    By jmbanales21485 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 7th June 2007, 16:26
  4. 1 slave 1 master 1 MAX232 1 problem ?
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 31st July 2005, 22:59
  5. 6 random numbers limiting to 49 ?????
    By SuB-ZeRo in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th June 2005, 23:27

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