Unformatted text preview:

l 1 Introduction to Embedded Systems Edward A. Lee Alberto Sangiovanni-Vincentelli UC Berkeley EECS 149/249A Fall 2014 Chapter 10: Interfacing to Sensors and Actuators EECS 149/249A, UC Berkeley: 2 Connecting the Analog and Digital Worlds Semantic mismatch: Cyber: • Digital • Discrete in time • Sequential Physical: • Continuum • Continuous in time • Concurrentl 2 EECS 149/249A, UC Berkeley: 3 Practical Issues • Analog vs. digital • Wired vs. wireless • Serial vs. parallel • Sampled or event triggered • Bit rates • Access control, security, authentication • Physical connectors • Electrical requirements (voltages and currents) EECS 149/249A, UC Berkeley: 4 A Typical Microcomputer Board Beaglebone Black from Texas Instruments This board has analog and digital inputs and outputs. What are they? How do they work?l 3 EECS 149/249A, UC Berkeley: 5 A Typical Microcomputer Board Beaglebone Black from Texas Instruments A “cape” is a daughter card that fits on the board. Arduino “shields” are similar. This one provides an accelerometer, gyro, and magnetometer. EECS 149/249A, UC Berkeley: 6 A Typical Microcomputer Board Beaglebone Black from Texas Instruments More interestingly, this one provides a protoboard to attach your own hardware. How to do that?l 4 EECS 149/249A, UC Berkeley: 7 Beaglebone Black Header Configuration One of eight configurations with SPI buses, analog I/O, etc. Many GPIO pins can be reconfigured to be PWM drivers, timers, etc. EECS 149/249A, UC Berkeley: 8 Wired Connections Parallel vs. Serial Digital Interfaces ¢ Parallel (one wire per bit) l ATA: Advanced Technology Attachment l PCI: Peripheral Component Interface l SCSI: Small Computer System Interface l … ¢ Serial (one wire per direction) l RS-232 l SPI: Serial Peripheral Interface bus l I2C: Inter-Integrated Circuit l USB: Universal Serial Bus l SATA: Serial ATA l … ¢ Mixed (one or more “lanes”) l PCIe: PCI Express PCI SCSI USB RS-232l 5 EECS 149/249A, UC Berkeley: 9 Wired Connections Parallel vs. Serial Digital Interfaces Parallel connectors have been steadily replaced by serial ones. Why? EECS 149/249A, UC Berkeley: 10 Simple Digital I/O: GPIO Open collector circuits are often used on GPIO (general-purpose I/O) pins of a microcontroller. The same pin can be used for input and output. And multiple users can connect to the same bus. Why is the current limited? GPIO pins configured for bus output. Any one controller can pull the bus voltage down.l 6 EECS 149/249A, UC Berkeley: 11 Example: Turn on an LED Assume GPIO pins can sink up to 18 mA. Assume the LED, when forward biased (turned on), has a voltage drop of 2 volts. What resistor should you use? 3V VDD EECS 149/249A, UC Berkeley: 12 Example: Turn on an LED Ohm’s law: V = IR When LED is on, V = 1 volt. To limit to 18mA, R ≥ 1/0.018 ≈ 56 ohms 3V VDDl 7 EECS 149/249A, UC Berkeley: 13 Serial Interfaces The old but persistent RS-232 standard supports asynchronous serial connections (no common clock). How does it work? Many uses of RS-232 are being replaced by USB, which is electrically simpler but with a more complex protocol, or bluetooth, which is wireless. Uppercase ASCII "K" character (0x4b) with 1 start bit, 8 data bits, 1 stop bit. Image license: Creative Commons ShareAlike 1.0 License EECS 149/249A, UC Berkeley: 14 UART: Universal Asynchronous Receiver-Transmitter • Convert serial data to parallel data, and vice versa. • Uses shift registers to load store data • Can raise interrupt when data is ready • Commonly used with RS-232 interface Variant: USART: Universal Synchronous/Asynchronous Receiver-Transmitterl 8 EECS 149/249A, UC Berkeley: 15 Speed Limitations RS-232 relies on the clock in the transmitter being close enough in frequency to the clock on the receiver that upon detecting the start bit, it can just sample 8 more times and will see the remaining bits. USB achieves higher speeds by beginning every packet with synchronization sequence of 8 bits. The receiver clock locks to this for the rest of the packet. EECS 149/249A, UC Berkeley: 16 Example Using a Serial Interface In an Atmel AVR 8-bit microcontroller, to send a byte over a serial port, the following C code will do: while(!(UCSR0A & 0x20)); UDR0 = x; • x is a variable of type uint8. • UCSR0A and UDR0 are variables defined in a header. • They refer to memory-mapped registers in the UART.l 9 EECS 149/249A, UC Berkeley: 17 Send a Sequence of Bytes for(i = 0; i < 8; i++) { while(!(UCSR0A & 0x20)); UDR0 = x[i]; } How long will this take to execute? Assume: • 57600 baud serial speed. • 8/57600 =139 microseconds. • Processor operates at 18 MHz. Each while loop will consume 2500 cycles. EECS 149/249A, UC Berkeley: 18 Receiving via UART Again, on an Atmel AVR: while(!(UCSR0A & 0x80)); return UDR0; • Wait until the UART has received an incoming byte. • The programmer must ensure there will be one! • If reading a sequence of bytes, how long will this take? Under the same assumptions as before, it will take 2500 cycles to receive each byte.l 10 EECS 149/249A, UC Berkeley: 19 Your Lab Hardware (2014) Source: National Instruments myRIO 1950 (National Instruments) Xilinx Zynq Z-7010 • ARM Cortex-A9 MPCore dual core processor • Real-time Linux • Xilinx Artix-7 FPGA • Preconfigured with a 32-bit MicroBlaze microprocessor running without an operating system (“bare iron”). EECS 149/249A, UC Berkeley: 20 Microblaze I/O Architecture Source: Xilinxl 11 EECS 149/249A, UC Berkeley: 21 Microblaze I/O Architecture AXI: “Advanced eXtensible Interface” Source: Xilinx EECS 149/249A, UC Berkeley: 22 Memory-Mapped Peripherals on the “Berkeley Personality” DIO158_OUT is a C preprocessor macro defined in a header file in your IDE project. It defines the memory address of this


View Full Document
Download Interfacing to Sensors and Actuators
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Interfacing to Sensors and Actuators and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Interfacing to Sensors and Actuators 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?