How to use analog multiplexer CD4051

Thread Starter

CrackJack

Joined Aug 7, 2009
127
oh,... actually i never used any simulators... the s/w that I used is Mindi simple software from microchip... i dont know if it is good or not.. i usually build the circuit directly on bread board and then practically make the changes needed....
thanks for the suggestion thou.. i shall try and simulate the circuit in spice...
i have a student version of that...
 

Thread Starter

CrackJack

Joined Aug 7, 2009
127
If the supply to the microcontroller is 5V then its outputs will try to go to 5V which is too high for the CD4051 that has a supply that is only 3V. So the input protection diodes on the control input of the CD4051 conduct and cause currents that are too high for both ICs.


Very wrong. Both ICs must have the same supply voltage. Besides, the CD4051 works poorly with a supply that is only 3V.
Hi Audioguru,
Can you suggest me any solution for this problem? How should I make sure that my select lines are getting selected in the scan mode?
 

Audioguru

Joined Dec 20, 2007
11,248
Hi Audioguru,
Can you suggest me any solution for this problem? How should I make sure that my select lines are getting selected in the scan mode?
Simply make the Vcc supply voltage of the CD4051 and CD4052 +5V, the same as the microcontroller. The Vss can be -5V if you are feeding the switches AC with a positive and negative 5V peak swing.
 

Thread Starter

CrackJack

Joined Aug 7, 2009
127
Placing a microcontroller into an analog signal environment is like inviting a punk band to play at a public library. :eek: You're going to have to slow down the rise/fall times of the address lines from the uC. You can do this by adding resistors in series with the uC address output, and using small caps to ground at the address select inputs. Otherwise, it's like hitting a bell with a sledgehammer. A perfect square wave is comprised of the fundamental frequency, and all of the odd harmonics of the fundamental frequency. Adding an RC time constant on the lines will help to remove the high harmonics.

How fast are you scanning these ports?
How fast do you HAVE to scan these ports?
I shall get to you with the specifications,.... thanks for the suggestions... :)
 

Thread Starter

CrackJack

Joined Aug 7, 2009
127
Simply make the Vcc supply voltage of the CD4051 and CD4052 +5V, the same as the microcontroller. The Vss can be -5V if you are feeding the switches AC with a positive and negative 5V peak swing.
Hi Audioguru,
Initially i had +5v as Vcc and -5v as Vee to 4051. But, the 4051 pins did not get selected as the voltage to the select pins were 3.8v RMS.
I changed the Vcc/Vee to +/- 3V and i saw the mux working.... :confused:
 

Audioguru

Joined Dec 20, 2007
11,248
The output of a Cmos microcontroller with a +5V supply is +5V when feeding another Cmos IC like a CD4051/CD4052 also with a +5V supply.
You never measure logic in RMS volts.
Which microcontroller are you using?
Is its supply +5V?
Are its outputs being loaded down by something else?

The select inputs on a CD4051/CD4052 with a +5V Vcc are high when the voltage is +3.5V or more and are low when +1.5V or less.
 

Thread Starter

CrackJack

Joined Aug 7, 2009
127
The output of a Cmos microcontroller with a +5V supply is +5V when feeding another Cmos IC like a CD4051/CD4052 also with a +5V supply.
You never measure logic in RMS volts.
Which microcontroller are you using?
Is its supply +5V?
I am using PIC 16f871. It is having +5v as Vcc.
Are its outputs being loaded down by something else?
The outputs are connected directly to the mux select lines... so, I doubt if there is any loading effect. Also, I checked the datasheet for 16f871... the i/o ports having an internal pull up resistor...
I am using PORTS B.4, B.2 to select A0,A1 of 4051 mux and PORTS D.7, D.6, D.5 to select A0,A1,A2 respectively.
The select inputs on a CD4051/CD4052 with a +5V Vcc are high when the voltage is +3.5V or more and are low when +1.5V or less.
Alright... thanks, had no idea about this... :)
 
Last edited:

Thread Starter

CrackJack

Joined Aug 7, 2009
127
CrackJack what is this thing supposed to do? Why do you want to listen to aluminum foil?
i am designing a floor which would detect presence of a person.. I am using aluminum foils as a sensor.. they produce 60hz spectrum signal.. the output amplitude of these foils increases when applied some pressure on it...
I am connecting several of these foils in matrix fashion and using a mux, passing them to an amplifier and from the amplifier to a uC.
:rolleyes:
 

Thread Starter

CrackJack

Joined Aug 7, 2009
127
Placing a microcontroller into an analog signal environment is like inviting a punk band to play at a public library. :eek: You're going to have to slow down the rise/fall times of the address lines from the uC. You can do this by adding resistors in series with the uC address output, and using small caps to ground at the address select inputs. Otherwise, it's like hitting a bell with a sledgehammer. A perfect square wave is comprised of the fundamental frequency, and all of the odd harmonics of the fundamental frequency. Adding an RC time constant on the lines will help to remove the high harmonics.

How fast are you scanning these ports?
How fast do you HAVE to scan these ports?
Hi SgtWookie... i found out the scan rate of the ports...
for 8:1 mux -- 4051, i am scanning at a frequency of 1.934kHz, period = 517.0uS, duty cycle = 92.1%
for 4:1 mux -- 4052(select line A0), i am scanning at a frequency of 320hz, period = 3.120ms,duty cycle = 64.1%
for 4:1 mux -- 4052(select line A1), i am scanning at a frequency of 961.5hz, period = 1.040ms,duty cycle = 49.6%

I think i am scanning at a very high rate... I do not have an exact idea of what the scan rate should be...
 

SgtWookie

Joined Jul 17, 2007
22,230
I think the electrical noise from the address lines will probably interfere with your readings.

You could slow the rise/fall times of the address lines by using small capacitors (say, 100pF total) at the far end of the address bus run (if the bus runs different directions, split the capacitance up) and use maybe 100 Ohm resistors right at the uC to connect the bus lines to the uC.

I don't know how long your address bus is, or how it's wired (on a PCB, or using individual wires on a breadboard)
 

Thread Starter

CrackJack

Joined Aug 7, 2009
127
I think the electrical noise from the address lines will probably interfere with your readings.

You could slow the rise/fall times of the address lines by using small capacitors (say, 100pF total) at the far end of the address bus run (if the bus runs different directions, split the capacitance up) and use maybe 100 Ohm resistors right at the uC to connect the bus lines to the uC.
I have actually included a delay loop in my uC code. a delay of 10ms after each address line has been scanned and read. But i see no improvement in the system. :(

I don't know how long your address bus is, or how it's wired (on a PCB, or using individual wires on a breadboard)
I have connected it on a breadboard. Shall take a snap of the layout tomorrow morning and post it here. that would solve many confusions...
 

Thread Starter

CrackJack

Joined Aug 7, 2009
127
Hi All,
I know i have bugged you all with my questions and problems... But i have mostly figured most of the problems... I solved the issues with the mux and the timings... I finally ended up having no delay when scanning the address lines.. the mux now follows the input... :)
But i have a last problem... the amplifier which is connected to the output of the mux kind of loads the mux... i have had this problem even before, but i did nothing ... new day.. new output!!! that's what i observed...

but is there a permanent solution to this problem???
 

Thread Starter

CrackJack

Joined Aug 7, 2009
127
Post your amplifier circuit how it is now.
Hello... please check the attached file...
I think it is because of the capacitor I have ... the circuit gets loaded, because, after i removed the capacitor, I saw there wasn't any loading effect, however, the output was very noisy...
Do i need to put any snubber circuit at the output to reduce the loading effect?

Also, this circuit works very nicely without the mux.... w/o mux also, it loads the aluminum foil output, however, the output gain is sufficient to produce an output that can be displayed on the micro-controller.

I had another question, is it necessary that the input for PIC micro-controller should be high for some particular time to be sensed as an i/p? I am having this problem in this current system.... the micro-controller cannot sense pulses of very short time....
 

Attachments

SgtWookie

Joined Jul 17, 2007
22,230
Hello... please check the attached file...
I think it is because of the capacitor I have ... the circuit gets loaded, because, after i removed the capacitor, I saw there wasn't any loading effect, however, the output was very noisy...
Do i need to put any snubber circuit at the output to reduce the loading effect?
I already told you that C1 was causing the loading problem. It will kill your input signal.

C1 needs to be in series with the input signal, not a shunt to ground. Also, you probably should increase it to 100nF.

Your breadboarded circuits' inputs are connected via muxes that are being switched by a uC, to strips of tin foil being used as antennas. Did you expect it to be quiet? If so, why?

I also do not understand why you have R2 in the circuit; as it is loading the output of the voltage follower for no good reason. If you wish to compensate for the input offset voltage, you use the offset adjust input, not load the output down.

Also, this circuit works very nicely without the mux.... w/o mux also, it loads the aluminum foil output, however, the output gain is sufficient to produce an output that can be displayed on the micro-controller.
Did you try slowing down the address lines like I suggested? It's going to be noisy when you mix digital and analog. Since you have the thing built on a breadboard, there's no telling how much energy is being radiated by the uC address lines.

I had another question, is it necessary that the input for PIC micro-controller should be high for some particular time to be sensed as an i/p? I am having this problem in this current system.... the micro-controller cannot sense pulses of very short time....
I don't know what uC you're using, what clock rate you're using, or how you are trying to sense an input.

You are using a TL072 opamp. While those are pretty decent opamps for audio use, they still have a limited bandwidth. If you're trying to amplify a signal by 10, you'll be doing good to see a 100kHz sine wave out of it. Forget about seeing brief transients; the opamp isn't fast enough to send it through. Besides, you're using slow rectifier diodes in the precision rectifier section. You could at least use 1N914/1N4148's.
 

SgtWookie

Joined Jul 17, 2007
22,230
OK, you are using a PIC16F871 with a 4MHz crystal for a clock.

I didn't know they existed. The PIC16F87x goes from PIC16F873 to PIC16F877, and they are obsolete, having been replaced by the PIC16F88x models.

You are trying to scan this thing pretty quickly.

It would help a great deal if you had voltage followers for each input to the 4051's. As a matter of fact, that is probably the only way you are going to be able to fix your problem.

Your strips of tin foil represent a series of very high impedance inputs. As you scan through the mux/demux lines, they are each connected to the same input capacitor, which represents a load.

The way to avoid that is to have each high-impedance input signal buffered to have a low-impedance output - into each 4051 mux/demux. Then, the signal will make it through to your amplifier, and even through the amplifier - providing that you correct C1, and remove R2.

You will need opamps that have rail-to-rail input and output that can operate with a +/-5v supply. Quad versions would save you some board space. You'll have some channel interference and the CMRR will go down, but it doesn't sound like your application is that critical about such things.
Some amps to consider are LM6134, MC33174, MCP6024.

[eta]
After more thought - you're going to have to remove C1 from the amplifier circuit entirely. It doesn't matter whether it's in series or shunt, it will simply load things down too much.

The 4051 and 4052 both have a typical channel resistance of 120 Ohms when the supply is +/-5v - but it could be as high as 400 Ohms per channel.. Since you have two in series, that's roughly 240 Ohms, or possibly up to 800 Ohms.

You simply can't afford to have any capacitance or loading at all on the input of that amplifier.

And you will have to use voltage followers/buffer amps on each input to your 4051 mux/demux ICs.
It's not as bad as it sounds - if you use quad opamps, that's only four more IC's. Make absolutely certain that you use 0.1uF bypass caps across each opamp's power rails to ground.
 
Last edited:

Thread Starter

CrackJack

Joined Aug 7, 2009
127
I already told you that C1 was causing the loading problem. It will kill your input signal.

C1 needs to be in series with the input signal, not a shunt to ground. Also, you probably should increase it to 100nF.
I tried connecting it in series, but i saw that the output was pretty noisy... so, i got confused, if i should connect in series or in shunt it to ground.

Your breadboarded circuits' inputs are connected via muxes that are being switched by a uC, to strips of tin foil being used as antennas. Did you expect it to be quiet? If so, why?[/QUOTE]
No, i never expected it to be quiet.

I also do not understand why you have R2 in the circuit; as it is loading the output of the voltage follower for no good reason. If you wish to compensate for the input offset voltage, you use the offset adjust input, not load the output down.
About R2-- I saw it in the datasheet... there was this application. on pg.8


Did you try slowing down the address lines like I suggested? It's going to be noisy when you mix digital and analog. Since you have the thing built on a breadboard, there's no telling how much energy is being radiated by the uC address lines.



I don't know what uC you're using, what clock rate you're using, or how you are trying to sense an input.

You are using a TL072 opamp. While those are pretty decent opamps for audio use, they still have a limited bandwidth. If you're trying to amplify a signal by 10, you'll be doing good to see a 100kHz sine wave out of it. Forget about seeing brief transients; the opamp isn't fast enough to send it through. Besides, you're using slow rectifier diodes in the precision rectifier section. You could at least use 1N914/1N4148's.
 
Top