EQD flexi-switch clone (kinda)

Started by matlevo12, March 28, 2020, 04:46:03 PM

Previous topic - Next topic

matlevo12

Hi,

I managed to modify the code in Coda Effects PIC controlled relay bypass to turn it into a EQD flexi switch clone (short push = change of state, long push = momentary change, either on-off-on on off-on-off).

Would someone be interested in this ? Do you think it's worth being posted on this marvellous forum ?

swamphorn

I think this would be neat. I've been wanting to develop a discrete flexi-switch circuit, myself. I suspect I can get most of the behavior (tap to switch, momentary hold on) with a dual 555 timer but I haven't messed around with it enough to try. One timer would toggle as normal and the second timer would detect a long-press and reset the toggle on release. I need to play around with 555 timer configurations though.

matlevo12

#2
Quote from: swamphorn on March 28, 2020, 10:34:24 PM
I think this would be neat. I've been wanting to develop a discrete flexi-switch circuit, myself. I suspect I can get most of the behavior (tap to switch, momentary hold on) with a dual 555 timer but I haven't messed around with it enough to try. One timer would toggle as normal and the second timer would detect a long-press and reset the toggle on release. I need to play around with 555 timer configurations though.

I wanted to do it without a microcontroller too at first, but I changed my mind after a few tries... If you manage to make one I'm really interested.


Anyway here's my solution :

I used Coda Effect Relay Bypass, that is using a momentary SPST footswitch and a PIC.
(quick intermission : Thanks a lot to coda for all of this. If you don't know about Coda Effects go and have a look, his work is fantastic and his blog is really really interesting and well explained. You have to try his Sunn T clone "Black Hole" if you still haven't, it's awesome : https://www.coda-effects.com/p/black-hole.html )

Here's a link to his shop (it's sold out atm though) : https://www.coda-effects.com/p/relay-bypass-pcb.html
And here are 3 articles from his (really cool) blog where he explains how he built and coded it :
https://www.coda-effects.com/2016/04/relay-bypass-conception-and-relay.html
https://www.coda-effects.com/2016/08/relay-bypass-with-anti-pop-system.html
https://www.coda-effects.com/2017/02/relay-bypass-final-code.html

And here are the building docs that I had with my version : https://drive.google.com/file/d/1HekCXi-hLtRO0xLEul-bFfgVm99znPkF/view

Here's the schem from it :



Here are the mods I did to it :
- SW2 (connected to pin 5 of the PIC) : instead of a momentary switch I used a SPST toggle. If there's not contact there, or if you don't use a switch at all on SW2 the switch will work like a flexi-switch, if you make contact sith the SPST it will work like a regular relay bypass (one click changes the state of the pedal, no tempoporary change)
- I connected pins 3 and 4 of the PIC on the back of the PCB, in order to be able to control the photofet with pin 3 instead of pin 4

And here's the code part.
Most (almost all) of it comes from whats on Coda Effect's blog pages (see above), I just modded it a bit, so thanks again to him.
Here's the header :

// CONFIG
#pragma config FOSC = INTRCIO // Oscillator Selection bits (Internal clock)
#pragma config WDTE = OFF // Watchdog Timer Enable bit
#pragma config PWRTE = OFF // Power-Up Timer Enable bit
#pragma config MCLRE = OFF // GP3/MCLR pin function select
#pragma config BOREN = OFF // Brown-out Detect Enable bit
#pragma config CP = OFF // Code Protection bit
#pragma config CPD = OFF // Data Code Protection bit

// Define Internal clock frequency
#define _XTAL_FREQ 4000000


And here's the code itself, in C :

/* SOURCE
* File:   relayonpress.c
* Author: Benoit
*
* Created on 5/02/2017
*/
//modded by Mat on Oct 7th 2019
// "flexi switch with toggle" version

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <xc.h>
#include "header.h"

// Initialization
void main(void) {
  ANSEL = 0; // no analog GPIOs
  CMCON = 0x07; // comparator off
  ADCON0 = 0; // Analog to Digital and Digital to Analog convertors off
  TRISIO0 = 0; // Pin 7 = NOTHING
  TRISIO1 = 1; // Pin 6 = input footswtich
  TRISIO2 = 1; // Pin 5 = input "flexi toggle", no contact or no switch connected on SW2 = flexi on
  TRISIO5 = 0; // Pin 2 = output activation relay and led
  TRISIO4 = 0; // Pin 3 = output photofet
  TRISIO3 = 0; // Pin 4 = NOTHING, connected to pin 3 DON'T FORGET TO DO IT;-)

  GPIO = 0; // set outputs as low level (0V)

  // Variables definition
  uint8_t state; // on-off state of the pedal (1 = on, 0 = off)
  state = 0;
 
  uint8_t flexi; // defines the mode of the pedal : classic or flexi activation
  flexi = 1;

  // Main loop
  while(1) {
        if(GP2 == 1) { // By default: flexi mode
        flexi = 1;
        }
        else { // If the "flexi" switch is turned off (meaning SW2 is closed and GP3/pin4 is connected to ground)
        flexi = 0;
        }
       if(GP1 == 0) { // footswitch pressed
         __delay_ms(15); // debouncing
         if(GP1 == 0) {
            // Changing state of the pedal
            if(state == 0) { // change to on
             GP4 = 1; // photoFET on
             __delay_ms(20);
             GP5 = 1; // relay and led on
            __delay_ms(20);
             GP4 = 0; // photoFET off
             state = 1;
            }
            else { // change to off
            GP4 = 1;
             __delay_ms(20);
             GP5 = 0; // relay and led off
             __delay_ms(20);
            GP4 = 0;
            state = 0;
            }
         __delay_ms(10);
            // To let the pedal in the good state (on or off)
            if (state == 1) { // effect on
            GP5 = 1; // relay and led on
            }
            else { // effect off
            GP5 = 0; // relay and led off
            }
        }
    if (flexi == 1) { //if flexitoggle on or if there's no switch on SW2
    __delay_ms(300);//waiting (change that value if you're not happy with the short/long push setting)
    if (GP1 == 0) {//if switch is still pressed
      while (1) {//nothing happens
        if (GP1 == 1) {//until it's released
            break;//and then             
            }
        }
        // Changing state of the pedal again
        if(state == 0) { // change to on
        GP4 = 1; // photoFET on
        __delay_ms(20);
        GP5 = 1; // relay and led on
        __delay_ms(20);
        GP4 = 0; // photoFET off
        state = 1;
        }
        else { // change to off
        GP4 = 1;
        __delay_ms(20);
        GP5 = 0; // relay and led off
        __delay_ms(20);
        GP4 = 0;
        state = 0;
        }
      __delay_ms(10);

        // To let the pedal in the good state (on or off)
        if (state == 1) { // effect on
        GP5 = 1; // relay and led on
        }
        else { // effect off
        GP5 = 0; // relay and led off
        }   
      }
    }
    else {
        while (1) {
            if (GP1 == 1) {
                break;
            }
        }
    }
   }
  }
}


You can change the delay value between short and long push to your taste by changing this parameter : "__delay-ms(300)..."
That also means two things :
- that you can't push make two "short" pushes in that amount of time. Two fast clicks (fast = in less time than that value) will only change the state once.
- that if you "short" push for too long, the state will change at rist but it will work as a momentary switch and the state of the pedal will come back when you release the switch

I don't own a EQD pedal with a flexi-switch, but it seems to me that 300ms was a good compromise between the two.


Anyway, hope it helps someone !

Mat

smilbourne

Thanks for this. I am getting a lot out of this post and the linked Coda Effects site, so thank you. I am going to try a variation on this myself, with a similar setup, but where the long press connects to the feedback on a delay pedal and self oscillates. I currently have 2 switches in that pedal, with one being a momentary performing that function. I will change that to be a 'flexi switch' as in this post to turn the effect on and off, and the other will be tap tempo (the delay is an Echo Base)...can you tell i just got mysel a PIC programmer  :D.

Regarding you (and the Coda) schematic. I believe the LDR should read CLR. I can't see a use for an LDR in this circuit.

iainpunk

this makes me wonder if its possible to make it without a micro controller or opamps.
i have a bunch of CMOS/analog hybrid switchable buffers somewhere in my IC pile, and im eager to have a 3 loop bypass switcher with momentary function.

thanks for the inspiration.

cheers, Iain
friendly reminder: all holes are positive and have negative weight, despite not being there.

cheers

matlevo12

Quote from: smilbourne on December 11, 2020, 06:52:58 AM
Thanks for this. I am getting a lot out of this post and the linked Coda Effects site, so thank you. I am going to try a variation on this myself, with a similar setup, but where the long press connects to the feedback on a delay pedal and self oscillates. I currently have 2 switches in that pedal, with one being a momentary performing that function. I will change that to be a 'flexi switch' as in this post to turn the effect on and off, and the other will be tap tempo (the delay is an Echo Base)...can you tell i just got mysel a PIC programmer  :D.

Regarding you (and the Coda) schematic. I believe the LDR should read CLR. I can't see a use for an LDR in this circuit.

Please share the code you come up with, that sounds like a really cool project !
Here LDR stands for Led Resistor, I think.

Quote from: iainpunk on December 11, 2020, 08:11:23 AM
this makes me wonder if its possible to make it without a micro controller or opamps.
i have a bunch of CMOS/analog hybrid switchable buffers somewhere in my IC pile, and im eager to have a 3 loop bypass switcher with momentary function.

I found this a few days ago :
https://diy.thcustom.com/shop/nope-relay-true-bypass-kit/
https://anasounds.com/fr/produit/kit-true-bypass-relais/
You probably can't do the flexi switch thing, but it'll work as a relay bypass.

iainpunk

i know them, but i really want one of those felxi switching things because i want that usefulness without a 2nd switch per loop.

im currently working on simple BJT logic, ill keep the thread updated.

cheers, Iain
friendly reminder: all holes are positive and have negative weight, despite not being there.

cheers

matlevo12

Quote from: iainpunk on December 12, 2020, 07:36:13 AM
i know them, but i really want one of those felxi switching things because i want that usefulness without a 2nd switch per loop.

im currently working on simple BJT logic, ill keep the thread updated.

cheers, Iain

Oh sorry.
Well I'd be really interested too !

Michael2

Hi and thanks for the code. I realise this post is kinda old but the momentary hold function only works 10% of the time here. I used an 2n2222 instead of an 2n5088. Can that be the culprit?

ElectricDruid

Quote from: Michael2 on July 03, 2021, 02:03:29 PM
Hi and thanks for the code. I realise this post is kinda old but the momentary hold function only works 10% of the time here. I used an 2n2222 instead of an 2n5088. Can that be the culprit?

Unlikely. More likely is bad switch bounce, or the "long press" time being too short. I generally use something around half a second for this, since that eliminates the possibility of a "firm short press" being interpreted as a "long press". And when you actually want a momentary burst of effect, you're highly unlikely to want it for less than half a second - a second is more like an actual minimum, and even that is pretty remote.

Michael2

Sorry for the late reply but I managed to fix the problem. It was not the transistor or the switch, it needed a higher filter cap to take out ripple and since I left out the toggle switch I expected that the 10k resistor at pin 5 to 5v was not necessary but it is. All works great now and the momentary function is working great. Thanks for your help and thanks again for the adjusted code.