electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » Lunettas - circuits inspired by Stanley Lunetta
easiest 3-bit random binary number generator?
Post new topic   Reply to topic Moderators: mosc
Page 1 of 1 [14 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
okelk



Joined: May 08, 2014
Posts: 71
Location: Vienna

PostPosted: Mon Sep 08, 2014 9:29 am    Post subject: easiest 3-bit random binary number generator? Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
gdavis



Joined: Feb 27, 2013
Posts: 359
Location: San Diego
Audio files: 1

PostPosted: Mon Sep 08, 2014 1:48 pm    Post subject: Reply with quote  Mark this post and the followings unread

How about a linear feedback shift register (LFSR)?
http://wiki.osdev.org/Random_Number_Generator#Linear_feedback_shift_register

_________________
My synth build blog: http://gndsynth.blogspot.com/
Back to top
View user's profile Send private message
DUBmatze



Joined: Feb 18, 2013
Posts: 150
Location: south Germaica (schwabilon)

PostPosted: Mon Sep 08, 2014 1:50 pm    Post subject: Reply with quote  Mark this post and the followings unread

mhm ... i have somthing like that in my lunetta ....
this is not realy random.

i use the same value for C1 - C4 and some close values for R1 - R4 (cant remember but somthing like 2,2 - 2,5 - 3 - 3,5
maybe you can bild this with just 3 osc.

U1 is starve down with the pot for changing the speed. U2 will nice up the signals with the schmitt inputs back to 5V...


random.png
 Description:
 Filesize:  20.22 KB
 Viewed:  494 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

random.png


Back to top
View user's profile Send private message Visit poster's website
RingMad



Joined: Jan 15, 2011
Posts: 427
Location: Montreal, Canada
Audio files: 4

PostPosted: Tue Sep 09, 2014 1:19 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
okelk



Joined: May 08, 2014
Posts: 71
Location: Vienna

PostPosted: Wed Sep 10, 2014 7:15 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
synaesthesia



Joined: May 27, 2014
Posts: 291
Location: Germany
Audio files: 85

PostPosted: Wed Sep 10, 2014 9:43 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
corex



Joined: Mar 02, 2010
Posts: 114
Location: Las Vegas

PostPosted: Wed Sep 17, 2014 9:51 pm    Post subject: Reply with quote  Mark this post and the followings unread

I sketched up the LSFR depicted here (wikipedia). Each of the 16-bits out (Q1-Q8 on each of IC1 and IC2) comprise the current state. I chose the 4094 because I have those on hand. Double-buffering is not used in this design, so STR is tied to CLK. Take bits from IC2.QS as output.

From the wiki article: "...the register cycles through the maximum number of 65535 states excluding the all-zeroes state." Assuming it doesn't start all-zero.

Edit: it needs a kick-start to IC1.D because it does start empty. The all-zero state is a dead state. If you clock at least one 1 into IC1.D, it will enter a valid state and cycle normally.


linear feedback shift register.png
 Description:
 Filesize:  4.76 KB
 Viewed:  509 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

linear feedback shift register.png


Back to top
View user's profile Send private message
okelk



Joined: May 08, 2014
Posts: 71
Location: Vienna

PostPosted: Thu Sep 18, 2014 9:15 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
corex



Joined: Mar 02, 2010
Posts: 114
Location: Las Vegas

PostPosted: Thu Sep 18, 2014 8:05 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 5591
Location: Moon Base
Audio files: 705

PostPosted: Fri Sep 19, 2014 6:04 am    Post subject: Reply with quote  Mark this post and the followings unread

you can find more taps (and info) here.
_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider Twitch YouTube
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
okelk



Joined: May 08, 2014
Posts: 71
Location: Vienna

PostPosted: Fri Sep 19, 2014 8:23 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
okelk



Joined: May 08, 2014
Posts: 71
Location: Vienna

PostPosted: Sat Aug 08, 2015 6:54 am    Post subject: Reply with quote  Mark this post and the followings unread

okelk wrote:
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


just for future reference...this link seems to be dead...
here's a link to a snapshot in the wayback mashine:

http://web.archive.org/web/20140627102757/http://home1.gte.net/res0658s/electronics/LFSRtaps.html
Back to top
View user's profile Send private message
Steveg



Joined: Apr 23, 2015
Posts: 182
Location: Perth, Australia

PostPosted: Sat Aug 08, 2015 11:36 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message
JovianPyx



Joined: Nov 20, 2007
Posts: 1988
Location: West Red Spot, Jupiter
Audio files: 224

PostPosted: Wed Aug 12, 2015 7:48 am    Post subject: Reply with quote  Mark this post and the followings unread

okelk wrote:
okelk wrote:
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


just for future reference...this link seems to be dead...
here's a link to a snapshot in the wayback mashine:

http://web.archive.org/web/20140627102757/http://home1.gte.net/res0658s/electronics/LFSRtaps.html


That link is indeed dead.

Here is the same document on an actively maintained site:

http://scott.joviansynth.com/electronics/LFSRtaps.html

_________________
FPGA, dsPIC and Fatman Synth Stuff

Time flies like a banana.
Fruit flies when you're having fun.
BTW, Do these genes make my ass look fat?
corruptio optimi pessima
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: mosc
Page 1 of 1 [14 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » Lunettas - circuits inspired by Stanley Lunetta
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use