Author Topic: Floating input pin to induce randomness  (Read 11577 times)

0 Members and 1 Guest are viewing this topic.

Offline mimmus78

  • Supporter
  • ****
  • Posts: 676
  • Country: it
Re: Floating input pin to induce randomness
« Reply #25 on: December 11, 2013, 11:05:05 am »
24 bit ADC is better :-)
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Floating input pin to induce randomness
« Reply #26 on: December 11, 2013, 12:27:33 pm »
Quote
if the input pin picks up something...

This is where you completely missed the approach outlined earlier. The point isn't to adc anything - if you did that, you will have biasness in the output as pointed out to you by others.

The point, instead, is to utilize the inherent randomness in the adc module - even if you adc a fixed voltage, you don't get the same results - by picking up the lsb.

Again, for what you do, a pseudo random number generator wold work more than fine.
================================
https://dannyelectronics.wordpress.com/
 

Offline Kaptein QK

  • Regular Contributor
  • *
  • Posts: 82
Re: Floating input pin to induce randomness
« Reply #27 on: December 11, 2013, 12:58:56 pm »
I got a good result from the following method:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=45522

Only 4 resistors and one cap, and it is good enough for blinky lights and stuff like that.

 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Floating input pin to induce randomness
« Reply #28 on: December 11, 2013, 02:28:24 pm »
Two similar approaches, along the same vine of thoughts:

1) use the onboard low-power oscillator: better with rc but crystal oscillator works as well. Use it to gate the main oscillator and pick the lsb.

2) use two io pins, + a cap (to gnd) and a resistor (to vcc / or one io pin). Use one io pin to discharge the cap and another to read the voltage over the cap as it is being charged by Vcc / the other io pin. Once the 2nd io pin turns high (you can use external int on that pin), read a timer powered by the main oscillator, and then reset the timer and discharges the capacitor.

As RC oscillators are fairly unstable (both in frequency + phase), you get fairly good results.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Floating input pin to induce randomness
« Reply #29 on: December 11, 2013, 02:29:08 pm »
Just wanted to add that in the 2nd approach, you read the lsb as well.
================================
https://dannyelectronics.wordpress.com/
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1836
  • Country: ca
Re: Floating input pin to induce randomness
« Reply #30 on: December 11, 2013, 03:01:55 pm »
I like both those from dannyf.  #1 uses just internal oscillators and counters, so fewer external parts.  #2 is interesting, but I'd rather it use the RC oscillator as well. I'm actually going to try that one out myself.

...... and don't forget, no matter which method you use to get that lsb, thou shalt whiten it :)

at least use the von Neumann method, which doesn't guarantee any more randomness than the source, but will guarantee a bitstream without any bias.

This thread has been very interesting with all the different approaches suggested.
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Floating input pin to induce randomness
« Reply #31 on: December 11, 2013, 03:25:09 pm »
The 2nd approach is actually how (external) rc oscillators are implemented on most mcus.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyf

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Floating input pin to induce randomness
« Reply #32 on: December 11, 2013, 11:27:29 pm »
Quote
2) use two io pins, + a cap (to gnd) and a resistor (to vcc / or one io pin).

That is a more generic set-up.

On mcus where weak pull-up is available, you can actually save that resistor and use only one capacitor and use one io pin:

1) enable the weak pull-up on the io pin, set up the pin as output and output a low on that pin.
2) set up the rest of your system - rising edge on int or pcint, timer, etc.
3) turn that pin as input - the weak pull-up will start to charge up the capacitor.
4) once the voltage across the capacitor triggers the int / pcint: in the isr, turn the pin to output - this discharges the capacitor; read the timer's lsb, reset it (optionally), and then turns the pin into an input - this starts to charge up the capacitor again.

On the avr, the coding is slightly different as it doesn't have separate bits to enable the weak pull-up but the general idea remains the same.

The speed depends on the strength of the weak pull-up and the capacitor used.
================================
https://dannyelectronics.wordpress.com/
 

Offline StonentTopic starter

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Floating input pin to induce randomness
« Reply #33 on: December 12, 2013, 05:31:13 am »
The larger the government, the smaller the citizen.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf