Main Site Documentation

Analogpin cleanup


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


If the pin is left floating the readings will change.


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


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


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?


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


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


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.


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.


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