This is Part 2 of a series on all of the available parts for your electronic project. In the last post, you learned about the fundamental circuit elements common to all electronic gadgets. We continue our overview in this lesson, with a look at switches, connectors, and sensors.
Switches are used to connect or disconnect a circuit element and are employed in power buttons, light switches, keyboards, mice buttons, multifunction buttons, slide switches, and more.
Switches often refer to a pole and a throw. The throw refers to the mechanical action, i.e. the button or lever. The pole is how many electrical terminals are on one side of the switch. A single pole device (also known as a two-way switch) can only connect two sides an electrical circuit together or disconnect the circuit. A switch that has a double pole (also known as a three way switch) means that the switch can connect one side of the circuit to two possible terminals on the other side. Finally a switch that has two poles and two throws is actually two switches built into a single device. This can be useful if two different circuits both need to be switched at the same time, for example if an AC supply voltage and DC supply voltage both need to be controlled simultaneously.
Push-button switches or momentary switches have a spring inside that allow the switch to be switched on or off momentarily and when released, the spring will allow the circuit to return to the default state. Such switches vary greatly in size, mounting styles, packages, and number of cycles before failure.
Dip switches are slide switches that can be used to configure electronic circuits. The small switches require a sharp instrument such as a pen or tweezers to slide the plastic sliders into position, which configures an option in a circuit.
Tilt switches can detect when the gadget is tilted beyond a certain angle, which closes the circuit, allowing current to flow. These devices allow the electronic gadget to detect something about its physical orientation in space.
Vibration switches contain a metal ball suspended inside a metal housing with insulating springs. When the device is shaken, the switch closes momentarily when the ball touches the housing. The switch can be ordered in a variety of sensitivities and is known as the poor maker’s accelerometer.
Reed switches connect its terminals in the presence of a magnetic field. These can be used with a magnet to detect when a door has been opened or closed.
Relays are switches that are controlled by an external voltage source. This allows an MCU to control any voltage that can be external to the gadget. Relays are typically used to allow the MCU to control much higher voltages, such as automotive 12V DC or household 120V AC power. When ordering relays, you must specify the control voltage as well as the operating voltage across the switch, and the isolation between the switched voltage and the control voltage. You wouldn’t want a high voltage to get through the switch to fry your MCU.
Connectors and Cabling
Connectors and cables allow your gadget to permanently or temporarily connect to the outside world. The simplest and cheapest of connections are formed by soldering wires to pads on the PCB and then providing strain relief with a glue compound that connects the jacket of the wire to the PCB, or by pinching the wire jacket in the enclosure as it is closed around the wire.
Standard connectors are more affordable than custom connectors due to economies of scale. Whenever custom cables are created, the cost of the non-recurring engineering needs to be factored into the economics of how many cables are going to be ordered.
Headers are metal pins that stand up from the PCB and allow a connector to be slid down over the pins, forming a temporary connection. These are used with ribbon cables to form a simple connector and cable solution, or by themselves as a board-to-board connection.
Jumpers are small lengths of wire or metal that “jumper” nearby header pins. These can be used to temporarily configure a circuit for debug purposes, and are found on many PC motherboards to clear the startup options to a default state, or for prototype cabling purposes.
Ribbon cables are formed by ganging many wires together to form a ribbon. The ribbon cable can provide a temporary or permanent connection between PCB boards and is readily available for ordering in various sizes and configurations, and attach to header pins on the PCB.
Spring pin connectors create a connection of a cable to a PCB board without a mating receiving socket. These types of cables are typically more expensive than standard cables and are generally reserved for factory programming or debug use. The advantage of these cables is that there is no physical connector required on the PCB, so there is zero cost per board during manufacturing.
Application-specific connectors and cables are available to connect your device to standard interfaces such as USB, HDMI, Ethernet, RCA audio cables, headphones, microphones, and more. It is often simpler and more cost effective to reuse a pre-existing cable and connector for your project than to create your own custom solution.
Sensors give your gadget the ability to detect or measure something about the environment that they operate within. They can be made up of simple unpowered physical sensors or all-in-one digital chips that perform analysis on the simple physical sensors and provide a digital interface to those sensors. Sensors can be cheap devices to detect a simple change in the environment or accurate, expensive devices that can require calibration procedures.
A passive sensor (i.e. a sensor that doesn’t require a power connection) is a device that is designed to create a measureable change in some electrical property that is brought on by the change in the physical nature of the material. For example, the application of heat, pressure, light, presence, or motion to a sensor can create a change in voltage, capacitance, piezoelectric, or some other electrical property that can then be measured by an external circuit.
A digital sensor will incorporate the passive sensor but combine that simple sensor with integrated circuits that provide an interface that make the measurement process simpler. These devices have the ability to offload the computational and time-critical tasks of sensor management so that your MCU can be free to do other things.
Most of the components of this section do not have a common schematic symbol. The schematic symbol is normally just a box with a part number above or below the box, and pin names on each pin. Likewise, the sensors themselves are a mix of different chip packages. Use the following section as a guide to the terminology that you will need to find more information at the component suppliers web sites.
Voltage sensors can be formed with transistors that are set to trigger at a specific voltage through the use of voltage dividers. Voltage can also be detected through peripherals on the MCU such as the Analog-to-Digital Converter (ADC) or the Analog Comparator. Voltage sensors can help your circuit detect proper operating voltage or take action to shut down or signal alarm if the voltage is leaving the safe operating zone.
Current sensors can be formed with a precision resistor of low resistance (under 1 ohm), whereby the voltage before and after the resistor is measured via an ADC or Analog Comparator and the current can then by calculated with the measured voltage drop and Ohm’s law. This information can be helpful in determining rate of battery consumption, or ensuring that a design does not consume more current than allowed.
Hall Effect sensors provide an analog output that changes proportional to the amount of magnetic flux in the environment. Two pins provide power and the third pin is the analog voltage output. Hall effect current sensors can detect the amount of current flowing in a wire since current flow produces a magnetic field. These sensors can also be used to build a proximity and/or distance detector by measuring the magnetic flux of a magnet embedded in the gadget.
Temperature sensors are available in a wide variety of technologies. Thermistors are resistors whose material properties are chosen such that the resistance changes reliably over temperature. Thermostats are switches that close at a specified temperature. Simple mechanical thermostats are formed with a coil of metal that changes shape with changes in temperature and causes a metal contact to close.
Thermocouples measure temperature by creating voltage at the union of two different types of metals. This allows a probe to be placed on the end of a long wire and the temperature of the wire to not affect the measurement of the temperature at the tip, where the measurement takes place.
Rotary encoders are used to measure the angle of rotation of a shaft. They can be based on optical or hall effect sensors. These are useful in any project that needs to determine the angle of a wheel or lever.
Strain gauges measure the amount of stretch in a material, which can then be used to calculate the tensile load. The gauges are attached to the material with a high-strength adhesive. Wires of a known resistance are embedded in the gauge in a particular pattern. As the strain gauge deforms, the resistance of the wires changes, which can then be correlated to the tensile load applied to the material.
Pressure sensors measure the pressure of a gas or liquid. There are many different types of pressure sensors that implement a wide range of mechanical solutions to determine the pressure. For example, a change in a diaphragm which has an internal spring can be measured with a simple potentiometer that changes the resistance of the sensor with spring deflection.
Microphones are a type of pressure sensor that is used to measure sound pressure waves.
Transducers act like both speakers and microphones for frequencies above the audible range, in the ultrasound frequency range. Transducers are used in proximity detection and in ultrasonic imaging systems.
Humidity sensors measure the amount of moisture in the air through resistive or capacitive changes in the sensor. The temperature must also be measured in order to calculate the relative humidity.
Accelerometers measure the amount of acceleration subjected to the sensor. The acceleration can be due to gravity, making a tilt sensor, or to the effects of movement of the sensor. Some accelerometers can offload processing of certain events, such as free fall, or the application of acceleration above a specific threshold, so that the MCU does not need to constantly monitor for those kinds of events. Accelerometers can be ordered for the number of axes that the device measures, or Degrees of Freedom (DOF), as well as the range of acceleration, specified in g’s.
Gyroscopes measure the angular rate of rotation or position in space. Similar to accelerometers, the gyroscopes have three axes or DOF and can be ordered according to the number of degrees of rotation per second that they can measure.
Magnetometers measure the strength and direction of a magnetic field and are used to measure the compass heading of the device, as long as nearby electric fields are not present to block the Earth’s magnetic field. Magnetometers have three axes or DOF.
Inertial Measurement Units (IMUs) combine the functions of accelerometers, gyroscopes and magnetometers to give a “9-axis” or 9 DOF sensor that allows a device to more precisely track its position in free space. This is known as sensor fusion.
In the next lesson, we will wrap up our overview of electronic components with a look at actuators, integrated circuits, and power regulation chips.