Hey folks,
As the title suggests, I’ve been working on a clock divider/multiplier. Yes yes I know there are heaps out there, but with this one it has some oddities which are pretty interesting:
- Based on Arduino and open source code
- Can deal with slightly wonky non-perfect clock inputs fairly gracefully (ie non electronic clock pulses)
- Has a phase-shifted output to allow you to move your outgoing pulses out of phase relative to the outgoing beat
- A multiplier and divider that interact with each other in simple (power of 2) or complex mode(prime numbers)
- The biggest most difficult part of this has been that it also allows for dynamic changes between incoming clock beats
So why would some of these quirky things be needed?
Well Sam (LMNC) had asked for a solution in Patreon to using his lovely phone exchange pendulum as a timing source to sync the whole museum together. The quirky problems are that it’s a very slow pendulum, and because it “recharges” the momentum periodically the clock isn’t perfectly even all the time.
This meant that classical approaches to multiplying/dividing this clock source meant that updates wouldn’t happen until the next tick which could be up to 2 seconds (depending on how it’s wired) meaning you’d be turning a knob and nothing would happen for a bit then pow we’re doing something unexpected because we didn’t have dynamic change happening. Also an uneven clock does some nasty things to most approaches to this making it not so pleasant to use.
So I wrote some code initially based on Atte Jensen’s a773 grains code for the ginko synthese grains eurorack module meant as an alternative firmware, but quickly realised that the base functionality wasn’t going to extend gracefully to deal with these quirks.
After a couple of weeks of spinning around in circles and revisiting the problem in a few different ways, I sat down with my friend Rohan and we nutted out this solution over 2 days with approximately 11,000 coffees. It’s about a 98% rewrite now and I’m pretty happy with it.
If you try it out, you’ll notice if feels a little more fluid than most clock multi/divs in that it tries to flow with a clock that isn’t perfect, and dynamic updates recalc on the fly which depending on when you do the change can throw the phase slightly as it catches up. I personally like it that way - feeling a little more organic.
EDIT: it appears that 100k resistors on the outlets is too miserly to trigger some modules, so switch them for 1k resistors instead - ill update this!
Here is the stripboard layout for now (I’ll make a PCB for it):
And Rohan is uploaded to his GitHub here:
https://github.com/RohanM/clock-with-shift
It’s a pretty tangled spaghetti of code, but it was necessary to fit all of those dynamic happenings in simultaneously. It also doesn’t suffer from accumulative drift which can happen with some simpler Arduino implementations as they’re quite slow, and simplistic delays can add up error as the loop spins but takes milliseconds for each loop around. This method uses a created waveform that we step through as the loop spins so we never lose sync with the incoming beats.
Let me know what you think - it was a wild ride. Look forward also to seeing how Sam goes with the pendulum as input!