0% found this document useful (0 votes)
171 views2 pages

Generate True Random Numbers On Microcontroller

This document discusses generating true random numbers on microcontrollers. It explains that microcontrollers can generate pseudo-random numbers using algorithms like linear feedback shift registers, but these are predictable. To generate true random numbers, a real-world entropy source is needed, like measuring the thermal noise of a diode with an analog-to-digital converter. Embedded systems with temperature sensors can also use the sensor's noise as an entropy source for random number generation without additional hardware.

Uploaded by

nevdull
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
171 views2 pages

Generate True Random Numbers On Microcontroller

This document discusses generating true random numbers on microcontrollers. It explains that microcontrollers can generate pseudo-random numbers using algorithms like linear feedback shift registers, but these are predictable. To generate true random numbers, a real-world entropy source is needed, like measuring the thermal noise of a diode with an analog-to-digital converter. Embedded systems with temperature sensors can also use the sensor's noise as an entropy source for random number generation without additional hardware.

Uploaded by

nevdull
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

scie nce pro g.

co m

http://www.sciencepro g.co m/generate-true-rando m-numbers-o n-micro co ntro ller/

Generate true random numbers on microcontroller


Sometimes there is really a problem of how to generate true random numbers using your microcontroller. Usually computer processor or any other MCU is capable to generate a Pseudo Random Number (PRN). T hese numbers are generated by algorithms so called Pseudo Random Number Generators (PRNG). Everything what pure algorithm produces is predictable in some sort of level. T here are many PRNG algorithms that generate random numbers, but there is always a def ined number of iterations when random number sequence will repeat itself . Sometimes it may be acceptable. One popular way to generate pseudo random numbers is using Timers. Moreuniversal algorithm is concept of Linear Feedback Shif t Register (LFSR). LSFR is a n -bit register which is initiated with non zero seed value and is clocked by shif ting values to the lef t and loading new bit in to bit0. New bit is calculated by XORing the bits of selected taps of LSFR. T his method is used in rand() f unctions. Usually we know simple solution of random number generation (AVR-GCC example): //Example how to generate PRN in range (0 to 9) uint8_t randNumber; // Get a random number (0 to 255) randNumber = (uint8_t) rand(); // Set number range to 0 to 15 randNumber = randNumber & 0x0F; // Set number range to 0 to 9 if (randNumber > 9) randNumber -= 6; But this algorithm will always get the same numerical order as long the same seed f or the rand() f unction is used. T his is nothing more than mathematical f unction that cycles through a range of numbers which can be predictable. If you need really true randomness you need to f ind real world source that could inject some entropy. T his could be any noisy diode connected to ADC. Such ramdom generators are so called Hardware Random Number Generators. T hey of ten use some microscopic phenomena like thermal noise, photoelectric ef f ect, etc. T here are complete random number generators in the market, that can be connected to PC via USB like this http://random.com.hr/products/hg400/index.html. T here is interesting reading about Random Noise Sources where as entropy source is Z ener diode used. Measurements are done using PC Sound Card. In general if you are prototyping some sort of Embedded platf orm with temperature sensor like AD7416 this menas that you already have a hardware random number generator. Because temperature sensor chips generates noise which can be used as source of entropy f or your RNG. And you dont need to connect additional devices like Z ener diodes or photo cells.

You may also like Marking of AVR microcontrollers Interf acing microcontrollers to external devices

Microcontroller Simulators and emulators Choose right electronic components f or your projects

You might also like