Multiplexing via CD74HC4067 to control LED

Hello guys,

I am trying to understand several things about the 16-channel multiplexer. I have found many topics on this forum and on the internet but I am still confused. Here is what I did:

  1. See attachement 1

I measured with a voltmeter the voltage between GND and S0,S1,S2,S3 and SIG. I was expected 0V but I found around 2.5V for all measurements.

  1. See attachement 2
    I sent 0000 on S0 S1 S2 S3. Then I connected the LED on C0, C1, C2.... C16. And the LED was always ON !!!

  2. See attachement 3
    The same as above...

What did I do wrong??

1.png

A 74HC4067 is a selector switch with 16 positions.
It connects a common pin to one of the 16 inputs/outputs (a switch works both ways).
Four control pins are needed to generate the binary numbers 0-15 to select the position of the switch.

If you connect the common pin to 5volt, then the selected output pin will also have 5volt on it, and the remaining pins are 'floating' (not connected to anything).

A switch of the 4067 has a rather high internal resistance, and is not designed to switch power, only signal.
A LED without current limiting is going to overload and likely fry the chip and/or the LED.
You should never use a LED without current limiting resistor. Try 1k resistors (~3mA LED current).

Try 74HC595 or TPIC6B595 shift registers if you're going to play with LEDs.
Then you can turn more than one LED on/off.
Leo..

Thanks for the answer.

Try 74HC595 or TPIC6B595 shift registers if you're going to play with LEDs.
Then you can turn more than one LED on/off.

My final application is not for LED so a switch is what I need.

A switch of the 4067 has a rather high internal resistance, and is not designed to switch power, only signal.

That is why I thought I didn't need any resistor.

alavida:
My final application is not for LED so a switch is what I need.

Then don't waste people's time. Explain what your real application is! :roll_eyes:

alavida:
That is why I thought I didn't need any resistor.

I did this some 35 years ago for a rotary display (Doppler Scan). Application now rendered obsolete by the MAX7219 with microprocessors. Yet to construct the new version.

Then don't waste people's time. Explain what your real application is! :roll_eyes:

My real application is to measure the voltage of several batteries.

I am just trying to understand why I got some weird results.

Nobody answered my question yet.

Nobody answered my question yet.

Yes they did.
Forget 1&2 they are wired wrong. Reply 1 told you what you were misunderstanding and what you were doing wrong with the LED.

Now if you remove the LED and measure the output what do you get in voltage?
What are you expecting to see?
Have you measured the other pins connected? Again what do you expect?

It is possible you have some fault with your code you should post that using the copy for forum option and pasting it into your reply.

As to the batteries they all need to have a common negitave terminal, is this what you have?

Grumpy_Mike:
As to the batteries they all need to have a common negative terminal, is this what you have?

Yes, and that's where newbies usually go wrong.
The voltages/signals you want to switch have to be within the boundaries of VCC and ground of the chip.
Leo..

Thank you for your answers.

Now if you remove the LED and measure the output what do you get in voltage?
What are you expecting to see?
Have you measured the other pins connected? Again what do you expect?

I tried again and now I have the expected output that only one output powers the LED. I guess there was a false connection, sorry :confused:

As to the batteries they all need to have a common negitave terminal, is this what you have?

No this is not what I have and that is why I want to use 2 multiplexers (see in attachment)

The voltages/signals you want to switch have to be within the boundaries of VCC and ground of the chip.

The voltage of each single battery is 2V (so between 0 and 5 V). I want also to measure the total voltage (48 V) and I used a voltage divider bridge for this.

The voltage of each single battery is 2V (so between 0 and 5 V). I want also to measure the total voltage (48 V) and I used a voltage divider bridge for this.

Sorry you don’t understand this is a way to make things go bang.

You can not measure a voltage on an Arduino without it being referanced to the ground of an Arduino.
You can not use a multiplexer to switch voltages outside the rails of the multiplexer.

Back to the drawing board. There are a few ways to do what you want but the do not look anything like this. I prefer the flying capacitor method, but others go for the voltage to frequency route.

Sorry I don't understand your answer. :confused:

You can not measure a voltage on an Arduino without it being referanced to the ground of an Arduino.

The multiplexer at the bottom will connect the ground to the battery.

You can not use a multiplexer to switch voltages outside the rails of the multiplexer.

What do you mean by "outside the rails of the multiplexer"? That I should not exceed a certain voltage?

I prefer the flying capacitor method, but others go for the voltage to frequency route.

I will check that

A few steps.

You can not use multiplexers to switch ground connections.

Any voltage greater than Vcc - whether 5 V or 3.3 V - must be measured using a voltage divider scaled so that the highest possible voltage compared to the relay ground will be scaled to the Vcc voltage.

You will therefore need a separate voltage divider for every voltage you wish to measure compared to the Arduino ground, and the multiplexer (generally built into the ADC device) will switch the voltage which has been scaled down not to exceed Vcc.

A "flying capacitor" is where you use a pair of DPST relays and a capacitor so that the capacitor is first connected by the first relay to the two points whose voltage differential you wish to measure, then that relay opens to completely isolate the capacitor from the first circuit, then after a settling time to ensure the relay has ceased bouncing, a second relay connects the capacitor to the voltage divider which scales the capacitor voltage to the ADC in order to measure it.

You can then switch the second relay off after the measurement is taken, and giving it time to settle, use the first relay to go back and sample the first voltage, or a third relay to sample a different voltage differential - and so on. If you are sampling a number of voltages, you may want an additional relay to short out a series resistor that allows the capacitor to charge at a limited rate to each different voltage.

One relay for every sample point and one or two more.

What do you mean by "outside the rails of the multiplexer"? That I should not exceed a certain voltage?

Yes, and that voltage is the power supply voltage of the multiplexer.

The multiplexer at the bottom will connect the ground to the battery.

Yes and that means when you switch the negitave of the other batteries to the ground of the Arduino you are shorting out all the batteries between the one you switch and the last battery.

Yes and that means when you switch the negative of the other batteries to the ground of the Arduino you are shorting out all the batteries between the one you switch and the last battery.

This is only true if I connect two different batteries on he ground of the Arduino (this is the case on my scheme) but if I make sure that at each time there is only one battery on the ground of the Arduino, I don't see where the shortcut it.

Negative of the bottom battery is connected to C13 of one 4067.
Positive of the top battery is connected to C15 of the other 4067.
The chips are connected to the same supply, so a higher battery stack voltage than ~6volt will power the chips (and the Arduino) through the pin protection diodes.

You obviously don't believe us, so go ahead and watch the magic smoke get out.
Leo..

Negative of the bottom battery is connected to C13 of one 4067.
Positive of the top battery is connected to C15 of the other 4067.

But C15 and C13 will never be active at the same moment.

Let's say, I active C15 on both multiplexer, if I understood good, there will be no connection between C13 and the multiplexer.

The chips are connected to the same supply, so a higher battery stack voltage than ~6volt will power the chips

I thought the 5V input of the Arduino would be enough.

A "flying capacitor" is where you use a pair of DPST relays and a capacitor so that the capacitor is first connected by the first relay to the two points whose voltage differential you wish to measure, then that relay opens to completely isolate the capacitor from the first circuit, then after a settling time to ensure the relay has ceased bouncing, a second relay connects the capacitor to the voltage divider which scales the capacitor voltage to the ADC in order to measure it.

Thanks I will check it out.

You obviously don't believe us, so go ahead and watch the magic smoke get out.

Of course I believe you, it's just I like to really understand your answers...

By the way, the project is to remotely monitor a solar power plant in Africa. So better not to see any magic smoke. And if you want to give a hand, you are most welcome. :wink:

a2d0d38fae03e33a47ce913693c7e9982c844545.png

OK, so that circuit is total nonsense.

Always the XY problem!

Let's forget the useless circuit for a bit. You are working on a solar power system for use in remote Africa. What are these batteries exactly, and what is your expectation for monitoring them? Are you actually using separate 2 V lead-acid deep discharge cells as in a telephone exchange?

The point is, if there is some anomaly, what do you imagine doing about it? Will you actually be able to swap batteries? From where will you swap - given that the batteries swapped in will also need their charge to be maintained whilst in storage?

And if there is someone available to swap batteries, will they not be able to perform regular monthly checks on the installation in any case, and measure the cells manually?

alavida:
But C15 and C13 will never be active at the same moment.

But the pin is still connected to that voltage, and pins can't be more than "GND-0.5volt" and "VCC+0.5volt".
(See the datasheet).

If you apply a voltage on a pin (active or not) outside the boundries of the chip's supply and ground, then internal pin protection diodes start to conduct, dumping the excess voltage onto the supply of the chip (and Arduino).

Google "clamping diodes" (images).

It seems you want to measure individual lead/acid cells in an 48volt stack.
"Flying capacitors" is an easy way to do this.
See post#49 and up on this page.
Leo..

Wawa:
"Flying capacitors" is an easy way to do this.

Easy? :astonished:

Paul__B:
Easy? :astonished:

Did you see the DIY 8-cell boards in the link.
A tiny DPDT relay and one capacitor to flick cell voltage between cell and A/D is complicated?
Leo..

OK, you better sell him three of those boards then. :grinning: