Electronics > Beginners
Random Seed using Micro controller floating pin
Unordung:
Hello,
I recently created a simple project (electronic dice) which required a random function using the Arduino development platform. In this project I opted to use the random function with an analog Read as the seed.
Previously I had discovered that using this function I would consistently get higher numbers on the output of the function (once I created a box plot of the data).
To counter this I created a PCB based Antenna which in theory would amplify random noise and in turn provide a more random output.
Once I tested the results and created a histogram the results, did indeed seem to level out with no statistical outlier.
My question is, am I insane or did I get lucky?
The more I think about this the more confused I get. The floating pin is an antenna, it will naturally change its voltage in relation to the background noise. My thought process seems too simple, the bigger pin means bigger variation. Whilst it seemed to work and indeed created a more even histogram, I'm not entirely sure as to why.
To create a PCB antenna, is simply lengthening the trace enough to create a greater variation of noise on the pin?
Is there a more dare I say, "professional" / mature way to approach this using the Arduino platform?
Wouldn't the length of the PCB antenna translate to the frequency being amplified?
Given the frequency of Australian AC, would it make sense to "tune" the antenna to match the 50Hz frequency?
Kind regards,
Unordung
BrianHG:
I would bias an analog input to 50% vcc and run the adc, summing up the noise in the least 2 significant bits, no antenna. After accumulating noise from a few k samples, use that number to feed your random number generator.
Psi:
Another way is to combine all the random things you can find on your MCU,
Temp sensor
Floating ADC
ADC of supply rail
ADC of any extra bandgap references
Then store a large array of true random numbers in code/flash/eeprom and use above method to pick the number of positions to increment through the block by each time you need a random number.
This will mask any non-randomness in the floating adc/hardware system which can sometimes pick similar numbers.
But keep in mind the only values it will ever output are numbers in your array. So the array really needs to contain all numbers in the range require unless extra methods are done.
Rerouter:
Shift your biases, the internal RC clock of an arduino is generally about 1-5% accurate, so you can use the beat frequency between it and the external crystal to make something very hard to externally influence.
https://sites.google.com/site/astudyofentropy/project-definition/timer-jitter-entropy-sources/entropy-library/arduino-random-seed
soldar:
One of my first projects decades ago was an electronic dice. You put your finger on a pad and you were the antenna collecting random noise. As long as your finger was on the contact the internal counter was counting, when you took off your finger the counter would stop.
A standard way of generating random numbers is by using white noise generated with a reverse biased transistor emitter.
Navigation
[0] Message Index
[#] Next page
Go to full version