Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital...

46
Introductory Medical Device Prototyping Digital Circuits Part 2 - Communication Prof. Steven S. Saliterman, www.tc.umn.edu/~drsteve Department of Biomedical Engineering, University of Minnesota

Transcript of Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital...

Page 1: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Introductory Medical Device Prototyping

Digital Circuits Part 2 - Communication Prof. Steven S. Saliterman, www.tc.umn.edu/~drsteve Department of Biomedical Engineering, University of Minnesota

Page 2: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Topics

UART Memory – RAM and ROM. Digital/Analog Converters - DAC and ADC. Current Communication protocols:

Low speed I2C (preferred) and SPI. High speed USB and Ethernet.

Wireless networks WLAN Bluetooth

Page 3: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Relevance…

Many prototypes you build will be based on microcontrollers, and peripheral devices, including user interfaces, sensors and actuators; that typically communicate with one or more of these protocols.

Images courtesy of Adafruit and DIY Mall

Absolute Orientation Sensor LCD Display Arduino WiFi Shield

Page 4: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Components of a Microcontroller…

Scherz, P.& S. Monk. Practical Electronics for Inventors, McGraw Hill, New York, NY (2016).

Page 5: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

The UART

Universal Asynchronous Receiver/Transmitter - A device that converts data from serial to parallel, and from parallel to serial, using shift registers. Historically the bases for the RS232 interface.

Has an on-chip bit rate (baud rate) generator to control transmit and receive data rate; and “handshake” lines.

They have an interrupt function to the host microprocessor. There are on-chip FIFO buffers for incoming and outgoing data.

Page 6: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

General Description of a Shift Register…

• Serial or parallel incoming data can be retransmitted in either a serial or parallel manner.

• Remember this concept for later discussion of bit manipulation when programming in C.

Lancaster, D. and Berlin, H.M. CMOS Cookbook. H.W. Sams, Indianapolis, IN (1988)

Page 7: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Serial Data Stream…

or Parallel in

Serial in Serial out

Lancaster, D. and Berlin, H.M. CMOS Cookbook. H.W. Sams, Indianapolis, IN (1988) Scherz, P.& S. Monk. Practical Electronics for Inventors, McGraw Hill, New York, NY (2016).

Page 8: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Simplified Explanation of a UART…

Sparkfun, https://learn.sparkfun.com/tutorials/serial-communication/uarts

Page 9: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

UART Block Diagram…

Courtesy of the Exar ST16C550 datasheet

Page 10: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Random Access Memory (RAM)

Static RAM (SRAM) Six transistor memory cell that does

not need refreshing. Holds its state while power is applied.

Dynamic RAM (DRAM)

Using only a single transistor and capacitor, it holds its state only momentarily, and must be “refreshed” regularly.

Less expensive, and commonly used for computer memory today.

DRAM Cell (1 Transistor and one capacitor)

SRAM Cell (6 Transistors)

Wikipedia, https://en.wikipedia.org/wiki/Random-access_memory

Page 11: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Read Only Memory (ROM)

ROM State remains after power is removed.

EPROM UV light erasable programmable ROM.

EEPROM Electronically erasable programmable ROM.

Flash Memory Based on NAND or NOR gates. Can be reprogrammed fewer times. Used in memory cards, USB drives and solid state

drives.

Page 12: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Analog to Digital Converters

Analog to Digital Converters (ADC) Convert an analog signal – such as voltage, into a digital

signal. Resolution is the number of discrete values the

converter can produce over the range of the analog signal. For example, an 8-bit encoder can decode an analog value to 28, or 256 different values.

Sampling rate is subject to the Nyquist-Shannon sampling theorem. In simple terms, you must sample minimally at a rate twice that of the frequency in order to reproduce the original analog signal.

Page 13: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Digital to Analog Converters…

Digital to Analog Converters (DAC) Convert digital data into an analog signal, such

as voltage or current. Commonly used to reproduce music from CD to

amplifiers, speakers and headphones. The Arduino pins can be configured for

ADC and DAC. Dedicated ADC/DAC chips are available

from a number of manufacturers.

Page 14: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

I2C or “Inter-Integrated Circuit” Only two bus lines are required; a serial data line (SDA) and a

serial clock line (SCL). Each device connected to the bus is software addressable by a

unique address and simple master/slave relationships exist at all times; masters can operate as master-transmitters or as master-receivers.

It is a true multi-master bus including collision detection and arbitration to prevent data corruption if two or more masters simultaneously initiate data transfer.

Serial, 8-bit oriented, bidirectional data transfers can be made at up to 100 kbit/s in the Standard-mode, up to 400 kbit/s in the Fast-mode, up to 1 Mbit/s in Fast-mode Plus, or up to 3.4 Mbit/s in the High-speed mode.

UM10204 I2C-bus specification and user manual (2014)

Page 15: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

I2C Features Continued…

Serial, 8-bit oriented, unidirectional data transfers up to 5 Mbit/s in Ultra Fast-mode

On-chip filtering rejects spikes on the bus data line to preserve data integrity.

The number of ICs that can be connected to the same bus is limited only by a maximum bus capacitance. More capacitance may be allowed under some conditions.

Video 2:46

UM10204 I2C-bus specification and user manual (2014)

Page 16: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Example I2C Applications…

UM10204 I2C-bus specification and user manual (2014)

Page 17: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Example of I2C Benefits…

The 2-wire serial I2C-bus minimizes interconnections so ICs have fewer pins and there are not so many PCB tracks; result — smaller and less expensive PCBs.

The completely integrated I2C-bus protocol eliminates the need for address decoders and other ‘glue logic’.

The multi-master capability of the I2C-bus allows rapid testing and alignment of end-user equipment via external connections to an assembly line.

The availability of I2C-bus compatible ICs in various leadless packages reduces space requirements.

UM10204 I2C-bus specification and user manual (2014)

Page 18: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

I2C Bus…

UM10204 I2C-bus specification and user manual (2014)

Page 19: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Master – Slave Addressing…

UM10204 I2C-bus specification and user manual (2014)

Page 20: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

I2C Communication Lines…

The I2C bus drivers are “open drain”, meaning that they can pull the corresponding signal line low, but cannot drive it high.

The result is there can be no bus contention where one device is trying to drive the line high while another tries to pull it low, eliminating the potential for damage to the drivers or excessive power dissipation in the system.

Each signal line has a pull-up resistor on it, to restore the signal to high when no device is asserting it low.

Sparkfun / https://learn.sparkfun.com/tutorials/i2c

Page 21: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

SDA and SCL are Bidirectional Lines…

UM10204 I2C-bus specification and user manual (2014)

Page 22: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Data Valid and Start/Stop Conditions…

UM10204 I2C-bus specification and user manual (2014)

Page 23: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Data Transfer on the I2C Line…

UM10204 I2C-bus specification and user manual (2014)

Page 24: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

I2C Communication Lines…

Sparkfun / https://learn.sparkfun.com/tutorials/i2c

Page 25: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

I2C and Arduino…

SDA SCL

Page 26: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

SPI – Serial Peripheral Interface

A Motorola protocol implemented on 4 signal lines: A clock signal named SCLK, sent from the bus

master to all slaves; all the SPI signals are synchronous to this clock signal;

A slave select signal for each slave, SSn, used to select the slave the master communicates with;

A data line from the master to the slaves, named MOSI (Master Out-Slave In)

A data line from the slaves to the master, named MISO (Master In-Slave Out).

Byte Paradigm, http://www.byteparadigm.com/applications/introduction-to-i2c-and-spi-protocols/

Page 27: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Master-Slave Transfer Diagram…

Motorola SPI Block Guide V03.06/ (2003)

Page 28: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

SPI Signals…

Sparkfun / https://learn.sparkfun.com/tutorials/i2c

Page 29: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

USB – Universal Serial Bus

Standardized interface to computer peripherals. Has largely replaced RS232 and parallel ports. Standard, mini and micro sizes. Downstream facing devices supply power.

Page 30: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

USB Speeds…

Wikipedia, USB

Page 31: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

USB Hubs in a Desktop Environment…

Universal Serial Bus Specifications, Revision 2 (2000)

Page 32: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

USB “A” and “B” Connectors…

Universal Serial Bus Specifications, Revision 2 (2000)

Page 33: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

USB Cable…

Universal Serial Bus Specifications, Revision 2 (2000)

Page 34: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Packet Voltage Levels…

Universal Serial Bus Specifications, Revision 2 (2000)

Page 35: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

USB Transceiver Circuit Example…

Universal Serial Bus Specifications, Revision 2 (2000)

Page 36: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

USB Implementation Areas…

Universal Serial Bus Specifications, Revision 2 (2000)

Page 37: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

FTDI Chips and Software…

Future Technology Devices International, Ltd. (FTDI)

They specialize in USB connectivity and display interfaces.

Their software drivers are commonly used with USB peripheral devices.

They have a number of USB based converter cables - e.g. for USB-TTL, USB-RS232, USB-RS422, USB-RS484 and others.

Future Technology Devices International, Ltd.

Page 38: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Adding FTDI to Arduino…

This is a USB to TTL serial cable, with a FTDI FT232RL USB/serial chip embedded in the head. It has a 6-pin socket at the end with 5V power and ground, as well as RX, TX, RTS and CTS at 3V logic level

Adafruit, https://www.adafruit.com/products/70

Page 39: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Ethernet

Networking method for home, business and communities.

Speed ups to 100 Gbit/s; with 400 Gbit/s coming.

Data streams are divided into frames. Each frame contains source and destination

addresses and error checking. Communication via twisted pair copper wire, fiber optics or wireless.

Page 40: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Adding Ethernet to Arduino…

Although available, Arduino is no longer supporting this Ver. 3 board. Consider instead a wireless interface discussed next.

Arduino

Page 41: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Wireless Network

Wireless data connection between nodes, using radio frequencies.

Includes internet, cell phones, sensor networks, stellite and terrestrial communication.

WLAN (wireless local area network) links two or more devices over a short distance – usually through an internet access. Wi-Fi.

Bluetooth is a licensed spread spectrum based communication protocol for short range.

Page 42: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Adding Wi-Fi to Arduino…

Arduino Wi-Fi Shield 101 connects the Arduino to the internet.

Open source documentation, software and even board files. Operating voltage both 3.3V and 5V (supplied from the host

board) Connection via: IEEE 802.11 b/g/n for up to 72 Mbps

networks Encryption types: WEP and WPA2 Personal Support TLS 1.1 (SHA256) Connection with Arduino on SPI port Onboard Crypto Authentication by ATMEL

Arduino, https://www.arduino.cc/en/Main/ArduinoWiFiShield101

Page 43: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Bluetooth…

Bluetooth operates at frequencies between 2402 and 2480 MHz, or 2400 and 2483.5 MHz including guard bands 2 MHz wide at the bottom end and 3.5 MHz wide at the top.

Uses the Industrial, Scientific and Medical (ISM) 2.4 GHz short-range radio frequency band.

Bluetooth uses a radio technology called frequency-hopping spread spectrum. Bluetooth divides transmitted data into packets, and transmits each

packet on one of 79 designated Bluetooth channels. Each channel has a bandwidth of 1 MHz It usually performs 800 hops per second, with Adaptive Frequency-

Hopping (AFH) enabled. Bluetooth low energy uses 2 MHz spacing, which accommodates 40

channels.

Page 44: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Adding Bluetooth to Arduino…

The Bluefruit EZ-Link - Bluetooth Serial Link & Arduino Programmer - v1.3

The Bluefruit LE UART Friend adds Bluetooth Low Energy

connectivity

Adafruit, https://www.adafruit.com/products/1588 https://learn.adafruit.com/introducing-the-adafruit-bluefruit-le-uart-friend Image courtesy of Kevin Townsend

Page 45: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Single Chip Microcontroller and Wi-Fi…

TI CC3200 SimpleLink™ Wi-Fi®

IoT (For future Internet of Things applications) Cloud Connectivity Home Automation Home Appliances Access Control Security Systems Smart Energy Internet Gateway Industrial Control Smart Plug and Metering Wireless Audio IP Network Sensor Nodes

Page 46: Introductory Medical Device Prototyping - Wikispacescobanoglu.wikispaces.com/file/view/Digital Circuits Part...Each device connected to the bus is software addressable by a unique

Prof. Steven S. Saliterman

Summary

UART Memory – RAM and ROM. Digital/Analog Converters - DAC and ADC. Current Communication protocols:

Low speed I2C (preferred) and SPI. High speed USB and Ethernet.

Wireless network WLAN Bluetooth