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
<on air> EdisonRex Edison's Electronic Review
Please visit the chat
 Forum index » DIY Hardware and Software » Lunettas - circuits inspired by Stanley Lunetta
Euclidean rhythm generator
Post new topic   Reply to topic Moderators: mosc
Page 1 of 1 [21 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
PHOBoS



Joined: Jan 14, 2010
Posts: 1732
Location: Moon Base
Audio files: 346

PostPosted: Sun Jul 06, 2014 11:26 am    Post subject: Euclidean rhythm generator
Subject description: CMOS math
Reply with quote  Mark this post and the followings unread

I noticed some talk about euclidean generators on the forum (here's a nice module, and here's some chuck code),
and I wondered how hard it would be to make one with some cmos chips. Cool
I read the pdf that was posted which gave me an idea of using several counters but I was not really sure how yet.
It was this piece of code that Blue Hell posted that gave me the idea for the circuit.
Code:
    function EuclideanRhythm3( aPulses, aSteps: Integer): string;
    var
      Error : Integer;
      i     : Integer;
    begin
      Result := '';
      if aSteps > 0
      then begin
        Error := 0;
        for i := 0 to aSteps - 1
        do begin
          Error := Error + aPulses;
          if Error > 0
          then begin
            Result := Result + '1';
            Error  := Error - aSteps;
          end
          else Result := Result + '0';
        end;
      end;
    end;


focussing on this section
Code:
 
          Error := Error + aPulses;
          if Error > 0
          then begin
            Result := Result + '1';
            Error  := Error - aSteps;
          end
          else Result := Result + '0';

It starts with adding a value (the number of pulses), then compares it (in this case with 0) and based on the outcome it either puts out a 1 and
subtracts a value (the number of steps), or it puts out a 0. And then it loops back. Adding and subtracting is nothing more then counting up or
down, so it switches between counting up or down a preset amount (steps, pulses).

In the original code the error value also goes negative which would add some unnecessary complexity to the circuit so I had to shift it to use
positive values only. For 8 steps it needs to be shifted 7 places so the Error value stays between 0 and 15. So I basically changed
[if Error > 0] to [if Error > 7]
For counting up/down a CD4029 seemed like a logical choice (but a CD4510 should work as well). It can count from 0 to 15 and to check if it
has counted above 7 you only have to look if output D is high Very Happy
Then 2 more counters, one for the number of steps and one for the number of pulses and some sort of comparator/switch.

So I tried patching something up on my modular lunetta to see how far I could get and I actually managed to get it working somewhat. However
the result wasn't synced to anything yet and the shiftregister was loaded at an uneven pace. And because I only have 1 decimal counter in there I
used a binary counter and could only do 2/4/8 steps. Since the results of 2 and 4 steps can also be achieved with 8 steps I didn't test those.
Here's what that first patch looked like:
Posted Image, might have been reduced in size. Click Image to view fullscreen.
Code:
 
Error := Error + aPulses;    (up/dwn = 1, count 'aPulses' steps using digital counter)
if Error > 7                 (output D of binary counter = 1)
then begin
  Result := Result + '1';    (shiftregister data 1, CLK 1 step)
  Error  := Error - aSteps;  (up/down = 0, count 'aSteps' steps using binary divider)
end
else Result := Result + '0'; (shiftregister data = 0, CLK 1 step)


When I tried to simplify the circuit (like replacing the NAND followed by an XNOR used as an inverter with a single AND) it didn't work anymore.
And although I got that part fixed after some small changes, it still looked a bit to chaotic compared to the code. It was after I changed the FlipFlop
from a Set/Reset to a D-type (with reset) that the circuit got it's current form. And by using a second FlipFlop I got it synced to an external CLK.
I also managed to get rid of the shiftregister for a lower chipcount, but it can still be added as an option. Might be fun with some resistors as a CV
generator Razz


Posted Image, might have been reduced in size. Click Image to view fullscreen.

The circuit has an internal oscillator which basically 'runs' the circuit between CLK pulses. So it calculates and waits until the CLK goes high
before the result appears on the output. (and then it waits for the CLK to go low and calculates the next and so on). Because of this oscillator there
is a maximum CLK frequency for which the circuit works. I initially wanted to set the internal CLK frequency at 100KHz but at high speeds the circuit
doesn't work anymore Confused. So I had to experiment a bit and with the current values it seems to work fine. However it's too slow to use it for
audio frequencies (not sure if that would be very useful and not what I designed it for anyway). If my calculations are correct it runs at ±200Hz
so with the counter having to count a maximum of 16 steps ( 8,8 ) the CLK could be 12.5Hz max.

The reset was the last addition to the circuit and although it seems to work there is a lag of 1 or 2 CLK pulses depending on when you press/release
the button, so I might do some more tests with that.


note: the connection between pin 2 and 5 of U2a is done for easy PCB design. The D input needs to be high when the CLK goes high and it
doesn't matter when the CLK is low, which happens to correspond with the /Q output. But you could tie pin 5 directly to (+) as well


!updated schematic 4 posts down!


Euclidean lunetta patch.gif
 Description:
Euclidean lunetta patch
 Filesize:  38.88 KB
 Viewed:  19 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

Euclidean lunetta patch.gif



Euclidean Rhythm Generator v2.1.gif
 Description:
Euclidean Rhythm Generator by PHOBoS
 Filesize:  143.88 KB
 Viewed:  28 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

Euclidean Rhythm Generator v2.1.gif



_________________
"My perf, it's full of holes!"
http://phobos.000space.com/ http://www.acidtrash.com/ Stickney Synthyards

Last edited by PHOBoS on Mon Jul 07, 2014 5:43 am; edited 2 times in total
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
DUBmatze



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

PostPosted: Sun Jul 06, 2014 2:05 pm    Post subject: Reply with quote  Mark this post and the followings unread

WOW!
amzing!
i have also have read the post with the euclidean generator. (all i have done was order 2 of the LED matrixes in china... and store them somewehre 5 weeks later)

_________________
http://matze.reggaestriert.de/diy-projekte/

Last edited by DUBmatze on Sun Jul 06, 2014 2:07 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 20570
Location: The Netherlands, Enschede
Audio files: 148
G2 patch files: 318

PostPosted: Sun Jul 06, 2014 2:06 pm    Post subject: Reply with quote  Mark this post and the followings unread

Ah you did it!

party!

_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
commathe



Joined: Jul 26, 2013
Posts: 80
Location: Beijing
Audio files: 5

PostPosted: Sun Jul 06, 2014 6:30 pm    Post subject: Reply with quote  Mark this post and the followings unread

Fantastic! I'm really into Euclydian rhythms myself, though I usually do it in Max. I will definitely be looking into making one of these in the future! Incredible work!

EDIT: Seriously, mind blown by this. Very cool.
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 1732
Location: Moon Base
Audio files: 346

PostPosted: Mon Jul 07, 2014 5:28 am    Post subject: Euclidean Rhythm Generator
Subject description: updated schematic
Reply with quote  Mark this post and the followings unread

Laughing

I made a small change to the circuit, which seemed to have solved the internal CLK speed problem. It also looks like it was only the shiftregister
that wasn't functioning correctly the output LED gave the correct rhythm. But I hadn't noticed that because I did the tests with the shiftregister since it's
easier to see the pattern that way. Anyway I now have it running at a much higher speed and so far it seems to be functioning correctly. I will solder it
onto a piece of perf and do some more tests to be sure.


Euclidean Rhythm Generator v2.2.gif
 Description:
Euclidean Rhythm Generator v2.2
(higher internal CLK speed)
 Filesize:  145.97 KB
 Viewed:  70 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

Euclidean Rhythm Generator v2.2.gif



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



Joined: Apr 15, 2006
Posts: 157
Location: shoreditch
Audio files: 1

PostPosted: Mon Jul 07, 2014 12:45 pm    Post subject: Reply with quote  Mark this post and the followings unread

Exemplary.

and the 4051s Twisted Evil ....


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



Joined: Jan 14, 2010
Posts: 1732
Location: Moon Base
Audio files: 346

PostPosted: Mon Jul 07, 2014 1:42 pm    Post subject: Reply with quote  Mark this post and the followings unread

Seems to work on perfboard as well banana

piedwagtail wrote:
Exemplary.

and the 4051s Twisted Evil ....

I thought about that, assuming you mean using muxes instead of the switches, and I think that should work Very Happy .
But I was also thinking about making a PIC version which could have 2 generators with 4bit inputs, and one 4bit input for the number of steps.
With 4051's you would need 7 chips for one 8 step generator, versus 1 chip (PIC) with two 16 step generators, hmm Rolling Eyes

but I bet it's a lot of fun Twisted Evil

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/ http://www.acidtrash.com/ Stickney Synthyards

Last edited by PHOBoS on Mon Jul 07, 2014 3:46 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
piedwagtail



Joined: Apr 15, 2006
Posts: 157
Location: shoreditch
Audio files: 1

PostPosted: Mon Jul 07, 2014 2:08 pm    Post subject: Reply with quote  Mark this post and the followings unread

It seems contrary to your stripboard genius to put a PIC in there Confused .

I'd like to try out Altera CPLDs and Quartus to accomplish CMOS extravaganzas of such scale. The directness of avoiding microprocessors and the schematic design input are very attractive. It's not 4000 series but it still feels like CMOS cookbook to me. Whereas PICs seem as detached as VSTi.

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



Joined: Apr 15, 2006
Posts: 157
Location: shoreditch
Audio files: 1

PostPosted: Fri Jul 11, 2014 12:42 am    Post subject: Reply with quote  Mark this post and the followings unread

Struggling to understand quite what you did here.

......


For anyone wondering what I was suggesting with 4051s the moment I saw the 8 way switches I saw a user control issue in music. The music would be rather rhythmically static with switches in that nothing changes until the musician actively changes a switch. Which is fine if you like hands always on.

Some people (or perhaps just me) want to set up CVs to change such parameters moving to the ultimate - hands always off.
Hence my jump to 8 into 1 mux.

Not that I'd thought about how to CV a 4051.

So I find the miracle that is the 3 bit flash ADC

Posted Image, might have been reduced in size. Click Image to view fullscreen.

which has the unique ability to play with the resistor string (comparator trigger points).
Empirical testing of resistor string between +/- supply will be necessary to suit the CV range needed.

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



Joined: Jul 26, 2013
Posts: 80
Location: Beijing
Audio files: 5

PostPosted: Fri Jul 11, 2014 2:24 am    Post subject: Reply with quote  Mark this post and the followings unread

What advantages are there to using the XORs over using a 4014 or 74HC148 (or some other priority encoder)?
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 1732
Location: Moon Base
Audio files: 346

PostPosted: Fri Jul 11, 2014 2:50 am    Post subject: Reply with quote  Mark this post and the followings unread

commathe wrote:
What advantages are there to using the XORs over using a 4014 or 74HC148 (or some other priority encoder)?

Posted Image, might have been reduced in size. Click Image to view fullscreen.
(from this page which also has the XOR/diode encoder)
I don't think there is an advantage in using XOR's, on the contrary you need an extra chip and some extra diodes.
But having said that, I think it'll be more common to have some XOR's and diodes lying around then a priority encoder.
You could also replace the opamps with a LM3914 for a 2 chip version. Someone actually suggested that combo recently,
but I forgot in which thread.

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



Joined: Apr 15, 2006
Posts: 157
Location: shoreditch
Audio files: 1

PostPosted: Fri Jul 11, 2014 6:47 am    Post subject: Reply with quote  Mark this post and the followings unread

Quote:
What advantages are there to using the XORs over using a 4014 or 74HC148 (or some other priority encoder)?


4014 needs clocked loading doesn't it, though that could be a sync feature?
74HC148 is low voltage per the datasheets, not 15V.
4070s are gathering dust and the transfer function is in the pico second category for when you need a quick decision made fast Twisted Evil

Didn't Ian Fritz mention about comparator switching problems with the LM3914?
plus as mentioned you can squeeze the string to suit your expected CVs whereas the 3914 is equal divisions as per the reference voltage which might be restricting or required in differing applications.


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



Joined: Jan 14, 2010
Posts: 1732
Location: Moon Base
Audio files: 346

PostPosted: Fri Jul 11, 2014 7:22 am    Post subject: Reply with quote  Mark this post and the followings unread

piedwagtail wrote:
4014 needs clocked loading doesn't it, though that could be a sync feature? 74HC148 is low voltage per the datasheets, not 15V.

Hmm I don't remember using a clock with a priority decoder, but I might be wrong or maybe I used a different one.
let me look that up,...

ah, I used the 4532, which doesn't have a CLK, the 4014 is a shiftregister Confused . 74HC series is indeed 5V max.

Quote:
Didn't Ian Fritz mention about comparator switching problems with the LM3914?

I think that 'problem' is that in dot mode the outputs overlap, so 2 outputs can be high at the same time and that could be a problem
for some circuits. However if you add a priority decoder that doesn't matter, and then you could also use it in bar mode.

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



Joined: Apr 15, 2006
Posts: 157
Location: shoreditch
Audio files: 1

PostPosted: Fri Jul 11, 2014 7:47 am    Post subject: Reply with quote  Mark this post and the followings unread

4532!
Wink

Ok that wins!

But if one wanted to jiggle a +/- 5V CV into the LM3914 that needs a fair bit of support structure to align the response whereas the resistor string is a little more straightforward (I presume) and could be presettable.


musing
An outside clocked s/h can change the euclidean rhythm at points sync'd to the master clock or more probably its inverse, through a divider etc.


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



Joined: Jan 14, 2010
Posts: 1732
Location: Moon Base
Audio files: 346

PostPosted: Fri Jul 11, 2014 8:07 am    Post subject: Reply with quote  Mark this post and the followings unread

piedwagtail wrote:
Struggling to understand quite what you did here.


Here's a slightly different simplified version without external CLK and reset, see if you can understand how that one works,.
and then you should be able to figure out the final version. Cool

Basically it counts up the number of steps that is set with the pulses switch, then it checks if the binary counter (4029) has counted >7 using
the flipflop. If so it will count down the number of steps that is set with the steps switch and then count up again, if not it will count up again straight
away.


Euclidean Rhythm Generator BLOCK.gif
 Description:
Euclidean Rhythm Generator
simplified version BLOCK schematic.
 Filesize:  24.94 KB
 Viewed:  26 Time(s)
This image has been reduced to fit the page. Click on it to enlarge.

Euclidean Rhythm Generator BLOCK.gif



_________________
"My perf, it's full of holes!"
http://phobos.000space.com/ http://www.acidtrash.com/ Stickney Synthyards
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: 1732
Location: Moon Base
Audio files: 346

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

piedwagtail wrote:
But if one wanted to jiggle a +/- 5V CV into the LM3914 that needs a fair bit of support structure to align the response whereas the resistor string is a little more straightforward (I presume) and could be presettable.


hmm it's actually not that hard to set the correct responce for the LM3914 and not using LED's makes it slightly easier.
However I'm not sure if you can tie the outputs directly to the priority decoder. I think the voltage levels are correct but I seem to recall
something about them being inverted or maybe that was a different chip. And yeah with resistors you can change the responce, heck go nuts
and use potentiometers Razz (which you could replace with vactrols etc,..)

Quote:
musing
An outside clocked s/h can change the euclidean rhythm at points sync'd to the master clock or more probably its inverse, through a divider etc.


and then you could,..
there's no end to it Shocked as you probably already know
but please keep coming up with those ideas Laughing

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



Joined: Apr 15, 2006
Posts: 157
Location: shoreditch
Audio files: 1

PostPosted: Fri Jul 11, 2014 8:33 am    Post subject: Reply with quote  Mark this post and the followings unread

Quote:
Basically it counts up the number of steps that is set with the pulses switch, then it checks if the binary counter (4029) has counted >7 using
the flipflop. If so it will count down the number of steps that is set with the steps switch and then count up again, if not it will count up again straight
away.


Thanks!
Ok, there's a door creaking open in my head Smile

Quote:
which you could replace with vactrols etc


right - ldrs and hamsters in wheels to configure Laughing

Quote:
but please keep coming up with those ideas


it's much easier for me to see those ideas with your solution than with code or the microprocessor versions.

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



Joined: Jul 26, 2013
Posts: 80
Location: Beijing
Audio files: 5

PostPosted: Fri Jul 11, 2014 9:32 am    Post subject: Reply with quote  Mark this post and the followings unread

PHOBoS wrote:
You could also replace the opamps with a LM3914 for a 2 chip version. Someone actually suggested that combo recently,
but I forgot in which thread.
That was actually me! It pulls low rather than high though, as it is for driving LEDs so it'd probably need some inverters in there. I think the 74xx 8 to 3 line encoder looks for negative, rather than positive, signals though so that could be a possibility
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 1732
Location: Moon Base
Audio files: 346

PostPosted: Fri Jul 11, 2014 10:35 am    Post subject: Reply with quote  Mark this post and the followings unread

piedwagtail wrote:
right - ldrs and hamsters in wheels to configure Laughing

you just made me visualize a hamsterwheel array
thanks for that.

commathe wrote:
PHOBoS wrote:
You could also replace the opamps with a LM3914 for a 2 chip version. Someone actually suggested that combo recently,
but I forgot in which thread.
That was actually me! It pulls low rather than high though, as it is for driving LEDs so it'd probably need some inverters in there. I think the 74xx 8 to 3 line encoder looks for negative, rather than positive, signals though so that could be a possibility

Very Happy
ah so it does pull low, ok Smile let me see what the 74xx does,
hmm there's the 74147, 74148, 74348, 74748, 74848 Shocked
74147 & 74148 have both in- and outputs working on low levels (inverted).
The other ones don't seem to be very common, so there's not much use in looking that up.

In that case 8 7 opamps + CD4532 looks like the best option.

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



Joined: Jul 26, 2013
Posts: 80
Location: Beijing
Audio files: 5

PostPosted: Fri Jul 11, 2014 7:34 pm    Post subject: Reply with quote  Mark this post and the followings unread

Now I feel really silly. Because the 4532 is called an "8 bit priority encoder" rather than a "8-line to 3-line priority encoder" I always thought it didn't something else Embarassed Seems I've been wasting my time with the 74HC148 when there was a CMOS chip that did exactly what I wanted... *sigh* The biggest bummer is I just put in a huge order and it already shipped out. I would have loved to have picked a few of those up if I realised what they were (as I ordered more 74HC148s...)

I always thought that the 8th op-amp could be used as a "clipping" detector if set up right. Use it to drive an LED to show a signal is exceeding the adc's range. Again, this is what I liked about the LM3914 - 10 outs, and they are already LED drivers so you could show negative and positive peak clipping. This'd be more useful for ac/audio than CV though.
Back to top
View user's profile Send private message
PHOBoS



Joined: Jan 14, 2010
Posts: 1732
Location: Moon Base
Audio files: 346

PostPosted: Sat Jul 12, 2014 3:43 am    Post subject: Reply with quote  Mark this post and the followings unread

I can see how "8 bit priority encoder" can be confusing, I probably saw it in another circuit once and therefor know what it is and does.
And I'm familiar with needing something else just after ordering, happens way too often

A clipping indicator sounds like a good use for the spare opamp thumleft

_________________
"My perf, it's full of holes!"
http://phobos.000space.com/ http://www.acidtrash.com/ Stickney Synthyards
Back to top
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic Moderators: mosc
Page 1 of 1 [21 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
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