The UC (µC) Clock Divider is a clock/beat/step counter/divider, based on Arduino, with 8 outputs, configurable in code.
With a clock divider you can slow down a tempo, create rhythmic patterns or, with a audio signal at the input, get sub-octaves.
It can also be used, with the right code, as a DIN Sync decoder.
The Hardware
The circuit is very simple and depends almost exclusively on the Arduino Nano module.
The input jack is stereo (TRS). Tip (T) is connected to Clock signal and Ring (R) is connected to Reset.
A +5V voltage triggers either Clock or Reset.
The outputs are +5V when ON and 0V when OFF. A 1k resistor protects against potential short circuits.
The Code
Code examples can be downloaded from https://github.com/dhaillant/uc_divider
The Clock Divider code is based on hardware interrupts. One for Clock signal and one for Reset signal.
Each output has its own individual counter.
A positive voltage on Reset input triggers the reset function and sets all individual counters at 0.
A rising edge on Clock input allows the outputs with counter at 0 to be activated (ON)
A falling edge increments each counters by 1. If counters have overflowed (based on settings in code) they are set back to 0.
The main loop activates the outputs based on their respective counters and the presence of a voltage on Clock input.
Downloads
- Demo Code (https://github.com/dhaillant/uc_divider)
- Schematics (uc_divider-1.0-20220131.pdf)
- Interactive BOM – Front PCB (uc_divider-front-1.0-ibom-2021-12-07)
- Interactive BOM – Rear PCB (uc_divider-back-1.0-ibom-2021-12-07)
- Assembly drawings (uc_divider-1.0-Assembly-20220510.pdf)
Hi David,
I want to build this on stripboard. The schematic refers to several SMD components. Do you have advice on through hole components for BC847 and BAT54S? Thanks in advance.
Kind regards,
Thomas
Hello Thomas,
BC847 can be replaced by any NPN transistor. For example BC547.
BAT54S is just two (Schottky) diodes in series, in a single package. So you can use any diodes, two 1N4148 in series should probably work.
Hope it helps.
David
Hi!
Thanks for a great build! I’ve had lots of use for it. I think I might have found a tiny bug in your code:
In MyButtons.on(), it appears that lastDebounceTime is updated for any/both button presses, instead assigning the last debounce time for each button individually, or am I reading the code wrong?
If not, it could easily be fixed by using a lastDebounceTime[_num] array.
Just a heads up!
Best regards
Erik
Hey Erik!
Thank you for your suggestion! I contacted Luther who wrote that code, and he said that you were correct and it would make the code fancier.
Anyway, please, feel free to modify and share the code if you think it could help anyone else.
Also, I’d love to see your module in your setup 🙂
Have fun!
Thanks for your reply! I wound up rewriting everything, for my own amusement and preferences.
There actually are no huge differences – if any – from a user perspective. However, the code is written to use interrupts, and is tested on an Nano every which I came across for cheaper – compared to a regular nano – when I sourced the components. This means that the code is not tested on a regular nano board.
If anyone is interested I’ve made the project public at: https://github.com/ErikErikErikErikErik/Clock-divider
I’d be happy to take pointers (no programming pun intended) in case I’ve missed something.
If you have other code ideas for your module, I might have some spare time. Just hit me up!
Best regards
Erik
Hi Erik,
thanks for your efforts!
In particular it was interesting for me to copy the input with a by-1 division as a thru port to save on multiples, so I upgraded my module to a Nano Every. However it does not work as intended, because the pulse on that output is rather short than mimicking the input pulse duration. Anything we can do about that…?
Best, Hanso