0
\$\begingroup\$

I'm a beginner and I'm currently working on simple PCB with LEDS and Multi-Directional Switch in EasyEDA.

The Switch is Korean Hroparts Elec K1-1505UA-01
https://www.lcsc.com/product-detail/Multi-Directional-Switches_Korean-Hroparts-Elec-K1-1505UA-01_C145912.html
Datasheet: https://datasheet.lcsc.com/lcsc/2108131730_Korean-Hroparts-Elec-K1-1505UA-01_C145912.pdf

LED is MEIHUA MHP1016WDT
https://www.lcsc.com/product-detail/Light-Emitting-Diodes-LED_MEIHUA-MHP1016WDT_C409775.html

Can you help me with the connection ? How to connect the Switch to battery and Switch to LEDs.

I am a little confused with the datasheet of the switch

Switch datasheet

Switch sheet

My Sheet in EasyEDA

enter image description here

\$\endgroup\$
13
  • \$\begingroup\$ what are you confused about? \$\endgroup\$
    – jsotola
    Mar 9 at 5:25
  • \$\begingroup\$ how to connect multi-directional switch? ... to do what? \$\endgroup\$
    – jsotola
    Mar 9 at 5:41
  • \$\begingroup\$ Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. \$\endgroup\$
    – Community Bot
    Mar 9 at 5:59
  • 1
    \$\begingroup\$ I think what you are asking is "How do I decode the 7 connections from the switch so that the correct LED lights when the switch is moved to one of its 5 possible positions" I don't think you can do this directly without some additional logic. In particular the "E" position. All you've got is contacts 5 and 6 connected, something that happens with EVERY switch position. The difference being that, for "E", there are no other contact connections. You say you've picked 3.7V LEDs that will require no resistor. What are these? Can we have a link to their specification please? \$\endgroup\$ Mar 11 at 18:32
  • 1
    \$\begingroup\$ Unfortunately you have picked project that is not quite as simple as it seems. To do justice to an answer, assuming you have no prior knowledge, would require much of a 1st year undergraduate course on digital logic and electronics (or maybe the A-Level syllabus covers it now). How to get usable signals out of the switch. How to decode them. Which type(s) of logic to use. And then how to drive the LEDs from the logic. \$\endgroup\$ Mar 12 at 14:56

1 Answer 1

1
\$\begingroup\$

Unfortunately you have picked project that is not quite as simple as it seems.

The outputs from the switch cannot be used to directly drive the LEDs, they need some decoding. In other words you need to use logical combinations of the 7 terminals to light only the correct LED and no other.

The contacts fall into 2 groups. 1,2,3,4&7 and 5&6

5&6 are connected whenever the switch is operated in any of its 5 positions and can be considered as an enable signal - if they are not connected then no LED lights.

1,2,3&4 all get connected (or not) to 7 in various combinations depending on which of the 5 positions the switch is operated. Note if 1 is connected then 3 is not and vice versa. Similarly 2 and 4 are inverses of each other.

But you are not going to be able to do this without additional logic. If we use the convention 1 is logically TRUE to indicate that terminal 1 is connected to terminal 7 and 0 or FALSE if it is not connected. We have already observed that 1 = NOT 3 and 2 = NOT 4, So you have all the logical signals you need to decode the switch plus 5-6 for enable.

A = 1 AND 2, B = 2 AND 3, C = 3 AND 4, D = 1 AND 4, E = (NOT 1) AND (NOT 2) AND (NOT 3) AND (NOT 4)

We now have to get into the topic of digital logic. How are you going to generate logical signals (TRUE and FALSE, 1 and 0) from the switch? First you need the concept of pull-up and pull-down resistors. There is a good article on them here.

{pause answer while you read the article - the rest of this answer will assume you have done so and understand most of it}

Now consider switch terminal 7. We have 2 options:

  1. Connect terminal 7 to Vcc and have pull-down resistors from 1,2,3&4 to ground. This has the advantage that, with the switch not operated, all of 1-4 will be near 0V via their pull-down resistors and this can be considered logical 0 (FALSE) and when the switch is operated some combination will be pulled up to near Vcc or logical 1 (TRUE). The values of these resistors depend on the type of logic that follows.

  2. Connect terminal 7 to ground and have separate pull-up resistors from 1 - 4 to Vcc. From the article value of these resistors is less critical.

I would say that (2) is a better solution (see article). However it does invert the logic. TRUE becomes 0V and FALSE is close to Vcc. If you are familiar with logic, this shouldn't bother you, if not have a look at this article followed by this one. Terminals 5 and 6 can be treated the same to produce the enable signal or in this case, switch on the power to the LEDs.

schematic

simulate this circuit – Schematic created using CircuitLab

Inverting the logic inverts everything, so A = NOT (NOT 1 OR NOT 2) = NOT (3 OR 4) = 3 NOR 4 and so on.

You now have to decide what type of logic you want to employ. There are numerous choices.

  1. You can use discrete logic such as the 74nnn series ICs some of which could probably do the entire decode / LED drive process in one chip such as the 74156. There are hundreds of different logic functions available in this series. These come on two basic sub-versions TTL and CMOS each of which has its advantages. On top of this, each sub-version comes in several different speed / power combinations. Their pros and cons warranted a whole answer of their own on this board here. Please read it.

  2. You could use a microprocessor such as an Arduino.

  3. You could burn your own decoder using a programmable memory chip.

  4. I'm sure other contributors could come up with several other viable methods.

Assuming that you are going to decode the switch using basic 74nnn gates rather then the more complex functions you will need 4 off 2 input NOR gates to decode A - D and one 4 input AND gate for E (all 4 switch signals need to be 1 to light LED E). This will give you the following logic (Note AND1 gate should be a 4 input AND, but Circuit Lab doesn't appear to provide this symbol.)

schematic

simulate this circuit

You now have 5 logic signals , A - E representing the 5 states of the switch. All that remains to do is drive the LEDs from these signals. Some LED / logic IC combinations may be able to do this directly, other combinations will need an additional driver or transistor.
The following circuit could be repeated 5 times to complete the project. The values of R1 needs to be adjusted to give reasonable current through the LED.

schematic

simulate this circuit

\$\endgroup\$
7
  • \$\begingroup\$ Peter - Hi, I didn't read it all yet, but thanks for trying to answer. However when I reviewed the switch datasheet yesterday, I noticed that your statement: "5&6 are connected whenever the switch is operated in any of its 5 positions" seems to be wrong :-( Look at the side views of the switch. It shows that action "E" is a z-axis "press down" on the switch actuator. My experience with a similar switch is that you can push the actuator sideways in any direction and you could (but don't have to) press down at the same time, hence why action "E" is an option for "A" - "D". See what I mean? \$\endgroup\$
    – SamGibson
    Mar 14 at 23:58
  • \$\begingroup\$ @SamGibson Hi Sam, My reading of the truth table , upper right diagram in the OP's question is that it shows which of the 7 terminals make contact with each other when the switch is operated in any one of its 5 positions. When it is pushed down, operation "E", Z-axis, I see 5&6 connected but no other connections made between pins 1-4 & 7. In any of the other 4 operations, 5&6 are also shown connected and simultaneously some combination of 1-4 are connected to 7 . Where can we see the truth table for your switch? \$\endgroup\$ Mar 15 at 0:34
  • \$\begingroup\$ Hi Peter, I see that we agree up to a point. Here is where I have a different view, after working with a similar switch. You said: "In any of the other 4 operations, 5&6 are also shown connected" I agree it could be interpreted that way, but IMHO the datasheet is actually trying to say that the 5-6 connection could also occur when pushing (for example) towards "A", if the user also pushes down. In other words, the 5-6 connection (action "E") means user is pushing down. If 1,2 & 7 are connected, user pushed towards "A". So connections 1-2-7 and 5-6 means push towards A and down IMHO. \$\endgroup\$
    – SamGibson
    Mar 15 at 0:43
  • 1
    \$\begingroup\$ @SamGibson Hi Sam, you may well be right. Without actually seeing the switch and putting a multimeter on it, who knows what it does. If I'm wrong in my interpretation then it's an exercise for the student to put it right. Thanks for your appreciation of my answer, it took me quite a few hours research to put it together, trying to condense a first year undergraduate course and my 40 years experience as an EE into an answer. I only hope it gets more widely appreciated!! \$\endgroup\$ Mar 15 at 1:51
  • 1
    \$\begingroup\$ @SamGibson Thanks Sam, I see what you mean about your switch. You may well be right. Maybe the OP will enlighten us as the data sheet is, as you say, ambiguous. I'm still not happy about the use of a 3.7V supply with 3.7V LEDs, but I let that slide. It's 2AM here in the UK and I'm off to bed! \$\endgroup\$ Mar 15 at 2:06

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.