Interfacing to External Devices

Similar documents
Activity 4: Due before the lab during the week of Feb

Citrus Circuits Fall Workshop Series. Roborio and Sensors. Paul Ngo and Ellie Hass

CMPS11 - Tilt Compensated Compass Module

9DoF Sensor Stick Hookup Guide

Figure 1: Functional Block Diagram

Single-wire Signal Aggregation Reference Design

The PmodIA is an impedance analyzer built around the Analog Devices AD bit Impedance Converter Network Analyzer.

Lesson 4 Examples of the Sensors. Chapter-7 L04: "Internet of Things ", Raj Kamal, Publs.: McGraw-Hill Education

Figure 1: Functional Block Diagram

MSP430 Teaching Materials

IMU: Get started with Arduino and the MPU 6050 Sensor!

Interfacing Sensors & Modules to Microcontrollers

DNT24MCA DNT24MPA. Low Cost 2.4 GHz FHSS Transceiver Modules with I/O. DNT24MCA/MPA Absolute Maximum Ratings. DNT24MCA/MPA Electrical Characteristics

Sensors Fundamentals. Renesas Electronics America Inc Renesas Electronics America Inc. All rights reserved.

CMPS09 - Tilt Compensated Compass Module

Master Op-Doc/Test Plan

Multi-Sensor Integration and Fusion using PSoC

BW-IMU200 Serials. Low-cost Inertial Measurement Unit. Technical Manual

Low Power 3D Hall Sensor with I2C Interface and Wake Up Function

HG1120 INERTIAL MEASUREMENT UNIT (IMU) Installation and Interface Manual

PWM LED Color Control

DS1803 Addressable Dual Digital Potentiometer

I 2 C RedBot & DC Motor Servo Motor Control

DNT90MCA DNT90MPA. Low Cost 900 MHz FHSS Transceiver Modules with I/O

Roland Kammerer. 13. October 2010

802.11g Wireless Sensor Network Modules

I2C Demonstration Board I 2 C-bus Protocol

IMU Platform for Workshops

Project Final Report: Directional Remote Control

SCA100T-D07 2-AXIS HIGH PERFORMANCE ANALOG ACCELEROMETER

CENG 5931 HW 5 Mobile Robotics Due March 5. Sensors for Mobile Robots

Modern Robotics Inc. Sensor Documentation

A Novel Tracking System for AAL Based on Smartphone Technology. DIEEI University of Catania, Italy

MT6803 Magnetic Angle Sensor IC

CPS131. Data Sheet. Water Resistant Pressure Sensor. Consensic. Preliminary 0.1 January 2013 DAT 0006

SUNSTAR 传感与控制 TEL: FAX: SCA3100-D04 Data Sheet SCA3100-D04 3-AXIS HIGH PERFO

The ST7588T is a driver & controller LSI for graphic dot-matrix liquid crystal display systems. It contains 132 segment and 80

Systems & Devices Part 1

I2C Encoder. HW v1.2

A Wireless Mesh IoT sensor system FEATURES DESCRIPTION. Vicotee Njord series Nodes

Characteristic Sym Notes Minimum Typical Maximum Units Operating Frequency Range MHz. RF Chip Rate 11 Mcps RF Data Rates 1, 2, 5.

SCA3100-D04 3-AXIS HIGH PERFORMANCE ACCELEROMETER WITH DIGITAL SPI INTERFACE

IMU60 Inertial Measurement Unit

im M o t i o n S e n s o r D a t a S h e e t Ver. 1.2

DS4000 Digitally Controlled TCXO

Reference Diagram IDG-300. Coriolis Sense. Low-Pass Sensor. Coriolis Sense. Demodulator Y-RATE OUT YAGC R LPY C LPy ±10% EEPROM TRIM.

FAH4830 Haptic Driver for DC Motors (ERMs) and Linear Resonant Actuators (LRAs)

DNT90MC DNT90MP. Low Cost 900 MHz FHSS Transceiver Modules with I/O

Web-Enabled Speaker and Equalizer Final Project Report December 9, 2016 E155 Josh Lam and Tommy Berrueta

Accelerometer user manual

Carbon Dioxide (Tiny CO2) Gas Sensor. Rev TG400 User Manual

In this lecture, we will look at how different electronic modules communicate with each other. We will consider the following topics:

Lab 1.2 Joystick Interface

LAX016 Series Logic Analyzer User Guide

+Denotes lead-free package. *EP = Exposed paddle. V CC GND AGND AV CC GND I 2 C INTERFACE. -35dB TO +25dB GAIN AUDIO SOURCE AUDIO AMPLIFIER DS4420

Brian Hanna Meteor IP 2007 Microcontroller

FEATURES DESCRIPTION APPLICATIONS BLOCK DIAGRAM. PT Channel Electronic Volume Controller IC

MiCo SnP HT-01D HT-01D. Humidity & Temperature Sensor Module. User s Manual. MiCo SnP. 1/16

CBM7021 Capacitive Touch Sensor Controller Datasheet Chipsbank Microelectronics Co., Ltd.

AMS0805WAH. CATALOG No.: AMS0805WAH. Motion Sensor Data Sheet Ver Advanced Material on Technology

Inclination Measurement Based on MEMS Accelerometer

DNT2400. Low Cost 2.4 GHz FHSS Transceiver Module with I/O

INF8574 GENERAL DESCRIPTION

RB-Dev-03 Devantech CMPS03 Magnetic Compass Module

Receiver 10-5 BER -100 dbm Transmitter RF Output Power 1 10 or 63 mw mw Antenna Impedance 50 Ω

I hope you have completed Part 2 of the Experiment and is ready for Part 3.

ADC081C021/ADC081C027 I 2 C-Compatible, 8-Bit Analog-to-Digital Converter (ADC) with Alert Function

Beyond-the-Rails 8 x SPST

EL6483: Sensors and Actuators

DNT900. Low Cost 900 MHz FHSS Transceiver Module with I/O

ADC081C021/ADC081C027

BW-VG525 Serials. High Precision CAN bus Dynamic Inclination Sensor. Technical Manual

Measuring and Implementing Lower Limb Motion Using Inertial Measurement Unit

OS3D-FG MINIATURE ATTITUDE & HEADING REFERENCE SYSTEM MINIATURE 3D ORIENTATION SENSOR OS3D-P. Datasheet Rev OS3D-FG Datasheet rev. 2.

Application Note. Communication between arduino and IMU Software capturing the data

Debugging a Boundary-Scan I 2 C Script Test with the BusPro - I and I2C Exerciser Software: A Case Study

Serial Communication AS5132 Rotary Magnetic Position Sensor

X3M. Multi-Axis Absolute MEMS Inclinometer Page 1 of 13. Description. Software. Mechanical Drawing. Features

Integrated Dual-Axis Gyro IDG-1004

External Peripherals: Interfacing

ADVANCED EMBEDDED MONITORING SYSTEM FOR ELECTROMAGNETIC RADIATION

MicroMag2 2-Axis Magnetic Sensor Module

MLX Triaxis Magnetometer IC With High Speed Serial Interface. Features and Benefits. Applications. Ordering Code

MB7137, MB7138, MB7139

RFM-CSB-2. Features of the Module include: The RFM-CSB-2 module

PNI MicroMag 3. 3-Axis Magnetic Sensor Module. General Description. Features. Applications. Ordering Information

Arduino Microcontroller Processing for Everyone!: Third Edition / Steven F. Barrett

DATASHEET. X-band Transmitter

DS1807 Addressable Dual Audio Taper Potentiometer

Servo click. PID: MIKROE 3133 Weight: 32 g

ARDUINO BASED CALIBRATION OF AN INERTIAL SENSOR IN VIEW OF A GNSS/IMU INTEGRATION

UM7 DATASHEET INTRODUCTION FEATURES. Rev. 1.3 Released 10/27/2014

EEL 4744C: Microprocessor Applications. Lecture 9. Part 2. M68HC12 Serial I/O. Dr. Tao Li 1

MEMS Accelerometer Specifications and Their Impact in Inertial Applications

FLCS V2.1. AHRS, Autopilot, Gyro Stabilized Gimbals Control, Ground Control Station

DISCONTINUED. Modulation Type Number of RF Channels 15

ILI2117 Capacitive Touch Controller

2F. No.25, Industry E. 9 th Rd., Science-Based Industrial Park, Hsinchu, Taiwan Application Note of OGM220, AN001 V1.8

ME 461 Laboratory #5 Characterization and Control of PMDC Motors

3-Channel Fun LED Driver

Transcription:

Interfacing to External Devices Notes and/or Reference 6.111 October 18, 2016 Huge Amount of Self-Contained Devices Sensors A-to-D converters D-to-A Memory Microcontrollers Etc We need ability/fluency to extract info from and work with them 1

Case Study 9 axis IMU (Inertial Measurement Unit) Accelerometer Gyroscope Magnetometer One of the only real MEMS (MicroElectroMechanical Systems) applications that has gone full-scale (others might be TI s DMD, gyroscopes, microphones, some microfluidics, Si resonators, Piezoelectrics from Inkjets, etc ) Accelerometers First MEMS accelerometer: 1979 Position of a proof mass is capacitively sensed and decoded to provide acceleration data Spring Proof Mass Spring d a " Δd Measure Capacitance via Impedance Divider SEM of two-axis accelerometer 2

Uses of Acceleration Measurements: Acceleration can be used to detect motion (pedometer, drop detection): a 1 = a. 2 + a ' 2 + a " 2 Accelerometer directions +X, +Y, +Z Chip Use gravity and trig to find orientation: a. θ ' = tan,- a " a. a " g Problems Accelerometers have huge amounts of high-frequency noise To fix, usually Low Pass Filter the raw signal This cuts down on frequency response though L θ ' [n] = θ ' [n 1]β + 1 β tan,- a "[n 1] a. [n 1] a. X acceleration a " z acceleration 0 < β < 1 θ ' Filter Coefficient Angle estimate around y axis 3

Bring in Gyroscopes Provide Direct Angular Velocity which we can integrate to get angle Very little high-frequency noise, but lots of low frequency noise (Gyros drift like crazy) Gyro readings are around the axis they refer to (use right-hand rule): angle (arb. units) Angular velocity (arb. units) time (seconds) Gyro Operation Resonating Resonating Proof Mass Electrostatic Drive Piezoelectric Drive Turning out-of-plane: Proof-mass fights turn Detect deviation via capacitance Measure Capacitance via Impedance Divider Spring Proof Mass Spring Measure Capacitance via Impedance Divider Do this for all three axes Rotation of Device Changes in capacitance measured at different points Scale not accurate/nor design details 4

How to use Gyro Readings: Because of Drift (low frequency noise/offset) you want to avoid doing much long-term integration Having beta less than unity ensures any angle that comes from gyro reading will eventually disappear, but in short term it will dominate Depending on time step: θ ' n = βθ ' n 1 + Tg ' [n 1] 0 < β < 1 Filter Coefficient β 0.95 starting point g ' T Gyro y reading Time Step What to do? Using only accelerometer, leaves us blind to motion/change in the short term but fine in the long-term Using only gyroscope, leaves us blind in the long term, but good in the short term What to do? 5

Merge the signals Complementary Filter: θ ' n = β θ ' n 1 + Tg ' [n 1] + 1 β tan,- a "[n 1] a. [n 1] 0 < β < 1 Filter Coefficient g ' Gyro y reading a. X acceleration a T Time Step " z acceleration β 0.95 good starting point Could also do Kalman Filter (LQE) if desired (or others) How to get Access to the signals in first place? Some accelerometers are analog out (can therefore read them with an A-to-D converter) (ADXL335, for example) These have limited functionality and also it is analog so there s the whole noise issue...which is not nice Most flavors of sensors are digital 6

MPU-9250 3-axis Accelerometer (16-bit readings) 3-axis Gyroscope (16-bit readings) 3-axis Magnetic Hall Effect Sensor (Compass) (16 bit readings) SPI or I2C communication (!) no analog out On-chip Filters (programmable) Board: $8.00 from Ebay On-chip programmable offsets Chip: $5.00 in bulk On-chip programmable scale! On-chip sensor fusion possible (with quaternion output)! Interrupt-out (for low-power applications!) On-chip sensor fusion and other calculations (can do orientation math onchip or pedometry even) So cheap they usually aren t even counterfeited! J Common Device-Device Communication Protocols Parallel (not so much anymore) Serial (UART) (still common in some communication and GPS devices) SPI (Serial Peripheral Interface) very common I2C (Inter-Integrated Circuit Communication) very common 7

Serial (UART) Stands for Universal Asynchronous Receiver Transmitter Requires agreement ahead-of-time between devices regarding things like clock rate (BAUD), etc Two wire communication Cannot really share (every pair of devices needs own pair of lines) TX/RX Data rate really < 115.2Kbps Device 1 Device 2 RX/TX SPI Stands for Serial-Peripheral Interface Four Wires: MOSI: Master-Out-Slave-In MISO: Master-In-Slave-Out SCK: Clock CE/CS (Chip Enable or Chip Select) Master MISO MOSI SCK removes need to agree ahead of time on data rate (from UART) High Data Rates: (1MHz up to ~70 MHz clock (bits)) SCK CE0/CS0 Slave 8

SPI Can share MOSI/MISO Bus Master Addition of multiple slaves requires additional select wires Hardware/firmware for SPI is pretty easy to implement: Wires are uni-directional Classic duh sort of approach to digital communication, but very robust. MOSI MISO SCK CE0/CS0 CE1/CS1 Slave1 Slave2 i2c Stands for Inter-Integrated Circuit communication Invented in 1980s Two Wire, One for Clock, one for data (both directions) Usually 100kHz or 400 khz clock (newer versions go to 3.4 MHz) Master SDA Slave SCL 9

On i2c Multiple Devices Require Same # of Wires Devices come with their own ID numbers (originally a 7 bit value but more modern ones have 10 bits) allows potentially up to 2^7 devices or 2^10 on a bus (theoretically anyways) Master SCL SDA Slave1 ID s are specified at build, usually several to choose from and you select them by pulling external pins HI or LOW Slave2 More to story (need pull-up resistors) i2c uses an open drain Meaning both Master and Slave are either: LOW High-Impedance Need external pull-up resistors 3.3V 3.3V 4.7kΩ 4.7kΩ Master SDA Slave1 SCL 10

Tri-State inout cannot be a reg ever, ever it is closer to a wire...usual way to work with them is the following: In verilog inout sda; reg sda_val; assign thing = sda_val? 1 bz: 1 b0; As a result: inout sda; reg sda_val; assign sda = sda_val? 1 bz: 1 b0; 3.3V 4.7kΩ SDA Wanna write to SDA? sda_val <= 0; //or 1 if desired :wq SDA in Wanna read to SDA? sda_val <= 1; //wait clock cycle some_reg <= sda; //read from input V GS Mode Master Slave Master Transmit HiZ (HI) or LOW HiZ (listening) Slave ACK/NACK HiZ (listening) HiZ (HI) or LOW Slave Transmit HiZ (listening) HiZ (HI) or LOW Master ACK/NACK HiZ (HI) or LOW HiZ (listening) 11

i2c Operation Data is conveyed on SDA (Either from Master or Slave depending on point during communication) SCL is 50% duty cycle SDA generally changes on falling edge of SCL (isn t required) SDA sampled at rising edge of SCL Master is in charge of setting SCL frequency and driving it Meanings I: (Start, Stop, Sampling) Idle State SDA and SCL sit HI Master Claims Bus (START) By pulling SDA LOW while SCL is HI Master Releases Bus (STOP) By pulling SDA HI while SCL is HI SDA: HI LO SCL: HI LO Data/State on SDA transitions @ negedge of SCL* Data from SDA sampled @ posedge of SCL *not specified but probably easiest spot to do 12

Meanings II Address First thing sent by Master is 7 bit address (10 bit in more modern i2c has some leading 11111 s in it..don t worry about that) If a device on the bus possesses that address, it acknowledges (ACK/NACK=0) and it becomes the slave All other devices (other than Master/Slave) will ignore until STOP signal appears later on. Meanings III (Read/Write Bit) After sending address, a Read/Write Bit is specified by Master on SDA: If Write (0) is specified, the next byte will be a register to write to, and following bytes will be information to write into that register If Read (1) is specified, the Slave will start sending data out, with the Master acknowledging after every byte (until it wants data to not be sent anymore) 13

Meanings IV (ACK/NACK) After every 8 bits, it is the listener s job to acknowledge or not acknowledge the data just sent (called an ACK/NACK) Transmitter pulls SDA HI and listens for next reading (@posedge of SCL): If LOW, then receiver acknowledges data If remains HI, no acknowledgement Transmitter/Receiver act accordingly Meanings V For Master to write to Slave: START Send Device Address (with Write bit) Send register you want to write to Send data until you re satisfied STOP For Master to read from Slave: START Send Device Address (with Write bit) Send register you want to read from ReSTART communication Send Device Address (With Read bit) Read in bits After every 8 bits, it is Master s job to acknowledge Slave continued acknowledgement leads to continued data out by Slave. Not-Acknowledge says no more data to Slave STOP leads to Master ceasing all communication 14

Implementing i2c on FPGA with MPU9250: Made master i2c controller in Verilog Used MPU9250 Data sheet: 42 pages (basic functionality, timing requirements, etc ) MPU9250 Register Map: 55 pages State-Machine Implementation of i2c Master Continuously reads 2 bytes starting at the 0x3B register (X accelerometer data) Print out value in hex in LEDs 34 States Clocked at 200kHz, and creates 100 khz SCL Change SDA on falling edge of SCL Sample SDA on rising edge of SCL 15

State-Machine Implementation of i2c Master Redundant states (repeated READ/WRITE, ADDRESS, ACK/NACK, etc ) ARM manual describes ~20 state FSM Included code on site for reference/starting point Diagram: on next page for reference 200 more lines STOP IDLE START1 ADDRESS1 READWRITE1 ACKNACK1A IDLE 7x ACKNACK1C NACK NACK READ4 8x READ3 ACK4 ADDRESS2 ADDRESS3 7x START2 REGISTER1 8x ACK READ2 ACKNACK3A ADDRESS4 REGISTER2 8x ACK ACKNACK3C READ1 READWRITE2 ACKNACK2C ACKNACK2A ACK NACK IDLE NACK IDLE 16

Communication Part VCC GND SCL Nexys4 SDA MPU9250 1 0 1 1 0 1 0 0 0 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 0 1 1 1 0 0 SDA 01010101010101010101010101010101010101110101010101010101010101010101010101010 SCL Communication Part VCC GND SCL SDA Nexys4 Acknowledge=0 ReStart MPU9250 Write=0 Read=1 Acknowledge=0 Start Device Address (0x68) Device Register (0x3B) Device Address (0x68) Data Read In SDA 1 0 1 1 0 1 0 0 0 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 0 1 1 1 0 0 SCL 01010101010101010101010101010101010101110101010101010101010101010101010101010 17

Communication Part VCC GND SCL Nexys4 I claim this bus Hey, 0x68 I wanna tell you something I m here. Sounds good Look at your 0x6B register OK Different thought Hey, 0x68 SDA Read to me from where you re looking MPU9250 For sure 0x6D More, please SDA SCL 1 0 1 1 0 1 0 0 0 0 0 0 0 1 1 1 0 1 1 0 1 0 0 1 1 0 1 0 0 0 1 0 0 1 1 0 1 1 1 0 0 01010101010101010101010101010101010101110101010101010101010101010101010101010 Nexys4 (Master) Dialog MPU9250 (Slave) Dialog Communication in Real-Life: Data being sent from MPU9250 SDA = Yellow SCL = Purple Triggered on leaving IDLE state 18

Running and reading X acceleration: HOOKUP Horizontal: 16 hfd88 = 16 b1111_1101_1000_1000 (2 s complement) Flip bits to get magnitude: 16 b0000_0010_0111_0111 =-315 Full-scale (default +/- 2g) -315/(2**15)*2g = -0.02g J makes sense Vertical: 16 h4088 = 16 b0100_0000_1000_1000 (2 s complement) Leave bits to get magnitude: 16 b0100_0000_1000_1000 =+16520 Full-scale (default +/- 2g) -16520/(2**15)*2 = +1.01g J makes sense! Clock-Stretching (Cool part of i2c!!!) Normally Master drives SCL, but since Master drives SCL high by going hiz, it leaves the option open for Slave to step in and prevent SCL from going high by setting SCL LOW Master wanted to pull SCL HI but slave prevents by going LOW (red never happens) SCL: Once Slave goes HiZ again, Master picks back up on SCL Allows Slave a way to buy time/slow down things (if it requires multiple clock cycles to process incoming data and/or generate output) 19

Final Thoughts What about SPI or Serial? If you can implement i2c, the others are easier. SPI is also a little less standardized Generally with communication protocols, the more wires, the easier the protocol/less overhead SPI (four wires) Serial TX/RX (little bit more complicated, but not too bad) Check out the example i2c code from this lecture see if you can add clock-stretching! (not required) 20