Author |
Message |
okelk
Joined: May 08, 2014 Posts: 71 Location: Vienna
|
Posted: Mon Sep 08, 2014 9:29 am Post subject:
easiest 3-bit random binary number generator? |
|
|
I something that outputs 3 bit random (or pseudo-random) binary numbers.
What's the easiest way to accomplish this? something with shift registers?
Hope you can help me! |
|
Back to top
|
|
|
gdavis
Joined: Feb 27, 2013 Posts: 359 Location: San Diego
Audio files: 1
|
|
Back to top
|
|
|
DUBmatze
Joined: Feb 18, 2013 Posts: 150 Location: south Germaica (schwabilon)
|
|
Back to top
|
|
|
RingMad
Joined: Jan 15, 2011 Posts: 427 Location: Montreal, Canada
Audio files: 4
|
Posted: Tue Sep 09, 2014 1:19 pm Post subject:
|
|
|
You could use one of the circuits posted in the thread "Pseudo-Random Bit Generators" here: http://electro-music.com/forum/topic-52066.html
and just use 3 outputs instead of 4. They are based on shift registers.
James. |
|
Back to top
|
|
|
okelk
Joined: May 08, 2014 Posts: 71 Location: Vienna
|
Posted: Wed Sep 10, 2014 7:15 am Post subject:
|
|
|
Thanks for your help!
I think I'll will explore the possibilities with shift registers....I'm kind of trying to avoid the cd4006 though... |
|
Back to top
|
|
|
synaesthesia
Joined: May 27, 2014 Posts: 291 Location: Germany
Audio files: 85
|
Posted: Wed Sep 10, 2014 9:43 am Post subject:
|
|
|
You could use a 4021 or 74HC595 as a shift register. The advantage of the 595 over the 4021 is that it has an edge-triggered RCLK input. You could send two high frequency inputs (>> sample frequency) to SER and SCLK and capture the state as a random value using RCLK.
The drawback of an LFSR is that when you clock it only once for a new random value and select the outputs from adjacent pins, two bits will always be copied from their predecessors. For example, you will never see a 000 following a 111 or vice versa. So for an LFSR use outputs a few bits apart, like Q0,Q3,Q6. |
|
Back to top
|
|
|
corex
Joined: Mar 02, 2010 Posts: 114 Location: Las Vegas
|
|
Back to top
|
|
|
okelk
Joined: May 08, 2014 Posts: 71 Location: Vienna
|
Posted: Thu Sep 18, 2014 9:15 am Post subject:
|
|
|
Thanks! That's great. I think I will try that with a 2 cd4015 because I have some lying around...
I found this table on Scott Gravenhorst's site. It shows the taps for various bit lengths.
http://home1.gte.net/res0658s/electronics/LFSRtaps.html
I wonder if it is better to get my three bits out of the 16 by taking three bits that are next to each other and let the shift register run at at least 3 times the speed of the 'sampling' clock, or if I should just take one from the end, one from the middle and one from the beginning... |
|
Back to top
|
|
|
corex
Joined: Mar 02, 2010 Posts: 114 Location: Las Vegas
|
Posted: Thu Sep 18, 2014 8:05 pm Post subject:
|
|
|
Thanks for finding that LFSR taps table, that's pretty handy!
Couple things. I found an old post by blue_hell where he recommends XNOR instead of XOR. With XNOR, the dead state is all 1's, so when it starts in the all 0's state, that is a valid state and it begins running immediately. That would be a good change.
Second, because it's a shift register, if you tap three consecutive bits then bit 2 will go to bit 1, and bit 1 to bit 0. The bits of the pattern will shift through the each of taps, one after the other. If the taps were further apart this would still be true but less apparent. |
|
Back to top
|
|
|
PHOBoS
Joined: Jan 14, 2010 Posts: 5591 Location: Moon Base
Audio files: 705
|
|
Back to top
|
|
|
okelk
Joined: May 08, 2014 Posts: 71 Location: Vienna
|
Posted: Fri Sep 19, 2014 8:23 am Post subject:
|
|
|
corex wrote: |
Second, because it's a shift register, if you tap three consecutive bits then bit 2 will go to bit 1, and bit 1 to bit 0. The bits of the pattern will shift through the each of taps, one after the other. If the taps were further apart this would still be true but less apparent. |
I'm planning to use the 3-bit number on the preset inputs of a 4029.
So If I choose 3 consecutive bits bits, then I would run the on 4029 at 1/3 of the shift register's clockspeed. I could use a 4013 and the leftover xor/xnor for a divide by 3 counter.
If I understand it right, this would also have the advantage that when the pseudo random sequence runs though the lfsr for the second and third time the 'sampled' 3-bit number wouldn't be the same because 3 is not a factor of the shift registers length. maybe, that way one 8-bit shift register would even be enough for my purposes...
on the other hand, I just found a few К176ИР10 (russian cd4006 equivalent) for really cheap....so maybe I just use them...
PHOBoS wrote: | you can find more taps (and info) here. |
good article, thanks! |
|
Back to top
|
|
|
okelk
Joined: May 08, 2014 Posts: 71 Location: Vienna
|
|
Back to top
|
|
|
Steveg
Joined: Apr 23, 2015 Posts: 182 Location: Perth, Australia
|
Posted: Sat Aug 08, 2015 11:36 pm Post subject:
|
|
|
Hello okelk,
I have some history with LSFRs and my take is that they are a waste of logic gates for a lunetta. It is much easier to build a rungler where you clock the shift register or whatever at the tempo you need and connect the data-input to a fast running oscillator. It doesn't have to be one specially dedicated to the task. Any LSFR that you can build with a reasonable number of chips will have a very short repetitive output.
If you do use a shift register rungler, don't use three consecutive taps unless you want each successive set of "random" bits to be strongly related to the last one. Using both halves of a 4015 and using taps 1, 3 and 7 would work well.
Personally I would use a couple of 4013s drive all the clocks from your tempo source and connect each data-in to a different audio oscillator. That would give you 4 high quality random bits for whatever purpose you need.
[Edit] And now I see that synasthesia gave the exact same advice earlier and this thread is resurrected from 2014 ... such is life. |
|
Back to top
|
|
|
JovianPyx
Joined: Nov 20, 2007 Posts: 1988 Location: West Red Spot, Jupiter
Audio files: 224
|
|
Back to top
|
|
|
|