Euclidean Polyrhythm generator - code and details
Moderators: Kent, luketeaford, Joe.
- whoop_john
- Veteran Wiggler
- Posts: 693
- Joined: Sun Mar 17, 2013 12:03 am
- Location: London UK
I don't use Arduinos or Atmel chips, I am coding directly for the PIC18F2520 for this project. I have an interrupt running that allows 96 time divisions per beat, up to a tempo of 180bpm, which I think should be enough for jazz.Grumble wrote:Do you use the Parola MAX7219 library? Since this may be at fault: http://forum.arduino.cc/index.php?topic=252091.0
I will be adding a one-shot LCM option that will calculate the least common multiple of all active sequences and output a single pattern, say for being sampled or for being triggered at key moments. The LCM of sequences of length 16, 15, 14 and 13, for example, would output 21,840 steps and stop. For 16, 8, 4 and 2 it would only output 16 steps.
Ⓞⓝⓔ ⓓⓐⓨ ⓨⓞⓤ ⓦⓘⓛⓛ ⓦⓐⓚⓔ ⓤⓟ ⓐⓝⓓ ⓕⓘⓝⓓ ⓨⓞⓤⓡⓢⓔⓛⓕ ⓓⓔⓐⓓ ⓐⓝⓓ ⓨⓞⓤ ⓦⓘⓛⓛ ⓢⓣⓐⓨ ⓛⓘⓚⓔ ⓣⓗⓐⓣ ⓕⓞⓡ ⓣⓗⓔ ⓡⓔⓢⓣ ⓞⓕ ⓨⓞⓤⓡ ⓛⓘⓕⓔ
I just put my Euclidean together and found I have rather 'noisy' triggers and as a result they don't actually trigger half of my modules. It would appear that patching via a buffered multiple removes the noise and leaves nice usable triggers. This affects all triggers and is the same whether the LED display is present or not. I assume this is ground related but I am not really sure where to start. Have I simply fried a transistor? Or should the pads 100K and BAT45S behind the reset jack not be shorted together? Any assistance appreciated.
The scope shot below shows the triggers coming out of the Euclidean. You can see the 'noise' and the triggers themselves seem to decay rather than end. This shot reflects the output regardless of which of my PSUs I use or what it shares the PSU with, including if it is on its own.

This next scope shot shows the triggers when patched into a buffered multiple and you can see they are nice and square. This reflects the trigger outputs regardless of whether the multiple shares the PSU with the Euclidean or whether the signal is read before or after its buffer.

Note - I don't have any encoders at the moment so these are simply missing.
The scope shot below shows the triggers coming out of the Euclidean. You can see the 'noise' and the triggers themselves seem to decay rather than end. This shot reflects the output regardless of which of my PSUs I use or what it shares the PSU with, including if it is on its own.

This next scope shot shows the triggers when patched into a buffered multiple and you can see they are nice and square. This reflects the trigger outputs regardless of whether the multiple shares the PSU with the Euclidean or whether the signal is read before or after its buffer.

Note - I don't have any encoders at the moment so these are simply missing.
- Grumble
- Super Deluxe Wiggler
- Posts: 1817
- Joined: Thu Dec 17, 2015 5:24 am
- Location: U aint much if U aint Dutch
- Contact:
The top figure shows a typical scope signal when there is no connection between de ground of the scope and the ground (0 volt) of the device under test (DUT).
As you can tell from the sinusoid signal it is 50 Hz (2 full sinusses in 40 Msec = 20 Msec/sinus = 50Hz)
So my guess is that you miss a connection inside the module or from the scope to the DUT.
The amplitude of the triggers is ok though (close to 5 volt)
As you can tell from the sinusoid signal it is 50 Hz (2 full sinusses in 40 Msec = 20 Msec/sinus = 50Hz)
So my guess is that you miss a connection inside the module or from the scope to the DUT.
The amplitude of the triggers is ok though (close to 5 volt)
Yes. I think I must be missing something obvious somewhere though as my testing appears to suggest there is no missing ground connectionGrumble wrote:The top figure shows a typical scope signal when there is no connection between de ground of the scope and the ground (0 volt) of the device under test (DUT).
As you can tell from the sinusoid signal it is 50 Hz (2 full sinusses in 40 Msec = 20 Msec/sinus = 50Hz)
So my guess is that you miss a connection inside the module or from the scope to the DUT.
The amplitude of the triggers is ok though (close to 5 volt)
I can measure continuity between ground on the header and all points that should be at ground on the PCB, including the jacks. I also have ground continuity to the sleeve of any cable plugged into the jack. The scope is then connected to the sleeve of the jack at the other end of the cable which also shows continuity when tested.

- Grumble
- Super Deluxe Wiggler
- Posts: 1817
- Joined: Thu Dec 17, 2015 5:24 am
- Location: U aint much if U aint Dutch
- Contact:
I think I see it: I think the transistors Q1 to Q4 are either of the wrong type (should be PNP in stead of NPN), or drawn wrong (Emitter and Collector switched)
This way the scope always sees a high impedance, hence the induced hum!
Edit: I see the 2N3904 is an NPN transistor, so the in drawing the Emitters and Collectors are switched.
This way the scope always sees a high impedance, hence the induced hum!
Edit: I see the 2N3904 is an NPN transistor, so the in drawing the Emitters and Collectors are switched.
Thanks for the inputs.
Following more testing I have found that simply probing the signal appears sufficient to make it trigger - this is with or without the probe grounded. As such the scope shots I posted above (which were taken without the triggers being patched anywhere else) are misleading since it would appear that they actually reflect the working state - although possibly also show a different problem.
As it stands I can patch straight from the Euclidean to my Toppo 281, Syncussion, Turing Machine, Barton Clock Divider or FCUK Enevelopes and they will react to the triggers just fine. However, if patched to my TH/Timo Bass++, either of my Barton Analog Drums, either of my Barton Decaying Analog Noises, my TH/Fonik CMOS ADSR or my fallabiels 808 Snare none will trigger unless patched via a buffered multiple. If not patched via a buffered multiple as soon as the probe of my scope is introduced to measure the trigger signal (at a point on or off PCB) it suddenly starts triggering successfully until the scope probe is removed again.
Pic of board in case that shows any oddities:

Probing the NPNs they don't seem to be connected as per the schematic. The base and collector appear to be as drawn but I can't seem to work out where the emitters are connected to. It does not appear to be VCC, in fact I seem to see M Ohms of resistance between the emitter and every point I tried on the board except ground where it is in the Ks.Grumble wrote:Connect the transistors like I suggested, or remove the transistors and the resistors R17, 2, 4 and 6 and use the outputs of the arduino directly to R16, 1, 3 and 5.
Following more testing I have found that simply probing the signal appears sufficient to make it trigger - this is with or without the probe grounded. As such the scope shots I posted above (which were taken without the triggers being patched anywhere else) are misleading since it would appear that they actually reflect the working state - although possibly also show a different problem.
As it stands I can patch straight from the Euclidean to my Toppo 281, Syncussion, Turing Machine, Barton Clock Divider or FCUK Enevelopes and they will react to the triggers just fine. However, if patched to my TH/Timo Bass++, either of my Barton Analog Drums, either of my Barton Decaying Analog Noises, my TH/Fonik CMOS ADSR or my fallabiels 808 Snare none will trigger unless patched via a buffered multiple. If not patched via a buffered multiple as soon as the probe of my scope is introduced to measure the trigger signal (at a point on or off PCB) it suddenly starts triggering successfully until the scope probe is removed again.
Pic of board in case that shows any oddities:

Straight from the pin looks to trigger the modules (or at least the couple I tried) from the list that don't work when just patched straight from the jack.Grumble wrote:What happens if you trigger straight from D11, D12, D13 or/and A3?
(Maybe to be sure have a resistor of 1k in series)
The encoders are currently missing.thx2112 wrote:Are the encoders working okay?
Looks like I misunderstood the schematic. The emitter of the NPNs are indeed connected to the 5V coming out of the nano. Does it generate this itself as I see no connectivity with the regulator but can read 5V when powered.thx2112 wrote:Can you check that the 5V line from the Nano isn't broken between the Nano and the triggers?
- Grumble
- Super Deluxe Wiggler
- Posts: 1817
- Joined: Thu Dec 17, 2015 5:24 am
- Location: U aint much if U aint Dutch
- Contact:
Oke, so the nano works as it should beduff wrote:Straight from the pin looks to trigger the modules (or at least the couple I tried) from the list that don't work when just patched straight from the jack.Grumble wrote:What happens if you trigger straight from D11, D12, D13 or/and A3?
(Maybe to be sure have a resistor of 1k in series)
The nano has a power supply ic on board that provides the atmega with 5Volt, but it has limited power, so thats why there is a secundairy power supply to provide 5 Volt to the rest of the circuit.Looks like I misunderstood the schematic. The emitter of the NPNs are indeed connected to the 5V coming out of the nano. Does it generate this itself as I see no connectivity with the regulator but can read 5V when powered.
The transistors are wrong! They cant work this way ( if someone can prove me different ... please do!)
FYI - I don't have schematics for all the modules, but it looks like the modules that are not triggering all have inline caps on the input as my 'schematic' below shows whereas the ones that are do not.
input ----||----> the rest of the circuit

input ----||----> the rest of the circuit
I tried switching the NPN around so that collector and emitter are swapped and the result is exactly the same as described previously. I'll try swapping it for a PNP now, but just in case I have failed to switch legs correctly (for some reason my brain finds working out which leg is which on a transistor a really hard task) here is a image showing what I did. Note the legs aren't shorting it is just the camera angle.Grumble wrote:The transistors are wrong! They cant work this way ( if someone can prove me different ... please do!)

- Grumble
- Super Deluxe Wiggler
- Posts: 1817
- Joined: Thu Dec 17, 2015 5:24 am
- Location: U aint much if U aint Dutch
- Contact:
I wrote:duff wrote:Hmm, switching in a PNP (2n3906) appears to stop the module functioning. Not sure if I had the legs all wrong but I have a 4 year old buzzing around at the moment so I'll have to come back it later when I can focus more easily.
So you should change the NPN for a PNP (thats what you did) OR switch the collector with the emitter, (thats what you did TO!)I think I see it: I think the transistors Q1 to Q4 are either of the wrong type (should be PNP in stead of NPN), or drawn wrong (Emitter and Collector switched)
This way the scope always sees a high impedance, hence the induced hum!
Edit: I see the 2N3904 is an NPN transistor, so the in drawing the Emitters and Collectors are switched.
So now it still won't work.
The new problem has to do with the power ic on the nano is (probably) blown...
- Grumble
- Super Deluxe Wiggler
- Posts: 1817
- Joined: Thu Dec 17, 2015 5:24 am
- Location: U aint much if U aint Dutch
- Contact:
I missed this part.FYI - I don't have schematics for all the modules, but it looks like the modules that are not triggering all have inline caps on the input as my 'schematic' below shows whereas the ones that are do not.
Now the failing triggers start to make sense...
As the schematics are drawn, the trigger outputs are open collector (ish)
Thats why modules with a resistor to gnd (or whatever) are triggerable, there needs to be a path for current, thats why you got triggers when you put the probe on the trigger outputs: this provided (albeid high impedance) a path for current to flow.
So I come back to my earlier suggestion: ditch the four transistors and have a resitor of about 1k in series from the output of your nano to your trigger outputs.
Do you use the same software as with the other diagram? Because I think that the transistors are a failed attempt to cconstruct an inverter.
Realy unnecesary since each output of the atmega can source and sink 20mA
I'm using the software that goes with the schematic and the trigger at the nano pin is not inverted. I thought the transistor was part of an output protection scheme but may well be completely wrong on that.
I have a new nano on order so I will switch to just using resistors in series as you recommend and which from the previous test looks like it does the business. Thanks for your input.
I have a new nano on order so I will switch to just using resistors in series as you recommend and which from the previous test looks like it does the business. Thanks for your input.