EveryCircuit
Contact
Reviews
Home
APO69
modified 4 years ago

Random with counter

7
9
599
05:44:53
-ReadMe- With this circuit we can check how long it takes to repeat a sequence. Due to the lack of space I could not implement a counter. So ... I added an (little) auxiliary RC circuit where the capacitor charge will give us a value directly related to the number of pulses counted until the repetition. The circuit only works in COUNTER mode. The orange line shows the growth of the capacitor voltage. The RC value is very large to ensure an initial curve as linear as possible, far from the exponential. Even after 4096 values, the capacitor would have a load of only 45 milli-volts. Very far from the exponential and practically linear. In the linear part, the load curve grows at a rate of 10 microVolts per pulse. This means that if the orange line is at 4.57 miliVolts, the pulses counted are: 4.57e-3 / 10e-6 = 457 pulses. If you like math, you can calculate the integral and get the number of pulses, approximately. The button is to "reset" the capacitor. Run it online, PC... Very^4 slow in my Android S3... And now faster on my new Xiaomi 9T. How does it work: I will not explain the Random section (top right) because you already know it although I am going to tell you a little trick: If you raise the ADC reference voltage, you can limit the maximum number of displays. For example, if you put it at 7v the display will be limited to number 9. Max number 999 => 10^3 - 1 To do this brings us another problem. The probability of nine increase respect all others... If you don't like this change the HIGH value of generators from 4V to... 3 or 2 or 1 or... The default value is 4v. Max number 0xFFF => 16^3 - 1 (4095) The Verification section is very simple. First and very important is to locate the "Logic Source" under the orange displays. This makes it possible to switch between GENERATOR and COMPARATOR modes. OFF (GENERATOR mode) The circuit generates random numbers constantly (green displays). Orange display don't changes. We can use this mode to wait for a certain sequence or to count numbers instead of sheep ... ON (COMPARATOR mode) The first thing the circuit does is to capture the number generated by storing it in a latch (orange displays). A few micro-seconds later the generator clock becomes controlled by an OR gate. When the comparator circuit detects a match, it sets its output to "1" (blue line) causing the OR gate to have its output to "1" and therefore, the CLK is disabled. Diode in RC circuit is to ensure that capacitor don't discharge. So you can go on holidays by a month and when you return the capacitor will be with the same value. So... If you have patience you can stay to count the pulses and check how many numbers are generated before the repetition. Keep in mind that a random number can be repeated long before all combinations have left. I hope you like it.
published 5 years ago
hurz
5 years ago
"Due to the lack of space" I hear that again and again. But why not show the principle for 1digit only, you save 66.66% of space. If EveryCircuit would double the space you would extend your circuit to 6digits and stll agrue for more workspace?
APO69
5 years ago
Then I coudn't make this circuit.
APO69
5 years ago
In addition, you challenged me to demonstrate the efficiency of my little card. Well here it is.
APO69
5 years ago
Random number generator with counter.
APO69
5 years ago
For example, at the time of writing this comment I am waiting for the count of the number 0xD78. The capacitor is charged with 4.32mV so 108 numbers have already passed.
APO69
5 years ago
...now 12.8mV -> 320...
APO69
5 years ago
...and it go on...
hurz
5 years ago
do it all for one digit and make a histogram by hand or even as circuit capacitors tick some defined current over time tonstep in 1 or 10mV steps to count 16caps, just an idea or limit to problem octal with 8 caps and see how the distribution is. Wait for a single combinatiin out of 4096-1 is an infinite job, have fun
APO69
5 years ago
That's a good idea

EveryCircuit is an easy to use, highly interactive circuit simulator and schematic capture tool. Real-time circuit simulation, interactivity, and dynamic visualization make it a must have application for professionals and academia. EveryCircuit user community has collaboratively created the largest searchable library of circuit designs. EveryCircuit app runs online in popular browsers and on mobile phones and tablets, enabling you to capture design ideas and learn electronics on the go.

Copyright © 2025 by MuseMaze, Inc.     Terms of use     Privacy policy