Adding Midi to Any Pedal with Tap Tempo

Started by charbot, April 02, 2015, 11:10:44 PM

Previous topic - Next topic

charbot

 thought Id share:  
I recently added a external tap switch jack to my Deluxe memeory boy and it got me thinking about how simple (and cool) it would be to add an arduino circuit that would read midi clock ticks and trigger the 'taps'.    Having no luck finding an existing sketch,   I started w/ littleScale's venerable "midi sync"  example - It blinks a LED on every quarter note.
That alone would have probably worked fine, but I didnt like that the 'taps' were always being sent while a clock signal was present; so I came up with a way make it count the time intervals and only send 3 taps when the bpm has changed.  (Seems to send 6 taps when first getting the midi start command... )  I've only tested it on the bench and all seems good, but Id be interested to see how it works for others.  

The hardware is pretty simple-  standard midi in optoisolator arduino RX.   The output can be handle several different ways, but keep in mind,  many digital circuits in pedals use 3.3v,  while  (most)  arduinos use 5v! which could fry the pedal, so you cant hook up the tapPin directly.    
 Safest way would be to use another opto isolator.   Alternately, you could probably use a voltage divider, but again, be careful and measure everything before wiring it to the pedal.   The simplest way would be to just use a 3.3v arduino pro mini.   I wanted to use an Attiny 85- and build the whole circuit on a 14-pin socket(6 pin opto + 8 pin attiny)- and powered by the 3.3v from the tap switch but  I couldnt get the softserial to work reliably.  ( Maybe someone else can figure it out? )    5v arduinos will have to be connected to  a >6+v source  from somewhere inside your pedal.  

It uses the ellapsedMillis library to count the time, so make sure that you find that and install it first.



/*MIDI CLOCK TO TAP TEMPO w/3 TAPS-Charlie Hobbs 2015 (based off of Littlescale's 'Midi Sync'  */
#include <elapsedMillis.h>
elapsedMillis timeElapsed2;
elapsedMillis timeElapsed;
unsigned long prevInterval ;
unsigned long interval ;
int tapCount = 0;
byte midi_start = 0xfa;
byte midi_stop = 0xfc;
byte midi_clock = 0xf8;
byte midi_continue = 0xfb;
int play_flag = 0;
byte data;
byte counter;
byte clickCounter;
int tapPin = 13;


/*The following declarations are for softserial- attiny use.  The small form is appealing, but I couldnt get it working reliably.  
To try it, uncomment these lines and change all Serial. commands to mySerial. and chane the tap pin to 0 */
//#include <SoftwareSerial.h>
//#define rxPin 3//RX
//#define txPin 4 // TX
//SoftwareSerial mySerial(rxPin, txPin);


void setup() {
pinMode (13, OUTPUT);
Serial.begin(31250);
}

void loop() {
if(Serial.available() > 0) {
  data = Serial.read();
  if(data == midi_start) {
    play_flag = 1;
    }
  else if(data == midi_continue) {
    play_flag = 1;
    }
  else if(data == midi_stop) {
    play_flag = 0;
    digitalWrite(tapPin, LOW);
    tapCount = 0;
    counter = 0;
    }
  else if((data == midi_clock) && (play_flag == 1)) {
    count();
    Sync();

 }
}
}
void Sync() {
if(counter == 23) {
     counter = 0;
  }
if((counter == 0) && (tapCount<= 3)){
    digitalWrite(tapPin, HIGH);
    tapCount++;
  }
if(counter == 6){ // this will set the duration of the tap
     digitalWrite(tapPin, LOW);
  }
if (interval != prevInterval){
     tapCount = 0;
  }
counter++;
prevInterval= interval;
}


void count(){
  if(clickCounter >= 71){  //72(#clicks counted= 3 quarter notes)
     interval = timeElapsed/72;
     timeElapsed = 0;
     clickCounter = 0;
  }
  clickCounter++;

}  


lars-musik

 Very nice. Seems like it was about time for such a device as I posted something similar a week ago!  Look  here.

charbot

#2
ha!  sheesh,   I must have missed that one... but great minds do think alike.   Doesnt look like Im encroaching on your turf, too much at least - more like different paths up the same mountain;  PIC vs AVR,   external controller vs internal mod.    Its nice to have options.

lars-musik

Quote from: charbot on April 03, 2015, 10:35:20 AM
Doesnt look like Im encroaching on your turf, too much at least - more like different paths up the same mountain;  PIC vs AVR,   external controller vs internal mod.    Its nice to have options.

Hi charbot,
No "encroaching" at all! I really appreciate your publishing and sharing of the code in an "open source spirit". That's fantastic. The more folks with µC programming skills the better (because I know nothing about it and rely absolutely on members like slacker and you). How about creating and publishing an alternative to the taptation for tap delays now that you're on it? As you say... options are a good thing.

charbot

honestly, im not that talented a programmer.   Arduino is just babytalk.   Though avr/ arduino-based taptation work-a-like does seem like it would be pretty simple.
Ill need some personal incentive to get into tho'.   -trying w to think what I could add tap tempo to.    trying to whittle down my rig.


BTW- it looks like my 3.v3 pro minis will be here soon.   I post some pics when I get a real hardwired version made and installed in the  dlx memory boy.

charbot

UPDATE-  Sadly Im now thinking that the 3.3v arduinos amy not work... I tried using at pulse from a 5v one thru voltage divider and it wasnt doing it, at least on the DMB.   I think I read somewhere that it uses a lot of current to trigger so that is probably it.   Work fine w/ opto coupler tho'- just want to keep the parts and wiring to a minimum.   

charbot

#6
Here are some images of the finished circuit insalled in my EH Deluxe memory Boy.  I used a 3.3v version since my pedal uses a 3.3v.  


the 1/4" jack on the back is for an external tap switch




purple and black wires are soldered to the pedal's SMA voltage reg. 




This is a shot of the little circuit I build- basically 2x optos  and a few resistors.   The arduino Mini Pro sits on top- in the sockets.

charbot

One last thing that Id like to add is a switch to select the frequency of the tap signals-  every quarter note or every half note.    Very easy, but Im a little reluctant to drill another hole in the memory boy.

I also made a few minor changes to the sketch.  I can post if there is any interest.    ATTiny85-20pu (5v)  does work on soft.serial but still seems a little buggy- tempo seems to drift sometimes.   I cannot get the 3.3v attiny85-10pu (3v)  to work at all.  ?

MakcZ

Hi guys! I'm looking to build tap tempo midi clock with midi cc or pg c send button! Basically it just two buttons- 1 tap tempo, 2 midi change send. Can you help me- where to start?

lars-musik

Look at this. I am not sure if it's exactly as you want it, but it sounds very close:

http://adanselm.github.io/padchokola/

MakcZ


ake7

Quote from: charbot on April 18, 2015, 10:14:41 AM
Here are some images of the finished circuit insalled in my EH Deluxe memory Boy.  I used a 3.3v version since my pedal uses a 3.3v.   


the 1/4" jack on the back is for an external tap switch




purple and black wires are soldered to the pedal's SMA voltage reg. 




This is a shot of the little circuit I build- basically 2x optos  and a few resistors.   The arduino Mini Pro sits on top- in the sockets.
Hi! Can I ask if you have a schematic of the circuit? Thank you!