Go Down

Topic: Random Seeds and Random Numbers (Read 10 times) previous topic - next topic

Graynomad

#15
Nov 04, 2011, 09:51 am Last Edit: Nov 04, 2011, 09:56 am by Graynomad Reason: 1
Yep there are methods that use diode-junction noise, presumably the signal has to be amplified but that's all a bit analog for me :)

As for the '04 oscillator, I really don't know, might work. Technically the oscillator and Arduino are still in sync but you don't need much of a change at 100MHz to get a different reading. Maybe if you feed the read value back into the oscillator to vary it just a tad. Say use the bit read as an output that is connected to the '04 through a 1M/10M resistor or some such.

Both these need external hardware though.

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

tim7

If non-deterministic randomness is needed as well as non-repeating randomness, you'll need a proper noise generator such as like this one from http://www.maxim-ic.com/app-notes/index.mvp/id/3469:


We don't need the higher frequencies (>10kHz), so filter them out before the first amplifier.  You don't have to use those particular amplifiers, any decent op-amp will do.   Connect the output to an analogue pin and ensure that the amplitude of the resulting waveform is much larger than the ADC resolution, but still comfortably within the ADC's input range.

To generate an n-bit random number: read the adc n-times (with a few ms pause between each read) and keep the LSBs of each readout.

Graynomad

My first thought was why use an LNA, then I read the posts on that appnote

Q: Why use a low-noise amp when you want nose?
A: Because nobody makes a high-noise amp.

Good point :)

______
Rob
Rob Gray aka the GRAYnomad www.robgray.com

baum

Something like this: http://robseward.com/misc/RNG2/ ?

maybe I'll take a look at that.

Coding Badly


I believe there is a minimum voltage (more than 5V) for the circuit to work correctly.  The author calls for a "12v DC Adapter".  The motivating design also calls for 12 volts.

There is no evaluation of the data quality.  Data that looks random is often not.  If you are building something that requires good quality data, you should perform the evaluation.  Given the references to "aging", occasionally reevaluating the quality may be necessary.

Quote
I suspect component (or board) aging was the culprit.

...indicates that the circuit may eventually become unreliable.

justjed




You don't have to use those particular amplifiers, any decent op-amp will do.


NE5532? (Any 5532?) :)
... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

GoForSmoke

Could you just tune in to an empty radio band and read the static?



I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

baum

Hmm... maybe just a length of wire, AC coupling cap, and an opamp + rectifier for static... but I think I'll just use the get-a-random-seed-from-random.org-and-store-next-seed-in-eeprom method. It should suffice for what I need.

But I may look into the radio idea...

Thanks a lot!

baum

Coding Badly

Quote
Could you just tune in to an empty radio band and read the static?


I believe that's the method used by random.org.

baum

Quote

Quote
Could you just tune in to an empty radio band and read the static?

I believe that's the method used by random.org.


I believe you are correct.

baum

Techone

Hum...  Using a radio band (AM-FM) is a good idea.  So I could build a simple AM radio (small DIY) tuning coil, with a fix small cap tune with a strong local station , amplify the audio, and get that audio signal into an analog pin of tha Arduino to get a value and use that value has a random seed.

Interesting...


GoForSmoke

I guess it doesn't matter if what you want is the noise. But it won't be as small or reliable as a cheap radio tuner chip. At least 1 with internal antenna.

I find it harder to express logic in English than in Code.
Sometimes an example says more than many times as many words.

justjed


If non-deterministic randomness is needed as well as non-repeating randomness, you'll need a proper noise generator such as like this one from http://www.maxim-ic.com/app-notes/index.mvp/id/3469:


We don't need the higher frequencies (>10kHz), so filter them out before the first amplifier.  You don't have to use those particular amplifiers, any decent op-amp will do.   Connect the output to an analogue pin and ensure that the amplitude of the resulting waveform is much larger than the ADC resolution, but still comfortably within the ADC's input range.


More questions about that. The input side looks like a 1st order high-pass filter with a cutoff freq. of 11MHz. So it seems like there won't be much signal left under 10kHz. Maybe a bandpass filter would be better there? And shouldn't there be a DC blocking cap between Vout and Vin? (see http://www.maxim-ic.com/datasheet/index.mvp/id/1521)
... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

tim7


More questions about that. The input side looks like a 1st order high-pass filter with a cutoff freq. of 11MHz. So it seems like there won't be much signal left under 10kHz. Maybe a bandpass filter would be better there?


On my first glance at the Maxim application note I thought the noise spectrum went down to low frequencies (fig 2).  Now I'm not so sure about the scale on that graph.  The input impedance of that amplifier chip is low: the data sheet implies 50 ohm, which would give a corner frequency of 6.8MHz on the input stage.

Since we're looking for much lower frequencies, a high input-impedance amplifier would be preferred.


justjed

You're implying (or, I'm inferring) that the input impedance affects the response characteristics of the filtration. That makes sense to me, as the cap and the impedance of the op-amp together resemble a high-pass filter. Can I analyze that as simply a low-pass filter, followed by a high-pass? IOW, treat them separately, using f=1/(2piRC)?

I decided to go ahead and breadboard this, using on-hand parts. Oddly, that doesn't include any zeners, or 470pF caps. So I got a 3.9V zener from the landlord, and sorta randomly selected capacitors.



This is a plot of the values on A0, measured every 1/2 second.



The values:
Code: [Select]
113 119 064 041 034 044 071 083 079 056 042 047 072 089 089 069 052 051 070 091
094 081 060 057 070 095 103 083 064 063 079 104 107 077 066 072 097 113 105 074
070 085 108 116 088 075 077 100 121 107 081 080 098 120 123 093 083 087 111 128
113 087 089 109 131 123 093 091 105 134 131 100 095 114 140 132 101 100 132 144
121 101 113 143 144 112 104 132 149 136 110 115 145 151 126 112 129 151 147 120
116 144 157 140 120 127 156 160 135 123 140 162 158 130 126 152 165 151 128 131
161 166 142 127 141 167 164 136 129 154 171 157 132 134 164 172 147 132 146 172
170 141 135 161 175 160 137 142 172 176 150 138 157 178 170 143 142 170 180 157
141 153 179 177 149 144 169 183 167 144 151 181 183 157 146 167 188 177 150 149
179 188 166 148 160 188 187 157 150 177 193 177 153 160 190 194 166 157 180 198
186 161 164 194 199 173 161 180 201 193 166 166 195 204 179 168 187 214 200 163
154 206 214 165 138 151 200 189 131 133 202 205 160 130 161 228 211 132 144 224
231 174 140 172 245 229 142 152 235 242 183 144 167 241 225 141 150 228 237 182
142 170 248 230 139 149 242 246 186 141 166 250 236 139 148 220 194 185 161 165
196 202 171 154 181 200 188 161 164 197 200 172 162 185 204 191 164 171 202 205
175 163 186 206 192 164 165 197 202 173 159 178 201 192 161 163 194 202 177 160
180 206 199 168 168 200 209 181 153 198 238 209

Code: [Select]

// Checking out reading white noise

void setup()
{
  Serial.begin(9600);          //  setup serial
  analogReference(DEFAULT);
  delay (1000); // give me time to turn on the power supply.
}

void loop () {

  Serial.println(analogRead(0));
  delay (500);
}



At this point, I can just let it run for a bit and see what happens, but I wouldn't mind some feedback before I do that.
... it is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier

Go Up