PIC based silent switching switch matrix

Started by tempus, May 26, 2009, 01:11:25 PM

Previous topic - Next topic

tempus

Hey all;

Here's the final design for my switch matrix:



I had toyed with the idea of building a cornish style board, but I get the odd gig here and there where I just need 1 pedal, so I think I'd rather have the option to just use individual pedals if I need to without having to bring the whole board. Each switch will basically do the following:

1. momentary switch engaged
2. shunt MOSFET on
3. (not) MOSFET for all FX switched on (to reset everything to bypass from whatever the previous setting was)
4. (not) FX1 MOSFET switched off
5. FX1 MOSFET switched on
6. (not) FX2 MOSFET switched off
7. FX2 MOSFET switched on
8. shunt MOSFET off

The shunt MOSFET shunts the signal to ground, and is the one at the end of the chain (right side). This makes for totally silent switching, except for when I switch amp channels - anyone have any ideas on that one?

Anyway, does anyone see any problems or have any other suggestions?

Thanks

Hmmm... I just looked at this and it's not very clear for some reason. I know the source image is easy to read though.


iaresee

#1
I'm assuming that:

Quote
1. momentary switch engaged
2. shunt MOSFET on
3. (not) MOSFET for all FX switched on (to reset everything to bypass from whatever the previous setting was)
4. (not) FX1 MOSFET switched off
5. FX1 MOSFET switched on
6. (not) FX2 MOSFET switched off
7. FX2 MOSFET switched on
8. shunt MOSFET off

Is your pseudocode for a patch change -- correct?

How do you know a relay is full switched before executing the next instructions? For example: you need to wait for your shunt MOSFET to go to the on position before you run line 3. How long do you wait? Add up all the waits and all the time to execute the lines in your program for a patch change -- what's the time? It feels like it might have a noticeable delay on patch changes with this approach.


tempus

QuoteIs your pseudocode for a patch change -- correct?

Sorry - should've specified that. Yes, that's a patch change.

QuoteHow do you know a relay is full switched before executing the next instructions?

That is something I've considered, but unfortunately will not be able to confirm until I actually have the components, build it, and try it out. However, I'm thinking that the shunt MOSFET only needs to be on for less than 50 mS to mute any switching noise, during which time instructions 3-7 can easily be executed (the PIC can run as fast as 20MHz). Hopefully that wont be an audible dropout in sound. I can also put a delay after #3 if necessary.

iaresee

I also don't understand why you have some of your switches setting lines low on the left side of the PIC. Specifically: 5, 6, 7, 9, 10 and 1 -- are these dual purpose inputs? I haven't looked at the datasheet for the PIC so this might be an ignorant question but...if you tie a switch to CLKIN doesn't that override the internal clock on your PIC? How do you run a multiple line program if you're only generating one clock cycle (switch down, switch up...). Maybe I need to read more? ;)

iaresee

Quote from: tempus on May 26, 2009, 01:27:38 PM
QuoteHow do you know a relay is full switched before executing the next instructions?

That is something I've considered, but unfortunately will not be able to confirm until I actually have the components, build it, and try it out. However, I'm thinking that the shunt MOSFET only needs to be on for less than 50 mS to mute any switching noise, during which time instructions 3-7 can easily be executed (the PIC can run as fast as 20MHz). Hopefully that wont be an audible dropout in sound. I can also put a delay after #3 if necessary.

But you need to wait until all the relays have switched before you execute 8 right? Otherwise you might hear the pops as the to-effect relays are changing. So you've got 50 ms for the shunt to take effect + X amount of time for your to-effect relays to reach steady state + Y amount of time to remove the shunt. I still think you're going to feel that amount of time.

tempus

QuoteI also don't understand why you have some of your switches setting lines low on the left side of the PIC. Specifically: 5, 6, 7, 9, 10 and 1 -- are these dual purpose inputs

The pins on the PIC can be software programmed for a number of different functions. The pins you specify are going to be programmed as inputs. They need the 10K pullup resistors because the ins on Port A don't have internal pullups.

Quote..if you tie a switch to CLKIN doesn't that override the internal clock on your PIC?

This will be my first PIC project, so I'm not 100% sure. My understanding of the data sheet is that pins 9 and 10 can be programmed to be data inputs or clock inputs.

QuoteBut you need to wait until all the relays have switched before you execute 8 right?

These aren't relays, they're MOSFETs, and they switch in 10nS. Again, I'll have to try it to see for sure, but I think that all the instructions will be executed and carried out in less than 50mS. Also, I don't think it will matter which instruction is completed first (i.e., in the list from 4-7), as long as they're all done in less than 50mS.

tranceracer

Tempus That's a very nice layout!  I too am working on a program to get a PIC to alternately pulse two pins for a latching relay.  Are you programming in Assembly or C?  (I'm using C btw.)

iaresee

Quote from: tempus on May 26, 2009, 01:53:17 PM
QuoteI also don't understand why you have some of your switches setting lines low on the left side of the PIC. Specifically: 5, 6, 7, 9, 10 and 1 -- are these dual purpose inputs

The pins on the PIC can be software programmed for a number of different functions. The pins you specify are going to be programmed as inputs. They need the 10K pullup resistors because the ins on Port A don't have internal pullups.

Perfect. You can probably ignore the rest of my rambling then :)

Quote
Quote..if you tie a switch to CLKIN doesn't that override the internal clock on your PIC?

This will be my first PIC project, so I'm not 100% sure. My understanding of the data sheet is that pins 9 and 10 can be programmed to be data inputs or clock inputs.

If that's the case, and you're using an internal clock, everything I'm asking is not a problem. Ignore me.

Quote
QuoteBut you need to wait until all the relays have switched before you execute 8 right?

These aren't relays, they're MOSFETs, and they switch in 10nS. Again, I'll have to try it to see for sure, but I think that all the instructions will be executed and carried out in less than 50mS. Also, I don't think it will matter which instruction is completed first (i.e., in the list from 4-7), as long as they're all done in less than 50mS.

Okay, this makes sense now. You're not waiting for the 50ms to pass, you're just trying to get all your switching done in 50ms. Got it.

tempus

QuoteI too am working on a program to get a PIC to alternately pulse two pins for a latching relay.  Are you programming in Assembly or C?

I haven't gotten my PIC yet, so I don't know what I'll program in. Is one easier than the other? I'm sure I'll be posting here for some programming advice in the next little while...
I'd also be interested in seeing your code if you didn't mind, just to see if I'm on the right track when I do start.

Thanks



R.G.

R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

tempus

QuoteOh dear!

Is that as in 'what an awesomely cool and ingenius design' or 'I don't remember the last time I've seen something quite this terrible'?

lol


Dave_B

Careful, Tempus.  Many a poster has started a µC-controlled switcher never to be heard from again.
Help build our Wiki!

nfxpedals

Quote from: R.G. on May 26, 2009, 10:20:33 PM
Oh dear!
Well I'd kinda take that as a oh dear you do not know what to program.
Be prepared to spend some time learning a language. Good luck!

~arph


R.G.

Quote from: tempus on May 26, 2009, 10:33:21 PM
Is that as in 'what an awesomely cool and ingenius design' or 'I don't remember the last time I've seen something quite this terrible'?
Neither. It's "Oh, dear!" as in "You may have further to go to get this finished than you are estimating right now if you are asking if assembler is harder to write than C." That "then I go learn to program a microcontroller" step can be a big one to some people. Unless you actually have long, deep experience with programming and you''re just jivin' us.

That was my tongue-in-cheek joke when I named the programmable footswitch projects "ASMOP" for "A Simple Matter Of Programming". Our management used to think that all the fuss was over once the resident hot-shot 'architect' had decided the concept level design, and that after that it was all a simple matter of programming.

I haven't looked at the switch matrix you're proposing in detail. Just off-hand, it looks like more of a 'which pedal(s) in this line of pedals' than what I'd call a matrix, but that's just semantics, and a 'which pedal(s)' switcher is a fine goal, too.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

tempus

Actually, I misspoke earlier. My understanding is that assembly is more difficult than C - I was asking more about compiling and that kind of thing (am I right in thinking that assembly doesn't require a compiler?). I know that the programming step is also going to be a big one for me, but I'm hoping that through tutorials and friendly advice that it shouldn't be too bad. Also, I used the term matrix loosely. This is indeed a ' stomp this switch and this combination of effects turns on' kind of system, which I'm also hoping will ease the programming - I would think that once I got the programming set for one switch, the others would be more or less a cut-and-paste of the code.

Thanks

tempus

Not to hijack my own post...

but I just got done reading the thread on increasing life expectancy of builds. It talked about putting reverse biased diodes on the inputs of semiconductors. Would that be a good idea here? IOW should I put some reverse biased diodes on each of my MOSFET inputs?

Thanks

iaresee

Quote from: tempus on May 27, 2009, 10:09:46 AM
Actually, I misspoke earlier. My understanding is that assembly is more difficult than C - I was asking more about compiling and that kind of thing (am I right in thinking that assembly doesn't require a compiler?).

If you have zero programming experience neither is easy. But neither is impossible. You have to post-process code written in either assembly or C in order for it to run on a chip. In the case of C you use a compiler to turn it into machine code. In the case of an assembly language you use an assembler to translate it to machine code.

C is, more or less, hardware generic -- you write it once and compile it for different hardware targets. Kind of. C still lets you touch hardware in ways that are non-portable (you access bit-level data in registers so you need to know how the hardware is storing those bits and so on).

Assembly is very hardware specific though most "families" of hardware like PIC chips share a pretty common set of assembly instructions.

With C you work with higher level functions and logic expressions. What you write in one line of C might turn in to 20 lines of assembly before it's translated to machine code by the compiler. In assembly you're working with very low level functions -- very simple. For example: lets say the hardware you're programming doesn't have a multiple operation in it's ALU -- in C you wouldn't care. You'd write:

int b = 10;
int c = 2;
int a = b * c

And the compiler is going to translate that into a repetitive add operation that adds 10 to a register two times. But in assembly you'd need to work this out for yourself -- you wouldn't have a MULT operation so you'd need to write:

INTREG #address 0000000000
ADD #address 10
ADD #address 10
ASSIGN #VARA #address

That's pseudo-code assembly, but you can see that I'm: intializing a register with zeros. Adding 10 to the register two times (10 * 2) and then assigning the contents of the register to the address pointed at by my variable VARA.

Fun!

QuoteI know that the programming step is also going to be a big one for me, but I'm hoping that through tutorials and friendly advice that it shouldn't be too bad. Also, I used the term matrix loosely. This is indeed a ' stomp this switch and this combination of effects turns on' kind of system, which I'm also hoping will ease the programming - I would think that once I got the programming set for one switch, the others would be more or less a cut-and-paste of the code.

You have to learn some place I suppose. Have you given anything to perhaps buying a development platform? Something fully integrated that doesn't require you to work out the subtleties of the hardware *and* the software -- just the software? I'd like to tell you that you'll solder that all up and it'll just work but that's not how it goes with uControllers. They're not *that* easy to work with.

There are a bunch of off-the-shelf uController dev kits you can buy that come with relays and such already to go. Arduino-based system are really popular. There's a good community of software developers around them to get help from and lots of tutorials and labs for learning. Check out this thread:

http://www.diystompboxes.com/smfforum/index.php?topic=70998.0

Lots of nice options listed there.

Thanks

[/quote]

R.G.

Give yourself six months to become modestly proficient at programming anything if you're starting from no background at all.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

nelson

Quote from: R.G. on May 27, 2009, 01:48:26 PM
Give yourself six months to become modestly proficient at programming anything if you're starting from no background at all.


Being self taught, I think that's optmistic.

I have about 20 úC books. I've glanced over the introductions to all the books, to get an idea of how to proceed with learning the skill set.

I mean, should I learn assembly, or C, should I use CISC or RISC architecture micro's? Etc etc.

I have assigned myself a simple little úC project - controlling grey code options on a DSP with a 1P6T switch + a úC, I've decided to go with learning C in relation to AVR's for the project.
C because it's portable to many other úC's and AVR's because development on the platform is relatively cheap and has wide support on the net.
I'd recommend www.smileymicros.com and their e-books, his writing style gets to me, but he teaches pretty well.
I particularly like how he approaches C.

Anyway, 6 months is optimistic, unless that's all you plan to do with your time.

I've been reading books for two months trying to get even a little bit of understanding.
So far, all I know is that I need to learn a lot more.





My project site
Winner of Mar 2009 FX-X