Random generator

Droopy
Benutzer
Avatar
Gender:
Age: 58
Posts: 24
Registered: 01 / 2016
Subject:

Random generator

 · 
Posted: 30.10.2016 - 00:35  ·  #1
Hello all,

I've some problems with the FillRandom function on the Xmega256A3U.
It is always given the same random bytes...

I added following to my program:
from System import Processes, Tasks, Pipes, Longint, Float, Random;

type tCode = array[0..5]of byte;
var Code : tCode;

FillRandom(@Code,SizeOf(Code));

If I look with the simulator (but also in the project with the xmega) the results of 'Code' are 6 random bytes. So far so good. But every time I run the program, it are the same 6 bytes.
I also tried to add the function RandomSeed($1234) before it. This will give 6 other random bytes but also this time they never change when I re-run the program.

I would expect to have every time other bytes? What is it I do wrong :dontknow:

Thanks a lot for some helping;)
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: Random generator

 · 
Posted: 30.10.2016 - 13:06  ·  #2
Hello Droopy,

we do not have a real random source (hardware) in the AVRs.
The numbers are calculated...
For real random numbers an external source is required.
Some use a "bad" Diode which produces heavy noises (popcorn).
Search in Google. For example search for "random diode".

rolf
Droopy
Benutzer
Avatar
Gender:
Age: 58
Posts: 24
Registered: 01 / 2016
Subject:

Re: Random generator

 · 
Posted: 30.10.2016 - 20:51  ·  #3
Ok, thanks, I understand it. It's a pseudo random generator that needs a seeder. I was first thinking it was something as 'passed tick counts till' or somthing like that ;)
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   66   80 · Page-Gen-Time: 0.043882s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI