Hello,
I am trying to make a HRNG (Hardware random number generator) and I'm using avalanche breakdown noise as the source of my random noise: Link
Here is my circuit:
Image Link
In order to test the distribution, I'm sampling it with the Arduino (an Uno), however, my distribution is skewed. I don't think it's the fault of my noise generator, because according to my University's scope, it looks pretty good:
Image Link
The yellow signal is the noise at the collector-emitter junction, and the green is it amplified (At the output of the second op-amp) and biased around 4.5V as virtual ground. Since I took that scope capture, I have changed the gain of the amplifier to give me roughly 3Vpp as opposed to the indicated 105 mVpp, but the signal should look the same. I then pass it through a voltage divider so that the Arduino can read it (to push it down from a 0-9V range to a 0-5V range) and capture it at Analog Out. I then sample it and map it from 1-20 (since that's what I need eventually anyway). However, my distribution is skewed:
Image Link
It seems to be clumped on the high and low ends of the spectrum, with 20 not even being mapped to. Any ideas why this could be? What I really want to do is show the entire distribution (from 0 to 1023) but the Arduino can't hold an array that large. Also, after some testing, it seems that my noise only ranges from 140 to 890 on the ADC's scale, so that's what I've mapped them by.
Here is my code:
///A sketch to sample and display the reading at analog 0 to test the generation of random noise
#define inPin A0
int distribution1 [20];
int distribution2 [20];
long times = 0;
int mini = 500;
int maxi = 500;
void setup()
{
pinMode(inPin, INPUT);
Serial.begin(9600);
randomSeed(analogRead(1));
}
void loop()
{
while(!Serial.available())
{
int inputLevel = analogRead(inPin);
int mapped = map(inputLevel, 148,881,1,21);
distribution1[mapped - 1]++;
Serial.println(inputLevel
);
if(inputLevel > maxi)
maxi = inputLevel;
if(inputLevel