DIYstompboxes.com

DIY Stompboxes => Digital & DSP => Topic started by: AdamB on July 08, 2019, 12:56:48 PM

Title: JFet switching with 3.3V logic
Post by: AdamB on July 08, 2019, 12:56:48 PM
Hi,

I'm working on a switching circuit that selects between audio signals, driven by a dspic. The pic's digital pins provide 3.3V TTL, wondering how I might go about rigging it up to replace the footswitch in this circuit that relies on a +9V supply for the JFETs;

(https://i.postimg.cc/4YPPJPC5/switching-Problem.png) (https://postimg.cc/4YPPJPC5)

I want to avoid using relays (too big) and haven't been able to find a switch IC that seems to do this job well/cheap/small TH footprint.

The schematic is from a unit I'm designing based around a dspic - the switching works fine driven by a 3PDT switch (with one pole used to control the dspic and the other 2 poles used to control the audio switching). However I want the ability to control whether the effect is latching or non-latching switching. So I'd like to simply use a SPST momentary switch to drive the dspic logic and then have the dspic control the audio switching side of things itself.

Any ideas?
Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on July 09, 2019, 04:52:34 AM
I'm not sure if you just want to interface the 3V microprocessor to the existing 9V circuit, or, remove 9V altogether.

For the first case you just need to drive the gates with an open collector or open drain circuit.   You probably won't be be able to drive the gates directly from the microprocessor with an open drain/collector configured pin.  You will need to add a transistor or MOSFET. 

Take this ckt
https://www.hobby-hour.com/electronics/s/schematics/od1-overdrive-schematic.gif

(Roughly) imagine stripping out:
LED drive ckt
R19, R18, C10, C13, C14
C11, C12,
then break R22 from R20 and R23 from R21
then drive the micro into the now floating resistor ends of R22 and R23.
You will need to reduce the 2x100ks to at least 56k so the transistors will switch at 3V3.

The whole idea is to provide a floating collector output which can go upto 9V when the switched (Q2, Q4) are off.
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on July 09, 2019, 11:11:25 AM
Thanks for the reply, I'll try and figure my way through your answer!
Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on July 09, 2019, 06:56:30 PM
This is a simpler version.

(https://i.postimg.cc/hzJncPT4/sw-itching-Problem-2.png) (https://postimg.cc/hzJncPT4)

The extra resistors and caps on the Boss circuit help reduce ticks when switching over.
The simpler version doesn't have this but it will help you understand the main idea.

Title: Re: JFet switching with 3.3V logic
Post by: AdamB on July 10, 2019, 04:55:15 AM
Ok I think I understand that now - time to breadboard! Once I got it I'll copy it over to my schematic and repost for others to use.

Massive thanks for the help!
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on July 16, 2019, 11:27:40 AM
Seems to work OK on the breadboard.

Here's my schematic for it;

(https://i.postimg.cc/mzLj2QFd/swtiching-new.png) (https://postimg.cc/mzLj2QFd)
Title: Re: JFet switching with 3.3V logic
Post by: MetalGuy on July 16, 2019, 03:00:14 PM
Quote...and haven't been able to find a switch IC that seems to do this job well/cheap/small TH footprint.

How about Analog's ADG series CMOS switches?
Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on July 16, 2019, 07:24:55 PM
QuoteSeems to work OK on the breadboard.
It should work.  The only thing you might have to watch out for is 'ticks' when changing over.   The extra caps on the Boss ckt help reduce that to a minimum.

QuoteHow about Analog's ADG series CMOS switches?
Nothing wrong with that path either.
Title: Re: JFet switching with 3.3V logic
Post by: ElectricDruid on July 17, 2019, 02:30:17 PM
Quote from: AdamB on July 16, 2019, 11:27:40 AM
Seems to work OK on the breadboard.

Here's my schematic for it;

(https://i.postimg.cc/mzLj2QFd/swtiching-new.png) (https://postimg.cc/mzLj2QFd)

I don't doubt that works, but is all that stuff *necessary*?

With the diode on the FET's gate, the pull-up to 9V doesn't do anything, does it? The diode is reverse-biased. I thought the original Boss idea was that the Gate floats high in this condition, but I might be wrong - never studied this stuff.
Also why drive the transistor bases from a voltage divider that reduces the voltage at the base? You can drop the resistor to ground, surely? If you're not getting enough current to switch them on, reduce the base resistor a bit.

I'm interested to see this succeed because this is something I've wanted to do too, so I hope my comments are useful and not just poorly-informed misunderstandings. Switching FETs on and off directly from a uP offers several interesting possibilities...;)

HTH,
Tom
Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on July 17, 2019, 07:41:00 PM
QuoteWith the diode on the FET's gate, the pull-up to 9V doesn't do anything, does it? The diode is reverse-biased. I thought the original Boss idea was that the Gate floats high in this condition, but I might be wrong - never studied this stuff.
It might work floating.  It's better to force the issue from a noise perspective and to avoid any weird behaviour related to the gate capacitances charging up and causing fizzyness.
[BTW:  In the Boss Vibrato thread a few months back a 10M pull-up had problems.]

QuoteAlso why drive the transistor bases from a voltage divider that reduces the voltage at the base? You can drop the resistor to ground, surely? If you're not getting enough current to switch them on, reduce the base resistor a bit.
That will work for sure.   The resistors make the transistor switch at 1.2V or so roughly mid 3V3 rail.  There's cases where you should use base-emitter resistors but in this case you don't really need them.

QuoteSwitching FETs on and off directly from a uP offers several interesting possibilities
If you look at professional products they often use circuits like the Boss circuit with the pull-ups, diodes, and RC networks to provide soft change-overs.
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on July 19, 2019, 06:24:25 AM
Ordered a PCB prototype to test this revision so will confirm how well this solution works and then move onto the next revision. I've left out the extra caps from the boss design for now, will asses whether I need them once I hear this working as is and add them to the next revision if needed.

I'll let you know how I get on!
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on July 19, 2019, 12:35:09 PM
QuoteHow about Analog's ADG series CMOS switches?

Good suggestion, however my issue is that looking around mouser I couldn't see any that are through hole to make designing with it easier for a simpleton like me! But, maybe I'm not looking hard enough. Whilst I am intending to use SMD in my project (the PCBs I have on order are the first that switch to SMD pics and RAM chips to reduce size, now that I know from previous revisions that my pic and ram stuff is working fine). But when designing each stage of the circuit I need to start first with through hole stuff to make prototyping easier and reduce the number of iterations I have to go through to get stuff to work, being as I don't really know what I'm doing!

That being said, assuming this switching stuff works as planned and I can move onto the next part of the project, I am faced with the daunting task of replacing the onboard ADC/DAC of the dspic with a codec chip of some sort, which are seemingly all SMD, too. So I'm gonna have to go through some pain there, building PCBs that might not work. Chip wise I'm looking at whatever is cheap/simple and supports SPI. SPI might not be ideal? But I have a good idea of how to wire up, so hopefully won't take too many revisions of rookie errors to get that working! The pic I'm using has 2 SPI modules, so I'm also kinda hoping it's speedy enough to do 16bit 48Khz audio as well as talking to the ram chips.
Title: Re: JFet switching with 3.3V logic
Post by: ElectricDruid on July 19, 2019, 02:24:42 PM
For talking to a codec, you might be better with I2S rather than SPI. I2S ("Inter-IC Sound") is the standard for that type of job. While there are plenty of SPI DACs and ADCs out there, the ones aimed at audio tend to go with I2S.

Some of the dsPICs have an I2S interface built-in to make life easier for connecting up a codec. Coupled with the DMA, you can get cool stuff going on where your data miraculously arrives in RAM without your code having to do anything at all and without holding up the processor with interrupts.
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on July 19, 2019, 03:03:05 PM
Ok good to know! I just found this prototyping board;

https://www.mikroe.com/audio-codec-proto-board

that looks like it supports both spi and i2s so I can try both ways, and means I can breadboard and get data going in and out of the pic before committing it to PCB.

Then I suppose I just have to figure out the input/output conditioning for guitar signals for it.

Title: Re: JFet switching with 3.3V logic
Post by: AdamB on August 12, 2019, 07:24:17 AM
Right, an update on this switching thing.

So breadboard tests went fine though I only tested 1 JFET switch attached to 1 pin on the dspic, but felt confident enough with it that I moved ahead and built a PCB version.

The PCB version is a fail, here's my problem; What I didn't test on the breadboard was two JFET gates operating together (one on the dry signal and one on the wet, controlled by separate logic pins) and it seems that somehow the 2 JFETs are interfering with one-another's operation;

I have 2 pins of 3.3V logic controlling the switching, one is the 'DRY_SWITCH' and the other is the 'WET_SWITCH'. Bringing this pin low should open the associated JFET gate. The idea with this setup is that the user can select whether the effect is latching/momentary, and whether the dry is muted while the wet is playing.

If you only have dry or wet, but not both, you get a useable signal. I can't be sure but I *think* it's slightly quieter than what it should be, which leads me to suspect the JFETs aren't opening up fully. However it "works".

But, if you try to un-mute both the dry and the wet together (pull both switch pins low) you get lots of buzzy heavy distortion of both signals. However, if you switch to bridge pickup and pick as hard as you can, then it seems to pop both the JFETs open (even the wet signal JFET, which is not playing any of the dry signal) and the distortion disappears completly (it also seems to go louder than the wet on its own or dry on its own, which is what leads me to believe the JFETs aren't opening properly when used independently).

Anyone have an idea what's going on here? Attached is the schematic, it's the same as what I posted earlier;

(https://i.postimg.cc/S2TxbQCq/switch-Probs.png) (https://postimg.cc/S2TxbQCq)
Title: Re: JFet switching with 3.3V logic
Post by: gena_p1 on August 12, 2019, 07:38:42 AM
Quote from: MetalGuy on July 16, 2019, 03:00:14 PM
Quote...and haven't been able to find a switch IC that seems to do this job well/cheap/small TH footprint.

How about Analog's ADG series CMOS switches?

FET switching is fine with capacitor on gate , but CMOS switching is edgy , and without zerocross or kind of that at the input of reverb it's harsh
Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on August 12, 2019, 07:49:24 PM
QuoteIf you only have dry or wet, but not both, you get a useable signal. I can't be sure but I *think* it's slightly quieter than what it should be, which leads me to suspect the JFETs aren't opening up fully. However it "works".
To cut to the chase I think you might be better-off moving the JFET switches to the input of the opamp.  Increasing the resistors on the opamp from 10k to 47k might also help. 

In your current set-up the input voltages modulate the JFET drain and source voltages relative to VR.  The JFETs voltage are "flapping about".  This in turn modulates the Vgs voltage and hence the JFET resistance.   The 10k resistances on the opamp are quite low and that makes the problem worse as the JFETs resistance needs to be low relative to the 10k value.

By moving the switches to the opamp of the 10k resistors the voltages on the JFETs are pinned at VR on one side and only modulate a small amount on the other (basically the divider formed by the 10k input resistor and the JFET resistance on the other).   Now you can see by making those resistors 47k the voltage across the JFET is kept 5 times lower than 10k (and probably 100 times less than what you have now).

Look at some Boss circuits.  This type of thing,

(https://www.hobby-hour.com/electronics/s/schematics/boss-ce2-chorus-schematic.gif)
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on August 13, 2019, 03:41:28 AM
Ok I think I understand it, cheers for the help - will roll that into the next version and see how goes!
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on August 13, 2019, 04:23:41 AM
Just mocking this up, this is what I got from your post, Rob. Blue squares are where I've moved the 10K resistors to so that the switch is between the resistor and the op-amp input, and bumped them to 47K. I've also added in the capacitors (orange squares) to remove the clicks on switching (as you suggested earlier - can confirm this thing pops like crazy when you switch :P). I *think* I've put the capacitors in the right place, but I find that old boss schematic hard to read for some reason, something about the way it's laid out doesn't agree with me.

(https://i.postimg.cc/4KKBwpqv/switching-Improved-Maybe.png) (https://postimg.cc/4KKBwpqv)

I'll hook up the wet side in the same way and then when I roll the next revision I'll let you know how it went!
Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on August 13, 2019, 05:20:03 AM
The series caps won't work.   The Bass-Emitter cap might work but it's often not a good place to put timing caps.
I've mark up the schematic to be more Boss-like.
Notice you don't need to 1M at the terminal going to the opamp.


(https://i.postimg.cc/gXDsMJSZ/JFET-3-V-Switching-V1-1.png) (https://postimg.cc/gXDsMJSZ)
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on August 13, 2019, 12:00:06 PM
Ah OK cool, thanks!
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on August 13, 2019, 12:10:45 PM
Here's the latest schem with the caps in as you suggest

(https://i.postimg.cc/k2GtwGn3/switch-Better-Fo-Realz.png) (https://postimg.cc/k2GtwGn3)
Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on August 13, 2019, 05:20:40 PM
QuoteHere's the latest schem with the caps in as you suggest
I have to apologize, I screwed up a bit when I added stuff to your schematic.  It's not quite there.

Hopefully, this is right,
(https://i.postimg.cc/6yC8FWFj/sw-itch-Better-Fo-Realz-V1-2.png) (https://postimg.cc/6yC8FWFj)

Notice I've added 2x 1M resistors .
It's getting pretty complicated.
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on August 14, 2019, 05:08:25 AM
Okykoke, I'm not at my desk today but will take a look tomorrow and see if I understand, thanks!
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on August 14, 2019, 12:04:32 PM
Right found some time after-all. Good spot on the flipped mosfet, tried to clean up the schematic by moving it over and mirroring but just rotated it instead of flipped it lols.

Here's the latest version:

(https://i.postimg.cc/xcwR8LPs/switch-Better-Fo-Realz-Strand-ified.png) (https://postimg.cc/xcwR8LPs)
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on October 13, 2019, 06:41:06 AM
Riiiight. Had a chance to build this finally. Only a quick test but it's looking a lot better - for some reason it still doesn't like the wet side being closed, I have to leave the wet side open for the dry switch to operate correctly. If I have dry open and wet closed the dry side produces distortion (like the jfet hasn't opened fully again...).

It's usable for what I need in this form, as I can just mute the wet output in software, but ideally I'd like to figure out why it causes this problem - it'd help for future projects and also for my understanding of this stuff.

There's also some slight thumps when switching, bigger cap C19 needed perhaps?
Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on October 13, 2019, 07:03:55 PM
QuoteRiiiight. Had a chance to build this finally. Only a quick test but it's looking a lot better - for some reason it still doesn't like the wet side being closed, I have to leave the wet side open for the dry switch to operate correctly. If I have dry open and wet closed the dry side produces distortion (like the jfet hasn't opened fully again...).
Something weird is going on.  As far as the switching is concerned the Wet and Dry paths are essentially the same.   The only thing different is the specific JFET in each position.  So if you swap the JFETs does that move the problem to the DRY signal?   That would be an extremely good sanity check.

Another extremely good check would be to pull the JFETS and put in links.  I'd pull the JFETs out entirely.  It would be good to try one at a time then both.  See if you get the same problems.   Also see if there's a pattern.   It might be the circuit itself oscillating or acting funny.

QuoteIt's usable for what I need in this form, as I can just mute the wet output in software, but ideally I'd like to figure out why it causes this problem - it'd help for future projects and also for my understanding of this stuff.
IMHO it's good to take that stance.  Weird problems often point to a bigger or more devious problem.

My guess is there's something different about the Wet circuit.  It can't be a DC issue on the Wet side.   What is feeding the Wet signal?  If you have a BBD or digital device driving the Wet side and there's not enough anti-aliasing filter there would be a high frequency modulation signal present on the wet line.  That will cause all sorts of havoc with the JFETs.   While you cannot hear the high frequency signal it can affect the circuit.

Another possible cause is the circuit feeding switch starts to oscillate when both wet and dry are active.  While it might happen more easily with a resistive mixer, the virtual ground mixer you are using is fairly immune to that effect.

QuoteThere's also some slight thumps when switching, bigger cap C19 needed perhaps?

Under normal circumstances you shouldn't get thumps. It might turn out that once the weird problem above is solved the thumps disappear.   Those caps should be plenty big enough.  One caveat is if the JFET cutoff voltage "Vgsoff" or VP  is too low the JFETs will see faster transitions than the RC circuit.  In which case a larger cap might help.

What's actually feeding the Wet and Dry signals?   Knowing that might help find the crack causing the problem.
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on October 14, 2019, 10:28:54 AM
The dry side is the dry guitar fed via a TL072 unity gain buffer.

The wet side is the output from a codec chip (CS4272), looks a little something like this:

(https://i.postimg.cc/vDnzVC7J/cs4272-output.png) (https://postimg.cc/vDnzVC7J)

I soldered the jfets in so can't switch them (debugging lesson learnt...). However what I'll try tonight is seeing whether the wet side operates correctly when the dry side is left closed. That way we can at least say that the jfet circuits operate as intended when used independently? Will try that tomorrow and report back.

Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on October 14, 2019, 05:57:01 PM
QuoteI soldered the jfets in so can't switch them (debugging lesson learnt...). However what I'll try tonight is seeing whether the wet side operates correctly when the dry side is left closed. That way we can at least say that the jfet circuits operate as intended when used independently? Will try that tomorrow and report back.

See how you go.  You might be able to lift some caps or resistors before the switch and that will let you wire them back "cross connected"  to do the test.

My gut feeling is there's some HF modulation on the output of the codec (or more precisely the filter).  I realized you have use the recommended output filter.  I'm assuming you are running at a high sample/clock rate so the is filtering the clock out.   One hidden source of clock leak-through is the common-mode rejection of the opamp.   So while the stage looks like a filter perhaps stuff is still getting out.  You could try putting a cap, say 10nF ***, across R89.  That will form a low-pass filter with R88 and hopefully remove any remnant high frequency rubbish.

[*** This value is a little heavy handed. It's only for the purpose of testing the theory.]
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on October 16, 2019, 12:32:28 PM
OK can confirm the following;

The wet switch never works properly, even when used isolated from the dry one. So I'd assume the problem is with the wet side (either the switch itself or the interference from the output signal like you suggest).

Built up a second board with different JFETs and got the same behaviour so I'd assume it's not the JFETs themselves, unless this batch of jfets are bad.

What I guess I don't understand is why interference from the wet signal would cause the dry switch to not function when the wet switch is closed. Does that make sense? I would think you'd just hear some grungy output from the wet side mixed with the dry signal. Or is that not the case?

I'll try the capacitor trick tomorrow and see whether that influences things.
Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on October 16, 2019, 05:44:19 PM
There's definitely something weird going on.  The cause is something outside of the general workings of the circuit, which is also why it's difficult to understand!
QuoteThe wet switch never works properly, even when used isolated from the dry one. So I'd assume the problem is with the wet side (either the switch itself or the interference from the output signal like you suggest).
Yes, at this point it's looking that way.

QuoteBuilt up a second board with different JFETs and got the same behaviour so I'd assume it's not the JFETs themselves, unless this batch of jfets are bad.
The dry side works so I guess they *can* work.   

QuoteWhat I guess I don't understand is why interference from the wet signal would cause the dry switch to not function when the wet switch is closed. Does that make sense? I would think you'd just hear some grungy output from the wet side mixed with the dry signal. Or is that not the case?
I don't understand it either but I can see that if there's some high frequency modulation on the wet path it would certainly cause problems and that would be a very good reason why wet is different to dry.

With these weird cases you can only propose a theory then see if it's true or not.

QuoteI'll try the capacitor trick tomorrow and see whether that influences things
See how go.  If you see *some* improvement it might mean that method is on the right track.  It could be you need a higher-order filter to remove the problem entirely.

Are you sure your clock frequency is correct?  if it's low that would make all the filtering ineffective and promote the behaviour we are seeing?

Do you have an oscilloscope?
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on October 18, 2019, 11:45:50 AM
Haven't gotten to this yet but will do asap and report back.

QuoteDo you have an oscilloscope?

No, no oscilloscope - that's on the wish list. Definitely a wise investment at this point I think.
Title: Re: JFet switching with 3.3V logic
Post by: Rob Strand on October 18, 2019, 05:30:36 PM
QuoteHaven't gotten to this yet but will do asap and report back.
No problem.

QuoteNo, no oscilloscope - that's on the wish list. Definitely a wise investment at this point I think.
You might be able to measure the clock frequency with your DMM if it has that feature.
Title: Re: JFet switching with 3.3V logic
Post by: AdamB on May 07, 2020, 12:14:42 PM
Some small update on this - after a lot of messing around I've never managed to make the JFET switching work. Last thing I tried was switching to SMD parts to see whether it was bad TH transistors - it's interesting that the performance was then better but never good enough.

I've "solved" the problem for my needs by using a TLP222G photoFET as a dry-kill switch instead. This seems to work well enough for what I want to do.
Title: Re: JFet switching with 3.3V logic
Post by: ElectricDruid on May 07, 2020, 03:50:33 PM
Glad you found something that worked for your purposes, but sorry to hear that you never got the FETs sorted. I was selfishly hoping you'd come up with a fantastic and ready-tested solution I could use for a few ideas I have!

It's frustrating when something apparently so simple gets so complicated. It happens all the time though!

Title: Re: JFet switching with 3.3V logic
Post by: AdamB on May 08, 2020, 06:28:27 AM
Ha sure! Always good when someone else has done the work, that's the beauty of the DIY community. The photoFET works quite well so might be worth taking a look to see if it suits what you want to do - it's a single 4pin DIP package - it's not particularly transparent but the pedal I'm building isn't true bypass anyhow so I'm not too fussed about it.

Pin 1 is driven by the MCU to open and close the switch and the other 2 pins connect the signal. I've also seen an arrangement where it grounds the signal to mute it (this then makes the switch transparent by not having the signal passing through the switch when the signal is on), but I haven't actually tried that yet - I figured in my setup I'd then need to add another buffer between the wet input and where the dry splits off to stop it grounding the input to the effect, and I've already got quite a high part count on this thing!

I'll post a schematic when I'm done - I switched to using a CS4272 codec on the newer prototypes and it's not quite working yet - I think it's the way I setup the clocking (I've since invested in a cheap oscilloscope and it seemed to be clocking at only 50Hz lol) so I've made changes and I'm now waiting on the latest boards to arrive from the PCB fab.
Title: Re: JFet switching with 3.3V logic
Post by: Ratskietv on September 13, 2023, 02:12:31 AM
I use this circuit to switch audio on off with microcontroller. When 5v in base of 2n3904 the audio should off, but it not. When i check voltage. The audio off.

https://postimg.cc/9wqBKT6Q
https://i.postimg.cc/9wqBKT6Q/20230913-132430.jpg