1.7. Sensors#

A mechatronic device can only respond and make decisions by sensing the real world. Sensors translate real world phenomena into electrical signals that can be interpreted by a microcontroller.

Sensors are external to the microcontroller and connect to its pins.

1.7.1. Types of Sensors#

There is a wide variety of types of stimulus that can be detected. Generally we can divide sensor types into the following categories:

  • Motion and Position tell your microcontroller how something is moving.

  • Light and Colour convert brightness or colour into an electrical signal.

  • Environmental watch the environmental conditions like air temperature around the device.

  • Proximity and Touch tell a system when something is close or making contact.

  • Force and Fluid Pressure sensors feel push, pull or squeeze.

At the same time there is also variation in the quality of the sensors such as their precision, error, response time. Many of those factors are driven by cost, size of the sensor and the type of environment that it needs to survive. For example, an optical encoder counting the RPM of a wheel might have great precision but if the vehicle drives through muddy environment the sensor might get visually blocked. Engineers might choose a magnetic Hall-effect encoder sealed behind a cover, which has lower resolution but a little bit of mud won’t affect it.

../../_images/sensor_collage.png

1.7.2. Sensor Data#

Sensors send data to the microcontroller in three main ways, which we will discuss in more detail later:

  • Voltages - converted by Analogue-to-Digital converters on the microcontroller

  • PWM - digital pulses of varying widths

  • Digital buses - protocols that support multiple devices over a shared wire and complex data transfer