sensors and peripherals
TRANSCRIPT
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
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/
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/
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
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
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
22
Microcontrollers and ComputersMICROCONTROLLERS
SPI◦ Slave or master◦ Hardware ◦ Software
I2C◦ Slave or master◦ Hardware ◦ Software
COMPUTERS
SPI◦ Master◦ Hardware
I2C◦ Master◦ Hardware
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
30
LCD LCD
◦ 16 pins◦ Two data protocols
◦ 4 bit◦ 8 bit
◦ Microcontroller◦ I2C version (with an adapter)
◦ How many pins?
34
Octave Application Make computations
Plot functions
View plot functions in the browser◦ Use the print file.svg
Enable popups