Results 1 to 9 of 9

Thread: Microcontrollers

  1. #1
    The King of Vague Steve B's Avatar
    Join Date
    Oct 2005
    Location
    Glasgow
    Posts
    5,051
    Thanks
    116
    Thanked
    67 times in 63 posts

    Microcontrollers

    Anyone here familiar with microcontrollers?
    I'm coding up a program for an M16C, which doesn't have a temperature sensor onboard.
    I'm required to create a random number generator, but as i have no timing capabilities, or no temperature sensor, i can't think of any way to pull a seed for the rand() function.

    Anyone shed any light on this?

  2. #2
    root Member DanceswithUnix's Avatar
    Join Date
    Jan 2006
    Location
    In the middle of a core dump
    Posts
    9,728
    Thanks
    479
    Thanked
    995 times in 847 posts
    • DanceswithUnix's system
      • Motherboard:
      • Asus X470-PRO
      • CPU:
      • 2600X
      • Memory:
      • 16GB 3200MHz
      • Storage:
      • 1TB Linux, 1TB Games (Win 10)
      • Graphics card(s):
      • Asus Strix RX Vega 56
      • PSU:
      • 650W Corsair TX
      • Case:
      • Antec 300
      • Operating System:
      • Fedora 28 + Win 10 Pro 64 (yuk)
      • Monitor(s):
      • Benq XL2730Z 1440p + Samsung 2343BW 2048x1152
      • Internet:
      • Zen 80Mb/20Mb VDSL
    Ideally you want to sample a noise source on an AtoD as that has known biasses (so not totally random) but is rather cheap.

    How random do you need it? To security standards is Dead Hard.

    If it is for user interaction of some sort then throwing away generated random numbers whilst waiting for a keypress can make it hard to predict the sequence even given the start value.

    Look at the design and tot up any environmentally influenced inputs you might have.

  3. #3
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    10,958
    Thanks
    987
    Thanked
    940 times in 700 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    Doesn't it have a clock generator you can use?
    Generally speaking the more sources you can seed from the better.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  4. #4
    The King of Vague Steve B's Avatar
    Join Date
    Oct 2005
    Location
    Glasgow
    Posts
    5,051
    Thanks
    116
    Thanked
    67 times in 63 posts
    Its for a game of Simon (the one with 4 coloured lights and you have to follow the sequence)

    So i need to produce 3 arrays of random numbers, 20,40 and 60 integers in length, depending on difficulty level set.

    The arrays are initialised before the game is started, which is where i have the problem with my non-existant seed value. Every time I ran the program on the M16, it produced the same array.

    I've thought about using the ADC register, but dont know how to access it I'm also considering using an external analogue influence, like the temperature sensor.

    Cheers for the input chaps
    Last edited by Steve B; 09-03-2007 at 06:25 PM.

  5. #5
    The King of Vague Steve B's Avatar
    Join Date
    Oct 2005
    Location
    Glasgow
    Posts
    5,051
    Thanks
    116
    Thanked
    67 times in 63 posts
    Quote Originally Posted by aidanjt View Post
    Doesn't it have a clock generator you can use?
    Generally speaking the more sources you can seed from the better.
    theres no timing on it at all, except for the timers that we initialise when the software is run. Hence, the array is executed at the same time every time, and the time seed is the same

  6. #6
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    10,958
    Thanks
    987
    Thanked
    940 times in 700 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    Quote Originally Posted by Steve B View Post
    theres no timing on it at all, except for the timers that we initialise when the software is run. Hence, the array is executed at the same time every time, and the time seed is the same
    Well bugger :/

    If you wanted to go the ADC register route, you could inline some assembly to access the register and assign it's value to your programs own register, nifty thing about inlining assembly is you don't need to worry about which register is yours, you just use the variable name you want to use and the compiler deals with the messy bits. I've never used the M16 before, so I can't be very specific, just tossing out some ideas that are generally relevant.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  7. #7
    The King of Vague Steve B's Avatar
    Join Date
    Oct 2005
    Location
    Glasgow
    Posts
    5,051
    Thanks
    116
    Thanked
    67 times in 63 posts
    i think i've stumbled across potentially the most efficient method:

    1) Program Instantiation - Start
    2) Activate Timer - every 5ms: i++
    3) Wait for user to select options, choose difficulty level, e.g. 2 and push button.
    4) Timer value used as seed

  8. #8
    Gentoo Ricer
    Join Date
    Jan 2005
    Location
    Galway
    Posts
    10,958
    Thanks
    987
    Thanked
    940 times in 700 posts
    • aidanjt's system
      • Motherboard:
      • Asus Strix Z370-G
      • CPU:
      • Intel i7-8700K
      • Memory:
      • 2x8GB Corsiar LPX 3000C15
      • Storage:
      • 500GB Samsung 960 EVO
      • Graphics card(s):
      • EVGA GTX 970 SC ACX 2.0
      • PSU:
      • EVGA G3 750W
      • Case:
      • Fractal Design Define C Mini
      • Operating System:
      • Windows 10 Pro
      • Monitor(s):
      • Asus MG279Q
      • Internet:
      • 240mbps Virgin Cable
    Ohhh, that'd work, simple, generic, relies on totally random user input.
    Quote Originally Posted by Agent View Post
    ...every time Creative bring out a new card range their advertising makes it sound like they have discovered a way to insert a thousand Chuck Norris super dwarfs in your ears...

  9. #9
    The King of Vague Steve B's Avatar
    Join Date
    Oct 2005
    Location
    Glasgow
    Posts
    5,051
    Thanks
    116
    Thanked
    67 times in 63 posts
    i know, i was rather pleased with myself

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Microcontrollers...
    By bsodmike in forum General Discussion
    Replies: 0
    Last Post: 13-07-2006, 06:32 AM

Posting Permissions

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