AUTOMATIC CONTROL SYSTEMS - Ferdowsi University...

38
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

Transcript of AUTOMATIC CONTROL SYSTEMS - Ferdowsi University...

Page 1: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

AUTOMATIC CONTROLAUTOMATIC CONTROLSYSTEMSSYSTEMS

Ali KarimpourAssociate Professor

Ferdowsi University of Mashhad

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

Page 2: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

2

Lecture 3

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

Page 3: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

3

Microprocessors

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

Page 4: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

Microcontrollers

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

4

Page 5: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 6: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 7: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

7

Microprocessor System Hardware

Page 8: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 9: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 10: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

10

Microprocessor Instructions & Op-Codes

Page 11: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

DAC - Parallel

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

digital data to analog.

11

Page 12: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 13: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

DAC Example

13

Page 14: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

DAC Example

14

Page 15: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

ADC

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

15

Page 16: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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.

Page 17: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

ADC Example

17

Page 18: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

18

A Parallel Control System

Page 19: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 20: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

20

Serial Interface

Page 21: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 22: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 23: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 24: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 25: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

Motorola 68HC11 Microcontroller Block Diagram

25

Page 26: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

26

Intel 8051 Microcontroller Block Diagram

Page 27: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

PIC 16C72 Microcontroller Block Diagram

27

Page 28: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

AVR Microcontroller Block Diagram (Atmega32)

28

Page 29: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

Single-Board Computers

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

29

Page 30: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 31: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

31

A simple example implemented by PLC

Example 4:

A batch process(filling a vat with a liquid, mixing the liquid, and draining the vat) is automated with a PLC.

2. The liquid in the vat is mixed for 3 min.

1. A fill valve opens and lets a liquid into a vat until it’s full.

3. A drain valve opens and drains the tank.

Page 32: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

32

A simple example implemented by PLC

Example 5:

Page 33: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

33

Using a PLC as a Two-Point Controller A

Example 5:

Page 34: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

Personal Computers Used in Control Systems

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

34

Page 35: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 36: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 37: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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

Page 38: AUTOMATIC CONTROL SYSTEMS - Ferdowsi University …profsite.um.ac.ir/~karimpor/autocontrol/lec3_aut_con.pdf ·  · 2013-04-11Serial Interface Data is sent 1 ... (Data Communication

Lecture 3

Ali Karimpour Apr 2013

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.