input noise into ADC

THE_RB

Joined Feb 11, 2008
5,438
It depends on your ADC sampling rate. Generally it doesn't matter that much as long as the analogue voltage signal is constantly moving through a range of many ADC counts (between taking each ADC sample). Then just keep one bit of the ADC sample, the LSB.

My experiments with a PIC input ADC module showed some bit bias, especially where the input noise was weak in drive ability (high source impedance). I scrapped the voltage noise source idea early on and made something better.

If you are going to use an ADC make sure the noise signal has been buffered by an opamp etc first, so the signal has good drive ability.

We really need to know what you need to achieve, so we can suggest a good way to do it. One fo the most important things is the datarate; how many bits of randomness do you need per second. That will be a big decider in choosing the best technique.

Also we need to know just how good the entropy needs to be. Is this for an electronic dice or do you want to beat the NSA? ;)
 

Lestraveled

Joined May 19, 2014
1,946
Macnerd
"White" and "Pink" noise and very old terms. They were used a lot in audio measurement before test equipment got really good.

What sets the quality of the noise you need to use, is what you are going to use the random numbers for. If you are going to do math processing on the numbers then yes, you need to use a transistor or diode to generate your noise. If you are making a poker program or a first person shooter game, then a shift register and a XOR gate will get you what you need.

Is this KISS enough?

Mark
 

Thread Starter

Macnerd

Joined May 22, 2014
67
We really need to know what you need to achieve, so we can suggest a good way to do it. One of the most important things is the datarate; how many bits of randomness do you need per second. That will be a big decider in choosing the best technique.


I was browsing around the 'net a while back & read about inputting noise into an ADC & the output is random numbers. That intrigued me. I found you guys & asked about it.

Sure, I can use software to generate random numbers, but I want to try hardware first. There are so many different microcontrollers & microcomputers that I can choose from. Whatever I choose, I'd have to first learn how to operate it & then learn how to program it.

I want to build a RGB LED array. Each LED has 3 color pins. Software can randomly choose a pin. Three pins on each LED has 8 possible combinations. I can use a shift register or walking ring counter, but they count in sequence. I want to be able to randomly choose the color pins on the LED & randomly choose the row(s) & column(s) in an array. Likewise, an 8X8 array has 256 possible combinations for the rows or columns. After reading what you guys have said about op-amps & stuff, I'd say that a shift register with feedback or a walking ring counter or something else is what I'm looking for.

I've watched YouTube videos & corresponded on an Arduino forum & my head is spinning. There is hardware between the Arduino & the LED array. I think that I would be totally confused & frustrated if I tried using a microcontroller. Then again, I might be just as confused & frustrated with hardware-only approach.
 

Thread Starter

Macnerd

Joined May 22, 2014
67
In my book that I had previously mentioned, it states that all zeroes in a shift register with Exclusive-Or feedback is a disallowed state. I want all zeroes included. That rules out shift registers. I was thinking about it & it occurred to me that electronic dice may be the way to simply produce pseudorandom numbers. You guys are confusing me with your technical mumbo-jumbo about bias & noise floors & scrambling processes(?) & coherent integration & stuck at the rails. How can I simply produce pseudorandom numbers in hardware that includes all possible combinations of random digits & no disallowed states? In other words, if its 4 bits I want all possible combinations from 0000 to 1111.
 

THE_RB

Joined Feb 11, 2008
5,438
The linear feedback shift register (LFSR) you mentioned makes n-1 states, where every state will eventually be produced apart from all bits = 0. The only problem with that is there will be a bit-bias, where bit 1 occurs slightly more often than bit 0.

You can fix that by running a process that "whitens" the data, which means it makes sure there is an equal chance of any bit being 1 or 0 (or gets so close to equal it doesn't matter).

One way is to use two LFSR processes, and XOR the outputs, which whitens the data. And improves its entropy. I would suggest different sizes for the two LFSRs.

You said above you want to randomly select one of 256 LEDs, and a colour with 8 options (256*8 = 2048). So if I understand you right, for each random event you want to select a "random" number with 2048 possibilities; ie from 0-2047. That is an 11bit binary number.

How often do you need to generate this 11bit randome number? And is this mains powered from wallwart/transformer or battery powered?

And, how good are your coding skills?
:)
 

Papabravo

Joined Feb 24, 2006
21,226
"White noise" is noise with an infinite frequency spectrum. That is there is an equal amount of energy at every frequency from DC to blue light and beyond. Another way of saying it is that it has a constant power spectral density. The term has nothing to do with amplitude.

http://en.wikipedia.org/wiki/White_noise

"Pink noise" has a power spectral density that varies inversely with frequency. At very high frequencies there is very little energy in the noise. It is band limited in a sense but not like a traditional filter.

http://en.wikipedia.org/wiki/Pink_noise

I'm not familiar with any other terminology relating color to power spectral density, but check wikipedia and new things pop up: like Red and Grey. Who knew?

http://en.wikipedia.org/wiki/Colors_of_noise
 

Thread Starter

Macnerd

Joined May 22, 2014
67
HUH? Entropy? Whitening?
As I previously stated, I'm an electronics newbie. I just recently retired & I want to take up electronics as a hobby. I'll have to start from the beginning. Reading schematic diagrams confuse me if it's not something simple. So, you guys are confusing me with the technical mumbo-jumbo.

So, you suggest using 2 LFSRs. I know that I'd have to XOR certain outputs back to certain inputs. How do I determine which 2 sizes of LFSR to use? Won't I have to combine the outputs of the 2 LFSRs into 1 output? How do I do that?

Each RGB LED has 3 color pins. Two raised to the third power is 8. So, each LED can produce 8 possible colors. I don't know if there is such a thing as an octal counter, but a thought occurred to me. If I use a BCD or Hex counter & connect the "1", "2" & "4" pins on the counter to the 3 color pins on the RGB LED & connect the "8" pin on the counter to the reset pin on the counter, then the counter would count from 0 to 7 & then reset. That's fine for a few LEDs but it would be unfeasible for an array. Maybe a multiplexer/demultiplexer would work to address the array. I'm just thinking about different ways that I can drive an array of RGB LEDs without using an Arduino & the hardware between the Arduino & the array. Maybe it isn't possible to address a RGB LED array without using an Arduino. Maybe it isn't possible to address a RGB LED using only hardware without the help of an Arduino, but I'd like to try anyway. I want to build an RGB LED array like I've seen in YouTube videos.
 

Papabravo

Joined Feb 24, 2006
21,226
It is perhaps unfortunate that complicated material can't be boiled down to terms you are familiar with and can understand. Maybe the fault is yours for rushing into material you are not prepared for. My advice to you is to slow down and learn to crawl and walk before you try running marathons.

Random number generation is not easy to understand, implement, and verify without a great deal of high power mathematics. Think about lowering your sights in the short term. Why are you swinging for the fences without being able to see the ball?
 

THE_RB

Joined Feb 11, 2008
5,438
HUH? Entropy? Whitening?
Entropy = randomness (how good it is)
Whitening = making sure there are an equal number of 1 and 0 bits

...
So, you suggest using 2 LFSRs. I know that I'd have to XOR certain outputs back to certain inputs. How do I determine which 2 sizes of LFSR to use? Won't I have to combine the outputs of the 2 LFSRs into 1 output? How do I do that?
The LFSR sizes don't really matter that much for your application. Actually just using one may suffice if it has >16 bits.


...
Maybe a multiplexer/demultiplexer would work to address the array. I'm just thinking about different ways that I can drive an array of RGB LEDs without using an Arduino ...
...
I think trying a non-microcontroller approach is like shooting yourself in the foot before you start on the journey. ;)

You have many other issues to deal with like how to drive an 8*8 array of 3pin LEDs, which is really a 24*8 array of single LEDs.

Rahter than get stuck on the "random" part you will first need to settle some design issues like how you will drive a 24*8 array. Papabravo made a good point; you need to walk and crawl first before this project will run.
 

Thread Starter

Macnerd

Joined May 22, 2014
67
It is perhaps unfortunate that complicated material can't be boiled down to terms you are familiar with and can understand. Maybe the fault is yours for rushing into material you are not prepared for. My advice to you is to slow down and learn to crawl and walk before you try running marathons.

Random number generation is not easy to understand, implement, and verify without a great deal of high power mathematics. Think about lowering your sights in the short term. Why are you swinging for the fences without being able to see the ball?

I think trying a non-microcontroller approach is like shooting yourself in the foot before you start on the journey.

You have many other issues to deal with like how to drive an 8*8 array of 3pin LEDs, which is really a 24*8 array of single LEDs.

Rather than get stuck on the "random" part you will first need to settle some design issues like how you will drive a 24*8 array. Papabravo made a good point; you need to walk and crawl first before this project will run.


I agree with what you all say.
Would you believe, as Maxwell Smart used to say, that I've thought about what all of you have said & it probably would be easier for me to accomplish what I want to do with a microcontrolller. I've played around with Visual Basic & it is fairly easy to create a program that will generate random integers in the range of say, 0 to 255. If I use an LFSR, there's a lot of soldering & disallowed states. I can use a counter but the "biggest" counters that I know of only count to 16. If I want to count higher than 16, I'd have to cascade the counters together. I have no idea how to switch from pseudorandom number generator hardware to counters using hardware only & integrate them into the LED array. I'm sure that it would be easy to create a program to do such a thing. I know that there would be LED drivers & other hardware between the Arduino or whatever & the LED array. I know that I can create a program that will convert decimal numbers into octal or hex numbers. I don't know how to assign binary values to the output pins on the Arduino or whatever, but I suppose that it is possible.

Now I have to decide on Arduino or Rasberry Pi or Beaglebone Black. Whatever I choose, I'll have to start at the very beginning.
 

THE_RB

Joined Feb 11, 2008
5,438
... If I use an LFSR, there's a lot of soldering & disallowed states. ...
...
If you do go with a microcontroller you can make the LFSR in code. It's quite easy to do. Every time you run it it makes one bit, so you just run it 11 times to make the 11 bit random number you need.
 

Thread Starter

Macnerd

Joined May 22, 2014
67
After I posted this, I googled Beaglebone & Raspberry Pi. Between the 2, I prefer the Beaglebone. But an Arduino would probably be easier for me to understand & learn. There are a lot of YouTube videos that I can watch to learn how to use the Arduino.

If you do go with a microcontroller you can make the LFSR in code. It's quite easy to do. Every time you run it it makes one bit, so you just run it 11 times to make the 11 bit random number you need.
Would there be disallowed states in the software LFSR? Would you happen to know what the code is for doing it? I can always ask someone in the Arduino forum. I have an account & I've asked a lot of questions.
 

THE_RB

Joined Feb 11, 2008
5,438
You must initialise the LFSR with a value >0.

So when you initialise it, one or more bits must be a 1. Then you just run it, and it will automatically step through every possible state but not 0.

My suggestion is that you get an arduino and make some simple "blinky LED" projects. Once you are familiar with coding for it and programming it etc, you can add a simple RNG and make the LED blink randomly. Then it all gets easier from there.
 

Thread Starter

Macnerd

Joined May 22, 2014
67
You must initialise the LFSR with a value >0.

So when you initialise it, one or more bits must be a 1. Then you just run it, and it will automatically step through every possible state but not 0.


Sounds to me that it is just like a hardware LFSR which also has all zeroes as a disallowed state. So, it appears to me that it doesn't make any difference whether it is a software LFSR or a hardware LFSR.

So, I'm better off using the Arduino to create random numbers. I've played around with Visual Basic & I know that one can create a program that can generate random numbers in a range of 0 to 255.

So, the more that I think about it, the more convinced I am that the Arduino can accomplish what I want to do more easily than using hardware only.
 

djsfantasi

Joined Apr 11, 2010
9,163
So, I'm better off using the Arduino to create random numbers. I've played around with Visual Basic & I know that one can create a program that can generate random numbers in a range of 0 to 255.

So, the more that I think about it, the more convinced I am that the Arduino can accomplish what I want to do more easily than using hardware only.
Do you know that the Arduino language has a built in random number function? It is this function and it's seed function to which I was referring in my earlier posts.

Arduino Random
Arduino Random Seed
 
Top