On and Off. It’s the basis for all electronics, from the most sophisticated computer network to a simple circuit. Sam explores different switch types such as latching to momentary along with what terms like SPST and DPDT mean.
Hey guys, how are you going, my names Sam and you’re watching another Core Electronics Tutorial and today we’re going to be taking a look at switches. Now switches are really important to understand even though they are pretty simple devices because electronics, everything about electronics is made up of switches. Be it mechanical or electronic, in fact the chips that power your phone, TV, computer every electronic device ever is really just a whole bunch of really really tiny switches. We’re at the point today where we can fabricate and manufacture a transistor which is an electronic switch controlled by an electrical signal, we can manufacture those in nano meters, incredibly incredibly tiny which is why there are millions and billions packed on to a tiny little processor or a circuit board. So lets take a look and how they operate today we’re pretty much going to be looking at mechanical switches, everything operates on ins and outs. You know most imbedded circuits, most projects just about everything operates on inputs and then doing something with that to outputs. There are lots of different types of inputs but primarily just about every device that you see will have some kind of button, some user feed back where you can define a state using a mechanical input be it a press or a rotation or something like that. So before we get into it lets take a look at some key terms that are important to understanding switches. So first up we have 2 main types of switches you have latching and you have momentary, now most switches are just derivates of these types of switches. Latching means that the switch will hold its position mechanically when it is turned or pushed or toggled into a state. So take this switch for example, you can hear a definitive click and then another click and that is toggling between two states and it is latching in between a bit like the click point on your pen that latches. It doesn’t have to be held there constantly when you want to write. Now momentary switches are the opposite, they are momentary. So imagine the click point on your pen again, except when you push it down the pen nib comes out and when you let go straight away it goes back up, it doesn’t hold its position, that’s a momentary switch. So its really good for selecting an input or changing something momentarily that you might want to be used as like, a press an hold kind of switch and when you release it it turns off or a pulse that can be read by a microcontroller to develop a latching function or something like that, so yeah that’s momentary versus latching.
Now within those types of switches you’ve got two main characteristics which define how the switch operates - poles and throws, now poles are like the individual channels,like signal channels that can be switched but if a circuit has a single pole, in fact lets draw - hope you guys can see this, so a simple schematic symbol for a switch might look like this, so this is a typical make or break switch and up here you have something else going to part of your circuit and here something else going to part of your circuit. If you push the switch its going to close, when you activate the switch its going to close the circuit and allow electricity to flow and when it’s open it breaks the circuit. Now this switch has a single pole because there’s only one point or one channel where the signal can flow. Now here we have single throw single pole switch so it either makes or breaks the circuit. Now as i said the pole is like an isolated channel, so take this switch here for example, this is a triple pole or three pole, double throw switch and its a foot switch, its designed for industrial applications and most commonly for audio effects circuits so guitar pedals, effects pedals and things like that where you need a really durable switch with nice tactile feel that you can press under your foot and it has three separate channels which means each one of these pins is isolated from each other and they each have their own throw so in a schematic you could imagine that inside one mechanical switch you have another 2 poles which can be switched and managed their own signals independently.
Now throws are something diifferent altogether, so throws is the number of contacts a single pole can make, the number of options if you will that that one pole can be connected to. Now as we said and I’ll use this as another example, this is a triple pole double throw switch which means that to make this correct there is actually, rather than this just being held open, so with this switch, a single pole single throw switch, when its disconnected that would be connected to nothing, theres no physical contact, theres only two contacts on it, that one and that one - when its closed they’re connected when it’s open there’s nothing. But a double throw switch actually has another pin connected to there so it gives you two state now rather that just on or off. It gives you two active states that you can toggle between, you could still leave that pin unconnected and use it as a single throw switch or say you’ve got a signal coming in here - this could be a pin on a micro controller and you want to toggle the pin high or low you could have 5 V connected there and ground, so 0 V connected there, you could use it like that. For example its important to note that switches, mechanical switches are just that, they’re 2 contacts connecting just metal conductive material means they are bi-directional so you can have a signal flowing from this direction right to left or you could have current flowing from left to right, it doesn’t really matter, so that’s poles and throws.
Now the last important characteristic of switches is the rating, not all switches are rated for the same application. So take this switch here, its a very small (we’ll put it on the paper so you can see it) its a very small tactile push button switch and it is a single pole single throw switch. When the switch is not pushed and these two pins are not connected there’s no circuit being made and when it is pushed they are connected and when you release it they are not connected so its a momentary single pole, single throw switch. Now as you can probably see the legs of this switch aren’t very big, they’re quite small, it’s designed for breadboarding applications. Whilst the legs might be that size the internal mechanisms are going to be different as well. There’s no guarantee that just because the legs are that thick they’re might to be able to handle say 1 Amp tag the internals of the switch can. That the contacts and the mechanisms that are carrying current can handle that so there is different ratings. So for example i’ve got a toggle switch, now this guy has a rating of, I can see on the bottom here and you’ll find on the product sheet but if you can’t see that it says 2 Amp at 250 V or 4 Amps at 125 V so switches are rated for power. So I could use up to, so you know power is equal to voltage multiplied by current so 250 V multiplied by 2Amps gives us 500 W that this switch can handle. Now, also you can divide the voltage by two which is 125 V and can increase the current capacity to 4 Amps which is fantastic. So these guys are designed for handling mains currents and things like that so you’ve got different ratings of switches, these guys might be only able to handle milliamps and say under 24 V or something. So ratings are something really important to observe, if you use them in small low power micro controller settings then really any switch you like is fine within reason but if you’re doing it with battery supplies where you are drawing a lot of current or if you’re using mains power - if you’re safety certified, then you need to be aware of that.
So thats a bit of an overview of the characteristics of switches, there’s some diagrams in the written tutorial for single pole double throw, double throw double throw, triple pole double throw. Now I’ve got here quite a wide variety of switches that all perform different functions. They take different forms of mechanical input to achieve the same thing. So here we’ve got a joy stick, now you may be familiar with this if you’re 20 years and older from arcade systems and things like that. This is designed to give directional movement or menu selection or things like that to a user. Now it’s actually incredibly simple. You have 4 switches here and they are single throw single pole switches. They are make or break switches. You can see here there is the contacts there, 2 contacts there and 2 contacts there and 2 contacts there. Now this joystick simply makes the connection so you can see the other arm of the joystick here making a switch connection here and there and there and there. It really just makes a switch in either direction and by combining both switches on this side and this side are connected then you know its a diagonal movement, different things like that so incredibly simply you get directional input from 4 switches. Now again this is a simple arcade much button switch and I can see, I don’t know if you can see from here but on the switch body itself its got a little circuit diagram of what the switch does and this is useful for recognising the type of switch it is on the fly. Now you can see theres a little, this is the switch itself and there’s a little actuator in there which I can get at with my pen and trigger. This plastic bit is just the body, its an arcade style buttoned its got a little arm there which activates the switch and its a single pole double throw switch hence the 3 contacts, the 3 contacts give it away because the single throw single pole switch would only have 2 contacts.
So this guy, this is a rotary switch, so a rotary switch is designed for rotational input as the name implies but where it gets a bit different from your other types of switches is your rotary switch usually only has one or two poles - this guy has one here, one pole, but it has a large number of throws and it’s designed so you can select a whole bunch of different options just from a single control where you know so this switch is a binary choice switch, you get on or off, you know selection or selection. This guy is I think a 12 throw switch so you get 12 individual positions that you can turn it to. Now, rotary switches come in 2 flavours, you have the ones that make 12 individual circuits so you would have one contact here which is say your signal contact and then you would have 12 other different contacts and pretty much it just looks a bit like this. You’ve got all these different switch contacts and depending on which one you’ve selected current will flow through that selected channel.
Now you’ve got another type of switch like this and these ones are designed for analogue input to microcontrollers so instead of having lots of different outputs you can see its got a connector for a sensor cable here by DF Robot and they’ve only got 3 pins so how do we get that? So what happens is it utilises a resistor ladder. You have one input here, and then there’s a bunch of resistors, you can see the resistors along here and this guy will in fact - so this is another type of rotary switch, they’re not all this way they’re usually on or the other - there’s a bunch of value resistors here. So lets pretend that there are 12 resistors and essentially you’ve got a bunch of different switches here which make or break the resistance and these are all tied together. So the signal is going to flow through only one of these resistors and you have different resistor values in the resistor ladder - that might be say 100 OHM, might be 500 OHM, might be 1 K and so on and so forth. By creating a voltage divider with those you can read an analogue input on a microcontroller and using only one pin you can get 12 different possible scenarios based on the voltage that you receive into that pin because of the resistor ladder, so its really cool. So they are a few different types of switches and the rest of them really area variations so different mechanical actuators, so here we’ve got a lever micro switch so it’s designed for incredibly low force to be applied hence the lever action creates an increase in torque from the mechanical input to where the switch is and it’s designed for really small fine applications where you just want a really small force to trigger that. the 3 pins gives it away that its going to be a single pole double throw switch. I can see on on and C, so probably common. Then we’ve got this large switch which is again a single pole double throw switch but instead you’ve got a slight actuation useful you know you find those in consumer electronics and things like that.
Here we’ve got a water proof switch and this guy is pretty unique because along with being durable with a sleek industrial looking metal housing it’s got an LED built in. I don’t know if you can see it but its that dark ring around the outside that is just some transparent plastic with a LED mounted inside here with individual contacts to control the LED. So you could hook this up to a microcontroller and it’s a momentary switch so I can feel that the switch is going to the same point on the data switch, it says that it’s a momentary switch. You can tell that you could use this for a whole bunch of different applications, you could control a microcontroller input and then have the microcontroller control the LED or you could hook the LED directly up to the switch contact so when it switch, you know when your holding it in the LED turns on or when you release it turns off things like that. Then lastly your standard kind of toggle switch so this guy is a single pole single throw and I can tell because there are only 2 contacts on it so it’s going to be a single pole single throw switch and its going to be on or off. Generally designed as a trigger for things like control interfaces or for master power switches, things like that where you want to really clearly defined simple switch.
So that’s a few different types of switches and how they work and the last thing that we’re going to cover is the phenomenon called bouncing or switch jitter. You might think that so let’s take this switch here for example. Now this is a very small switch and you might think that when I push it, let’s say we’ve got it connected up to ground and when its unconnected we have a high voltage - so if this is our 5 V and this is our ground or zero volts. When it’s not being pressed it might have a nice 5 V and then when its pressed it falls down and when its released it goes high again now that is generally how they are designed to operate.The important thing to note is that inside every switch there are mechanisms, there are mechanical contacts which have to make contact in order for electricity to conduct. Now like anything mechanical those contacts have momentum which means that when they make contact with each other they have momentum, they have a velocity and a mass behind them so they’re going to actually bounce because when they hit they’re not just going to sit and stick, they’re going to bounce. So they’ll hit connect and bounce bounce bounce and finally settle. So you might have hit, connect, bounce and the bigger the switch the more momentum that the contacts are going to have. So take this switch here, this guy is rated for mains voltages which means it needs to be able to handle 2 Amps at 250 V, thats 500 W of power, thats a lot of power people. Thats as much power as a typical desktop computer would consume and thats a decently powerful one as well. The contacts in here are going to be big, they’re going to be heavy and they have to be rated for that kind of current to go through them otherwise they are going to get too hot and melt the plastic or destroy the entire mechanism so that’s why you pay attention to the rating. But because they are big and they are weighty they have more momentum and momentum is a function of velocity and mass and the greater the mass the greater the momentum. The greater the momentum the more inertia they are going to introduce into the system which causes bouncing. A really small switch might only bounce a tiny bit but a really big switch might bounce quite a lot which gives you a longer time period. What you have to do is do de-bouncing. Now this is important if you are using this as an on/off switch for mains power or for a selectional switch where it’s not timing sensitive, you know it’s not going to matter if for an extra 10 nano-seconds there’s this sort of de-bouncing because it’s going to settle pretty quickly. If you’re using a microcontroller for example where you’re reading the state of this push button, micro controllers operate anywhere between 2 - 4 Mhz right through to Ghz you know really high processing speeds and this is important because if you’re sampling the pin that’s there instead of this nice clean break you’re going to get, it’ll go down and up, down and up and then finally it might settle and likewise when you release it, there’ll be this jitter on either side and you’re going to need to handle that because if you’re turning an LED on or off with this switch you’re going to get false positives. If you’re just sampling that straight away it’s going to say you turned it on then off then on then off then on and so on and so forth. That can be a real issue so you need to use what’s called de-bouncing, we’re not going to go into de-bouncing in this tutorial because its another conversation in itself and there’s alot of different ways you can do de-bouncing, through hardware, resistor capacitor filter network, schmit triggers and flyback diodes and all the rest. Or you can implement it in software you know, like limiting the amount of times that that button can trigger an action for your microcontroller. So we’ll get that tutorial up so you can take a look at that but pretty much every project that we do or very tutorial where there is de-bouncing you can find some form of switch and you’re going to find some form of hardware or software de-bouncing in there because it’s really important. So that’s just a few things to consider when you’re using switches in your projects and I hope this has answered a few questions, if there is something you’re unclear about or you’d like us to go into more detail on it then hit the comments below, get the conversation started. We’d love to hear your feedback on how useful this was to you and some projects that you guys have made using this information. Don’t forget to subscribe, hit the like button, whatever platform you’re viewing this video on and stay tuned for more awesome analogue videos and tutorials. I’m Sam and I’ll see you next time guys.