electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
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 
Live streaming at radio.electro-music.com

  host / artist show at your time
  Muied Lumens Frequencies
Please visit the chat
 Forum index » DIY Hardware and Software
CD4021 shift register magic?
Post new topic   Reply to topic Moderators: jksuperstar, Scott Stites, Uncle Krunkus
Page 1 of 1 [8 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
e1999



Joined: Apr 25, 2019
Posts: 26
Location: naples

PostPosted: Thu Dec 12, 2019 8:38 am    Post subject: CD4021 shift register magic? Reply with quote  Mark this post and the followings unread

Hi Ladies and Gents

Anyone fancy discussing the CD4021?

Of course this is the chip used in the Rob Hordijk's Rungler circuit but what are some other ways it has been or could be used?

I'd be interested in hearing anything anyone wants to share regarding this chip, although I do have a few specific questions.

I'm interested in making a pulse generator/sequencer/pseudo-not-sequencer, that can go from standard user controlled input to controlled randomness. Initially I'd been using several oscillators gating each other out of a 4093, and I was surprised at the variety of rhythms (and their musicality) that could be generated with just a few knobs. I thought a shift register might be a way to expand this idea further.

So far what i've gotten out of it is interesting if not mostly arrhythmic, and very random and hard to control in any predictable way. It also tends towards faster rhythms because it seems to stop outputting pulses when the clock frequency falls below a certain threshold, or if clock and serial oscillator are at certain settings in relation to each other.

Does anyone know if its possible to output p1-8 in plain vanilla fashion in the way that the Klee sequencer can play a programmed sequence back and then the user can affect or indicate how much randomness?

The datasheet hints at this saying:
"When the PARALLEL/SERIAL CONTROL
input is high, data is jammed into the 8-stage register via the parallel input lines and synchronous with the positive transition of the clock line. In the CD4021B, the CLOCK input of the internal stage is "forced" when asynchronous parallel entry is made"

When I pull P/S high it seems to just stop outputting anything at all.
And can anyone explain the last sentence of that quote about "the clock input of the internal stage...asynchronous parallel entry..."

Anyone have an idea why it seems to stop spitting out pulses when the clock goes too slow or when the clock and serial are at certain settings?

One thing I like about the chip is that adding all the Q outputs together you get a kind of pulse phasing that sounds quite nice with certain percussion voices. But maybe a different shift register ic is more suited to what I want to do?

Would love to hear any thoughts on this strange chip.
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 4723
Location: Moon Base
Audio files: 641

PostPosted: Thu Dec 12, 2019 2:55 pm    Post subject: Re: CD4021 shift register magic? Reply with quote  Mark this post and the followings unread

Quote:
Does anyone know if its possible to output p1-8 in plain vanilla fashion in the way that the Klee sequencer can play a programmed sequence back and then the user can affect or indicate how much randomness?

yes, or at least you will only get 3 outputs at a time, but let me add that to the answer of the next question.

Quote:
The datasheet hints at this saying:
"When the PARALLEL/SERIAL CONTROL
input is high, data is jammed into the 8-stage register via the parallel input lines and synchronous with the positive transition of the clock line. In the CD4021B, the CLOCK input of the internal stage is "forced" when asynchronous parallel entry is made"

When I pull P/S high it seems to just stop outputting anything at all.
And can anyone explain the last sentence of that quote about "the clock input of the internal stage...asynchronous parallel entry..."

ok, so when the par/ser control (pin 9) is low it works as a standard shiftregister. Data on the serial input (pin 11) is shifted through
everytime the clock input (pin 10) changes from low to high. The first output is stage 6 (pin 2) so it'll take 6 transitions before the
data appears on the this output.

When the par/ser control is high data on the parallel inputs is loaded into every stage of the siftregister and appears on the outputs.
Since only the last 3 stages are available as outputs you won't see data that is added to the parallel inputs P1~P5 but it is loaded into
the shiftregister. Asynchronous means it happens instantly and not on a clock transition and as long as the par/ser control pin is high
the clock is ignored, so it won't shift anything.

This could be useful if you want to make a sequencer: add some switches to the parallel inputs to 'program' the desired sequence
and send a short (high) pulse to the par/ser ctrl pin. For experimenting you could simply use a pushbutton to do this (you also need
a pulldown resistor to keep the input low if the button isn't pressed). If you add a clock signal after loading the sequence it will shift
through the shiftregister.

Of course after 8 steps it would be empty again but if you connect the last output (pin 3) to the serial input it will keep shifting around
and around and around untill another sequence is loaded or you break the connection. If you want to have some more fun you can add
an XOR gate between the output and the serial input. if the other input of the XOR is low it will just function as before, however if you
make it high it will invert the data. If you control this pin with a noise source you have the basics of the turing machine and I think the
rungler functions like this aswell. To control how much the sequence will be changed (inverted) you can add a comparator with an adjustable
treshold level between the noise source and the XOR. If you set this level high it will only invert bits occasionally (or not at all if you set it
higher than the output of the noise source) if you set it low it will invert a lot of the bits creating a more random sequence.

Quote:
So far what i've gotten out of it is interesting if not mostly arrhythmic, and very random and hard to control in any predictable way. It also tends towards faster rhythms because it seems to stop outputting pulses when the clock frequency falls below a certain threshold, or if clock and serial oscillator are at certain settings in relation to each other.

Using 2 oscillators is another way to create a sequence. as you already noticed the output data depends on the relation between the
2 oscillators. When you set them exactly 'right' you'll get a repeating sequence but if it is a bit off the sequence will slowly change up
to a point where it seems random. Speaking of random a shiftregister (and one or more XOR gates) can be used to create a pseudo
random generator or Linear-feedback shift register (LFSR).

Instead of using 2 oscillators you can also use one oscillator which you connect to the clock input and also to a counter/divider and then
connect an output of this counter/divider to the serial input. This wil result in a repeating sequence that doesn't change if you adjust the
frequency. You can find some examples of that in the thread about the CMOS waveshaper

For an analog output the CD4021 and a resistor network works very nice. Personally I like to use a shiftregister which has all stages
available like the CD4015 or CD4094 and use these outputs to control other digital inputs. They don't have parallel inputs though.

Quote:
Anyone have an idea why it seems to stop spitting out pulses when the clock goes too slow or when the clock and serial are at certain settings?

This could happen if you have some pins floating and indeed also at certain ratios between the oscillators but unless they are very stable and
precisely tuned you should get something out of it. Or if you use very short pulses on the serial input it might hardly ever 'catch' them.

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
PHOBoS



Joined: Jan 14, 2010
Posts: 4723
Location: Moon Base
Audio files: 641

PostPosted: Thu Dec 12, 2019 3:07 pm    Post subject: Reply with quote  Mark this post and the followings unread

I also used shiftregisters in the RGB Shroom Synth & Drums
_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
e1999



Joined: Apr 25, 2019
Posts: 26
Location: naples

PostPosted: Fri Dec 13, 2019 2:51 am    Post subject: Reply with quote  Mark this post and the followings unread

hi Phobos,
thank you once again for such a detailed answer!
this really clarified things for me quite a lot.

also the links that you included to that Waveshaper and your RGB Shroom Synth and Drums look very interesting. definitely going to have a closer look at those when I have the time.

If I use switches to set p1-8 on or off, do you think I would need pull down resistors on those pins for that fraction of a second that the pin is left floating?

also, one other question- not so much related directly to shift register, you mentioned using a pushbutton to pulse the p/s ctrl pin...

I've only been making circuits since this summer, but from my experience so far, the momentary push buttons i've found tend to be somewhat unreliable (ie double triggering, unwanted crackling in the signal if its being used to trigger a drum, and things of that nature). I found that using the pushbutton to control a vactrol that gates the pulse or signal actually improves things a lot, i guess due to the led/ldr natural decay time. but that can end up being a lot of vactrols!

When making actual builds do you have any preferred way of implementing
pushbuttons? would it be possible or worthwhile to buffer the outgoing side of the pushbutton with a transistor to keep the pulse "clean"?
Back to top
View user's profile Send private message
MapacheRaper



Joined: Feb 15, 2018
Posts: 164
Location: Spain

PostPosted: Fri Dec 13, 2019 11:36 am    Post subject: Reply with quote  Mark this post and the followings unread

Phobos is such a luxury of this forum. Finally I understood the Turing mechanics and how to do the looping in the Rungler (that I have breadboarded but didnt know how to put it to loop)

Thanks!
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 4723
Location: Moon Base
Audio files: 641

PostPosted: Fri Dec 13, 2019 3:49 pm    Post subject: Reply with quote  Mark this post and the followings unread

Quote:
If I use switches to set p1-8 on or off, do you think I would need pull down resistors on those pins for that fraction of a second that the pin is left floating?

That would only happen if you use a toggle switch between V+ and GND. You can prevent it by only switching to V+ and using pulldown
resistors. In this case I don't think it would cause any problems though as the parallel inputs are only read when the par/ser ctrl pin is high.
Although if you use the outputs of the shiftregister to CLK something and you toggle the switches while the par/ser ctrl pin is high it might
do something you don't want but that can also happen just because of some bouncing caused by the switch itself, which I will get into with the
next question. Also if you don't want to use the parallel inputs at all I would still connect them to something and not leave them floating.
I don't think it would cause any issues but better safe than sorry.

Quote:
also, one other question- not so much related directly to shift register, you mentioned using a pushbutton to pulse the p/s ctrl pin...
I've only been making circuits since this summer, but from my experience so far, the momentary push buttons i've found tend to be somewhat unreliable (ie double triggering, unwanted crackling in the signal if its being used to trigger a drum, and things of that nature).

That's bouncing and just something that happens with mechanical contacts. In case you are not familiar with switch bouncing it happens
because contacts don't make an instant connection, they literally bounce a bit on/off. Although this happens very fast and the duration is
usually short, digital chips are susceptible to this since they can work at high frequencies, and if there is a lot of bouncing it can be audible.

It does matter what kind of switch you use. A simple pushbutton relies on pressure (and speed) to make a connection. if you don't press it
hard enough it can produce a lot of noise. Better are microswitches that use a snap-action mechanism which is like the mechanical equivalent
of a comparator. So when you press it it will switch at some point and make a very fast connection unrelated to the pressure you use.

Quote:
I found that using the pushbutton to control a vactrol that gates the pulse or signal actually improves things a lot, i guess due to the led/ldr natural decay time. but that can end up being a lot of vactrols!

You are correct. A vactrol works as a low pass filter which is helpful to debounce a switch. It's just the LDR btw, the LED itself can switch on/off
VERY fast but the LDR has a rather slow responce. (can be nice for audio circuits).

Quote:
When making actual builds do you have any preferred way of implementing
pushbuttons? would it be possible or worthwhile to buffer the outgoing side of the pushbutton with a transistor to keep the pulse "clean"?

A transistor wouldn't be helpful here just a debounce circuit which can be simple depending on the quality of the switch.
I wrote something about that very recently here.



MapacheRaper wrote:
Phobos is such a luxury of this forum. Finally I understood the Turing mechanics and how to do the looping in the Rungler (that I have breadboarded but didnt know how to put it to loop)

aw, thanks! it's great to hear it's helpful Very Happy

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
PHOBoS



Joined: Jan 14, 2010
Posts: 4723
Location: Moon Base
Audio files: 641

PostPosted: Sun Dec 15, 2019 9:35 am    Post subject: Reply with quote  Mark this post and the followings unread

Julian Ilett made a nice video about shiftregisters and XORs:
https://www.youtube.com/watch?v=juoM7VhXQDM

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/
SoundCloud BandCamp MixCloud Stickney Synthyards Captain Collider
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
JovianPyx



Joined: Nov 20, 2007
Posts: 1943
Location: West Red Spot, Jupiter
Audio files: 221

PostPosted: Sun Dec 29, 2019 10:54 am    Post subject: Reply with quote  Mark this post and the followings unread

Don't let this side-track this thread, this is just incidental information that some might find interesting.

Xilinx has an excellent document regarding LFSR pseudo random number generators.

LFSR

It explains LFSR action, shows example circuits and at the end is the gift of a table of LFSR shift register sizes along with taps for maximal sequences. The table gives LFSR sizes up to 168 stages.

Note that these systems can have problems, especially as the shift register is made larger (which has the advantage of not repeating after a longer period of time than shorter registers run at the same clock rate). The state of all zeroes is usually forbidden and never comes up (however, the XORs can be wired to forbid all ones pattern instead of all zeroes), but all of the other numbers do. This means that a 32 bit register will have somewhere in the sequence a stream of 31 consecutive zeroes. If the stream were listened to directly, that would cause a noticeable artifact in the sound. This can be avoided using several techniques, one technique would be something like running two LFSRs of different lengths and XORing the bits together. For example, for 32 bit results, a 32 stage register and a 33 stage register could be used with the 33 stage register just not using one of the bits in the output.

_________________
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: jksuperstar, Scott Stites, Uncle Krunkus
Page 1 of 1 [8 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
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
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


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