I'm working on a circuit to control some number of 1W Power LEDs with Arduino. I used the constant current driver with MOSFET from here: http://www.pcbheaven.com/userpages/LED_driving_and_controlling_methods/ but connected the MOSFET gate to Arduino output pin - and it worked like a charm.

But because I need to control more LEDs than Arduino output pins, I added multiplexers in-between. The complete circuit looks like this:


The control logic on Arduino is straightforward and simply outputs HIGH to the common output and appropriate address to A/B/C pins. The problem is that when switching between LEDs they don't turn off completely. They behave as if the the output from the multiplexer was left floating, even though the tech sheet (http://www.ti.com/lit/ds/symlink/cd4051b.pdf) says that inactive pins should get '0'.

It seemed like a reasonable idea to put a resistor between the MOSFET gate and the ground to pull it down, like this:


and it does work just fine, but I have two questions:

  • why didn't it work properly without it? which part of the multiplexer tech sheet actually indicates that I need that resistor?
  • what should be the value of R3? I had 100kOhm at hand, so I just put them in, but I would much rather have something chosen based on R1/R2/Q1/M1/V1. Same question for R2 actually - what does it influence? just the switching time for M1?
  • \$\begingroup\$ Note that if you use the CircuitLab button on the editor toolbar the schematics are saved with an edit link so that you can update and we can copy the schematic into the answers. No membership is required. No screengrabs are needed. Your V1 looks backwards in each schematic and the other end is open-circuit. The word "inactive" does not appear in the datasheet. Can you give a section reference? \$\endgroup\$ – Transistor Jul 24 '18 at 18:20
  • \$\begingroup\$ Are you aware of the technique called Charlieplexing? I recognise that this is answering a different question than the one asked, but it seems like it might be relevant to what the asker is trying to do. \$\endgroup\$ – Hearth Jul 24 '18 at 18:34
  • \$\begingroup\$ I would put R3 after R2 and reduce R2 to 5-10k \$\endgroup\$ – Maple Jul 24 '18 at 20:58

The datasheet for the CD4051 shows that both ON and OFF there will be +/- leakage current on the output pins. This tells you that the voltage present on an output pin can be EITHER high or low depending on the leakage current. It is no '0' which is a digital state.

Your addition of the 100 kohm resistor simply provided a path for enough of the leakage current to ensure the output was low enough to cutoff the FET.

enter image description here

You would be much better to use a digital device such as the 74HCT595 serial shift register to achieve your goal. With this device you can serially shift out the state required for each of your LEDs and then transfer from storage to output using the STCP transition. You'd need only 3 MCU pins to do all this and with the /OE set low you get definite high and low signals for all channels.

One potential negative is that the 74HCT595 does not work at 9 V ….so this would need to be powered from the Arduino 5 V supply.

  • \$\begingroup\$ Thanks for all the help! I ended up switching to the shift register, everything works like a charm. \$\endgroup\$ – miciwan Jul 31 '18 at 17:58
  • \$\begingroup\$ Then you might select the answer as appropriate …..we work for points. \$\endgroup\$ – Jack Creasey Jul 31 '18 at 18:00

CD4051 is an analog multiplexer/demultiplexer (first page of the datasheet) so all other outputs excepting the selected one are left floating, this is what an analog multiplexer/demultiplexer does.

The selected one acts as connected to the input with a resistor, this explains the bidirectional behaviour, actually you use the chip as a demultiplexer for the Arduino output.

To have a good noise resilience you would want to have R3 as low as possible.

The limit is given by the I/O resistance of the multiplexer (stated in the datasheet as max 550 ohm for VDD = 10V) that together with R3 will divide the Arduino output voltage at the demultiplexer output.

A 20 times this value for the R3 will lower the demux output voltage with maximum 5% so I think a value around 10k is safe to use and with a good noise threshold.

Edit, not related with the question but important.

I see that you use 9v supply for the mux. The data sheet states a 7v minimum high logic level for 10V VDD so it might work but you don't use the mux in the right parameters (mostly the select inputs are in question).

I would advise to supply the mux from 5V where the minimum input high level is 3.5V compatible with the Arduino output.

In this case the max I/O resistance is 1300ohm and the safe value for R3 would be somewhere above 26k.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.