Arbeitskreis Hardware. Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz michael.rohs@ifi.lmu.de MHCI Lab, LMU München



Similar documents
Arbeitskreis Hardware. Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz MHCI Lab, LMU München

AVR Timer/Counter. Prof Prabhat Ranjan DA-IICT, Gandhinagar

DS1307ZN. 64 x 8 Serial Real-Time Clock

PROJECT PRESENTATION ON CELLPHONE OPERATED ROBOTIC ASSISTANT

Elettronica dei Sistemi Digitali Costantino Giaconia SERIAL I/O COMMON PROTOCOLS

Embedded Systems Design Course Applying the mbed microcontroller

Data Acquisition Module with I2C interface «I2C-FLEXEL» User s Guide

Interfacing Of PIC 18F252 Microcontroller with Real Time Clock via I2C Protocol

DS1621 Digital Thermometer and Thermostat

DS1621 Digital Thermometer and Thermostat

PWM IN AVR. Developed by: Krishna Nand Gupta Prashant Agrawal Mayur Agarwal

MODULE BOUSSOLE ÉLECTRONIQUE CMPS03 Référence :

Tire pressure monitoring

DS Wire Digital Thermometer and Thermostat

A 5 Degree Feedback Control Robotic Arm (Haptic Arm)

AVR Butterfly Training. Atmel Norway, AVR Applications Group

Arbeitskreis Hardware. Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz MHCI Lab, LMU München

HDMM01 V1.0. Dual-axis Magnetic Sensor Module With I 2 C Interface FEATURES. Signal Path X

MMC314xMR. Ultra Small 3-axis Magnetic Sensor, With I 2 C Interface. Signal Path X. Signal Path Y. Signal Path Z FEATURES

AVR131: Using the AVR s High-speed PWM. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

Develop a Dallas 1-Wire Master Using the Z8F1680 Series of MCUs

64 x 8, Serial, I 2 C Real-Time Clock

Allows the user to protect against inadvertent write operations. Device select and address bytes are Acknowledged Data Bytes are not Acknowledged

Small, Low Power, 3-Axis ±3 g Accelerometer ADXL335

Programmable Single-/Dual-/Triple- Tone Gong SAE 800

PACKAGE OUTLINE DALLAS DS2434 DS2434 GND. PR 35 PACKAGE See Mech. Drawings Section

Servo Info and Centering

DS12885, DS12885Q, DS12885T. Real Time Clock FEATURES PIN ASSIGNMENT

The I2C Bus. NXP Semiconductors: UM10204 I2C-bus specification and user manual HAW - Arduino 1

USING I2C WITH PICAXE

MXD7202G/H/M/N. Low Cost, Low Noise ±2 g Dual Axis Accelerometer with Digital Outputs

INTRODUCTION TO SERIAL ARM

Hardware Connections between Arduino and IMU Nori Wilkins Apr. 5, 2013

DS1821 Programmable Digital Thermostat and Thermometer

HANDLING SUSPEND MODE ON A USB MOUSE

Embedded Systems on ARM Cortex-M3 (4weeks/45hrs)

AND8336. Design Examples of On Board Dual Supply Voltage Logic Translators. Prepared by: Jim Lepkowski ON Semiconductor.

Microcontroller Based Low Cost Portable PC Mouse and Keyboard Tester

Tutorial for MPLAB Starter Kit for PIC18F

- 35mA Standby, mA Speaking pre-defined phrases with up to 1925 total characters.

Data Sheet. Adaptive Design ltd. Arduino Dual L6470 Stepper Motor Shield V th November L6470 Stepper Motor Shield

Atmel Norway XMEGA Introduction

POCKET SCOPE 2. The idea 2. Design criteria 3

Supply voltage Supervisor TL77xx Series. Author: Eilhard Haseloff

System theremino MasterDIL-V3

TLI4946. Datasheet TLI4946K, TLI4946-2K, TLI4946-2L. Sense and Control. May 2009

Current Loop Tuning Procedure. Servo Drive Current Loop Tuning Procedure (intended for Analog input PWM output servo drives) General Procedure AN-015

Application Note: Using the Motor Driver on the 3pi Robot and Orangutan Robot Controllers

Real Time Clock USB Evaluation Board V3.0

The Programming Interface

1. Learn about the 555 timer integrated circuit and applications 2. Apply the 555 timer to build an infrared (IR) transmitter and receiver

DS2401 Silicon Serial Number

Using the Siemens S65 Display

ET-BASE AVR ATmega64/128

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

AT15007: Differences between ATmega328/P and ATmega328PB. Introduction. Features. Atmel AVR 8-bit Microcontrollers APPLICATION NOTE

If an occupancy of room is zero, i.e. room is empty then light source will be switched off automatically

Serial port interface for microcontroller embedded into integrated power meter

AN141 SMBUS COMMUNICATION FOR SMALL FORM FACTOR DEVICE FAMILIES. 1. Introduction. 2. Overview of the SMBus Specification. 2.1.

AVR126: ADC of megaavr in Single Ended Mode. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

LEVERAGING FPGA AND CPLD DIGITAL LOGIC TO IMPLEMENT ANALOG TO DIGITAL CONVERTERS

Pulse Width Modulation

UniPi technical documentation REV 1.1

Wireless Temperature

Pulse Width Modulation (PWM) LED Dimmer Circuit. Using a 555 Timer Chip

Serial Communications

revolution Contents: Introduction Power 28-pin Project Board with input/output cables

Hello, and welcome to this presentation of the STM32L4 reset and clock controller.

CHAPTER 11: Flip Flops

DIGITAL-TO-ANALOGUE AND ANALOGUE-TO-DIGITAL CONVERSION

Flight Controller. Mini Fun Fly

Pulse Width Modulation Applications

The quadrature signals and the index pulse are accessed through five inch square pins located on 0.1 inch centers.

Signal Processing in So.ware and Electric Field Sensing

Computer Systems Structure Input/Output

User s Manual of Board Microcontroller ET-MEGA2560-ADK ET-MEGA2560-ADK

Palaparthi.Jagadeesh Chand. Associate Professor in ECE Department, Nimra Institute of Science & Technology, Vijayawada, A.P.

Arduino ADK Back. For information on using the board with the Android OS, see Google's ADK documentation.

Bluetooth + USB 16 Servo Controller [RKI-1005 & RKI-1205]

ASL Fingerspelling Translator Glove

ADVANCED FIRE ALARMING SYSTEM THROUGH MOBILE PHONE

Monitoring of Intravenous Drip Rate

MC433 Stepper Motor Controller

Micro-Step Driving for Stepper Motors: A Case Study

KTA-223 Arduino Compatible Relay Controller

Pmod peripheral modules are powered by the host via the interface s power and ground pins.

NB3H5150 I2C Programming Guide. I2C/SMBus Custom Configuration Application Note

EVAL-UFDC-1/UFDC-1M-16

ADT7467. dbcool Remote Thermal Monitor and Fan Controller

ABRIDGED DATA SHEET EVALUATION KIT AVAILABLE

PCAN-MicroMod Universal I/O Module with CAN Interface. User Manual. Document version ( )

Microtronics technologies Mobile:

QUICK START GUIDE FOR DEMONSTRATION CIRCUIT BIT DIFFERENTIAL ADC WITH I2C LTC2485 DESCRIPTION

AVR315: Using the TWI Module as I2C Master. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

DP8570A DP8570A Timer Clock Peripheral (TCP)

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

Digital Single Axis Controller

Using Arduino Microcontrollers to Sense DC Motor Speed and Position

Electronics. Discrete assembly of an operational amplifier as a transistor circuit. LD Physics Leaflets P

A DIY Hardware Packet Sniffer

Transcription:

Arbeitskreis Hardware Prof. Dr. Michael Rohs, Dipl.-Inform. Sven Kratz michael.rohs@ifi.lmu.de MHCI Lab, LMU München

Schedule (preliminary) Date Topic (preliminary) 2.5. Introduction to embedded interaction, microcontrollers, hardware & software tools 9.5. keine Veranstaltung (CHI) 16.5. soldering ISP adapter, AVR architecture 23.5. LED displays, LED multiplexing, transistors, electronics basics 30.5. AVR architecture, AVR assembler, sensors: light, force, capacity, acceleration, etc. 6.6. PCB design & fabrication, EAGLE, 3D printing 13.6. keine Veranstaltung (Pfingsten) 20.6. Actuation: stepper motors, servo motors, I2C: interfacing to other chips (EEPROM, real-time clock, digital sensors) 27.6. USB to serial chips, storage on memory cards, capacitive sensors 4.7. Displays (character LCDs, graphics LCDs), audio (speakers, amplification, op-amps) 11.7. Communication: fixed-frequency RF, ZigBee, Bluetooth 18.7. Project 25.7. Project Arbeitskreis Hardware 2

SERVO MOTORS Arbeitskreis Hardware 3

Servomotors Precise angular position control Limited to ±90 rotation Can be modified to unlimited rotation and velocity control Used in RC models, robots, sensor positioning, etc. Arbeitskreis Hardware 4

Operating Principle DC motor with a servo mechanism for precise control of angular position Motor + feedback device + control circuit Gear box Output Control signal (PWM) Position sensor (potentiometer) PW to voltage converter Error amplifier DC motor Motor speed depends on error Fast if large difference between sensor and signal Slow if small difference between sensor and signal Arbeitskreis Hardware 5

Controlling Servo Motors Wiring: red, black, yellow cables red = V CC (4.8-6V), black = GND, yellow = PWM signal PWM signal: 1.5ms is always neutral, min/max times and positions may vary 1.0ms 0 20-30ms -90 +90 1.5ms 0-90 +90 neutral position 2.0ms 0-90 +90 Arbeitskreis Hardware 6

Controlling Servo Motors Motor can draw huge amounts of power Use large Elko between red and black wires ( 1000µF) High precision requirements for PWM signal External quartz rather than internal RC oscillator (otherwise, motor will jitter) Simplest case: busy waiting (not recommended) // yellow wire of motor on PB3 DDRB = 0b00001000; // port PB3 output PORTB &= 0b11110111; // port PB3 low while (1) { PORTB = 0b00001000; // port PB3 high _delay_us(1500); PORTB &= 0b11110111; // port PB3 low _delay_ms(18); // 1.5 + 18 = 20 ms } Arbeitskreis Hardware 7

Controlling Servo Motors Timer-generated PWM signal Problem, long gaps (20-30ms) between signals (1-2ms) For 8-bit timers (e.g. ATtiny45) this results in very low resolution: 20ms = 256 counts ó 1ms = 13 counts = -90, 2ms = 26 counts = +90 ó resolution = 180 /14 counts = 13 Solution: 16-bit timers For 16-bit timers (e.g. ATmega8) resolution is better: 20ms = 65536 counts ó 1ms = 3277 counts = -90, 2ms = 6554 counts = +90 ó resolution = 180 /3278 counts = 0.05 Solution: Combine PWM with timer interrupts Use shorter timer period to optimally use 1-2ms Deactivate signal generation (but not timer) during gaps Tradeoff between interrupt rate and angular resolution Arbeitskreis Hardware 8

Timer-generated PWM + Interrupts GTCCR = (1 << TSM) (1 << PSR0); // halt timer, reset prescaler DDRB = 0b00000001; // port PB0 (OC0A) output PORTB &= 0b11111110; // port PB0 (OC0A) low TCCR0A = (2 << COM0A0) (0 << COM0B0) (3 << WGM00); // Clear OC0A on Compare Match, set OC0A at BOTTOM (non-inverting mode); Fast PWM, TOP = 0xFF TCCR0B = (0 << WGM02) (4 << CS00); // prescaler: clkio/256 TCNT0 = 0; // reset conter OCR0A = 94; // should be 93.75 for 1.5ms TIMSK = (1 << OCIE0A); // Timer0 Output Compare Match A Interrupt Enable sei(); // enable interrupts GTCCR = (0 << TSM) (0 << PSR0); // start timer while (1) { } 16 MHz external quartz ATtiny45 datasheet, ch. 11: 8-bit Timer/Counter0 with PWM, 11.9 Register Description Arbeitskreis Hardware 9

Timer-generated PWM + Interrupts #include <avr/interrupt.h> int interruptcount = 0; ISR(TIMER0_COMPA_vect) // interrupts occur at a frequency of 244.14Hz { interruptcount++; if (interruptcount == 1) { // switch off OC0A output // Normal port operation, OC0A/OC0B disconnected; Fast PWM TCCR0A = (0 << COM0A0) (0 << COM0B0) (3 << WGM00); } else if (interruptcount >= 5) { // produce OC0A output } // Clear OC0A on Compare Match, set OC0A at BOTTOM; Fast PWM TCCR0A = (2 << COM0A0) (0 << COM0B0) (3 << WGM00); interruptcount = 0; 16 MHz external quartz, prescaler 256, 256 counts // set OCR0A: 63 = -90,, 94 = 0,, 125 = +90 (2.9 resolution) } Arbeitskreis Hardware 10

Unlimited Rotation and Velocity Control Useful for robot wheels Servo needs to be modified by cutting off link to potentiometer cut Steps: remove mechanical stop on gear, cut/file off potentiometer axis, glue potentiometer to neutral position Arbeitskreis Hardware 11

STEPPER MOTORS Arbeitskreis Hardware 12

Stepper Motors Rotates fixed number of degrees per step Typically 15 or 30 Lower maximum speed than DC motor High torque at low speeds Used in printers, plotters, sensor positioning Do not need feedback device, but control circuit ( translator ) Different wiring schemes Unipolar, biploar, etc. Nicolas Kruse, CC-BY-SA N S S N N S S N Honina at de.wikipedia, CC-BY-SA Arbeitskreis Hardware 13

SENSORS (CONTINUED) Arbeitskreis Hardware 14

Piezo Elements as Sensors Piezo elements can be used for output, but also for sensing vibration, e.g. knocks Generates voltage when deformed by vibration, sound wave, mechanical strain Generates vibration (a sound), when voltage is applied Directly usable as sensor by reading analog value with AVR's ADC Piezos are polarized (red = V cc, blue= ground) Need a current-limiting resistor (1MΩ) Glue against sensing surface Stefan Riepl (Quark48), CC-BY-SA Arbeitskreis Hardware 15

Hall Sensor (TLE 4905) Senses magnetic field: switch on, when magnet nearby Used in bike computers to count wheel revelations Principle: Magnetic field perpendicular to Hall sensor induces voltage V S = 3.8..24V I out = 100mA Image sources: Infineon datasheet Arbeitskreis Hardware 16

Accelerometer ADXL335 Polysilicon surfacemicromachined sensor 3-axis sensing, ±3g Gravity as static reference Source: Analog Devices datasheet Low power (350µA @ V cc = 3V) Output voltages X out, Y out, Z out proportional to acceleration Selectable bandwidth / filtering Capacitors C X, C Y, C Z F 3 db = 1 / (2π (32kΩ) C (X, Y, Z) ) Max: 1600 Hz (x,y axes), 500 Hz (z axis) Source: Analog Devices datasheet Arbeitskreis Hardware 17

How do Accelerometers work? Causes of acceleration Gravity, vibration, human movement, etc. Operating principle Conceptually: damped mass on a spring Typically: silicon springs anchor a silicon wafer to controller Movement to signal: Capacitance, induction, piezoelectric etc. For ADXL335 Polysilicon surface-micromachined structure containing mass Polysilicon springs suspend mass Deflection of mass measured with differential capacitor: one plate fixed, other attached to moving mass Square waves drive plates Deflection unbalances differential capacitor Arbeitskreis Hardware 18

Gyroscope IDG500 Dual-axis angular rate sensor (gyroscope) Senses rate of rotation about X- and Y-axis (in-plane sensing) Factory-calibrated Low-pass filters V CC = 3V Source: InvenSense datasheet Source: InvenSense datasheet Output voltage proportional to the angular rate Separate outputs for standard and high sensitivity X-/Y-Out Pins: 500 /s full scale range, 2.0mV/ /s sensitivity X/Y4.5-Out Pins: 110 /s full scale range, 9.1mV/ /s sensitivity Arbeitskreis Hardware 19

I2C Magnetometer / Compass Honeywell HMC6352 Compass module 2-axis magneto-resistive sensors Support circuits Algorithms for heading computation Source: Honeywell datasheet Parameters V CC = 2.7..5.2V, typ. 3.0V Update rate: 1..20Hz Heading resolution: 0.5 I2C interface used for complex sensors (e.g., allows sending configuration commands) Source: Honeywell datasheet Arbeitskreis Hardware 20

Sparkfun Sensors Many more sensors http://www.sparkfun.com/categories/23?page=all Arbeitskreis Hardware 21

INTERFACING HARDWARE Arbeitskreis Hardware 22

Inter-Integrated Circuit (I 2 C) Low-speed data bus developed by Philips to interconnect components, aka. two-wire interface Requires only two wires, connected to all devices on bus Two bidirectional open-drain lines, pulled up with resistors Serial Data (SDA) Serial Clock (SCL) Colin M.L. Burnett, CC-BY-SA 7-bit address space with 16 reserved addresses up to 112 nodes on one bus Bus speeds arbitrarily low clock non-uniform frequencies possible typical: 100 kbit/s standard mode, 10 kbit/s low-speed mode Arbeitskreis Hardware 23

Inter-Integrated Circuit (I 2 C) Node roles: master and slave Master node: issues clock signal and addresses slaves Slave node: receives clock signal and own address Multiple masters can be present, master and slave roles can be changed Operation modes Master transmit Master receive Slave transmit Slave receive Colin M.L. Burnett, CC-BY-SA Arbeitskreis Hardware 24

Inter-Integrated Circuit (I 2 C) Protocol Master node (in master transmit mode) sends start bit, followed by slave address, followed by read(1)/write(0) bit Slave responds with ACK-bit (0) Master continues in master transmit / receive mode; slave continues in slave receive / transmit Master sends stop bit to finish transmission (or repeats start) Conventions Bytes are sent MSB first Start bit: SDA high-to-low transition with SCL high Stop bit: SDA low-to-high transition with SCL high Bytes sent/received are ACKed by other node Master can read bytes repeatedly: ACKs every byte but the last one Arbeitskreis Hardware 25

I2C EEPROM 24LC256 Features 256 Kbit, V CC = 2.5-5.5V Pins Max. write current 3mA at 5.5V Max. read current 400µA at 5.5V Standby current 100nA 64-byte pages Source: Microchip datasheet A0..A2 connected to GND or V CC Write protect if WP connected to V CC Pullup resistors on SCL, SDA lines: R PU = 10kΩ for SCL 100kHz Arbeitskreis Hardware 26

I2C EEPROM 24LC256: Sequence Data transfer sequence SCL and SDA high on inactive bus (pulled up to V CC ) Acknowledge bit timing Figure sources: Microchip datasheet Arbeitskreis Hardware 27

I2C EEPROM 24LC256: Control Byte Control byte (first byte after start bit) holding ACK low pauses protocol Figure sources: Microchip datasheet Control code (1010) reserved for 24LC256 A2..A0 assigned according to pin wiring Up to 8 24LC256s on one bus Arbeitskreis Hardware 28

I2C EEPROM 24LC256: Write Byte write Page write (up to 64 bytes) master continues to send more bytes, finally STOP Figure sources: Microchip datasheet Arbeitskreis Hardware 29

I2C EEPROM 24LC256: Read Byte read Sequential read master continues to send ACK to get more bytes finally NO ACK and STOP Figure sources: Microchip datasheet Arbeitskreis Hardware 30

Open Drain / Open Collector IC output applied to base (B) of (internal) transistor, collector (C) is output to IC pin, emitter (E) is connected to GND B C E If base (B) is low C is at high impedance Pull-up resistor required to put C to defined state If base (B) is high C is close to E (GND) Sources: Omegatron, public domain Multiple open collector drain/outputs connected Logical AND Arbeitskreis Hardware 31

I2C Physical Layer Start/stop bits vs. data bits Start/stop: SDA transitions while SCL is high Data: SDA transitions while SCL is low Channel access Start/Stop delimit bus transactions Masters continuously monitor the state of bus (Start/Stop conditions and state of SDA/SCL lines) Masters drop transmission if SDA/SCL other than expected, retries after sensed STOP message Clock stretching: slave keeps SCL low Example: EEPROM needs time to save a byte What happens if two masters initiate a transfer at the same time? to the same device? same message? Arbeitskreis Hardware 32

Real-Time Clock DS1307 with I2C interface Highly stable time/date, battery buffered Clock/calendar: provides seconds, minutes, hours, day, date, month, and year information Leap year handling, 12-/24-hour format Power-sense circuit to switch to backup supply 500nA in Backup Mode (e.g. button cell battery) Normal operation: 5V Useful for long-term sensing applications that need time-/date-stamps I2C commands to set/read time/date 3V Figure sources: MAXIM datasheet Arbeitskreis Hardware 33

AVR Universal Serial Interface Two-wire interface (I2C) Three-wire interface (e.g. for programming) ATtiny45 and ATmega8, not ATtiny13 Arbeitskreis Hardware 34

Universal Serial Interface: I2C, TWI Source: Atmel Datasheet Arbeitskreis Hardware 35

Universal Serial Interface: I2C, TWI Interrupt on detected start condition 14 0x000D USI_START USI START Interrupt on sent/received byte 15 0x000E USI_OVF USI Overflow Registers (ATtiny45 datasheet, ch. 15.5) USIDR USI Data Register USIBR USI Buffer Register (buffers data register) USISR USI Status Register (interrupt, collision, stop, counter) USICR USI Control Register (interrupt enable, wire mode, clock strobe) Arbeitskreis Hardware 36