Advertisement

Lecture 4 - Sensors and Peripherals

Jan. 24, 2018
Advertisement

More Related Content

Advertisement
Advertisement

Lecture 4 - Sensors and Peripherals

  1. Sensors and Peripherals
  2. Outline Sensors ◦ Button ◦ Potentiometer ◦ Light Sensor ◦ Temperature Sensor ◦ Distance ◦ Gas Sensor ◦ Digital Sensors Peripherals ◦ LED ◦ 7 Segment ◦ 74595 ◦ LCD Questions 2
  3. Sensors 3 Image from http://energia.nu/rapid-prototyping-made-easy-with-the-grove-base-boosterpack-starter-kit-from-seeedstudio/
  4. Types 4 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 5 Image from https://learn.sparkfun.com/tutorials/voltage-dividers/applications
  6. Button “Analog Sensor” Resistance ◦ Infinite if released ◦ 0 if pressed 6
  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 7 Image from http://www.engscope.com/pic-example-codes/basic-io-button-debounce/
  8. Potentiometer Variable resistance Connect the ◦ middle pin ◦ One Side pin 8
  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 9
  10. Light Sensor Photo Resistor ◦ 2 pins ◦ R inverse proportional with the light Sensor ◦ Photo Resistor ◦ Voltage divider ◦ Three pins 10 Image from https://inventrom.wordpress.com/2014/11/27/the-thing-in-internet-of-things/
  11. Photo Resistor 11 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 12 measuredV = pin 5 1023 TR = 5 measuredV R ratio = 1 B ln( TR 25R ) Temperature = 1 1 298 +ratio
  13. Temperature Sensor LM35 Temperature Sensor 13 measuredV = pin 5 1023 Temperature = mesuredV *100
  14. Gas Sensor Gas Sensor ◦ Heats up ◦ Three pins ◦ Vcc ◦ Signal ◦ Ground 14
  15. Distance Sensor SRF04 ◦ Ultrasonic ◦ Sends a pulse ◦ Real time system ◦ Works on microcontrollers 15 Image from http://www.robot-electronics.co.uk/htm/srf04tech.htm
  16. Distance Sensor Infrared ◦ Analog ◦ Measure voltage 16
  17. Digital Sensors Use protocols ◦ SPI ◦ I2C 17
  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 18
  19. SPI 19 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 20
  21. I2C 21 Image from http://opencores.org/project,openmsp430,downloads
  22. Microcontrollers and Computers MICROCONTROLLERS SPI ◦ Slave or master ◦ Hardware ◦ Software I2C ◦ Slave or master ◦ Hardware ◦ Software COMPUTERS SPI ◦ Master ◦ Hardware I2C ◦ Master ◦ Hardware 22
  23. Peripherals 23
  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 24
  25. 7 Segment Display Seven LEDS ◦ Common Cathode ◦ Common Anode ◦ Who many pins do we need for a digit? 25
  26. 7 Segment Display Seven LEDS ◦ Common Cathode ◦ Common Anode ◦ Who many pins do we need for a digit? ◦ Multiplexing ◦ Microcontrollers 26
  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 27
  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 28
  29. Shift Register 29 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? 30
  31. Arduino Firmata 31
  32. Standard Firmata Standard Firmata https://pastebin.com/uVgsFvD0 32
  33. Questions? 33
Advertisement