AUTOMATIC CONTROL SYSTEMS Ali Karimpour Associate Professor Ferdowsi University of Mashhad Main reference: Christopher T. Kilian, (2001), Modern Control Technology: Components and Systems Publisher: Delmar
Lecture 3 Introduction to Microprocessor-Based Control 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. 2
Microprocessors Microprocessors require additional components to be useful RAM, ROM, etc. 3
Microcontrollers Microcontrollers are essentially microprocessors with built-in features to be used independently. 4
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
Microprocessor System Hardware 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 7
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
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
Microprocessor Instructions & Op-Codes 10
DAC - Parallel Parallel Interface: Transfers 8-bits (or more) at once. Digital-to-Analog Converter (DAC) converts 8- digital data to analog. 11
DAC Formula & Resolution V out = DAC output analog voltage input = Decimal value of binary input V ref = Reference DC voltage Resolution 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
DAC Example 13
DAC Example 14
ADC Analog-to-Digital converter (ADC): A circuit that converts an analog voltage to digital. 15
ADC Formula & Resolution V in = ADC input analog voltage output = Decimal value of binary input V ref = Reference DC voltage Resolution 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 Time The time required to convert an analog voltage to digital. 16
ADC Example 17
A Parallel Control System Lecture 3 18
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
Serial Interface 20
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
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
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
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
Motorola 68HC11 Microcontroller Block Diagram 25
Intel 8051 Microcontroller Block Diagram 26
PIC 16C72 Microcontroller Block Diagram 27
AVR Microcontroller Block Diagram (Atmega32) Lecture 3 28
Single-Board Computers A computer on a single board. Programmable for I/O control and the ability to use high level peripherals. 29
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
A simple example implemented by PLC Lecture 3 Example 4: A batch process(filling a vat with a liquid, mixing the liquid, and draining the vat) is automated with a PLC. 1. A fill valve opens and lets a liquid into a vat until it s full. 2. The liquid in the vat is mixed for 3 min. 3. A drain valve opens and drains the tank. 31
A simple example implemented by PLC Lecture 3 Example 5: 32
Using a PLC as a Two-Point Controller A Lecture 3 Example 5: 33
Personal Computers Used in Control Systems PCs with dedicated I/O and data acquisition cards and specialized software may be used as controllers. 34
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
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
AVR 8-Bit RISC Compatibility AVR Flash microcontrollers share a single core architecture 8 to 100 pins use the same code for all families 1 Kbytes to 256 Kbytes of code all devices have Internal oscillators
Why Atmel s AVR Microcontroller? 1. RISC architecture with mostly fixed-length instruction, loadstore memory access, and 32 general-purpose registers. 2. A two-stage instruction pipeline that speeds up execution. 3. Majority of instructions take one clock cycle 4. Up to 20-MHz clock operation 5. 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 memory 7. Available in 8-pin to 64-pin package size to suit wide variety of applications 8. Up to 12 times performance speedup over conventional CISC controllers. 9. Wide operating voltage from 2.7 V to 6.0 V.