Main Site Documentation

Analogpin cleanup


#1

If I read from an analog pin with nothing connected to it I get random #s. Is this expected?


#2

Yes.
If the pin is left floating the readings will change.


#3

Ok, So it’s not noise that I will have to worry about when I read in an analog signal?


#4

Actually it is not random, it is reading the noise it is picking up, which is random :slight_smile:


#5

Then again, random generators are hard to build so it might be a source for random numbers?
Have anyone tested the NETMF random generator? Will it give the same sequence at boot up a many other micro controllers?


#6

If you want a simple hardware RNG you could connect a white noise generator to an analog input and convert it to numerical output.

http://www.maxim-ic.com/app-notes/index.mvp/id/3469


#7

I’m pretty sure the RNG is seeded from the clock so if there is an RTC on board microsoft’s seed is derived from the second so with an RTC connected you should not get the same set of random numbers. If there is no RTC the number set will be the same

Cheers Ian


#8

The issue I can see with the RNG on a FEZ is the RTC isn’t battery backed so on powerup all clocks are reset. Now with this the random sequence should become predictable between resets because the source of the random seed is now deterministic. A simple test I am gunna do when I get home is just print a random sequence of numbers out a serial port and compare them between power cycles. Also the default RNG in .net is not the greatest quality. Where as even a simple hardware rng from a white noise generator has a nice coolness factor.


#9

the RNG in .net is pretty awful to be honest. We had huge issues with it at work and ended up creating a true mathematically random number generator. The builtin was creating all sorts of havoc with our algorithms heh.


#10

hi MarkH
How do you seed the random generator. Is it based on the RTC or something else?