Using a CD4066 5v and 9v

Started by alparent, January 28, 2011, 12:37:01 PM

Previous topic - Next topic

alparent

I'm working on controlling a CD4066 with outputs from my Arduino. (+5v)

From reading Wicked Switching on The Tone god site I see that supplying the CD4066 with 5v is not good for my analog needs. (9v is recommended). But to I also read on R.G. site the to make a 9v supplied CD4066 go high, you need 6v.

My Arduino only gives out 5v!  What can I do? From what I could figure out from the data sheet. With 5v I could control a 7v supplied CD4066. (Would that be enough for analog?)

Are there other simple options I'm just not thinking of?
I there a safe way to boost the 5v from the Arduino pin to 6v?

Some options I was thinking of:
1- Use another 5v supplied CD4066 controlled by the Arduino to let 9v power controlled the 9v supplied CD4066.
2- Use transistors to controlled by the Arduino to let 9v power controlled the 9v supplied CD4066.
3- don't know if this is a good option? Ditch the CD4066 and use transistors to controlled by the Arduino to switch the audio signal.

This is a bummer 'cause I had a lot of ideas for my arduino and cmos (CD4066, CD4051, CD4052, CD4053.....)
What about switching between different cap values is an effect.....would the same 5v is not good for analog rule apply?

Don't know if this is all clear?
Thanks for helping me out...............again!

earthtonesaudio



NPN transistor can be turned on by as little as 0.7V, collector resistor can be tied to a much higher voltage.

This turns your 0-5V signal into approximately a 0-9V signal. (or 0-12V in the picture)

Mark Hammer

Do you need the signal-switching itself to be done by the CMOS switches?  Why not use small relays, where the signal-handling capability is not a function of the supply-voltage?

alparent

Do I NEED the signal-switching itself to be done by the CMOS switches? No
Would I LIKE the signal-switching itself to be done by the CMOS switches? Yes

Relays are big and $$$ (compared to CMOS). I was even thinking of building my first SMD project with this one.

Any suggestions on the smallest appropriate relay for this?

This switch box will have 4 input jacks, 4 output jacks, 2 jacks for an effect loop. A foot switch and a bunch of LED's.
I don't want the enclosure to be huge.


cpm

Quote from: alparent on January 28, 2011, 12:37:01 PM
Some options I was thinking of:
1- Use another 5v supplied CD4066 controlled by the Arduino to let 9v power controlled the 9v supplied CD4066.
2- Use transistors to controlled by the Arduino to let 9v power controlled the 9v supplied CD4066.
3- don't know if this is a good option? Ditch the CD4066 and use transistors to controlled by the Arduino to switch the audio signal.

This is a bummer 'cause I had a lot of ideas for my arduino and cmos (CD4066, CD4051, CD4052, CD4053.....)
What about switching between different cap values is an effect.....would the same 5v is not good for analog rule apply?

Don't know if this is all clear?
Thanks for helping me out...............again!

its as simple as that: logic level conversion. Turn your 0-5v into 0-9v. You can do that with npn, bjt, mosfet, ...., and both inverting or non inverting logic...

for an extremely minimal setup (not optimal, my thought), i gess you can tie your pin directly to the 4066 gate, and use a pullup resistor to your 9v.
Setting the pin as input turns it into a high impedance terminal, which wont mess with the 4066 (swicthed high). Setting as output Low, you pull the 4066 to 0v.
The tradeoff is that you'd end with a much more complex code.

JKowalski

One resistors and a transistor (MOSFET) isn't much of a burden. Especially with SMD.

alparent

Thanks for all the replies folks!

But last night I physically tried it. And it works?????

Supplying the CD4066 with 9v and controlling it with the Arduino's 5v. It works????

These are the readings I took:

Powering  the 4066 with 5v and controlling with 5v = 8.55v in ----------------- 6.53v out
Powering  the 4066 with 9v and controlling with 5v = 8.55v in ----------------- 8.05v out
Powering  the 4066 with 9v and controlling with 9v = 8.55v in ----------------- 8.40v out

So controlling with 5v works but I loose .4v......is that really so bad?


But the weerd part is that even without any power to pin 14 and the 4066 it work???? I get like 3v out????

R.G.

The details matter.

CMOS transmission gates consist of a parallel N-channel device and a P-channel device. These are in parallel because they use opposite control voltages to turn off. The P-channel device needs a control voltage of 3V negative compared to the signal voltage to turn on; the The N-channel device needs over 3V positive with respect to the signal voltage to turn on. With the signal level anywhere between 0V and the power supply, if you turn on BOTH N and P channels with opposite direction drivers, one or both of them are sure to be "on" even if the signal voltage is near the power supplies. Furthermore, the internal resistance is much more constant than it would be with only one type conducting.

But if you leave off or abuse the power supply, there's still the drive to one side or the other. That's not ideal, but it does account for everything you're describing. You're only turning on the P-channel device with the low- or no-power operation. Works, but not ideal, as the switch distortion itself may be bad. You might like how the switch distortion sounds, but it's not only acting as a switch, which is what you wanted when you started.

As noted, you need level shifting to drive the control pins from a 5V signal from your Arduino. Logic level shifting is an old and well-known pastime from the early days of logic. The CD4049 is **designed** to do this function well. It's inputs switch with about a 3-5V logic signal and you can put 9V on its power supply and get it to do your logic level translation for you. Same for using a MOSFET or BJT with an input resistor and a pull up to the new 9V logic level. The Arduino drives the gate or base OK, and the drain/collector can swing the full 9V on the output to drive the switch pin.

Note that every one of these solutions is inverting. You'll have to program the Arduino to give you the opposite polarity "ON" signal, or use two of the inverters. Changing the programming is easier.
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.

amptramp

I have used grounded base and grounded gate level shifters in the past to preserve phase.  The input goes to the source or emitter, the base or gate is taken to a fixed voltage and the collector or drain can drop below the base or gate in voltage.  No current amplification, but you wouldn't need it in this case.  This has taken the place of two inverting stages in series before without any ill effect if you choose your base or gate voltages properly.

R.G.

Quote from: amptramp on January 29, 2011, 06:56:42 PM
I have used grounded base and grounded gate level shifters in the past to preserve phase.  The input goes to the source or emitter, the base or gate is taken to a fixed voltage and the collector or drain can drop below the base or gate in voltage.  No current amplification, but you wouldn't need it in this case.  This has taken the place of two inverting stages in series before without any ill effect if you choose your base or gate voltages properly.
Yep, been there. It works best if there's a solid offset or a "reflection" around ground to work from. It's hard to do that with single supply and a CMOS device that expects rail to rail inputs. But maybe. Maybe.
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.

alparent

Quote from: R.G. on January 29, 2011, 02:42:07 PM
The CD4049 is **designed** to do this function well. It's inputs switch with about a 3-5V logic signal and you can put 9V on its power supply and get it to do your logic level translation for you.
Note that these solutions is inverting.

When reading the 4049 data sheet the also mention the 4050 (same thing, I think, but no inverting.)
So would using a 4050 allow me to do the same thing but without having to modify my Arduino code?

alparent

One more thing......isn't the 4049 used to go from CMOS level (9v) to TTL level (5v)?

I need to go from TTL to CMOS.......

As usual, there must be something I'm not getting!? :icon_redface:

R.G.

Quote from: alparent on January 31, 2011, 07:12:26 AM
One more thing......isn't the 4049 used to go from CMOS level (9v) to TTL level (5v)?
I need to go from TTL to CMOS.......
As usual, there must be something I'm not getting!? :icon_redface:
Nope - there's something I remembered wrong. You're right, the 4049 goes only one way, high level inputs to TTL outputs.

There are others that go both ways, including the CD4504, which has the same pinout as the 4049 excepting for using the otherwise unused pins to shift mode. It will happily translate 5V logic to CMOS level with different power supplies.
See http://www.instructables.com/id/Level-Shifting-Between-TTL-and-CMOS/step8/Dedicated-IC-CD4504-Level-Translator/

You can also use a single MOSFET,  or a bipolar transistor with resistor to its base, and the drain/collector pulled up to a high voltage.

All of these invert the logic signal. Your choices are to either invert the signal in your Arduino, or add a second inverter on the outside of the level shifter.
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.

alparent

So one bipolar (let's say 2n2222) will give me inverted results.
If I use 2 I'm back to non-inverted........right?

So what happens if I use a Darlington?

~arph

#14
You could also use a MAX395/335/295
With the added benefit that you have eight switches in one IC. And they can be chained..
You only need three wires from the arduino. The selected switches are set through (SPI), you basically shift in a byte. Pretty straightforward.
It is a bit more expensive though (about $3 each I think)

alparent

#15
What if I used one 4066 power with 5v and controlled with 5v, but I put 9v on the input and switch that? It gives me about 6.5v at the output then use that output to switch the 9v powered 4066 switching my signal? I there difference between using 6.5v or 9v to control the switching of the signal switching CMOS? Or is it as long as I have 6v it's on? I that clear?  

cpm

my advice: read back to the basics.

you usually dont propagate a digital signal by routing it through a switch. you hit a buffer with it, and let it throw out a new signal that is conveniently optimum in voltage (level shifted if needed) and intensity (drive capability)
moreso, i think its pretty comon the inverted logic in microcontrollers. Switches usually are active-low, outputs usually are active-low too when interfacing with drivers...
you can light a small led up with the current supplied by the chip, but its better that an external transistor bear the workload, avoids dissipating power inside the chip, and is easier to upgrade in number of outputs and power demands.

if by any reason cant spare 4 of the cheapest transistors, you could try my suggestion (not tested, but looks feasible) - read previous post

alparent

#17
Thanks for that Carlos.
I am reading every word in every post. I ask a lot of questions 'cause I want to learn.
I suggest stuff and you teach me why they are not good solutions (This is great!)

So if I understand this right. I pull-up 9v via a 10k resistor to the 4066 control pin and set the Arduino pin to input (9v in the input will not harm the Arduino pin?) And this would set the 4066 gate to on. Then turning the Arduino pin to OUTPUT LOW would send 0v to the 4066 gate = off.

This is very simple and minimal extra part count. Is this safe? If so.......this is a great solution!

But you are saying that this isn't the best setup. I should use NPN's and let them do the heavy lifting.
But that would invert the voltage (I can deal with that!) But just out of curiosity. I can re-invert it back with another NPN. Right?
That's why I was thinking of using Darlingtons isn't a Darlington like two NPN's?

cpm

Quote from: alparent on January 31, 2011, 01:49:29 PM
So if I understand this right. I pull-up 9v via a 10k resistor to the 4066 control pin and set the Arduino pin to input (9v in the input will not harm the Arduino pin?) And this would set the 4066 gate to on. Then turning the Arduino pin to OUTPUT LOW would send 0v to the 4066 gate = off.

This is very simple and minimal extra part count. Is this safe? If so.......this is a great solution!
4066 control are mosfet gates which dont need any high current to turn on. Having a pin output-low will sink as many as it can. if you use a 100k pullup the current into the pin will be <0,1 mA for 9v supply. Arduino pins may handle as much as 20mA (this is on the datasheet). this is safe as the current going into the pin is far below that limits
When pin is set as input, lets say it has 1Meg impedance, forms a voltage divider with the pullup resistor, so the 4066 gate would be around 8v.

The downside again, is that the code gets more complex as you have to change pin direction and pin state for any output change.

Quote
But you are saying that this isn't the best setup.

The trick relies on the nasty details of both port internals (arcuino chip) and cmos gates (4066). Is prone to software bugs becasue code is not intuitive. Not for beginners.

QuoteI should use NPN's and let them do the heavy lifting.
But that would invert the voltage (I can deal with that!) But just out of curiosity. I can re-invert it back with another NPN. Right?
That's why I was thinking of using Darlingtons isn't a Darlington like two NPN's?

when you foresee this kind of designs, i find useful to just use a "#define C4066_OFF 1" and "#define C4066_ON 0" in code, and forget about it from then on, as you will think over those names instead the real 0's and 1's. Whenever i will write code to output to that pin, just use the names and dont care for the real bits (and helps avoiding bugs in case you'd forget to use the inverted logic in a single line). Also, if you have to change values for any reason, they are in only one place in the code, usually all grouped at the beginning.

i'd say that rewritting your code, cleaning it and making a good use of constants and #define directives, is worthier that throwing 2 transistors at each pin.

by the way... if i had to absolutely cut on external components, i would probably also remove the 16Mhz crystal, but then i had to reprogram the arduino bootloader, but then it'd be easier to just use a smaller and cheaper pic, but then i'd have to learn the new development tools for that pic...
and all that is a rewarding learning process, if you like the arduino you'll probably want to go a step further the standard arduino enviroment.

alparent

Quote from: cpm on January 31, 2011, 03:16:05 PM
Quote from: alparent on January 31, 2011, 01:49:29 PM
So if I understand this right. I pull-up 9v via a 10k resistor to the 4066 control pin and set the Arduino pin to input (9v in the input will not harm the Arduino pin?) And this would set the 4066 gate to on. Then turning the Arduino pin to OUTPUT LOW would send 0v to the 4066 gate = off.

This is very simple and minimal extra part count. Is this safe? If so.......this is a great solution!
4066 control are mosfet gates which dont need any high current to turn on. Having a pin output-low will sink as many as it can. if you use a 100k pullup the current into the pin will be <0,1 mA for 9v supply. Arduino pins may handle as much as 20mA (this is on the datasheet). this is safe as the current going into the pin is far below that limits
When pin is set as input, lets say it has 1Meg impedance, forms a voltage divider with the pullup resistor, so the 4066 gate would be around 8v.

OK this is almost working......but I'm only getting 5.5v at the gate? I guess the 100k  pullup resistor is to big? How low can I make the pullup resistor to get more voltage but not harm the Arduino pin?

Sooooooooooo close!  :icon_biggrin: