Essential Electronics & Microcontrollers: FYS3240-4240 Data Acquisition & Control
Essential Electronics & Microcontrollers: FYS3240-4240 Data Acquisition & Control
Bekkeng, 11.02.2018
Essential Electronics
Topics you should know
• Duty-cycle
• Port
• High-impedance state (outputs)
• Pull-up and pull-down
• Relay driver
• Counters and Timers
Pulse-width modulation (PWM)
Serial I/O
• SynchronousTransfer
– Data sent at constant rate using a
shared periodic clock
• AsynchronousTransfer (i.e.,
Handshaking)
– Data sent upon request using
handshake signals
– Tx and Rx still have internal clocks,
they just don’t share them
Asynchronous transfer means that the information is not sent in predefined time
slots. Data transfer can start at any given time and it is the task of the receiver to
detect when a message starts and ends.
Synchronous serial data communication
SPI
• SPI = Serial Peripheral Interface
• Serial data link (bus) standard that operates in full duplex mode
• Devices communicate in master/slave mode where the master
(only one master) device initiates the data frame. Multiple slave
devices are allowed with individual slave select (chip select)
lines.
• Sometimes SPI is called a "four-wire" serial bus, contrasting
with three-, two-, and one-wire serial buses.
– Serial Clock (output from master)
– Serial Data In Notes:
• CS = Chip Select (an enable signal)
– Serial Data Out • An n before a signal name, such as
– nCS nCS, means that the signal is active
low
• Bit rate usually in the MHz range • A bar over a signal name, such as 𝐶𝑆,
• Short distance communication means that the signal is active low
0-7 0-15 0-15 All bits are read close to the middle of a bit value
• AVR studio 5
– Works as editor for Assembly and C
– Integrated C-compiler (AVR-GCC)
http://www.avrfreaks.net/
Some common uC resources
• Counters
• UART (Universal Asynchronous Receiver/Transmitter)
• A/D Converters (ADC)
– Time-multiplexing of channels is common
– Usually 12 or less bits per sample (8, 10, 12 bits common)
• SPI (Serial Peripheral Interface)
• I2C (at least slave function)
I2C
• I²C = Inter-Integrated Circuit
• Is a multi-master serial computer bus (but only one master at a
time)
• Uses only two bidirectional lines
– Data (SDA)
– Clock (SCL)
• Speed up to 3.4 Mbit/s (high speed mode)
– 100 kbit/s or 400 kbit/s more common?
• Practical communication distances are limited to a few meters
– The longer the cable, the lower the speed
Example: AVR XMEGA B
• A family of low-power, high-performance, and peripheral rich CMOS
8/16-bit microcontrollers based on the AVR enhanced RISC (reduced
instruction set) architecture
• Two-channel DMA controller
• Multilevel interrupt controller
• Up to 53 general purpose I/O lines
• 16-bit real-time counter (RTC)
• Up to three flexible 16-bit timer/counters
• Up to two USARTs
• I2C and SMBUS compatible two wire serial interface (TWI)
• One full-speed USB 2.0 interface
• One serial peripheral interface (SPI)
• Up to two 8-channel, 12-bit ADCs
• Up to four analog comparators
• Watchdog timer
• LCD controller
• Internal oscillators with PLL
XMEGA