2
\$\begingroup\$

I've been trying to get an 8x3 encoder (IC 74LS148) working using a 10 pin dip switch, I simply connect the 1-7 ON sides of the switch as inputs for the encoder and the OFF sides of the switch to the VCC. The A0 output of the Encoder I get is always a High logic level or "1" (LED light turns on) regardless if any switch is on or not.

\$\endgroup\$
3
  • \$\begingroup\$ what is the part number for your DIP switch? \$\endgroup\$
    – tcrosley
    Commented Jun 8, 2014 at 3:16
  • \$\begingroup\$ there's no part number, the only writing I can see are "EGE" (logo maybe) "ON" and numbers "1-10" \$\endgroup\$ Commented Jun 8, 2014 at 3:24
  • \$\begingroup\$ If it has 10 switches, then I assume you mean 20-pin, not 10-pin. \$\endgroup\$
    – tcrosley
    Commented Jun 8, 2014 at 3:35

2 Answers 2

3
\$\begingroup\$

Since the the inputs to the 74LS148 are active low, you actually want the common lead of all the switches to go to ground, instead of VCC.

This is why the outputs of the encoder are always high -- if the switches are off, the floating inputs act as high inputs, and when a switch is on it is also driving the input high. So there is no way to drive any of the inputs low.

Besides tying the common lead of the switches to ground, I would also connect 4.7K pull-up resistors between each of the inputs of the encoder to VCC, rather than leaving them floating. It's just better practice for TTL (74LS series), and required for CMOS (74HC or 74HCT series). This way it will work for both types of chips.

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ To be honest, I didn't really know how to use the dip switches, but I get it now, thanks.. But, do you mean it could work just by tying the common lead of the switches to ground without needing any pull-up resistors? \$\endgroup\$ Commented Jun 8, 2014 at 3:37
  • \$\begingroup\$ @user2868984 yes, it will probably work with a 74LS148 chip. So you can just move your common lead from VCC to ground and try it. I'd still add the pull-ups though. \$\endgroup\$
    – tcrosley
    Commented Jun 8, 2014 at 4:00
  • \$\begingroup\$ well, yes I think I need to add the pull ups because now it does the opposite (output always low).. Thanks.. \$\endgroup\$ Commented Jun 8, 2014 at 4:45
  • \$\begingroup\$ @user2868984 First of all, the resistor values can be anything from 1K to 10K, don't worry about making them exactly 4.7K. Second, make sure your switches are all off to begin with, and then turn only one on at a time (if you do turn on more than one, there is a table in the 74LS148 datasheet which will indicate what the output should be). \$\endgroup\$
    – tcrosley
    Commented Jun 8, 2014 at 5:48
1
\$\begingroup\$

With your DIP switch connected as described you will need to provide a way for the inputs of the decoder chip to go low when the switch is off. That said, when using a chip like the LS148 you may want to rearrange the connections as shown below and use pullup resistors to establish the high levels on the inputs to the chip.

enter image description here

\$\endgroup\$
2
  • \$\begingroup\$ The 74LS138 you show is doing just the opposite of what he wants, the 138 takes 3 inputs and expands it to 8, he is taking 8 inputs and encoding it as 3. In any case, in your example only inputs A, B and C should come from switches. I don't know why you are connecting the enable lines of the '138 (G1, G2A and B) to switches also. \$\endgroup\$
    – tcrosley
    Commented Jun 8, 2014 at 4:34
  • \$\begingroup\$ @tcrosley - I fixed for '148. I read the question in dyslexic manner. \$\endgroup\$ Commented Jun 8, 2014 at 19:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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