35
AUTOMATIC CONTROL AUTOMATIC CONTROL SYSTEMS SYSTEMS Ali Karimpour Associate Professor Ferdowsi University of Mashhad Main reference: Christopher T. Kilian, (2001), Modern Control Technology: Components and Systems Publisher: Delmar

AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec13_auto.pdf · useful –RAM, ROM, etc. ... AVR Microcontroller Block Diagram (Atmega32)

  • Upload
    lythien

  • View
    223

  • Download
    0

Embed Size (px)

Citation preview

AUTOMATIC CONTROLAUTOMATIC CONTROLSYSTEMSSYSTEMS

Ali KarimpourAssociate Professor

Ferdowsi University of Mashhad

Main reference:Christopher T. Kilian, (2001), Modern Control Technology: Components and SystemsPublisher: Delmar

Lecture 13

Ali Karimpour Nov 2012

2

Lecture 13

Topics to be covered include: What a microprocessor and microcontroller.

Analog-to-digital converters and digital-to-analog converters.

Understand the principles of digital controller software.

Various types of available digital controllers, that is, microcontrollers, single-board computers, programmable logic controllers, and personal computers.

Introduction to Microprocessor-Based Control

Lecture 13

Ali Karimpour Nov 2012

3

Microprocessors

Microprocessors require additional components to be useful – RAM, ROM, etc.

Lecture 13

Ali Karimpour Nov 2012

Microcontrollers

Microcontrollers are essentially microprocessors with built-in features to be used independently.

4

Lecture 13

Ali Karimpour Nov 2012

Reasons for Microprocessor Control

Low-level signals converted to digital can be transmitted long distances error free.

Micro can handle complex calculations.

Memory is available for tracking and storage.

Loading new programs for control change is easy.

Easily connected to networks.

5

Lecture 13

Ali Karimpour Nov 2012

A computer is made up of four basic blocks: Central Processing Unit (CPU)

• Does the actual computing. • Arithmetic Unit – performs math and logic• Control: Manages flow of data

Memory • RAM – volatile, read/write memory• ROM – nonvolatile, read only• EPROM/EEPROM/Flash – Erasable ROM

Input ports Output ports 6

Microprocessor System Hardware

Lecture 13

Ali Karimpour Nov 2012

7

Microprocessor System Hardware

Lecture 13

Ali Karimpour Nov 2012

Microprocessor Instructions & Op-Codes

Each processor has its own instruction set of commands to control its operation. Move data Perform math operations Perform logical operations

Each instruction has a unique Op-code, a binary value associated to it. (0100 1101 or 4D).

An Accumulator is staging area for data – data is moved into it, and operations are performed on that data.

8

Lecture 13

Ali Karimpour Nov 2012

Machine Code/Mnemonics/PC

Machine Code The program the CPU follows represented in binary or hex.

Mnemonics Abbreviations representing an op-code. Programs written in

assembly language use mnemonics. Program counter

Used to point to the memory address of the instruction to be performed.

Fetch-execute cycles Performed to bring an instruction into memory and execute it.

9

Lecture 13

Ali Karimpour Nov 2012

10

Microprocessor Instructions & Op-Codes

Lecture 13

Ali Karimpour Nov 2012

DAC - Parallel

Parallel Interface: Transfers 8-bits (or more) at once. Digital-to-Analog Converter (DAC) converts 8-

digital data to analog.

11

Lecture 13

Ali Karimpour Nov 2012

DAC Formula & Resolution

Vout = DAC output analog voltage input = Decimal value of binary input Vref = Reference DC voltageResolution

The worst case error introduced when converting. In an 8-bit DAC, there are 255 possible steps. The resolution is the smallest step size, or 1/255, 0.39%.

12

Lecture 13

Ali Karimpour Nov 2012

DAC Example

13

Lecture 13

Ali Karimpour Nov 2012

DAC Example

14

Lecture 13

Ali Karimpour Nov 2012

ADC

Analog-to-Digital converter (ADC):A circuit that converts an analog voltage to digital.

15

Lecture 13

Ali Karimpour Nov 2012

16

ADC Formula & Resolution

Vin = ADC input analog voltage output = Decimal value of binary input Vref = Reference DC voltageResolution

The worst case error introduced when converting. In an 8-bit ADC, there are 255 possible steps. The resolution is the smallest step size, or 1/255, 0.39%.

Conversion TimeThe time required to convert an analog voltage to digital.

Lecture 13

Ali Karimpour Nov 2012

ADC Example

17

Lecture 13

Ali Karimpour Nov 2012

18

A Parallel Control System

Lecture 13

Ali Karimpour Nov 2012

Serial Interface

Data is sent 1 bit at a time. Reduces number of cables or lines More easily shielded from noise. Existing data lines may be used (phone).

Parallel data must be converted to serial to transmit, and vice-versa on receive. A UART (Universal Asynchronous Transmitter

Receiver) is a device which performs this conversion.

19

Lecture 13

Ali Karimpour Nov 2012

20

Serial Interface

Lecture 13

Ali Karimpour Nov 2012

RS-232

RS-232 is a specification which defines standard for serial interfaces between DTEs (Data Terminal Equipment – Computers), and DCEs (Data Communication Equipment – Modems, etc).

DTE to DTE communications can be performed serially using a cross-over or Null-Modem cable.

21

Lecture 13

Ali Karimpour Nov 2012

Controller Programmer

Real Time control – Program runs in a loop, sensing the current condition and calculating new output to the actuator.

Each pass through the program is an iteration or scan.

The frequency at which new data is collected is the sampling rate (scan time).

Time-delay loops may be inserted to slow the execution or scan time.

Programs can be written at the lowest level (machine code, assembler) or high level languages (C), BASIC, etc. 22

Lecture 13

Ali Karimpour Nov 2012

Microcontrollers

A single-chip computer specifically designed for I/O control.

On board RAM, ROM, possibly timers and ADCs. High speed is not required due to low complexity of

tasks. Very large cost savings over microcomputers. Use reduced instruction set computer (RISC). Motorola 68HC11, Intel 8051, PIC 16C72, Atmel

AVR, BASIC Stamp

23

Lecture 13

Ali Karimpour Nov 2012

Most common microcontrollers

8-bit microcontrollers AVR Advanced Virtual RISC

Alf-Egil Bogen and Vegard Wollan PIC Programmable Interrupt Controller HCS12 8051

32-bit microcontrollers ARM Advanced RISC Machine PIC32

Lecture 13

Ali Karimpour Nov 2012

Motorola 68HC11 Microcontroller Block Diagram

25

Lecture 13

Ali Karimpour Nov 2012

26

Intel 8051 Microcontroller Block Diagram

Lecture 13

Ali Karimpour Nov 2012

PIC 16C72 Microcontroller Block Diagram

27

Lecture 13

Ali Karimpour Nov 2012

AVR Microcontroller Block Diagram (Atmega32)

28

Lecture 13

Ali Karimpour Nov 2012

Single-Board Computers

A computer on a single board. Programmable for I/O control and the ability to use high level peripherals.

29

Lecture 13

Ali Karimpour Nov 2012

Programmable Logic Controllers

Self-contained microprocessor based controller. Designed for fast connection and control of processes. Used extensively in industrial control environments. Programs in relay-logic to be compatible to the more

traditional electrical workforce.

30

Lecture 13

Ali Karimpour Nov 2012

Personal Computers Used in Control Systems

PCs with dedicated I/O and data acquisition cards and specialized software may be used as controllers.

31

Lecture 13

Ali Karimpour Nov 2012

A little history

The PIC appeared around 1980.→ 8 bit bus → executes 1 instruction in 4 clock cycles

AVR (1994)→ 8 bit bus→ one instruction per cycle

Lecture 13

Ali Karimpour Nov 2012

AVR 8-Bit RISC Low Power Consumption

1.8 to 5.5V operation→ will use all the energy stored in your batteries

A variety of sleep modes→ AVR Flash microcontrollers have up to six different sleep modes → fast wake-up from sleep modes

Lecture 13

Ali Karimpour Nov 2012

AVR 8-Bit RISC Compatibility

AVR® Flash microcontrollers share a single core architecture

→ use the same code for all families→ 1 Kbytes to 256 Kbytes of code

→8 to 100 pins→ all devices have Internaloscillators

Lecture 13

Ali Karimpour Nov 2012

Why Atmel’s AVR Microcontroller?1. RISC architecture with mostly fixed-length instruction, load-

store memory access, and 32 general-purpose registers.2. A two-stage instruction pipeline that speeds up execution.3. Majority of instructions take one clock cycle4. Up to 20-MHz clock operation5. Wide variety of on-chip peripherals, including digital I/O,

ADC, EEPROM, Timer, UART, RTC timer, pulse width modulator (PWM), etc

6. Internal program and data memory7. Available in 8-pin to 64-pin package size to suit wide variety

of applications8. Up to 12 times performance speedup over conventional CISC

controllers.9. Wide operating voltage from 2.7 V to 6.0 V.