Society of Robots - Robot Forum
Electronics => Electronics => Topic started by: MangoBot on October 08, 2009, 04:18:35 PM
-
From the tactile bumper switch i got the idea that when it is "bumped" power does from lead 1 and 2 to 1 and 3(could be different leads) is this correct or am i wrong? if so what does happen when it is switched.
-
Hi,
Link please.
-
So, what kind of switch is it?
Do the leads have names? Any pictures? Links?
-
srry forgot to add links and stuff heres one from radioshack http://www.radioshack.com/product/index.jsp?productId=2049718 (http://www.radioshack.com/product/index.jsp?productId=2049718) same thing. but i scrapped mine so that is why the leads might be different.
-
So its a microswitch then?
It should have three legs: COM, NO and NC.
Com should be connected to one side and NO or NC to the other depending on what you want to do.
NO if you want to close a circuit with a bump and NC to open one with a bump.
(http://img.alibaba.com/photo/50358221/Micro_switch.jpg)
Finding out which legs are which shouldn't be hard, NC and COM should be connected with the switch up.
-
NO and NC stand for Normally Open and Normally Closed. As in, when the switch is just sitting there and no forces are acting on it. NO means that Com (or Common .. to either state) and the NO pin are in connection when the switch is open, and NC is the opposite.
So, say you're using one as a bump switch: You don't want current running though the switch unless you bump into something (and Close the switch). So, you'd connect a line from your Pos. regulated power rail to the COM pin, then run a lead from the NC Pin to your MCU. This means that the switch is open and reading 0 to your MCU unless you bump something. In that instance the switch closes, causes the IO pin on your MCU to read High (ie digital 1) and you have successfully detected a bump. :)
And if your microswitch isn't labeled then you can just pull out your Multimeter and do some testing on the leads to see what does what.
Hope this helps.
-
That is a SPDT switch. Single Pole Double Throw like the feelers on the Beetlebot. If you go to Instructables (http://www.instructables.com) and do a search on Beetlebot, there should be an explanation there of what the switch does.
-
thanks for the help guys
-
Hi,
[...] So, you'd connect a line from your Pos. regulated power rail to the COM pin, then run a lead from the NC Pin to your MCU. This means that the switch is open and reading 0 to your MCU unless you bump something.
No, that means you have a floating input until the switch is hit!
Allways use a pull-up/-down resistor on the I/O line when a switch is used, or you'd get strange and unpredicted results.
It is better to connect the com terminal to ground and use a pull-up on the input line, to keep the "loose" power wiring at ground potential.
Allways keep the least amount possible of non-ground wires running around your constructions (and those you need - keep them fused).
-
That's a good point Soeren. Thank you for adding.
This site: http://www.micahcarrick.com/05-15-2006/avr-tutorial-switch-debounce.html (http://www.micahcarrick.com/05-15-2006/avr-tutorial-switch-debounce.html) Has a lot to say about a problem with using switches (like that SPDT micro switch as a digital input. The mechanical action of the switch closing isn't actually instantaneous. Those "strange or unpredicted" results that Soeren was talking about. (An O-Scope view of a switch closing will show you all of the fluctuation in signal which equals to a bunch of inputs. (As seen on that link I just posted)).
Also, when the switch is just sitting open there is no definite signal (either 0Vdc (digital 0) or +5Vdc (digital 1)) on that I/O Pin. In that state the pin is said to be floating. (Do I have that concept correct?) So in this case you'd attach your switch as I had said before, but also running from NC pin of the switch would be a fairly high ohm resistor (10K or some such) going to ground. That way, when the switch is open the input pin is pulled low (definitely) and when the switch closes on bump you get that draw from the + rail and a digital 1 signal to your MCU.
-
Hi,
Those "strange or unpredicted" results that Soeren was talking about.
Please don't put words in my mouth that I have never spoken!
The strange and unpredictable results I referred to was when an input is floating.
I didn't discuss debouncing at all, since that can be dealt with in software.
So in this case you'd attach your switch as I had said before, but also running from NC pin of the switch would be a fairly high ohm resistor (10K or some such) going to ground. That way, when the switch is open the input pin is pulled low (definitely) and when the switch closes on bump you get that draw from the + rail and a digital 1 signal to your MCU.
Not at all, that will still create a floating condition when the switch is shifting (between the n.c. and n.o. contact points).
It's not that hard, just do this:
(http://That.Homepage.dk/Img/SW.png)
-
Ahhh, thank you for clarifying things for me.