Random generator

Droopy
Benutzer
Avatar
Geschlecht:
Alter: 59
Beiträge: 24
Dabei seit: 01 / 2016
Betreff:

Random generator

 · 
Gepostet: 30.10.2016 - 00:35 Uhr  ·  #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
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: Random generator

 · 
Gepostet: 30.10.2016 - 13:06 Uhr  ·  #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
Geschlecht:
Alter: 59
Beiträge: 24
Dabei seit: 01 / 2016
Betreff:

Re: Random generator

 · 
Gepostet: 30.10.2016 - 20:51 Uhr  ·  #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 ;)
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 8 · Cache Hits: 14   67   81 · Page-Gen-Time: 0.015193s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI