Top Banner
Sensors and Peripherals SUMMER SCHOOL
36
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Sensors and Peripherals

Sensors and PeripheralsSUMMER SCHOOL

Page 2: Sensors and Peripherals

2

Outline

Sensors◦ Button◦ Potentiometer◦ Light Sensor◦ Temperature Sensor◦ Distance◦ Gas Sensor◦ Digital Sensors

Peripherals◦ LED◦ 7 Segment ◦ 74595◦ LCD

Questions

Page 3: Sensors and Peripherals

3

Sensors

Image from http://energia.nu/rapid-prototyping-made-easy-with-the-grove-base-boosterpack-starter-kit-from-seeedstudio/

Page 4: Sensors and Peripherals

4

Types Analog

◦ Two pins◦ There pins◦ Use pin functions

Digital◦ Use some digital protocol◦ Use libraries Two pins

Three pins

Page 5: Sensors and Peripherals

5

Measuring Analog Voltage divider

We measure the voltage in Vout

We have errors◦ Read many values and average them

Image from https://learn.sparkfun.com/tutorials/voltage-dividers/applications

Page 6: Sensors and Peripherals

6

Button “Analog Sensor”

Resistance◦ Infinite if released◦ 0 if pressed

Page 7: Sensors and Peripherals

7

Button Debounce When the button is pressed

◦ Signal is bouncing◦ Fast reading results in 0s and 1s

Solutions◦ Read more values and average them◦ Use a trigger

Image from http://www.engscope.com/pic-example-codes/basic-io-button-debounce/

Page 8: Sensors and Peripherals

8

Potentiometer Variable resistance

Connect the ◦ middle pin◦ One Side pin

Page 9: Sensors and Peripherals

9

Potentiometer is a voltage divider

Variable resistance

Connect the three pins◦ One side pin to Vcc◦ The middle pin the analog◦ One Side pin to the ground

Page 10: Sensors and Peripherals

10

Light Sensor Photo Resistor

◦ 2 pins◦ R inverse proportional with the light

Sensor◦ Photo Resistor◦ Voltage divider◦ Three pins

Image from https://inventrom.wordpress.com/2014/11/27/the-thing-in-internet-of-things/

Page 11: Sensors and Peripherals

11

Photo Resistor

Image from https://inventrom.wordpress.com/2014/11/27/the-thing-in-internet-of-things/

Page 12: Sensors and Peripherals

12

Temperature Sensor Thermistor

◦ Resistance

Parameters◦ R25 resistance - 25 degrees◦ B – constant

Page 13: Sensors and Peripherals

13

Temperature Sensor LM35 Temperature Sensor

Page 14: Sensors and Peripherals

14

Gas Sensor Gas Sensor

◦ Heats up◦ Three pins

◦ Vcc◦ Signal◦ Ground

Page 15: Sensors and Peripherals

15

Distance Sensor SRF04

◦ Ultrasonic◦ Sends a pulse◦ Real time system◦ Works on microcontrollers

Image from http://www.robot-electronics.co.uk/htm/srf04tech.htm

Page 16: Sensors and Peripherals

16

Distance Sensor Infrared

◦ Analog◦ Measure voltage

Page 17: Sensors and Peripherals

17

Digital Sensors Use protocols

◦ SPI◦ I2C

Page 18: Sensors and Peripherals

18

SPI Master / Slave

◦ One Master◦ Several slaves◦ Master always initiates communication

Wires◦ MOSI – Master Out Slave In◦ MISO – Master In Slave Out◦ SCLK – SPI Clock◦ SSn – Slave Select

Speeds

Page 19: Sensors and Peripherals

19

SPI

Image from http://dlnware.com/theory/SPI-Transfer-Modes

Page 20: Sensors and Peripherals

20

I2C Master / Slave

◦ One or more masters◦ Several slaves◦ Master always initiates communication◦ Each device has an address

Wires◦ SDA – Serial Data Line◦ SCL – Serial Clock Line

Speeds◦ Standard 100 Kbit◦ Up to 3.4 Mbit

Page 21: Sensors and Peripherals

21

I2C

Image from http://opencores.org/project,openmsp430,downloads

Page 22: Sensors and Peripherals

22

Microcontrollers and ComputersMICROCONTROLLERS

SPI◦ Slave or master◦ Hardware ◦ Software

I2C◦ Slave or master◦ Hardware ◦ Software

COMPUTERS

SPI◦ Master◦ Hardware

I2C◦ Master◦ Hardware

Page 23: Sensors and Peripherals

23

Peripherals

Page 24: Sensors and Peripherals

24

LED LED

◦ Diode◦ Two legs

◦ Anode (+)◦ Cathode (-)

◦ Start lighting up if it has more than 0.6V◦ Infinite resistance up to 0.6 V◦ 0 resistance when it lights up

Page 25: Sensors and Peripherals

25

7 Segment Display Seven LEDS

◦ Common Cathode◦ Common Anode◦ Who many pins do we need for a digit?

Page 26: Sensors and Peripherals

26

7 Segment Display Seven LEDS

◦ Common Cathode◦ Common Anode◦ Who many pins do we need for a digit?◦ Multiplexing

◦ Microcontrollers

Page 27: Sensors and Peripherals

27

Shift Register Serial to Parallel Register

Pins are limited◦ Use expanders◦ Shift register

QA .. QH – data stored

OE – enable (if 0)

SEN – Serial input

SRCLK – Serial clock

RCLK – register clock (outputs)

SRCLR – clear

QH’ – shift output bit

Page 28: Sensors and Peripherals

28

Shift Register Serial to Parallel Register

QA .. QH – data stored

OE – Output enable

SEN – Shift In

SRCLK – Shift clock

RCLK – Latch clock

SRCLR – clear

QH’ – Shift out

Page 29: Sensors and Peripherals

29

Shift Register

Image from http://makeyourownchip.tripod.com/74hc595.html

Page 30: Sensors and Peripherals

30

LCD LCD

◦ 16 pins◦ Two data protocols

◦ 4 bit◦ 8 bit

◦ Microcontroller◦ I2C version (with an adapter)

◦ How many pins?

Page 31: Sensors and Peripherals

31

Signal Processing

Page 32: Sensors and Peripherals

32

Octave Similar to Matlab

Works on IoT Servers

Process signals◦ Export values from dashboard

Page 33: Sensors and Peripherals

33

IoT Server

Page 34: Sensors and Peripherals

34

Octave Application Make computations

Plot functions

View plot functions in the browser◦ Use the print file.svg

Enable popups

Page 35: Sensors and Peripherals

35

Octave Signal

◦ the message is sent to octave◦ msg will be sent◦ Good for mathematics

Page 36: Sensors and Peripherals

36

Questions?