help with parallel multiplexers...

Hi !

I give you here the schematics of a project I already soldered, but doesn't work... The idea is to build a controller (communicating with puredata), sending pots, pushbuttons and rotative coders values and receiving commands to know which leds have to be turned on.
This project uses mainly the 4067B 16-channel multiplexer. In fact, multiple in parallel.

I must give some precisions about this schematics :
-- each multiplexers uses 10 channels, but to keep it clear, only 2 are actually drawn. So in fact, there are 10 potentiometers, 10 rotary encoders, 20 push buttons and 20 LEDs.
-- i don't have enough digital I/O (need two additional digital pins for the 2 LED groups), because i decided to separate the readings of the pots coders and buttons from the LEDs. This because i wanted to keep the "LEDs switching" fast enough to have the optical illusion they're always on.
-- push-buttons and rotative coders are read with the following method (avoiding the use of resistors) :
pinMode(X, INPUT);
digitalWrite(X, HIGH);

I never finished the code because even on a small part of the project, it doesn't work. I give as an example the test for the LEDs (make all of them blink) :

int i;
int b = 0;
boolean st;

void setup() {
  for (i = 8; i < 14; i++) {
    pinMode(i, OUTPUT);
  }
  st = true;
}

void loop() {
  for (i = 0; i < 10; i++) {
    PORTB = i << 2;          // 4-bit address coding on pin 10-13
    digitalWrite(8, st);     // set the LED pin HIGH or LOW
    digitalWrite(9, st);
    delayMicroseconds(100);  // wait
  }
  b++;
  if (b > 500) {             // toggle LED pin value
    b = 0;
    st = ~st;
  }
}

The result is that all LEDs of the first multiplexer blink, but for the second, only one glows.
If I re-build the circuit on a breadboard with only the two groups of LED an 2 multiplexers, it works fine, while the same doesn't with all the rest of the circuit. I must say that I verified ten times every connection with a multimeter.

The only strange thing I found is that the current between VDD and VSS was about 3,6V instead of 5V. I'm not very good with the electric laws so I'm suspecting that I need some resistors, somewhere..... but I saw some similar examples of "in parallel multiplexers" technique (like "fluidform" tutorial from Playground).

Please help me ! I'm hopeless, since this is the controller of my dreams...

PS : i'm french, please forgive my approximate english :wink:

Thanks by advance

Your English is just fine!

A tangential question for you...

Your schematic diagram is very beautifully designed and easy to read. What software did you use to create it? I will soon need to make some similar diagrams, just for documenting my circuit, not for creating a PCB, so I am looking for a nice tool.

Thanks.

.andy

Hi!

I just have some quick observations (I hope).

Your LED multiplexers are not on output pin 8 and 9, like you set in your code:

...
    digitalWrite(8, st);     // set the LED pin HIGH or LOW
    digitalWrite(9, st);
...

I don't know if the schematics are wrong or just a quick oversight, but as you see it says it's on the rotative "coders phase A/B". (Your LED wires have question marks at the end...)

I have no experience with rotary encoders (or rotative coders?), but I think you should think about what speed do they rotate and change code, vs how fast can the arduino read and multiplex the signals. Maybe you will get some kind of interference, if these speeds are comparable (arduino reading speed vs the rotary coder speed).

Also:

-- push-buttons and rotative coders are read with the following method (avoiding the use of resistors) :

Dont avoid the use of pull-up/down resistors. When no connection is made and the input is unconnected, it is "floating" - not defined and easily disturbed by other signals or even objects nearby.
The arduino have internal pullup resistors, but as you go via multiplexers first for input they won't help much here. I'd strongly suggest having one on the multiplexers input side.

Probably also debounce the signals, via capacitors and resistor(s), and / or do it in software, depending on the speed and update frequency.

I'd also suggest some small 100 nF capacitors across the power near the IC's reduce noise, and a bigger one in general across the Vcc-Vdd to stabilize voltage, if needed.

I don't know why your voltage is not 5V, it could be a lot of things. Do you drive it from a battery? It seems your power source have a too high an internal resistance for your circuit (in other words - too weak a power source - well not neccessarily, it can be a lot of things).

As for your english it seems just fine :slight_smile:

Also, I agree with Andy and have the same question: What software did you use to draw your schematics?

About the error of pin for the LED.... For the test the common I/O of the LED multiplexers where actually connected to arduino pins 8 and 9. As mentionned on the schematics, I didn't define the pins for them...
This drives me to one of my question : is it possible to turn an analog pin to a kind a digital input, or even output ? I think that you can read push-buttons with analog input, by using a threshold (something like [0-100] = 0 ; [900-1023] = 1) but much more slowly ?

For the rotary/rotative en-coders (don't know how to say it... even in my french electronic shop they don't know how to call it), I made some test before and it looked quite OK... There's a good discussion about them on the Playground, and one solution is to use interruptions. But with a multiplexer I don't know. But well, when I did some tests, it worked fine and it's not a big trouble for me if one step is missed sometimes...

Ok, I will try to change the method for the digital readings and use pull-up or pull down resistors...
I don't exactly get the idea of "debouncing the signals" with resistors/capacitors...

For the 100nf capacitors : should I put them just before the Vdd input voltage of every multiplexers ?

What is the "Vcc-Vdd line" ? I know where to Vdd on multiplexer and arduino, but don't see what is "Vcc" ? Does it mean "arduino ground" ? What kind of value do you suggest for this big capacitor ? Would 100 microfarads be OK ?

I must say that everything is powered via arduino+5V and arduino (duemilanove) is powered through USB... Maybe should prefer a 9V battery ?

And for the schematic diagram... it was designed with Inkscape on my ubuntu... With a grid and the "stick-to-grid" option well calibrated, it's quite easy. I tried at least three "professionnal" circuit designing software before, but I prefer a clean "hand-drawn" software... It seems like I don't like to follow the software's built-in's rules and "industrial" production's rules to draw something...

Thanks a lot for the answers !

OK there is a lot wrong with that design.

  1. The LEDs - there can only ever be one LED on per multiplexer on at any one time. I assume you don't want this. Also you are also putting a lot of current through the multiplexer and the ON resistance is too high to drive an LED - it's in the order of 250R.

  2. The rotary encoders, you can only read the value of the encoder when the multiplexer is selected, you will not be able to scan all the encoders fast enough to get anything like an accurate response, especially in sensing the direction of rotation.

  3. The pots and switches look ok at a first look.

  4. Analogue inputs can be used as digital inputs, just use pin number 14 for analogue 0, 15 for Analogue 1 and so on.

Thanks for the answer, Grumpy_Mike

  1. For the LED I thought to scan them fast enough to look like they're all on. They glow a little bit brightly but it's fine. Of course a system that could keep many LEDs on, without using lots of arduino pins would be great !
    However, I don't get the idea about the resistance : it seemed to me that 220 Ohms was a good value for only one LED.

  2. I made some tests with rotary encoders & multiplexers (one for all the phases A, the other for all the phases B) and it seemed to work unless the analogRead function for the pots slows down the scanning. Do you have a suggestion on how i could do it ? I heard about using a "D flip-flop" to detect the direction in a faster way that software do. Using a IC counter ?

As I said I'm not good at all in the electronic part...

Well it's a good news for me to know that analog pins could be turned into digital...

But my main problem is still about the fact that the multiplexers act as if they didn't actually receive the address information, or didn't not take account of it. In the LEDs test described above, the voltage of the A, B, C & D pins is correct (it correspond to the values of digitalWrite), but the channel isn't changed (it's always the same led that is turned on) on the second multiplexer (while the first works). Of course, i tried to change the multiplexer to ensure it wasn't broken, but i get the same results with a new IC.

And for the schematic diagram... it was designed with Inkscape on my ubuntu... With a grid and the "stick-to-grid" option well calibrated, it's quite easy. I tried at least three "professionnal" circuit designing software before, but I prefer a clean "hand-drawn" software... It seems like I don't like to follow the software's built-in's rules and "industrial" production's rules to draw something...

I agree with your philosophy. It is one thing to design a good circuit, and another thing completely to be able to document it carefully and beautifully. Compliments! Do you have training in graphic design?

No more ideas on the problems with this circuit ?

No more ideas on the problems with this circuit ?

I would say this:

I must say that everything is powered via arduino+5V and arduino (duemilanove) is powered through USB... Maybe should prefer a 9V battery ?

USB (probably USB 2.0 specs but I'm not sure about that) can only give 500 mA of current max. Your circuit seem to want more (but I haven't calculated it, I'm just guessing)

However, even if CMOS IC's can have 9V as power, the arduino/atmega chip cannot, and I'm not sure it would like that voltage on its input pins either.. you could use a 7805 voltage stabilizer for instance, to get 5 volt power on your circuit. L7805CV is good for about 1A if I read the specs right. Or use some other device. A 9V battery would probably not last too long.

Oh, and don't connect both of the USB power (plus and minus) to another power source on you circuit. Only have GND (0 V) connected together for common reference.

I disagree somewhat with Grumpy's #1, 250 ohm is fine for a LED, maybe even a little low. Depending on the LED of course.. even 4-5-6 times that can work (some LED's can be really bright!). But "ON" resistance for a 4067 is stated as typical 470 ohm, max 1050 ohm, in addition to your 220.

Oh:

  1. For the LED I thought to scan them fast enough to look like they're all on. They glow a little bit brightly but it's fine. Of course a system that could keep many LEDs on, without using lots of arduino pins would be great !

Look up shiftregisters :wink: Just remember you will need one resistor pr. LED then!
But fast switching between them works too!

However I agree with his #2.

I take it inkscape is not an electronics CAD at all, but a general graphics software?

I found kicad http://www.lis.inpg.fr/realise_au_lis/kicad/ a little while back and really like that one! Cross-platform and open source GPL. Even though it has some quirks. But a little googling solves most of that, luckily! http://www.curiousinventor.com/guides/kicad
Some libs: http://www.kicadlib.org/
Libs converted from Eagle: http://library.oshec.org/

Thanks for the anwer !

Your circuit seem to want more (but I haven't calculated it, I'm just guessing)

How could I know the current need/usage of my circuit ? I think my multimeter can measure Amp. but I don't know where to put the tips...

you could use a 7805 voltage stabilizer for instance, to get 5 volt power on your circuit. L7805CV is good for about 1A if I read the specs right. Or use some other device. A 9V battery would probably not last too long.

Oh, and don't connect both of the USB power (plus and minus) to another power source on you circuit. Only have GND (0 V) connected together for common reference.

If I correctly get your idea, I should try the following operation :

  • use a 9V power supply and connect it to arduino's power jack
  • change the jumper so that the board isn't powered through USB anymore
  • connect everything that went to "arduino +5V" (cf. my shematic diagram above) to a voltage 78O5CV regulator instead
  • source this voltage regulator with arduino's Vin (which means +9V)
  • let everything connected to ground (arduino's GND)

Did I understand your suggestion rightly ?

But "ON" resistance for a 4067 is stated as typical 470 ohm, max 1050 ohm, in addition to your 220.

I don't understand this "ON resistance" on the multiplexer : is it an internal resistance that you cannot avoid to pass through ? Or is it an external resistance needed ?

For the rotary encoders, I will leave this part aside for now... If it doesn't work with the rest I will search how to solve this or simply remove them from the circuit. Sometimes the simpler, the better... I prefer to have something not as cool as I wanted, but that actually works, than an useless circuit left in my garage...

About Inkscape : yeah, it's a general graphics software, mainly dedicated to vectioral graphics such as Illustrator, but open-source. Of course, Kicad must be better to design a PCB, but i don't need to build my own PCB at the moment (or at least, don't have the tool and courage...)

How could I know the current need/usage of my circuit ? I think my multimeter can measure Amp. but I don't know where to put the tips...

Ok. Then I'd suggest learning some basics about electricity, in particular Ohms law. Don't take this the wrong way, I'm only trying to help. I tried to google a bit and came up with this, if you are interested:
http://hyperphysics.phy-astr.gsu.edu/Hbase/electric/ohmlaw.html

As for knowing the current through your circuit:

You could do the math, and add the different current requirements of your IC's and LED's together (keeping in mind that multiplexed LED's only light up one at a time), at least for some "ballpark" rough estimate.

To measure the current, you must break one connection to the power, either plus or minus, and insert the ampere meter (ammeter) in between. This is called connecting it in series with the circuit.
(There are exceptions, like clamp ammeters that use magnetic fields to measure current, but mostly for AC, at least on multimeters I think).
For most practical purposes you can think of an ammeter as a short-circuit. You just diverge the current into your meter to measure it.

Like this:

+-----(A)---------+

  • --- |
    power (LOAD)
  • --- |
    GND +-----------------+

The (A) is the ampere meter / ammeter, or multimeter connected as an ammeter. Usually on multimeters you need to physically move one connector to the ampere-meter plug. The (LOAD) is any load. Like your circuit.

Unless you have an idea of how much to measure, it is best to set it in the largest range first, then move down if needed. This goes for voltage measurements too. Which by the way is the complete opposite of current measurement: A voltmeter has a hight input resistance, and is connected in parallell over the circuit/load.

+------------------+--------------+

  • --- | |
    power (LOAD) [Voltmeter]
  • --- | |
    GND +------------------+--------------+

(Had to include this for completeness sake)

To measure the current need of your circuit, you should make sure you measure it while it also have the correct voltage.

To use an analogy I like, current is like the flow of water, while voltage is like the pressure of the water.

If I correctly get your idea, I should try the following operation :

  • use a 9V power supply and connect it to arduino's power jack
  • change the jumper so that the board isn't powered through USB anymore
  • connect everything that went to "arduino +5V" (cf. my shematic diagram above) to a voltage 78O5CV regulator instead
  • source this voltage regulator with arduino's Vin (which means +9V)
  • let everything connected to ground (arduino's GND)

Did I understand your suggestion rightly ?

I don't have an "original" arduino/Duemilanove/Diecemiela, and I don't know how much current those can handle, and so, assuming your circuit needs more, and your 9V power source can hande it, you got it right! :slight_smile:

I don't understand this "ON resistance" on the multiplexer : is it an internal resistance that you cannot avoid to pass through ?

I would think so.

I forgot to mention the caps. One 100nF pr. IC would seem a nice starting point. If these are neccessary or not you will have to experiment. Like see if the circuit works as intended or not. As well as 100uF (beware, microfarads, not nanofarads) for the hole circuit. Excact value need not be critical. But it depends on a lot of thing, how much noise there is etc..

As for kicad, it's a complete package. It can also do schematics, and if you don't want to make PCB's you don't have to :slight_smile:
You don't really have to draw everything in schematics correctly. That is you could simplify it like you did in incscape. But not as nice I would think (But I'm no expert in kicad).

For the LED I thought to scan them fast enough to look like they're all on.

You have to refresh them so that each LED is on at least 32 times every second to make them look all on at the same time. So with 8 LEDs that means you have to refresh at t rate of 32 * 8 = 256 times a second or every 3.9mS, that's quite fast. You should not use analogue multiplexers in this way. You should use a 74LS259, which contains a latch so once an LED is set it stays on.

Your circuit seem to want more

No it doesn't just 7 CMOS multiplexers are not going to take more than 35uA and you only have two LEDs on at any one time so power is not an issue for you.

I made some tests with rotary encoders & multiplexers

You can use hardware to help:-

but the channel isn't changed (it's always the same led that is turned on) on the second multiplexer (while the first works).

In that case I can promise you that your wiring is wrong.