Author Topic: Possibility of C code for controlling triple pedal with ONE PIC microcontroller?  (Read 5405 times)

thanal9999

 So, the idea is the following…

I am working on a triple pedal. And because I like silent switches I decided to use a relay switching system for the three circuits.
Something like Mr. Benoit of CODA-effects is suggesting and sharing the information and C code for the PIC12F675 microprocessor:

http://www.coda-effects.com/2016/04/relay-bypass-conception-and-relay.html

This would be perfect because I have a Pickit2 programmer lying around.

But I was wondering… (Because I am a noob at programming really)

Is it possible to use ONE (1) bigger PIC microprocessor, like the PIC16F676, with more I/Os to make the switching of the 3 relays with the 3 momentary switches…?
Is there a way of “putting the three codes in one processor” and have the possibility for the 2 or 3 circuits to be engaged and disengaged together if the 2 or 3 momentary switches are pressed together by the foot…?

And if so, is there any suggestions from the more experienced in programming members of the forum about the code for such a task…?

I guess this could be used for double pedals also...

potul

For sure you can do this.

If I undersatnd correclty, you want 3 switches and 3 relays. So you need a PIC with at least 6 GPIO.
I think you can still use the PIC12F675

But looking at the page you shared, I would not recommend driving the relay directly from the PIC. You would need a relay driver for each relay, and add an LED controlled by the same driver.

Of course... you will need to redo the code. It's not like you copy paste 3 times and they work in parallel :)






thanal9999

For sure you can do this.

If I undersatnd correclty, you want 3 switches and 3 relays. So you need a PIC with at least 6 GPIO.
I think you can still use the PIC12F675

But looking at the page you shared, I would not recommend driving the relay directly from the PIC. You would need a relay driver for each relay, and add an LED controlled by the same driver.

Of course... you will need to redo the code. It's not like you copy paste 3 times and they work in parallel :)

You understood it correctly .
I think I need 12 GPIOs (for the Led for each ciruit also)
I will use transistors to drive the relay... and maybe for the led as you suggested (so maybe less GPIOs are enough as you said  :))
My problem is the code of course, because I dont have no real experience with programming...
How will I combine the 3 codes... this is my problem really...

samhay

>I think I need 12 GPIOs (for the Led for each circuit also)

You could use separate outputs to drive the LEDs, but even then (and it is not necessary) that would be 9 GPIOs - 3 x switch, 3 x relay coil, 3 x LED. I would stick to six and drive the relay driver and LED with the same output.

The code needed is pretty trivial, but if you have no programming experience, I guess it seems pretty insurmountable. However, it didn’t take Mr Benoit very long to learn how to do this - see: http://www.diystompboxes.com/smfforum/index.php?topic=113094.0

>...and have the possibility for the 2 or 3 circuits to be engaged and disengaged together if the 2 or 3 momentary switches are pressed together by the foot…?

You can also have slightly more complicated code that can tell whether you have tapped on or held down the switch. This might be a nice way of controlling multiple circuits.
« Last Edit: June 17, 2016, 07:49:10 AM by samhay »
I'm a refugee of the great dropbox purge of '17.
Project details (schematics, layouts, etc) are slowly being added here: http://samdump.wordpress.com

thanal9999

>I think I need 12 GPIOs (for the Led for each circuit also)

You could use separate outputs to drive the LEDs, but even then (and it is not necessary) that would be 9 GPIOs - 3 x switch, 3 x relay coil, 3 x LED. I would stick to six and drive the relay driver and LED with the same output.

The code needed is pretty trivial, but if you have no programming experience, I guess it seems pretty insurmountable. However, it didn’t take Mr Benoit very long to learn how to do this - see: http://www.diystompboxes.com/smfforum/index.php?topic=113094.0

>...and have the possibility for the 2 or 3 circuits to be engaged and disengaged together if the 2 or 3 momentary switches are pressed together by the foot…?

You can also have slightly more complicated code that can tell whether you have tapped on or held down the switch. This might be a nice way of controlling multiple circuits.

I understand that I only need one output for the relay (and possibly the LED combined) since the ( - ) pin of the relay coil should be connected to ground.

So why Benoit is using 2 outputs for the relay in his schematic ?

Anyway, I have a lot of reading to do, starting from the post that you mentioned and going into some C programming territory... It is a learning process worth the effort... ;)

Thank you for your help.

samhay

>So why Benoit is using 2 outputs for the relay in his schematic ?

Hadn't looked at that properly before. He is using one of the pins (GP4) as ground. I see no advantage to this, and I would also advice you to drive the relay coil with a transistor so the PIC doesn't have to work so hard. Something like this (you may not need R3):

I'm a refugee of the great dropbox purge of '17.
Project details (schematics, layouts, etc) are slowly being added here: http://samdump.wordpress.com

potul

This is exactly what I was referring to as using a relay driver. It's usually a bad idea to drive the relay directly from the PIC.

thanal9999

So I suppose this way I can use 9VDC relays and not stress the 78l05 regulator (there will be 3 relays plus the microcontroller to be powered from it... if 5v relays are used)...

Benoi31

Quote
Hadn't looked at that properly before. He is using one of the pins (GP4) as ground. I see no advantage to this, and I would also advice you to drive the relay coil with a transistor so the PIC doesn't have to work so hard. Something like this (you may not need R3):


Hello!
I think this is actually better than my system.
The transistor will avoid to use to much current through the microcontroller (which could damage it)
And you use only one pin instead of three! (with the LED)

I kept it like this on my post because it was working ^^ (do not change something that works, 2nd rule of "guitar electronics" haha (firt one would be "it never works on the first attempt"))

Anyway, I recently improved a bit the circuit by adding a mute system to avoid popping (that happens very often as the relay switches faster than a 3PDT, especially with high gain circuits)
here is a small video of it:

The pop is totally removed with this system (the small click that you hear is the relay switching, does not go through the signal chain)

I will post an article on my blog with it soon
« Last Edit: June 19, 2016, 03:36:01 PM by Benoi31 »

potul

So I suppose this way I can use 9VDC relays and not stress the 78l05 regulator (there will be 3 relays plus the microcontroller to be powered from it... if 5v relays are used)...
Yes, you can do this. And I recommend it.

ElectricDruid

Anyway, I recently improved a bit the circuit by adding a mute system to avoid popping (that happens very often as the relay switches faster than a 3PDT, especially with high gain circuits)
here is a small video of it:

The pop is totally removed with this system (the small click that you hear is the relay switching, does not go through the signal chain)

I will post an article on my blog with it soon

I look forward to the article, that sounds very interesting.

To a non-purist like me, using a relay and then adding more circuitry to avoid the relay popping seems like a lot of work, so I'm interested to see what you've done. I'd be more inclined to move to an electronic switching system like CMOS switches (4066/4053 for example) or FETs like the Boss pedals did. These can give you noiseless switching and could easily be controlled from a uP, with the benefits that can give (like latching/non-latching operation, MIDI-controller In/Out switching etc etc - anything else you can dream up).

Tom

Benoi31

It is actually just one component to add, so quite easy to implement, I was inspired by this post on stompville :
http://stompville.co.uk/?p=423