Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/30/09 02:24
Modified:
  10/30/09 02:33

Read: times


 
#170226 - Modulating the /INT0 input by a simple noise generator
Responding to: ???'s previous message
Hi Kiran,

Kiran said:
If you want a truly, truly random number, then the method mentioned by Kai is the best one.


The standard 8051 has a feature, which supports the generation of random numbers similar to the scheme Erik already mentioned (a fast running oscillator, read out at random instants): The 8051 can have the timers/counters be gated by the /INT input, will say, the timer can be set into a mode, where it counts the internal clock (crystal clock / 12) only when one of the /INT inputs is brought high. So, if you connect a noise generator to the /INT0 input, which sets this input randomly low and high, then the counter register will show random contents.

More, if you use the auto reload feature of the standard 8051 you can even directly generate the random numbers 1 to 37, which Roberto is needing.

The following scheme shows a noise generator, which could be used for this purpose:



Usually, noise generators use the noise of a reverse biased zener diode. Unfortunately, these noise generators need a supply voltage, which is very clean and is way higher than 5V. To avoid the interference of an additional switcher or a charge pump, I use a different source for the noise here, the thermal noise of a resistor. By this, the circuit doesn't need a high supply voltage, but can run at 5V.

As the scheme shows, much filtering is needed to remove interference from Vcc, which can be digital noise from switchings and the crystal oscillator. The two chokes are soft ferrite beads presenting a high impedance in the 100MHz range, to compensate for the parasitic inductance of the filtering caps.

The 10M and 4M7 not only produce the noise, but also bias the input of first TLC271 at about 1.4V. This is the DC level finally reaching the output of this noise generator.

Each TLC271 has a gain of 101, resulting in a total gain of about 10200. The upper bandwidth is about 20kHz, as a result of the finite speed of TLC271, which are running in the high bias mode. The lower bandwidth is defined by the two 100n caps, which is about 2.5kHz. So, the DC gain is 1, eliminiating all trouble from offset voltages of OPamps.

High pass filtering of noise is very important here. Without a high corner frequency, low fequency noise could block the output of noise generator, causing it to stay a rather long period logic high or low. So, two or more subsequent readings of the counter register could show the same result. With a corner frequency of 2.5kHz the counter register should not be read earlier than about every 1msec. Better, to wait even longer, to be sure, that the counter was clocked in the meantime.

Of course, I would prefer to reduce this latency even further. But this would mean to shift the noise bandwidth to higher frequencies, which isn't possible with these low cost OPamps.

As with all high gain OPamp circuits, the layout of this circuit is critical:
Keep the signal ground of this circuit well isolated from the signal ground of any other circuitry, especially the microcontroller circuit. Use a local ground plane for this circuit and connect it to the signal ground of rest circuitry only at a single point. Move the 10M and 4M7 resistors and corresponding circuitry far away from this point, so that they see a very quiet signal ground. Shield the whole circuit and connect the shield to this single point. I can show you a suited layout, if you want.

What is this circuit doing, finally?
At the output a DC level of about 1.4V can be seen. This level is right between the maximum input low voltage of 0.9V and the minimum input high voltage of 1.9V of /INT0 input (an AT89S52 assumed here). The noise at the output of this noise generator is about 2Vss, causing the /INT0 input randomly toggling between low and high.

Eventually, the 100k resistor of second TLC271 might be adjusted slightly, to allow the output a full output voltage swing without going into saturation. Eventually, a comparator could be added, with a threshold voltage of 1.4V and a hysteresis of let's say 20...30mV. But I don't think, that this is really needed.

Kai Klaas

List of 67 messages in thread
TopicAuthorDate
Random numbers            01/01/70 00:00      
   How random?            01/01/70 00:00      
   extract?            01/01/70 00:00      
      Time for Google            01/01/70 00:00      
      Extract            01/01/70 00:00      
   you can't            01/01/70 00:00      
      a very good way to get random numbers            01/01/70 00:00      
      Interesting anecdote regarding timers:            01/01/70 00:00      
      Periodicity            01/01/70 00:00      
   Just curious...            01/01/70 00:00      
      Didn't search first!            01/01/70 00:00      
         New Information not searchable            01/01/70 00:00      
            Using life itself as part of its computational matrix...            01/01/70 00:00      
               Sure it is            01/01/70 00:00      
         Show me any real new thread...            01/01/70 00:00      
            But...            01/01/70 00:00      
               It really means...            01/01/70 00:00      
                  No "Come In!", but a "Go Home!"            01/01/70 00:00      
                     Exclusive information...            01/01/70 00:00      
                        Thanks...            01/01/70 00:00      
                        First and ONLY Time I reply to this            01/01/70 00:00      
                           Completely ridiculous might be a bit strong            01/01/70 00:00      
                           Lazyness...            01/01/70 00:00      
                              ...is already ignored            01/01/70 00:00      
                                 But we restrict ourselves!            01/01/70 00:00      
                                    No, you are restricting the definition of "help"            01/01/70 00:00      
                                       Your propaganda again...            01/01/70 00:00      
                                          People ARE posting code snippets etc            01/01/70 00:00      
                                             Come on, how many do so?            01/01/70 00:00      
                                                Do what?            01/01/70 00:00      
                                          The limiting factor            01/01/70 00:00      
                                             Mixing subjects            01/01/70 00:00      
                                                Not a valid answer            01/01/70 00:00      
                                                   Are we poluting this thread?            01/01/70 00:00      
                                                      Yes, but Roberto has gone already...            01/01/70 00:00      
                              true for good schools, but not for diploma mills            01/01/70 00:00      
                     Balance            01/01/70 00:00      
                        Warding people away is no good policy either            01/01/70 00:00      
                           Bully for seeing problems with negative votes???            01/01/70 00:00      
                              Its his will            01/01/70 00:00      
                              Its just a biginning!            01/01/70 00:00      
                                 Still extrapolating            01/01/70 00:00      
                                    Relativity?            01/01/70 00:00      
                                    Extrapolating What            01/01/70 00:00      
                                       Not a valid conclusion!            01/01/70 00:00      
                                       Still extrapolating            01/01/70 00:00      
                           Wrong link?            01/01/70 00:00      
                              link to link            01/01/70 00:00      
                                 But nothing about fear of 8052.com?            01/01/70 00:00      
                                    At least,...            01/01/70 00:00      
   This method might work...you can try it....            01/01/70 00:00      
      Unnecessary complication!            01/01/70 00:00      
         Watch out for distribution problems for small ranges            01/01/70 00:00      
         Yes..But for added randomness, use the table            01/01/70 00:00      
            Incorrect - the table adds nothing!            01/01/70 00:00      
               Quality often important even for simple devices            01/01/70 00:00      
                  can be dangerous            01/01/70 00:00      
                     Bus arbitration needs a lot            01/01/70 00:00      
            HUH????            01/01/70 00:00      
      he can't            01/01/70 00:00      
      Modulating the /INT0 input by a simple noise generator            01/01/70 00:00      
         Post-processing needed            01/01/70 00:00      
            What interrupt?            01/01/70 00:00      
               Both interrupt or gating possible            01/01/70 00:00      
                  Full agree with everything you wrote!            01/01/70 00:00      
         Addendum...            01/01/70 00:00      
   Google as a resource?            01/01/70 00:00      

Back to Subject List