Title：Using GR-KURUMI to create a Simple Random Number Generator Based on Physical Phenomena
Displayed Name：Michihiro IMAOKA
|Concept / Overview|
|A few years ago, NHK broadcast a special program called Scientists Confront Supernatural Phenomena. It was apparently rebroadcast several times; I myself saw the show during this past New Year holiday. I suspect quite a few people saw it. The program highlighted how individuals’ ranging emotions impact random number generators, which are grounded in physical phenomena. The latter half of the program explored an experiment tapping how the emotions of Burning Man festival participants impacted random number generators. Burning Man is an event staged in a desert in one of the American states in which tens of thousands of individuals cohabit in a self-contained environment, cut off from the outside world for one week. The event concludes with the burning of a huge effigy right in front of everyone’s eyes. At that time, participants’ emotions are at their peak, and are said to bias random number generation.
The program content generated a variety of responses, and I encourage individuals to refer to relevant websites exploring this topic. At the same time, as a technical engineer, I also strive to find the true meaning of the program results. To that end, I would like to introduce how to make a random number generator based on physical phenomena. I hope that as many readers as possible will use that information to help verify the truth with their own eyes.
Random numbers from natural phonomena
There are multiple methods for generating random numbers. For example, you can generate random numbers purely using software. This method yields what is called pseudo-random numbers. There are various algorithms available for generating random numbers which I will not get into here, as failure to assign a different initial value each time will cause generation of the same random number sequence. Random number generation can also be accomplished by hardware logic. The diagram shown below is a circuit from an exclusive OR and a shift register.
The randomly generated number is binary. The shift register has multiple stages, with the most significant bit circulating the least significant bit out. The more stages in the shift register, the longer the generated random number sequence. If the clock is continually supplied, the random number sequence will circulate in a fixed length. Random numbers generated in this manner are referred to as M-sequence (maximal length sequence) pseudo-random numbers. The point at which the exclusive OR factors in determines the M-sequence random numbers. Several such points in the shift register number have already been discovered. In order to generate random numbers, the initial shift register value must be 1 in at least one instance.
Now let us put that aside and examine random number generation from physical phenomena. The most familiar example of this might be tossing dice. However, this would be an exhausting way for individuals to generate many random number sequences. Even if you could create a machine to retrieve and toss dice (which in itself would be exhausting), the dice would age, causing deviations in face-up results. As I wrote in the Introduction, my purpose was to create as simple a device as possible, so that would seem to rule out the above idea. Instead, I would like to begin by using electrical transistors—priced at \10 or less each—to create a source for generating random numbers.
First of all, let us listen to white noise
The transistor used as a generation source for random numbers in this project was a 2SC1815L-GR. It is one of the more least-expensive and easily-obtainable transistors. An online shop with a branch in Akihabara prices them at about 20 for 100 yen.
The transistor appears in circuit diagrams as shown here.
B represents what is known as the base. The directional arrow indicates the emitter (E). At the opposite end is the collector (C). The name “emitter” reflects its function as the pole emitting the electron. Similarly, the collector’s name stems from its role in collecting the emitted electron. When the transistor was first invented, it was manufactured with the collector and emitter electrodes attached above the base, so unlike “emitter” and “collector,” the term “base” does not derive from its function. Transistor manufacturing is completely different from what it was in the early days, but the term remains.
Incorporating white noise with KURUMI ADC
So let’s try using KURUMI to generate white noise between the transistor’s emitter and base. The circuit is what generates the white noise, as we discussed before. The transistor base (output from the circuit) is connected to KURUMI analog input 0. The FTDI Basic Programmer to the left of KURUMI is use to write the prepared program to KURUMI itself, and it is also used to send the value of the white noise retrieved by by the AD converter to the PC.
This diagram shows the circuit described here, mounted onto the breadboard.
Resolving insufficient gain with an operational amplifier
Insufficient gain should be resolved by amplifying the input signal. There are many ways to various filters, comparators, and signal generators. The op-amp offers a neat package integrating circuitry comprised of simple elements such as a transistor and FET. As the name infers, op-amps enable various operations, such as signal conditioning, mathematical operations, and filtering. Before digital computers were mainstreamed, op-amps were used as operational elements in analog computers. The LM358N op-amp used in this project.
The LM358N was originally developed by National Semiconductor, but a variety of semiconductor companies worldwide have become second source manufacturers, making this one of the most popular low-priced op-amps available. Electronics parts shops also have a variety of LM358s made by various manufacturers, but any of them would work fine for this project. It would be fine to purchase the one offered at the most reasonable price. An online retailer with a branch in Akihabara sells them at a price somewhere around 5 for \100. Please be sure to get the DIP type package, as shown in the diagram. This will allow direct insertion onto the breadboard. There are two op-amps in the package, as the diagram illustrates.
The diagram shows how to use the op-amps.
The circuit shown here uses a single power supply. Op-amps normally use two power supplies—positive and negative. However, the LM358N enables a single-source circuit. Input is applied to the minus input (pin 2) through resistor R2. Output is through pin 1. Output is returned to the minus input through resistor R3. The diagram depicts an inverting (negative) amplifier, which outputs an inverted signal in response to the input signal. When a sine wave is input, the amplifier will output a signal that is 180°”out-of-phase” with the input signal. Of course you could also configure a non-inverting circuit, but an inverting amplifier normally offers better performance.
Amplification efficiency depends on resistors R3/R2. The amplification efficiency of the circuit in the diagram is 33,000/100 = 330. R2 input resistance should ideally be a bit greater, but I ended up with this value because I only had a 100-ohm resistor on hand as I was on a business trip. Normally, at least 1K-ohm resistance is recommended. R4 regulates voltage applied to the op-amp’s positive input. Normally, a fixed resistor divides the voltage to ensure that half of the power voltage is applied, but, in this project, variable resistance was used for adjustment because bias voltage is applied to the input signal.
This diagram shows the circuit that inputs the signal amplified by the op-amp into the GR-KURUMI ADC. The LM358N includes two op-amps in a single package, but only one was used in this project. The other is left over; whenever there is an unused op-amp, please be sure to apply differing voltage to the two inputs and fix the outputs. If neither input is connected or if the same voltage is applied, the output value will not be fixed and may generate noise. Please use these precautionary measures to avoid noise.
This diagram shows the above circuit mounted on a breadboard.
The diagram depicts the op-amp pin assignments. The surface of the op-amp shows a crescent-shaped depression; make sure the depression is facing upward and the pin on the left becomes pin 1. Pin numbers 1 through 8 are as shown on the diagram. In the breadboard diagram, the side of the op-amp with the depression faces left.
Connect earphones between pin number 1, which represents the LM358N output, and GND to adjust variable resistance and hear maximum possible white noise.
The following graph depicts the terminal emulator buffer copied into a spreadsheet program and shown in graph form.
Use of the op-amp ensures the signal is sufficiently amplified. We can confirm that there is no saturation on either the plus or minus side.
Owner/CEO, Imaoka Engineering
Michihiro Imaoka was a full-time programmer until about 15 years ago. Basically, he wrote code day in and day out, coming up for air only occasionally. He is particularly adept at FPGA coding and SMD soldering. Lately, he transitioned into authoring technical materials. Now he sits at his desk writing from dawn to dusk.
Mr. Imaoka is located in Matsuyama, Ehime Prefecture, where he:
- Focuses on contract-based work, developing embedded systems
- Continues to write manuscripts
- Lectures at “security camps” and other IT events
- Provides hardware startup support
- Remains active in the open source community