Generic I/O board for pedals, with bistable relay  [documentation]

Original effects with schematics, layouts and instructions, freely contributed by members or found in publications. Cannot be used for commercial purposes without the consent of the owners of the copyright.
User avatar
Pruttelherrie
Solder Soldier
Information
Posts: 248
Joined: 18 Feb 2011, 19:35
Location: The low lands
Has thanked: 46 times
Been thanked: 96 times

Post by Pruttelherrie »

Hi All,

The idea below has been floating around, I know of some others who have done it but can't find their postings right now. I decided to post it so interested people can use it as they like.

It's a small double-sided PCB, that contains all the I/O that you normally use in a pedal. Input, output, power, switch, led.

It uses a bistable relay, like mictesters switching scheme, but then controlled by an Attiny85 (these are only $1.15 at Tayda). Furthermore it uses a momentary for switching, I like those cheap soft-switching momentaries. The PCB is small enough to fit on the head-end of a Hammond 125B, and you can space the output so that it will also look ok on the short end of a 1590BB. There are connections for a battery clip, which will be switched off if you use a powersupply. The input of the effect will be shorted when the effect is switched off.
Here are a few pics to get an idea of what it looks like:
photo 2.JPG
Suitable for 1590BB:
photo 3.JPG
Mass-production:
4 relays.JPG
This is what it looks like in a 125B:
photo 4.JPG
Gut shot, enough room for pots to sit under the pcb:
photo 5.JPG
And now the projectfiles, first the eagle files:
Relay2.sch
(130.87 KiB) Downloaded 489 times
Relay2brd.sch
(52.74 KiB) Downloaded 365 times
(rename to .brd, cannot attach .brd files!)

I had the pcb's made at iTeadstudio, using this zip-file:
Relay2.zip
(36.38 KiB) Downloaded 330 times
The code can be found at the bottom of this post, I programmed this with the Attiny85 core for Arduino which can be found here: http://highlowtech.org/?p=1695
The code supports the 'Primetime' feature, when you hold the switch for more than a predefined time (set at 1s for the moment) it will switch back to off when you release the switch. Idea stolen from TC Electronic :)
The led shows the entering of PrimeTime with a double-flash. Also, when you hold the switch at powerup, you can toggle the power-up state of the relay. The led will flash to confirm this. Just check the code, it's all in there. You need the Arduino EEPROM and Bounce libraries. Todo: low-power code, sleep/standby, pin-change interrupt to wake etc.

Have fun!
Pruttel.

Code: Select all

// Relay.ino
// true-bypass pedal switcher for guitar effects
// (c) 2014 Iwan Heskamp, but this is really basic so anybody could probably do it better!

#include <EEPROM.h>
#include <Bounce.h>

// for attiny25/45/85
#define SW            3    // pin 2 
//#define SW_INT        PCINT3 // interrupt name
#define RELAY1        4    // pins for AL5WN-K bistable (latching) relay
#define RELAY2        0
#define LED           2    // pin 7 on ATtiny 45/85

#define ON            1
#define OFF           0
#define DEBOUNCETIME  25   
#define RELAYDELAY    15   // bi-stable relay, time for the coil to be energized
#define PRIMETIME     1000 // PrimeTime delay in milliseconds
#define DOUBLECLICK   500  // click twice in less than these ms to be registered as doubleclick 

Bounce sw = Bounce(SW, DEBOUNCETIME); // initialize debouncer

int state     = 0;   // effect on or off?
int primetime = 0;   // TC Electronics 'PrimeTime' mode
int address   = 0;   // EEPROM address of state value
unsigned long lastMillis=0;
unsigned long doubleMillis=0;

void effectOn() {
  digitalWrite(LED, LOW);      // turn LED on
  digitalWrite(RELAY1, HIGH);  // switch relay to on position
  delay(RELAYDELAY);           // wait a little bit
  digitalWrite(RELAY1, LOW);   // turn current through coil off
  state = ON;                  // remember on state
}

void effectOff() {
  digitalWrite(LED, HIGH);     // turn LED off
  digitalWrite(RELAY2, HIGH);  // switch relay to off position
  delay(RELAYDELAY);           // wait a little bit
  digitalWrite(RELAY2, LOW);   // turn current through coil off
  state = OFF;                 // remember off state
}

void setup() {
  ADCSRA = 0;  // turn ADC off
  pinMode(SW, INPUT);                    // make switch input
  digitalWrite(SW, HIGH);                // internal pullup 
  digitalWrite(LED, HIGH);               // led off
  pinMode(LED, OUTPUT);                  // make led output
  digitalWrite(RELAY1, LOW);
  pinMode(RELAY1, OUTPUT); digitalWrite(RELAY1, LOW);
  digitalWrite(RELAY2, LOW);
  pinMode(RELAY2,OUTPUT); digitalWrite(RELAY2, LOW);
  
  state = EEPROM.read(address);          // get state from EEPROM
  sw.update();
  if(digitalRead(SW) == 0) {             // button pushed at startup -> save 'on' state for next!
    state &= 1;                          // to be sure it's written only 1 or 0. (chip can be initialized to random value!)
    state ^= 1;                          // flip stored state
    EEPROM.write(address, state);        // write flipped state to EEPROM
    digitalWrite(LED, HIGH); delay(300); // blink three times as confirmation
    digitalWrite(LED, LOW);  delay(300);
    digitalWrite(LED, HIGH); delay(300);
    digitalWrite(LED, LOW);  delay(300);
    digitalWrite(LED, HIGH);               
  } 
  if(state == OFF) {             // state == 0 -> turn effect off, led off
    effectOff();
  } else {                       // state == 1 -> turn effect on, led on
     effectOn();
  }
  // TODO: this would also be the time to switch some stuff off (UART, ADC, etc) (p.34?)
  // more power can be saved by running the attiny on 128kHz! (p.28)
  // TODO: interrupt on switch input? 
  unsigned long lastMillis = millis(); // store timestamp for PrimeTime function
}

void loop() {
  if(sw.update()) {
    if(sw.fallingEdge() == 1) { // switch is pressed (it's pulled-up, remember?)
      if(state == 1) {  // were we on, turn off
        // remember: we cannot be on *and* in PrimeTime when the button is pressed!
        effectOff();    // turn effect off, led off
      } else {          // we were off, turn on
        effectOn();
        lastMillis = millis(); // update timer for PrimeTime checks
      }
      // now check when the last time was that we were here        
      /* if(millis() - doubleMillis < DOUBLECLICK) { // SPECIAL SUPER DUPER MODE!
        digitalWrite(LED, LOW);  delay(100);
        digitalWrite(LED, HIGH); delay(100);
        digitalWrite(LED, LOW);  delay(100);
        digitalWrite(LED, HIGH); delay(100);
        digitalWrite(LED, LOW);  delay(100);
        digitalWrite(LED, HIGH); delay(100);
        digitalWrite(LED, LOW);  delay(100);
        digitalWrite(LED, HIGH);
        doubleMillis = 0;
      } else {
        doubleMillis = millis();     
      } */
    }
    if(sw.fallingEdge() == 0) {    // switch is released (it's pulled up so invert test)    
      if(primetime == ON) {        // we're in PrimeTime mode, so switch effect off
        effectOff();               // turn effect off
        primetime = OFF;           // turn off PrimeTime mode
      } // there is no else: if not in PrimeTime mode, do nothing on release of the switch...
    }
  }
  // now check if enough time has passed to turn on PrimeTime mode
  if(state == ON && (millis() - lastMillis > PRIMETIME) && primetime == OFF) { // more than PRIMETIME ms since button was pressed!
    if(!sw.read()) {                 // button still pressed, so enter PrimeTime
      primetime = ON;
      digitalWrite(LED, HIGH); delay(50);
      digitalWrite(LED, LOW);  delay(50);
      digitalWrite(LED, HIGH); delay(50);
      digitalWrite(LED, LOW);
    }
  }
  // TODO: check if we should sleep for a while?
}


User avatar
Pruttelherrie
Solder Soldier
Information
Posts: 248
Joined: 18 Feb 2011, 19:35
Location: The low lands
Has thanked: 46 times
Been thanked: 96 times

Post by Pruttelherrie »

One more note: there's an error on the silkscreen; the case of the 78L05 is 180 degrees wrong! I used a standard library and I found out after I received the PCB's. See the gutshot image where I barely managed to remove the regulator and put in a new one. On the 'mass-produced' ones it looks like they are mounted wrong but they are actually ok. I'll have to fix that in the CAD files.

User avatar
aion
Solder Soldier
Information
Posts: 230
Joined: 22 Mar 2012, 00:12
Location: Des Moines, IA
Has thanked: 9 times
Been thanked: 472 times
Contact:

Post by aion »

Very nice and well thought-out! The relay switching system is very similar to Jack Orman's: http://www.muzique.com/schem/dpdt.htm

A couple of features that his uC has that you might consider adding in the next revision:
- Flashes twice on power-on
- Set a jumper on the board to set whether it defaults to "on" or "off" when initially powered up (default is off)
- Periodically checks to make sure the LED and relay are in sync

I also had the same issue with the default 78L05 in the library I used... very frustrating! The 7805 and 78L05 are opposite pinouts, but whoever made the library must not have done the research and just assumed they were the same.

User avatar
J0K3RX
Degoop Doctor
Information
Posts: 1058
Joined: 29 Jun 2011, 01:25
Location: US Florida
Has thanked: 316 times
Been thanked: 556 times

Post by J0K3RX »

aionios wrote:Very nice and well thought-out! The relay switching system is very similar to Jack Orman's: http://www.muzique.com/schem/dpdt.htm

A couple of features that his uC has that you might consider adding in the next revision:
- Flashes twice on power-on
- Set a jumper on the board to set whether it defaults to "on" or "off" when initially powered up (default is off)
- Periodically checks to make sure the LED and relay are in sync

I also had the same issue with the default 78L05 in the library I used... very frustrating! The 7805 and 78L05 are opposite pinouts, but whoever made the library must not have done the research and just assumed they were the same.

- Flash twice at power on.... not really a high demand feature, i guess unless you are "default off" at power up just to let you know it's on..
- Set a jumper on the board to set whether it defaults to "on" or "off" when initially powered up (default is off)
No need for jumper on Pruttel's design... when you hold the switch at powerup, you can toggle the power-up state of the relay. The led will flash to confirm.
- Periodically checks to make sure the LED and relay are in sync
I don't see how this configuration would get out of sync?

Primetime feature...led shows the entering of PrimeTime with a double-flash - not on the AMZ
Looks like there are a few other features optional in the code, not sure?

***Best Feature*** He gave us the code!! :D


Have a look here!
http://stompville.co.uk/?p=423
This guy has some good ideas with using optoisolators (TLP222G or H11F1M) to short the audio signal to ground (mute the signal), then switch the relay, then release the mute to eliminate clicks from the relay.. Then a bit further with the idea, soft muting.. Soft mute so the sound would fade out over a period of time 20 ms then switch the relay, then un-mute over 20ms, with a total switching time of 50 ms allowing 10 ms for the relay to change-over.

User avatar
Pruttelherrie
Solder Soldier
Information
Posts: 248
Joined: 18 Feb 2011, 19:35
Location: The low lands
Has thanked: 46 times
Been thanked: 96 times

Post by Pruttelherrie »

J0K3RX wrote:Looks like there are a few other features optional in the code, not sure?
Jep, there is a bit of code for the next revision of the board, with the extra out. Stolen from one of Jack DeVille's pedals.
***Best Feature*** He gave us the code!! :D
Hehe it's not that big of a deal. I tried to make it really straightforward, nothing is optimized or made efficient, but at least I can follow what I try to do :D
Have a look here!
http://stompville.co.uk/?p=423
This guy has some good ideas with using optoisolators (TLP222G or H11F1M) to short the audio signal to ground (mute the signal), then switch the relay, then release the mute to eliminate clicks from the relay.. Then a bit further with the idea, soft muting.. Soft mute so the sound would fade out over a period of time 20 ms then switch the relay, then un-mute over 20ms, with a total switching time of 50 ms allowing 10 ms for the relay to change-over.
Yes! That's the idea! I was experimenting a bit with a lone mosfet/diode/resistor/cap combination, like that Jack DeVille pedal (Deuce Coupe I believe). 50ms is a bit on the long side though, you might have to experiment a bit with the timing because I don't know the speed of the relay, might depend on the brand/type, but one should be able to squeeze it in less than say 10ms~15ms. The cap makes sure it's a 'soft' mute.

User avatar
J0K3RX
Degoop Doctor
Information
Posts: 1058
Joined: 29 Jun 2011, 01:25
Location: US Florida
Has thanked: 316 times
Been thanked: 556 times

Post by J0K3RX »

I was thinking you could probably make it (optional) use a bi-color LED say red for ON and green for BYPASS.. Then there would be no doubts if it was on or not... Maybe make an extra pad to connect to another switch (release other switch if new switch is pressed) so, if you had another one of these switch units you could toggle between the two?

User avatar
karter2000
Information
Posts: 24
Joined: 11 May 2009, 21:50
Has thanked: 19 times
Been thanked: 6 times

Post by karter2000 »

I'm a little new to having PCBs made. What service did you use at iTeadstudio, and what were the parameters used? Thanks!

User avatar
Pruttelherrie
Solder Soldier
Information
Posts: 248
Joined: 18 Feb 2011, 19:35
Location: The low lands
Has thanked: 46 times
Been thanked: 96 times

Post by Pruttelherrie »

karter2000 wrote:I'm a little new to having PCBs made. What service did you use at iTeadstudio, and what were the parameters used? Thanks!
I normally use this one:
http://imall.iteadstudio.com/open-pcb/p ... 18001.html
with all the standard options, 1mm thick, but on the pictures above you see the white pcb variant which is a bit more expensive.

You order first, they will send you your order number and then you mail them the zipfile which you renamed to that ordernumber+description. Just read the text on that page, it's pretty straightforward. I used their Design Rule Checks and CAM files to check and generate the files in the zip.

I have never had a problem with iTead so far; I have ordered some 8 batches. The silkscreens can be slightly off sometimes (see pictures above, this is actually the worst I ever received) but not unusable, and you can't beat the price!

Oh, be sure to place the components correctly the first time, de-soldering them is a bitch and you risk ruining the board and the component!

User avatar
coldcraft
Diode Debunker
Information
Posts: 725
Joined: 11 Jul 2009, 01:00
Has thanked: 38 times
Been thanked: 85 times

Post by coldcraft »

very cool.
Black Dynamite wrote:you need to shut the fuck up when grown folks is talkin.

User avatar
commathe
Breadboard Brother
Information
Posts: 97
Joined: 01 Jul 2013, 22:31
Has thanked: 5 times
Been thanked: 7 times

Post by commathe »

:applause: Fantastic! Good effort, and thanks for the code! I'll definitely be studying it.

User avatar
stevo83
Information
Posts: 37
Joined: 06 Feb 2010, 23:28
Has thanked: 8 times
Been thanked: 6 times

Post by stevo83 »

This is really great.

Thank you for contributing such a cool project (and the code to boot)!

User avatar
coldcraft
Diode Debunker
Information
Posts: 725
Joined: 11 Jul 2009, 01:00
Has thanked: 38 times
Been thanked: 85 times

Post by coldcraft »

would anyone who knows how to write PIC code be willing to help translate this code?
Black Dynamite wrote:you need to shut the fuck up when grown folks is talkin.

User avatar
J0K3RX
Degoop Doctor
Information
Posts: 1058
Joined: 29 Jun 2011, 01:25
Location: US Florida
Has thanked: 316 times
Been thanked: 556 times

Post by J0K3RX »

coldcraft wrote:would anyone who knows how to write PIC code be willing to help translate this code?
I am working on a PIC12f683 version now because I have a bunch of them sitting doing nothing... When/If I get it I will post here.

User avatar
coldcraft
Diode Debunker
Information
Posts: 725
Joined: 11 Jul 2009, 01:00
Has thanked: 38 times
Been thanked: 85 times

Post by coldcraft »

J0K3RX wrote:
coldcraft wrote:would anyone who knows how to write PIC code be willing to help translate this code?
I am working on a PIC12f683 version now because I have a bunch of them sitting doing nothing... When/If I get it I will post here.
If you want some help let me know. I have not coded for PIC before but I'm trying to get into it.
Black Dynamite wrote:you need to shut the fuck up when grown folks is talkin.

User avatar
Pruttelherrie
Solder Soldier
Information
Posts: 248
Joined: 18 Feb 2011, 19:35
Location: The low lands
Has thanked: 46 times
Been thanked: 96 times

Post by Pruttelherrie »

A few notes for those porting it to PIC code: there's a lot functionality hidden in the Bounce() library that I used. You could either rewrite/port that part as well or use a different lib. Or test it with no debouncing at all first, then add a debouncer?
Also, the code above is pretty ugly with all the Delay() calls, it's better to use non-blocking timers. However, as it is, it seems to work ok. For those interested in the non-blocking delays, check out the 'Blink without delay' examples for Arduino.

User avatar
J0K3RX
Degoop Doctor
Information
Posts: 1058
Joined: 29 Jun 2011, 01:25
Location: US Florida
Has thanked: 316 times
Been thanked: 556 times

Post by J0K3RX »

I am actually starting from scratch for the most part and keeping it very basic to start off... All I really want it to do is the bare bone basic function of turning flipping the latching relay and LED off and on with de-bounce... The startup state can always be off, no need to have any options there, for me anyway... and with that no need for the blinkiing LED confirmation etc.. Just On / Off :D

On the other hand I would like to try Flowcode 6, looks amazingly simple but I don't know? Sometimes stuff looks one way and then you run into some limitation or whatever. Looks like you could poop out a pic stomp switch in minutes.. I have a 30 day functional (I think) demo of it and if I like it I may buy it.. dunno? Still using MPLAB IDE v8.10 at the moment and it alright...

Check it out and see what you think. http://www.matrixtsl.com/index.php

User avatar
sinner
Old Solderhand
Information
Posts: 4709
Joined: 06 Nov 2008, 17:16
Location: ...no more
Has thanked: 1031 times
Been thanked: 909 times

Post by sinner »

Thats the coolest contribution I've seen here in months

Thanks for the code man and the project in whole

User avatar
sinner
Old Solderhand
Information
Posts: 4709
Joined: 06 Nov 2008, 17:16
Location: ...no more
Has thanked: 1031 times
Been thanked: 909 times

Post by sinner »

...BTW - Im also interested in the PIC version

User avatar
stevo83
Information
Posts: 37
Joined: 06 Feb 2010, 23:28
Has thanked: 8 times
Been thanked: 6 times

Post by stevo83 »

Is there any particular reason why you guys are interested in a PIC based implementation?

Or is it just personal preference?

I am asking out of genuine curiosity, as Atmel stuff is becoming more and more popular (thanks to Arduino I guess) and I was looking to start experimenting with programming again (not done any for years).

Are there specific reason for choosing between the two platforms or is it just 'horses for courses'?

User avatar
sinner
Old Solderhand
Information
Posts: 4709
Joined: 06 Nov 2008, 17:16
Location: ...no more
Has thanked: 1031 times
Been thanked: 909 times

Post by sinner »

The only reason is I already did my basic learning curve with PIC, and I've purchased PIC kit too

In my understanding PIC is more popular platform as well

I guess I will start getting myself into Atmel now

Post Reply