Start count from a given number.

Thread Starter

Stefan Peter

Joined Apr 26, 2017
2
I wanna do a counter, using jk flip flops, that start count from a random number. I'l give an exemple for an easy understanding.
I generate a random number(between 0 and 9) and i want to start counting from that number to 9 and when get to 9 to return to 0.
I already know how to do the basic asynchronous/synchronus counters modulo n/even numbers etc.
 

WBahn

Joined Mar 31, 2012
32,823
How would you build a machine that always starts at 5 and returns to 5?

How would you build a machine that always starts at 5 and returns to 7?
 

WBahn

Joined Mar 31, 2012
32,823
Generating a random number isn't that impractical. Just have a fast free running counter that stops when you start the main counter and use the value it stopped at as your random number.
 

Thread Starter

Stefan Peter

Joined Apr 26, 2017
2
Welcome to AAC!
Random or user-specified? One isn't practical...

Is this homework?
It is a random number.
I wanna do a digital clock that starts from a random time(u dont need to set up the time) and no isn't homework.
Thanks @WBahn i will try with that free running counter.
 

AnalogKid

Joined Aug 1, 2013
12,128
Actually, you can do it all with only one counter. As in post #4, have the counter run very fast until you push the start button. Then at whatever number it is at, it starts counting slowly until it gets to 9, rolls over to 0, and stops. If the counter is counting seconds, start with a high speed clock and divide that down to the seconds clock (or use a 555 with two different timing resistors (not capacitors); less work but less accurate), and go between the two with a pushbutton and flipflop.

ak
 

MrAl

Joined Jun 17, 2014
13,704
I wanna do a counter, using jk flip flops, that start count from a random number. I'l give an exemple for an easy understanding.
I generate a random number(between 0 and 9) and i want to start counting from that number to 9 and when get to 9 to return to 0.
I already know how to do the basic asynchronous/synchronus counters modulo n/even numbers etc.
Hi,

It sounds like you generate a number yourself, then use that number as the start count, then start counting, then when you get to 9 reset to zero.

You could start with a preloadable decade counter.
Set up the circuit so that when it resets to 0 naturally (as they do) it stops the clock.
Load the count, start counting, wait for it to stop.

So you dont need to make one with flip flops, but you can still do that too if you wish.
If you do not know how to create a preloadable decade counter using flip flops then you can look up the data sheet on one that already exists, then use that data sheet internal diagram to create one from separate flip flops.
That's the easiest way because you'll have the design of the required counter then without trying to figure anything out really. You then only have to get it to stop counting when it reaches zero, which should not be that hard to do using maybe a gate and another flip flop.

Whatever circuit you use, test the circuit carefully because circuits that turn the flip flop clock on and off can be tricky sometimes.
 

Bernard

Joined Aug 7, 2008
5,784
The data sheet for the 4018, presettable / by N counter shows the layout., but post #6 by AK should work.
Just for illustration I'll throw in an example of a random number generator. It has both slow, about 16 min., & fast clock, U1-A. I have notice a quirk in this method in that the counter sometimes developed a repeating number preference. In this example some noise is introduced by a candle LED, which keeps it random.
OWL 1 00000.jpg
 
Last edited by a moderator:
Top