MIDI Beat Clock (Arduino-powered) - details

From circuitbending to homebrew stompboxes & synths, keep the DIY spirit alive!

Moderators: Kent, Joe., luketeaford, lisa

User avatar
Tombola
Super Deluxe Wiggler
Posts: 1878
Joined: Sun Jan 23, 2011 11:33 am
Location: London, England

MIDI Beat Clock (Arduino-powered) - details

Post by Tombola » Thu Apr 14, 2011 6:52 pm

A couple of people asked for some details on the Midi beat clock mentioned here

I built it using a proto kit and faceplate from http://synovatron.blogspot.com/ - had to drill out a few of the holes, but it's much easier than starting from scratch.

The circuit is super simple, and I haven't drawn out a proper schematic. There are 4 parts to it

ARDUINO: The supporting circuitry for the Atmega 328 chip is surprisingly straightforward- +5v power, ground, one resistor, one 16mhz crystal, two caps, a press switch and some header. I used this Boarduino schematic from LadyAda.

I bought an ATmega with the bootloader already in place. You then need an FTDI cable to program it - it works exactly like a normal arduino. You can power the module over USB while programming it - presumably not a good idea to attach USB and the power ribbon at the same time! There is supposed to be a way to use a normal arduino board as an FTDI cable, I didn't try that.

Once it's in place, it's easy to attach a couple of pots (+5 and GND on each side, the centre lug going to an analog input), a switch (rigged as a voltage divider giving three levels on an analog input) and a pulse input (a 3.5mm jack going straight into an analog input with a pull down resistor to filter out noise when it's not connected)

OUTPUT: You can clock a sequencer, trigger a Maths or ping a Qmmg using a digital pulse straight from the digital out of an arduino. So the outputs are just a digital pin connected to a 3.5mm socket, with an LED going to ground through a resistor. I'm sure it would be better to buffer everything properly, but I didn't.

POWER: You can pull 5v from your case. Buy the little doepfer/makenoise adaptor, or make one from a 7805 regulator, a heat sink, perfboard, header and a capacitor.

MIDI: The Midi In schematic is in this thread. I think the original handrawn schematic has the midi pins the wrong way round. I certainly had to try a couple of times to get it working. I used a CNY14-4 optocoupler.

Midi goes into the serial RX pin on the Arduino. You can't have Midi playing while you upload code to the board. I had some weirdness with my board and my FTDI cable (I needed a 5v version, had a 3.3v version) that meant I had to halve the baud rate. YMMV.

Image
Untitled by Tom.Whitwell, on Flickr

CODE:

I'm not going to post all my code here because it's too gruesome. If you want it, I'll happily send it to you.

It's all built on the sample code here at Little Scale. The arduino listens for a clock. When it hears a clock pulse, it triggers a subroutine.

The clock divider itself is simple: Set a counter running when the clock starts - midi clock comes 24 times per quarter note - then divide down using modulus

Code: Select all

if (count%6 == 0){ // do something every 16th note}
if (count%12 == 0){ // do something every 8th note }
if (count%24 == 0){ // do something every quarter note  }
The swing is a bit fiddly - I used the technique apparently used in the TR707, which just shifts within the 24ppqn of the midi clock, rather than trying anything cleverer.

That's it. It was fun, and I learned lots.

User avatar
Luka
Super Deluxe Wiggler
Posts: 5380
Joined: Tue Jul 15, 2008 9:15 am
Location: melbourne

Post by Luka » Thu Apr 14, 2011 9:50 pm

nice work

User avatar
widdly
Super Deluxe Wiggler
Posts: 1096
Joined: Wed Jan 21, 2009 1:31 am
Location: australia

Post by widdly » Thu Apr 14, 2011 11:21 pm

Cool. It would be handy if it captured FA on the midi and output a start trigger. That way you could reset your sequencer on midi start.

User avatar
limpmeat
Super Deluxe Wiggler
Posts: 1113
Joined: Tue Feb 08, 2011 9:40 pm
Location: Melbourne

Post by limpmeat » Thu Apr 14, 2011 11:39 pm

good idea

User avatar
falafelbiels
still learning to wiggle
Posts: 4356
Joined: Tue Aug 04, 2009 7:15 am
Location: Rotterdamm son

Post by falafelbiels » Fri Apr 15, 2011 5:26 am

I am keeping an eye on this...

User avatar
Tombola
Super Deluxe Wiggler
Posts: 1878
Joined: Sun Jan 23, 2011 11:33 am
Location: London, England

Post by Tombola » Fri Apr 15, 2011 7:14 am

widdly wrote:Cool. It would be handy if it captured FA on the midi and output a start trigger. That way you could reset your sequencer on midi start.
Would be easy to do - reserve one of the ouput pins and only flash it on the start trigger.
Unfortunately my seq doesn't have a reset in, so I didn't bother...

User avatar
wetterberg
Super Deluxe Wiggler
Posts: 7673
Joined: Thu Jul 24, 2008 5:31 pm
Location: Copenhagen, Denmark.

Post by wetterberg » Fri Apr 15, 2011 2:24 pm

nice. Thanks for the update. Now, I'm not all that savvy on the tech here; what would happen if you accidentally sent *in* a 12v pulse to an output? You'd fry the ATmega, wouldn't you?

User avatar
nickciontea
brownshoesonly
Posts: 1268
Joined: Wed Feb 03, 2010 10:37 am
Location: Chicago
Contact:

Post by nickciontea » Fri Apr 15, 2011 2:27 pm

i've given my analog ins severely wrong voltage and my original arduino is still pounding away..

seems to me they can take some abuse. :deadbanana:

plus you can always use a diode

User avatar
Tombola
Super Deluxe Wiggler
Posts: 1878
Joined: Sun Jan 23, 2011 11:33 am
Location: London, England

Post by Tombola » Fri Apr 15, 2011 4:57 pm

nickciontea wrote: seems to me they can take some abuse.
That's certainly my impression - I've definitely fed them +/- 6v with no trouble.

Put the Atmel 328 in a socket and the worst that can happen is you loose a few quid.

User avatar
falafelbiels
still learning to wiggle
Posts: 4356
Joined: Tue Aug 04, 2009 7:15 am
Location: Rotterdamm son

Post by falafelbiels » Sun Apr 17, 2011 10:43 am

Tombola wrote:
widdly wrote:Cool. It would be handy if it captured FA on the midi and output a start trigger. That way you could reset your sequencer on midi start.
Would be easy to do - reserve one of the ouput pins and only flash it on the start trigger.
Unfortunately my seq doesn't have a reset in, so I didn't bother...
Does anybody happen to be working on this? I suck at programming but I need some clock divider and this seems to be a real life saver. Would it be possible to have n/3, n/5, n/6 and n/7 as in the CGS pulse divider? Would be a dream come true!

User avatar
falafelbiels
still learning to wiggle
Posts: 4356
Joined: Tue Aug 04, 2009 7:15 am
Location: Rotterdamm son

Post by falafelbiels » Sun May 01, 2011 11:35 am

no?

User avatar
Tombola
Super Deluxe Wiggler
Posts: 1878
Joined: Sun Jan 23, 2011 11:33 am
Location: London, England

Post by Tombola » Tue May 03, 2011 2:34 pm

falafelbiels wrote:
Tombola wrote:
widdly wrote:Cool. It would be handy if it captured FA on the midi and output a start trigger. That way you could reset your sequencer on midi start.
Would be easy to do - reserve one of the ouput pins and only flash it on the start trigger.
Unfortunately my seq doesn't have a reset in, so I didn't bother...
Does anybody happen to be working on this? I suck at programming but I need some clock divider and this seems to be a real life saver. Would it be possible to have n/3, n/5, n/6 and n/7 as in the CGS pulse divider? Would be a dream come true!
If you build the hardware, I can do that code - is a 5 minute job

User avatar
falafelbiels
still learning to wiggle
Posts: 4356
Joined: Tue Aug 04, 2009 7:15 am
Location: Rotterdamm son

Post by falafelbiels » Tue May 03, 2011 4:07 pm

OK, I have plenty excuses not to do this right now, but I will PM you when I have the time, OK?

5 minute job, I really must learn to do this stuff...

User avatar
knob_alchemist
Common Wiggler
Posts: 236
Joined: Sun Jan 22, 2012 3:18 pm
Location: Bolzano, Italy

Post by knob_alchemist » Fri Feb 17, 2012 4:01 am

Very interesting project, I have an unused Arduino and I will try to do this instead to buy an A-160.....Is possibile to use also the 6 PWM outputs as a 6 sub-divided clock signal outputs??

User avatar
Tombola
Super Deluxe Wiggler
Posts: 1878
Joined: Sun Jan 23, 2011 11:33 am
Location: London, England

Post by Tombola » Fri Feb 17, 2012 5:40 am

Yes, all outputs are digital, would work for pulses

User avatar
sicpaul
Wiggling with Experience
Posts: 342
Joined: Thu Dec 22, 2011 9:28 am
Location: Berlin

Post by sicpaul » Fri Feb 17, 2012 6:23 am

Cool project! :love:

I wish I was able to understand how to put all these fragments together to get a full schematic by now ... the time will come ... one day

FA (Start) will be a great feature, indeed.

And maybe the possibility to have a switch choosing CV-Clock instead of MIDI to increase the flexibility.

Again: great work, Tom


best regards
Paul

User avatar
sanders
Veteran Wiggler
Posts: 738
Joined: Tue Feb 03, 2009 4:42 pm

Post by sanders » Sun Feb 19, 2012 6:24 am

I just bought an Arduino from Radio Shack with the intention to build some kind of MiDI to pulse/trigger for triggering some korg and rhythm ace drum boards (most of the drum sounds seem to trigger on 4 or 5v, some seem to want -4v or so). I don't have code or a schematic, but I figured someone must have done something like this already.

But I haven't found anything after immediate searches. Can anyone point me to a drum trigger/ pules/ gate output project?
Tombola wrote:
falafelbiels wrote:
Tombola wrote:
widdly wrote:Cool. It would be handy if it captured FA on the midi and output a start trigger. That way you could reset your sequencer on midi start.
Would be easy to do - reserve one of the ouput pins and only flash it on the start trigger.
Unfortunately my seq doesn't have a reset in, so I didn't bother...
Does anybody happen to be working on this? I suck at programming but I need some clock divider and this seems to be a real life saver. Would it be possible to have n/3, n/5, n/6 and n/7 as in the CGS pulse divider? Would be a dream come true!
If you build the hardware, I can do that code - is a 5 minute job
What about a multiplier? Would that be easy to do also? Dividers are easily done with CMOS. Cheaper and maybe easier w cmos. Multipling is not possible without processing I don't think-- this would pretty cool to have code for.
I'd love to be able to take a regular audio source, from a mic, or line level, like live drums, and derive a synced clock plus multiples, like triplets, 16th notes, etc. That would be pretty amazing for live synth processing.

User avatar
krz
Ultra Wiggler
Posts: 873
Joined: Tue May 18, 2010 11:16 pm
Location: Canada
Contact:

Post by krz » Sun Feb 19, 2012 9:06 pm

[quote="sanders"]But I haven't found anything after immediate searches. Can anyone point me to a drum trigger/ pules/ gate output project?[/quote]

just on the off chance u haven't searched here...

http://www.arduino.cc/playground/Main/MIDILibrary

User avatar
knob_alchemist
Common Wiggler
Posts: 236
Joined: Sun Jan 22, 2012 3:18 pm
Location: Bolzano, Italy

Post by knob_alchemist » Mon Feb 20, 2012 1:45 pm

Hey what do you think, is possible a simple clock divider like this using your project/code? simple put in an LFO to one analog input and the 6 PWM ouputs give the divided clock...What do you think?

Image

User avatar
EMwhite
Super Deluxe Wiggler
Posts: 1878
Joined: Wed Feb 08, 2012 7:48 am
Location: NY Metro area

Post by EMwhite » Mon Feb 20, 2012 10:34 pm

I never messed with the *duino stuff but had a question.

I'm after a small / inexpensive or DIY device with a 3 digit LED display for BPM (tempo), a pot to change (from 40..240 possibly), that could output SYNC24 and have a clock divider. Is the platform above a good starting point?

Ideally, I'd like it to ALSO send Midi clock and have not only Run/Stop button, but also a positioning for Reset and Record that simply sends a predefined MMC command.

Any help in understanding how easy or difficult would be welcome. I was interested in the TeenageEngineering kit that they just released but zero details on the API and aside from not yet being available, it's $299 USD which is a bit much.

Thank you.

User avatar
Tombola
Super Deluxe Wiggler
Posts: 1878
Joined: Sun Jan 23, 2011 11:33 am
Location: London, England

Post by Tombola » Wed Feb 22, 2012 5:29 am

EMwhite wrote:I never messed with the *duino stuff but had a question.

I'm after a small / inexpensive or DIY device with a 3 digit LED display for BPM (tempo), a pot to change (from 40..240 possibly), that could output SYNC24 and have a clock divider. Is the platform above a good starting point?

Ideally, I'd like it to ALSO send Midi clock and have not only Run/Stop button, but also a positioning for Reset and Record that simply sends a predefined MMC command.

Any help in understanding how easy or difficult would be welcome. I was interested in the TeenageEngineering kit that they just released but zero details on the API and aside from not yet being available, it's $299 USD which is a bit much.

Thank you.
All of these things are *relatively* straight forward. There are two parts to it, the hardware and the software.

Hardware:
Out of the box, Arduino can accept 0-5v voltages, send 5v pulses and output 0-5v variable voltages (it does this using PWM, so you should probably put a resistor/capacitor low pass filter onto it)

- You could certainly run a 3 digit LED (would need a driver/multiplexer chip, but it's the kind of thing people will have done before, and blogged about)
- You could certainly run MIDI out, again, it's something people will have done before. It's just serial, so the Arduino can output whatever code you like.
- You could very easily do the pot (pot = easy, CV input = slightly harder)
- Sync24 I don't know anything about, but it's definitely possible: http://stevewoodward.posterous.com/sync ... an-arduino
- If you want to be more robust & 100% modular compatible (i.e. accept negative voltages, properly buffered inputs, 10v output gates and triggers, creating +/-12v voltages) you'll need to wrap the thing of op amp circuits and use an external DAC.

Software:
- All of this will be possible, but writing the code will take a while
- To me as a non technician, non coder, Arduino code is much more approchable than, say PIC code (at first glance) which you could use to do the same thing, probably in a smaller sized unit (Arduino runs on a big-ol 28 pin chip which uses an external crystal)

User avatar
ringroad1
Common Wiggler
Posts: 161
Joined: Mon Oct 18, 2010 7:17 am
Location: Coventry, UK

Post by ringroad1 » Wed Feb 22, 2012 2:18 pm

what tom said, and:
EMwhite wrote: I'm after a small / inexpensive or DIY device with a 3 digit LED display for BPM (tempo)...


have a look at the Sparkfun serial display, it's a bit more expensive than getting a display and a multiplexer (and possibly slower?) but less of a faff.

Sync24 output should easily be possible. It runs at twenty four ticks every quarter note, so I think I ended up dividing it by six to get sixteenth triggers out.

I replicated the socket on the x0xb0x for my din sync divider, have a look at this schematic, just the bit around the din sync port: http://www.ladyada.net/media/x0xb0x/iob ... 20v1_0.png

There's a minor gotcha detailed in the 808 service manual, apparently the run/stop line should be switched on 9ms before the clock starts, but that kind of fiddling could wait for when you've got something going.

The Arduino is a great toolbox for sending control signals to a modular, it's ace. Basically just get one, and start off by writing a dead basic program (plug an LED in, turn a digital out on, wait half a second, turn it off again, loop forever) and go from there.

User avatar
mechie
Wiggling with Experience
Posts: 334
Joined: Thu Jan 20, 2011 6:36 am
Location: North Lincs, UK

MIDI Beat Clock

Post by mechie » Mon Aug 20, 2012 9:03 am

Tombola
Hi,
I have just been wandering around the MW dungeons and found your "MIDI Beat Clock (Arduino-powered) - details" thread from Thu Apr 14, 2011

I wondered if I could get a copy of the code to have a go at building this - I fancy wrapping a bit of buffering around the arduino, maybe fiddling with options, but I don't have anything like this in my rig at the moment so would love to have a pop at it.

wjh
1-Post Wiggler
Posts: 1
Joined: Fri Oct 18, 2013 7:24 am

arduino code

Post by wjh » Fri Oct 18, 2013 7:30 am

hello,

i really like the project, i want to build as well.,would be really nice if you could send the code .., ( if it still exsist) already a while ago.

thx in advance

r

wjh

Aveface
Learning to Wiggle
Posts: 7
Joined: Sat Jul 28, 2012 8:38 pm
Location: Phoenix

Arduino code!

Post by Aveface » Mon Dec 09, 2013 1:31 pm

Tombola

Hey tom!

Can I get that Arduino code from you for the midi clock divider with swing?

Thanks!

Your efforts seem tireless!

I want to say good work!

Matthew

Post Reply

Return to “Music Tech DIY”