Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Digital switch?

Status
Not open for further replies.

Marks256

New Member
I have numerous 2 pin push button switches(SPST). You know, the ones that have in and out? Just two pins. Ok, now the problem. I would like to use these as digital switches. How would i do that? I have been using the attached schematic, but that doesn't give me an absolute 0. I need a 1 or a 0. Not and NC! Any ideas, or will i need to get a SPDT switch?
 

Attachments

  • DigSwitch.PNG
    DigSwitch.PNG
    2.8 KB · Views: 194
Try using 4.7k instead of 10k. Your pull-down resistor might not be strong enough.

YOu should have a switch debouncer there where the 220 ohm resistor is. It looks like it should work to me unless something about the lack of a debouncer is confusing your uC. What are the two states you are getting? High impedence and...?

Also, I am not entirely sure if you need the 220 resistor, but if there is sufficient leakage current going through to form a sufficient voltage drop, that could be messing around with your results, but that seems unlikely
 
Last edited:
Usually we put one side of the switch to ground and the other end to a pullup resistor (say 10K) That way it'll work with TTL style devices also, because those require more current to be toggled low than high. HCMOS etc won't care either way. A 0.1uf cap in parallel with the switch will provide debounce if the switch is connected to a schmitt trigger style input. You don't really need the 220R..... The only use I could see for it was if you were interfacing with a microcontroller where the pin could be configured as either an input or an output and you were worried about a mis-configured pin (set to output) being damaged when the swich is pressed.
 
Last edited:
This isn't for a uC. It is just for some test circuits i would like to make before i connect them to the uC. Isn't 4.7k smaller than 10k? What good would that do?

I don't quite know the terminology of High and Low impedance, but i am getting a steady "1", or High, in each switch position. I need 0 while the switch is Not Connected, and a 1 while it is connected. What am i doing wrong? I will try a switch debouncer soon.
 
Marks256 said:
This isn't for a uC. It is just for some test circuits i would like to make before i connect them to the uC. Isn't 4.7k smaller than 10k? What good would that do?

I don't quite know the terminology of High and Low impedance, but i am getting a steady "1", or High, in each switch position. I need 0 while the switch is Not Connected, and a 1 while it is connected. What am i doing wrong? I will try a switch debouncer soon.


You said you didn't need a NC so I assumed that meant "not connected", which is what high impedance (or high resistance as in infinite resistance)means.

Using a smaller pull down resistor would make it so that more current flows through the resistor from +5V to GND when the switch is closed and make the 5V drop across the resistor stronger and less sensitive to noise (since more current is flowing through it, it is harder to disrupt). Just imagine if the pull down resistor was 1 trillion ohms. Still a pull-down resistor right? Or would the current flowing through it be so little that the slightest thing could disturb it enough to cause the voltage drop across the resistor to jump back up to 5V and always cause the output to be high? Now if the pull-down resistor was 0 ohm, it would pull down so strongly that you could never pull it high again because the +5V would be shorted and an infinte amount of current would be flowing which is really hard to disrupt.

YOu could always try a pull-up resistor instead like Kchriste said (but then pushing the button would pull the circuit low). YOu don't see many pull-down resistors.
 
Last edited:
Oh, ok. Yes, i ment Not Connected, but i'm not sure what i ment by it? I ment not connected to ground. My mistake. But yes, i will try the pull-up, and then run it into a hex inverter. Thanks
 
You need to use different resistor values for different logic families.
You didn't say whether your hex inverter is a TTL 7404, or a Cmos 4069.
A TTL input draws a max of 1.6mA at 0.4V when low. So the max value resistor to ground is 0.4V/1.6mA= 250 ohms.
A Cmos input draws no current so the max value for a resistor to ground to make it low could be anything.
 
How do i tell if it is TTL, or CMOS?
 
Yes, i know that datasheets will tell you. I just thought there was some way just to look at the chip. The inverter is TTL compatable.
 
just use relay

Marks256 said:
I have numerous 2 pin push button switches(SPST). You know, the ones that have in and out? Just two pins. Ok, now the problem. I would like to use these as digital switches. How would i do that? I have been using the attached schematic, but that doesn't give me an absolute 0. I need a 1 or a 0. Not and NC! Any ideas, or will i need to get a SPDT switch?


i hink u should use relay
 
Marks256 said:
Yes, i know that datasheets will tell you. I just thought there was some way just to look at the chip. The inverter is TTL compatable.
The chip has a part number marked on it. What is it?
TTL= 7404, 74LS04. Cmos= 4069, 74HC04.
It might even have Schmitt trigger inputs. Its number will tell you.
 
I have found a resistor that works perfect. The 150 ohm resistor. It gives me absolute "1" and absolute "0". I have attached the schematics.
 

Attachments

  • DigSwitch_works.PNG
    DigSwitch_works.PNG
    3.2 KB · Views: 162
Is that resistor able to hand the power dissipation? it seems like a lot of heat would be going through that resistor. You don't want too small a resistor because you use up a lot of uneeded current, but you don't want one too high either so that the resistor isn't strong enough to pull-down.
 
Your hex inverters don't need an absolute 1 and 0 at their inputs. The max voltage for a logic low for TTL is 0.8V and the min high voltage is 2.0V. The outputs go to a max voltage of 0.4V for a logic low and to a min voltage of 2.4V for a logic high. The extra 0.4V is for noise immunity.

The logic voltage limits for Cmos inputs is 1/3 and 2/3 of the supply voltage. The outputs go to the positive supply and ground voltages if they don't need to supply current.
 
Is that resistor able to hand the power dissipation? it seems like a lot of heat would be going through that resistor. You don't want too small a resistor because you use up a lot of uneeded current, but you don't want one too high either so that the resistor isn't strong enough to pull-down.

I don't know. The resistor doesn't get hot. The 10ohm got very hot, but the 150 works slick.

Your hex inverters don't need an absolute 1 and 0 at their inputs. The max voltage for a logic low for TTL is 0.8V and the min high voltage is 2.0V. The outputs go to a max voltage of 0.4V for a logic low and to a min voltage of 2.4V for a logic high. The extra 0.4V is for noise immunity.

The logic voltage limits for Cmos inputs is 1/3 and 2/3 of the supply voltage. The outputs go to the positive supply and ground voltages if they don't need to supply current.

I know it doesnt require it, but it helps me a lot when it comes to debugging.
 
Marks256 said:
I don't know. The resistor doesn't get hot.
5V across 150 ohms causes a power dissipation of only 167mW, you know.

The 10 ohm got very hot.
5V across 10 ohms causes a power dissipation of 2.5W, you know.
 
Is 167mW good, or bad? How do you calculate that? What is a good power dissipation?
 
Marks256 said:
Is 167mW good, or bad?
167mW in a 1/4W (250mW) rated resistor is pretty good, because the resistor won't get too hot. 250mW in a 1/4W resistor causes it to reach about 200 degrees C.

How do you calculate that?
Power in a resistor is calculated by squaring the voltage across it then dividing by the resistor's value. Power in a resistor is also calculated by squaring the current in the resistor then multiplying it by the resistor's value.

What is a good power dissipation?
It is good to keep the power dissipation as low as possible so the parts don't get hot.
 
What do you mean by "voltage across it"? The power going into it, or the amount that it reduces?
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top