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
Silver Blues
Breadboard Brother
Information
Posts: 70
Joined: 23 Apr 2013, 19:25
my favorite amplifier: Genz-Benz Shuttle 3.0
Completed builds: Many, at this point...
Location: Atlantic Canada
Has thanked: 23 times
Been thanked: 24 times

Post by Silver Blues »

gena_p1 wrote:ATtiny current is 20mA per pin, relay current may be 30mA, so we are close to absolute maximum ratings of MCU.

Latching relay could be driven with only 1 transistor with fixed state button (like Carling spst), or 1 pcs. 74hc(t)00 with non-fixed state botton, like in Boss stompboxes.
No micro controller needed, no software debounce, etc.
Do you have an example circuit? I've seen a few single-transistor relay drivers like this and have breadboarded one or two and haven't been able to get the relay to switch.

@pruttel can this be done with standard mono or stereo jacks with switches? I see in your schematic that the jacks you've used have switches on every terminal.

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 »

Silver Blues wrote:@pruttel can this be done with standard mono or stereo jacks with switches? I see in your schematic that the jacks you've used have switches on every terminal.
Sure. I only use the stereo connection on the input for connecting the ground of the circuit (on the sleeve) to the ground of the power (ring). The ring on the output is not used.
Also, the 'switch' on the input-tip makes sure the input (and thus the output if bypassed) is grounded when no plug is present.

User avatar
Silver Blues
Breadboard Brother
Information
Posts: 70
Joined: 23 Apr 2013, 19:25
my favorite amplifier: Genz-Benz Shuttle 3.0
Completed builds: Many, at this point...
Location: Atlantic Canada
Has thanked: 23 times
Been thanked: 24 times

Post by Silver Blues »

Bit of a zombie thread now, but here's a vero for this project.
ATTiny85 RBM.png

User avatar
Silver Blues
Breadboard Brother
Information
Posts: 70
Joined: 23 Apr 2013, 19:25
my favorite amplifier: Genz-Benz Shuttle 3.0
Completed builds: Many, at this point...
Location: Atlantic Canada
Has thanked: 23 times
Been thanked: 24 times

Post by Silver Blues »

Fixed a small error with the relay arrangement. I have confirmed this arrangement works via a different system. Should be good to go now.
Attachments
ATTiny85 RBM.png

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 fine Gentleman notified me that the code in the first post won't work on current versions of Arduino and the Bounce library. Below's an updated version of the code, it is verified to work on the latest Arduino and the Bounce2 from the arduino playground.

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 <Bounce2.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(); // 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 
 sw.attach(SW); 
 sw.interval(DEBOUNCETIME);
 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.fell() == 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.fell() == 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
Silver Blues
Breadboard Brother
Information
Posts: 70
Joined: 23 Apr 2013, 19:25
my favorite amplifier: Genz-Benz Shuttle 3.0
Completed builds: Many, at this point...
Location: Atlantic Canada
Has thanked: 23 times
Been thanked: 24 times

Post by Silver Blues »

Thanks for the heads up. I had already programmed three uC's with the first code and was about to build a pedal with one. :P

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 »

Oh the first code will work if it compiles and uploads to the AVR. With newer versions of the Arduino environment the old Bounce library wouldn't compile. With the latest Arduino application and the latest Bounce library the newer code above compiles (and works ;)) as well.

User avatar
roseblood11
Tube Twister
Information
Posts: 1887
Joined: 23 Aug 2008, 14:21
Has thanked: 366 times
Been thanked: 313 times

Post by roseblood11 »

Pruttelherrie, could you add a version of the layout that is small enough for a 1590B? If the DC jack was wired offboard, this should be easy. If a small Lumberg jack was used, no square hole would be needed.

User avatar
Silver Blues
Breadboard Brother
Information
Posts: 70
Joined: 23 Apr 2013, 19:25
my favorite amplifier: Genz-Benz Shuttle 3.0
Completed builds: Many, at this point...
Location: Atlantic Canada
Has thanked: 23 times
Been thanked: 24 times

Post by Silver Blues »

Pruttelherrie wrote:Oh the first code will work if it compiles and uploads to the AVR. With newer versions of the Arduino environment the old Bounce library wouldn't compile. With the latest Arduino application and the latest Bounce library the newer code above compiles (and works ;)) as well.
Oh, I see. Thanks

User avatar
batteryacidtea
Breadboard Brother
Information
Posts: 104
Joined: 18 Feb 2009, 03:42
Has thanked: 57 times
Been thanked: 18 times

Post by batteryacidtea »

I'm just getting startarted on Arduino, and I built the veroboard and worked great, but can anyone give me directions on how to make the switching faster? I mean, I have to hold the momentary button too long for the pedal status to change. Thanks in advance!

User avatar
Silver Blues
Breadboard Brother
Information
Posts: 70
Joined: 23 Apr 2013, 19:25
my favorite amplifier: Genz-Benz Shuttle 3.0
Completed builds: Many, at this point...
Location: Atlantic Canada
Has thanked: 23 times
Been thanked: 24 times

Post by Silver Blues »

You built my vero? That means I can definitively verify it? :thumbsup

User avatar
batteryacidtea
Breadboard Brother
Information
Posts: 104
Joined: 18 Feb 2009, 03:42
Has thanked: 57 times
Been thanked: 18 times

Post by batteryacidtea »

Silver Blues wrote:You built my vero? That means I can definitively verify it? :thumbsup
Yes! works great, thanks a lot!

User avatar
Leetut
Information
Posts: 1
Joined: 15 May 2018, 08:06

Post by Leetut »

Can this work with a TQ2-L-5v Relay?
I’ve got the led working but the relay never does anything

Post Reply