sensors and peripherals

36
Sensors and Peripherals SUMMER SCHOOL

Upload: alexandru-radovici

Post on 03-Aug-2015

227 views

Category:

Education


3 download

TRANSCRIPT

Sensors and PeripheralsSUMMER SCHOOL

2

Outline

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

Peripherals◦ LED◦ 7 Segment ◦ 74595◦ LCD

Questions

3

Sensors

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

4

Types Analog

◦ Two pins◦ There pins◦ Use pin functions

Digital◦ Use some digital protocol◦ Use libraries Two pins

Three pins

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

6

Button “Analog Sensor”

Resistance◦ Infinite if released◦ 0 if pressed

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/

8

Potentiometer Variable resistance

Connect the ◦ middle pin◦ One Side pin

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

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/

11

Photo Resistor

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

12

Temperature Sensor Thermistor

◦ Resistance

Parameters◦ R25 resistance - 25 degrees◦ B – constant

13

Temperature Sensor LM35 Temperature Sensor

14

Gas Sensor Gas Sensor

◦ Heats up◦ Three pins

◦ Vcc◦ Signal◦ Ground

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

16

Distance Sensor Infrared

◦ Analog◦ Measure voltage

17

Digital Sensors Use protocols

◦ SPI◦ I2C

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

19

SPI

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

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

21

I2C

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

22

Microcontrollers and ComputersMICROCONTROLLERS

SPI◦ Slave or master◦ Hardware ◦ Software

I2C◦ Slave or master◦ Hardware ◦ Software

COMPUTERS

SPI◦ Master◦ Hardware

I2C◦ Master◦ Hardware

23

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

25

7 Segment Display Seven LEDS

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

26

7 Segment Display Seven LEDS

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

◦ Microcontrollers

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

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

29

Shift Register

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

30

LCD LCD

◦ 16 pins◦ Two data protocols

◦ 4 bit◦ 8 bit

◦ Microcontroller◦ I2C version (with an adapter)

◦ How many pins?

31

Signal Processing

32

Octave Similar to Matlab

Works on IoT Servers

Process signals◦ Export values from dashboard

33

IoT Server

34

Octave Application Make computations

Plot functions

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

Enable popups

35

Octave Signal

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

36

Questions?