2
\$\begingroup\$

I am using a CP2103 to interface with a simple 74HC4051 MUX. I want to use 3 of the I/O ports on the CP2103 to control the input pins of the MUX. The 4th I/O port is being used for something else. The problem is, when switching the I/O ports, there is a delay which the MUX reacts to far too quickly. If I went from a 0-0-0 input to a 1-1-1, then during the time it takes for the CP2103 to switch all its outputs, on the output of the MUX, I will also see the outputs for 0-0-1 and 0-1-1 go high for about 10uS each. I know this is due to the I/O ports of the CP2103 switching high one by one, rather than simultaneously.

Unfortunately, I can't go into much more detail about what is on those outputs as it is a work thing, but all I can say is even the small 10uS pulse is having an undesired reaction.

So, my question is, is there a MUX out there that has some sort of built in debounce (5mS or something) so these small delays won't register? I would really like to do this without having to get a microprocessor as it seems a bit unnecessary for something like this.

I did think about using capacitors to delay it, but then realised it would just delay the other outputs as well and not actually fix anything.

I hope I have managed to relay my question properly and you guys understand. Feel free to ask any questions and I will try to answer.

\$\endgroup\$
  • \$\begingroup\$ Please show the wiring diagram too. It helps resolving issues soon. \$\endgroup\$ – Umar Feb 8 '17 at 12:26
  • \$\begingroup\$ Are you setting each bit of the output port individually? \$\endgroup\$ – HandyHowie Feb 8 '17 at 12:40
  • \$\begingroup\$ @HandyHowie, I am setting them up so that 0 is equal to 0-0-0, 1 is equal to 0-0-1 and so on, and I just tell it to switch to 1, 2, 3 or whatever I want it to. But it has that small delay between changing each port. \$\endgroup\$ – MCG Feb 8 '17 at 12:52
  • \$\begingroup\$ @Umar, unfortunately, as it is part of a larger diagram with bits from work I am not allowed to put it up online. Imagine it, however as just 3 input pins and an LED on each output of the MUX. when changing from 0-0-0 to 1-1-1, I get 2 extra LEDs that light up along the way, but I do not want them to. That is the best way I can explain it and shouldn't be too diffcult to imagine \$\endgroup\$ – MCG Feb 8 '17 at 12:53
  • \$\begingroup\$ Why don't you draw only the part of schematics we are dealing with. Be reasonable. Don't share IP but just interconnection between two devices alone. \$\endgroup\$ – Umar Feb 8 '17 at 14:44
2
\$\begingroup\$

If your application allows, you could use a Gray code for the mux channel assignments. That is, choose the channels such that when switching between them, you only ever change one bit of the S[2:0] address word at a time.

\$\endgroup\$
  • \$\begingroup\$ Possibly, but only if you always change them in sequence. If they are all scanned, it may even be possible to change the order of scanning without changing the meaning, ie, do the gray code sequence in software. \$\endgroup\$ – Chris Stratton Jul 20 '17 at 3:44
  • \$\begingroup\$ +1 for this, I had never heard of Gray code! I can see that being handy in the future! Unfortunately, I managed to resolve the issue. I was using this to test different functions on a target device and even the small change in state was only having an undesired effect when checking the button functionality on the target. Turned out the capacitor value was too large on the target which meant the capacitor stayed charged for longer than the digital debounce programmed in to the target, so it recognised those small pulses as button presses, which is why strange things happened! \$\endgroup\$ – MCG Jul 20 '17 at 7:42
  • \$\begingroup\$ I just needed to make a hardware change on the target device (change a 100nF cap to 1nF) and it works fine now. I do apologise as I should have changed the status of this question to say it has been resolved. Do I just close the question or edit the question to say it is all fixed now? \$\endgroup\$ – MCG Jul 20 '17 at 7:44
  • \$\begingroup\$ I'm glad you solved your problem another way, but the question is a valid one and should remain for the benefit of others - if you think any of the answers is adequate you can "accept" that answer, or just leave it open in the hope of a better answer in the future. \$\endgroup\$ – pericynthion Jul 20 '17 at 8:01
1
\$\begingroup\$

You can either figure out how to make the outputs change simultaneously (if possible) or you can add some barnacle logic that will allow you to fix it. This is definitely not something that comes up very often.

One example would be to add a 74HC595 shift register to control the address lines. The HC595 has an output latch. So you need three lines to control it- clock data and output latch. You will have to bit-bang the serial output which will take somewhat longer (but you can then have 8 outputs if you need them- if you don't just use the lower order bits and shift three bits in at a time, then latch).

enter image description here

\$\endgroup\$
  • \$\begingroup\$ Sorry for the long delay in reply, I was on annual leave! Thank you very much for this suggestion. Think I am going to give this one a go and see how I get on. Thank you! \$\endgroup\$ – MCG Feb 14 '17 at 9:03
1
\$\begingroup\$

The source code of the cp210x Linux driver makes it appear as if the chip itself takes a bitmasked GPIO word controlling all the pins, which could potentially make it possible to perform a fairly coordinated change. However, that driver only seems to expose a one-at-a-time interface. Who knows what you'd find on other operating systems. Most systems however will allow someone with administrative privileges to disconnect the usual driver and talk explicit USB operations to a device instead, so you could perhaps achieve better performance operating the chip directly via something like libusb.

Even if you can change the output bits at the same time though, you still shouldn't be paying un-synchronized attention to the multiplexer result. You really should put something in to sample that only when it is valid.

Once you have the CP2103 and a multiplexor chip, and have to do something about the glitch issue, you'd probably be better off just getting the lowest end USB enabled MCU you can find and programming it to be a USB controlled MUX which transfers the selected input to the output at a high sample rate, synchronous with any change in the input selection.

\$\endgroup\$
0
\$\begingroup\$

Use the enable pin.

Make the enable low, only after the address is selected.

\$\endgroup\$
  • \$\begingroup\$ I did think of this, I was silly enough not to mention that in the original post.... As I do have a spare I/O on the CP2103, but that needs to be used for something else, so I do not have anything I can use to toggle the enable pin. But thank you for the response. \$\endgroup\$ – MCG Feb 8 '17 at 12:55
  • \$\begingroup\$ Loose one address line then? :-) \$\endgroup\$ – skvery Feb 8 '17 at 13:29
  • \$\begingroup\$ That will only give me access to 4 outputs. I need 5. Is there no MUX's out there that have an in built debounce thing to combat these sorts of things? I found it weird I couldn't find anything about this issue on google... surely I can't be the only one with it! Lol \$\endgroup\$ – MCG Feb 8 '17 at 13:35
  • \$\begingroup\$ @MCG Are the 5 outputs predetermined? If so, what are the all 5 possible outputs? Perhaps we can find a specific solution. \$\endgroup\$ – C K Feb 8 '17 at 16:34
  • \$\begingroup\$ A more tricky, but possible work-around would be to clock two flip flops in series for the three address lines. You now need enable, clock and address. A0, clock, A1, clock, A2, enable, yay! The enable is still needed. \$\endgroup\$ – skvery Feb 8 '17 at 16:51
0
\$\begingroup\$

I can't imagine a situation where I'd need an analogue multiplexer combined with debounce circuits, which by their nature are digital - but do you actually need an analogue multiplexer anyway? For a simple 3 in and 8 out circuit like you describe I'd use a 74HC138 or 74HC238 instead, according to whether the outputs need to be active low or active high.

Depending on exactly what the outputs are driving, you could use an RC filter on each output to filter out the unwanted pulses or you could put the outputs through a debounce circuit such as the MC14490 that has six channels, although that's a relatively expensive component and also requires an external capacitor to set its timing.

Although you've said a microprocessor would bit a bit of an overkill, it's an ideal application for something like the PIC16F505, which comes in a single 14 pin package and would directly replace the 74HC4051 with no additional components and low additional cost.

\$\endgroup\$
  • \$\begingroup\$ Sorry for the reply delay, Was on annual leave. I am going to try the suggestion above, but if that does not work or I have any problems, then I guess I could just bite the bullet and get in some form of microprocessor. I'll look at the PIC16F505. Thanks for the suggestion! \$\endgroup\$ – MCG Feb 14 '17 at 9:05
  • \$\begingroup\$ Once you use an MCU, you might as well use one with USB and drop the CP2103 as well. \$\endgroup\$ – Chris Stratton Jul 20 '17 at 3:44

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.