Electronics notes/Knobs and dials
- 1 Potmeters
- 2 Rotary/linear encoders
- 3 Resolver
- 4 Switches
Variable resistors (see potmeters), many of the ones with a knob are single-turn, meaning they go though their resistance range in ≤ 360 degrees.
Servos use a potmeter as a sensor, so you could solder wires to that potmeter.
Mostly makes sense to do to continuous-rotation servos, and/or when you also want to move the servo (because otherwise it's just a pricier pot)
Also, the higher the torque, the more that manually turning the servo is likely to damage said gears, so in general this is not very useful.
Incremental encoders, a.k.a. Relative encoders (only) report/detect change in position.
Also often report which of the two ways they are turning, via quadrature coding (see below, but basically a second output 90 degrees out of phase, so you can tell by which leads the other).
This video is a decent indication of what happens on these two outputs.
Speed is the speed at which the changes happen, so needs a CPU to pay attention.
- rotary knobs
- ball-and-roller computer mice used two rotary encoders
Absolute encoders also report their actual position. These are harder to find than incremental encodes, because it's more complex and pricier to do, and often you could use a potmeter instead (...though it's not as easy to find continuous-rotation potmeters, and they take a little extra care).
Both relative and absolute can be intuitively understood as pulses/states coming from (different) encoder discs (optical, magnetic, capacitive, or even conductive) - see
- relative is the variant with just the slits, often with two channels out of phase (see quadrature encoder disk), so that one signal is ahead of the other, and you can additionally detect direction
- absolute encoder disk are the variant which looks like it may have its position as a binary number -- but is actually a the slightly more useful Gray code
As-is, relative encoders are useful for things like menu navigation, where only movement mattersmatter in the first place, and when sensing speeds.
There are a few applications where you can use a relative and add absolute position, by calibrating, e.g. by starting by moving to an end switch (or some other calibration point), and then never missing any movement.
- three-phase motors can, with a bit of sensing on top, be used as relative linear encoders.
- There's an interesting DIY project in taking a broken hard drive and using it like this
When using switches as input
- Avoid floating
With most switches, one of the switch states will mean a broken circuit. When this is sensed by ICs or amplifiers this means a floating input and implies unpredictable behaviour.
You'll need a pullup/pulldown resistor.
In some PICs (such as AVRs in Arduinos) you can enable internal pullups via code, which means you don't need to add a resistor to such a circuit.
- Avoid reacting to bounce
The mechanics of contacts in switches means they show contact bounce will be mirrored in electrical contact: a very quick flip-flop between contact and no contact. In buttons that you have to hold down, this may also happen on movement.
Instant senses (such as those from PIC) may accidentally sense a moment of disconnection, where you basically want the state it is mostly in in a short term (or perhaps you want to know whether it has switched recently).
Also, there are some electrical components that don't like switching that fast.
Both tend to mean you want to filter input from switches somehow.
In analog circuits, one way to debounce is a simple RC circuit - the capacitor will charge slow enough to mean that only consistent contact will get the voltage to a fairly high level (and in a relatively monotonous way, but that's not really the point, nor something you can count on).
When sensing digitally you can debounce in software. With PICs, one simple solution is to take a bunch of samples over the time it takes the switch to bounce (often a millisecond at most) and check how consistent they are.
You can bias this to the safer state (e.g. consider a pushbutton off until it's fairly consistently on), but beware of variants of that code that will effectively debounce in one direction but not in the other.
|This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)|
Encompasses combinations of:
- Multiple positions,
- a mechanical tendency to go to one position
- toggle/flip, or momentary
- multiple electronic states,
- and other electronic properties
Bistability refers to switches that will rest in both states.
It could be both a mechanical and electronic descriptor, though on the mechanical side it's often called latching, or some such term, whereas a monostable would refer to what most relays do (the term "monostable switch" would be rare because we have words like "momentary" and "pushbutton").
...so the terms monostable and bistability are usually about electronic switching, e.g. to pointing out e.g. that
- digital circuits can be made to sustain their current state.
- thyristors will stay in their current state, while transistors are not
- ...often then mentioning a simple bistable multivibrator circuit, a.k.a. flipflop), or contrasted with a monostable multivibrator
The distinction between buttons and switches is not more pragmatic than it is hard/strict. Can be a pain in webshopping :)
A few more specific buttons/switches:
- toggle switch
- states: often two. Toggled
- toggle switch
- rocker switch
- states: often two or three. Usually toggled, sometimes momentary
- rocker switch
- states: two. often momentary, sometimes toggled
- mainly a small momentary push-button
- states: Two. Momentary.
- Mercury switch
- states: Two. Depends on orientation (because gravity).
- no contact bounce
- mercury switch
- Reed switch
- states: Two.
- Mechanical, closed by nearby magnet
- reed switch
- knife switch
- The circuit breaker of old
- states: Two. toggled
- end switch
- a switch positioned at the end of a mechanical range, often to detect when actuation should go no further
- often a microswitch with some sort of lever, wheel, etc. for durability.\
Contact bounce (behaviour)
Contact bounce indicates the time in which an arriving contact mechanically settles and in which the connection is not yet stable. See some images. This bounce is often tiny, both in movement and time.
This bounce is rarely important when driving resistive loads, but in anything more complex there the reaction to the bounce itself can matter.
For example, a digital system observing/sampling it may see very fast switching back and forth.
Some components, such as ICs, also don't deal too well with bounce on their Vcc. A bypass capacitor helps here, and is nice for its power stability anyway.
Default switch state (design)
Switches that are typically in one state (in the case of buttons will probably return there, rather than be toggled) can be referred to as Normally Open (NO) and Normally Closed (NC)
If it has contacts for more than one state (which, when one state is most natural, can be termed NO and NC contacts), the switch is termed Changeover (CO) (also Double-Throw, implying a typical two-state switch, Triple-Throw, etc.).
Changeover switches can be:
- break before make, meaning there is some time in which neither side makes contact. This may cause temporary high impedance long enough to cause some unpredictable behaviour
- make before break, meaning there is some time in which both sides make contact. This may easily cause temporary shorts.
Poles and throwing (design)
Depending on what exactly you want to do, poles and throws can matter when buying a switch.
Amount of poles matters to whether you want to do something with one state (e.g. powered or not) or with both.
Amount of throws matters when you want to control things independently from the same mechanical switch (without digital logic doing it for you). Consider that a car's emergency light switch turns on both turn signals without tying them together electrically.
In some constructions, both matter. Consider multiway switching.
- SPST (Single Pole, Double Throw)
- open or closed
- DPST (Double Pole, Single Throw)
- two separate SPST-style switches controlled by the same mechanics
- SPDT (Single Pole, Double Throw)
- a common lead switched between two other leads.
- Used e.g. in multiway switching
- DPDT (Double Pole, Double Throw)
- two separate SPDT-style switches controlled by the same mechanics
There are further variants of design.
Triple pole and similar also exist, for example triple pole single throw mechanical knife switch circuit breakers.
A relay is an electronically controlled switch.
Often electromechanical, though solid state relays are becoming more common.
Relays mean a circuit can switch a electronically separated circuit, which can be particularly handy when they deal with different voltages and currents. This can be useful when switching a completely distinct device, as part of process control, or as part of safety design.
Electromechanical relays are solenoids (electromagnets). As inductive elements they have flyback, so you'll often want a protection diode (flyback diode).
With the electromagnetism involved, thy are not completely isolated. With large voltage differences, you have a potential source of arcing (although this is more of a problem at kilovolts than at regular mains voltages).
Relays may need need on the order of at least 20mA-50mA to be held, so ICs driving them regularly use a transistor - and not unusually something for flyback protection.
Solid state relays are a relatively new development, and have no moving parts
- Relays can generally deal with more voltage (e.g. 40V, 400V) than transistors/optocouples, and with more load (regularly a few amps or more).
- Relays don't care what's on them (AC or DC) while in-circuit transistors are only really DC
- Relays can often switch more than one thing at the same time
- Transistors use less power than relays
- Transistors react faster
- Transistors use less power than relays (most relays cannot be driven directly by most ICs and need a transistor)
Reed relays can switch faster than regular coil relays, but have a current limit that is often on the order of half an amp.