A Control System Plant Simulator

Similar documents
Laboratory: Introduction to Mechatronics. Instructor TA: Edgar Martinez Soberanes Lab 1.

I2C and SPI Foundation

RDB1768 Development Board User Manual

mbed Hello World! Introduction to mbed

An Arduino Controlled 1 Hz to 60 MHz Signal Generator

Group 10 Programmable Sensor Output Simulator Progress Report #2

Description Building Automation Platform ARM mbed and Arduino

Chapter 2: Introducing the mbed tw rev

CONTENTS. dspicpro4 KEY FEATURES 4 CONNECTING THE SYSTEM 5 INTRODUCTION 6

MicroBolt. Microcomputer/Controller Featuring the Philips LPC2106 FEATURES

TNG-3B derives its operating power from the serial port. The DTR, RTS, and both data lines are all used, and must be properly connected.

PIC Serial Peripheral Interface (SPI) to Digital Pot

Microcontrollers. Principles and Applications. Ajit Pal +5 V 2K 8. 8 bit dip switch. P2 8 Reset switch Microcontroller AT89S52 100E +5 V. 2.

MAXSANTAFEEVSYS User Manual

Arduino Uno R3 INTRODUCTION

Project Abstract. (VI)sualizer: A Smart Electronic Load. An instrument for profiling solar, chemical, and grid-powered energy delivery devices

Overview of Microcontroller and Embedded Systems

Gooligum Electronics 2015

User Manual. LPC-StickView V3.0. for LPC-Stick (LPC2468) LPC2478-Stick LPC3250-Stick. Contents

Development of a MATLAB Data Acquisition and Control Toolbox for PIC Microcontrollers

AMS 5812 OEM pressure sensor with an analog and digital output

eip-24/100 Embedded TCP/IP 10/100-BaseT Network Module Features Description Applications

I2C-AI418S I2C Bus Voltage and Current Analog Input Board

DSP Research Project

Advanced Debugging I. Equipment Required. Preliminary Discussion. Basic System Bring-up. Hardware Bring-up, Section Plan

1/Build a Mintronics: MintDuino

Product Overview -A 16 bit Micro Experimenter for Solderless Breadboards

The industrial technology is rapidly moving towards ARM based solutions. Keeping this in mind, we are providing a Embedded ARM Training Suite.

THE LPC84X MCU FAMILY A MULTI-TESTER TOOL OFFERING FEATURES FOR YOUR NEXT IOT DESIGN

EZ-Bv4 Datasheet v0.7

Introduction to MATLABs Data Acquisition Toolbox, the USB DAQ, and accelerometers

DEVELOPMENT OF USER FRIENDLY DATA ACQUISITION AND ACTUATION SYSTEM ON EMBEDDED PLATFORM

CSE 466 Exam 1 Winter, 2010

SECTION 1 INTRODUCTION. Walt Kester

PRACTICAL DESIGN TECHNIQUES FOR SENSOR SIGNAL CONDITIONING

ECE 189A Senior Capstone December 16, 2014 Team Leader: Will Miller Charles Crain, Isaac Flores, Brian Phan, Sarah Pilkington

CORRIGENDUM ISSUED FOR NATIONAL COMPETITIVE BIDDING UNDER TEQIP PHASE-II

Lab 01 Arduino 程式設計實驗. Essential Arduino Programming and Digital Signal Process

Layad Circuits Arduino Basic Kit B. Content Summary

Downloaded from Elcodis.com electronic components distributor

MT2 Introduction Embedded Systems. MT2.1 Mechatronic systems

University Program Advance Material

Unlocking the Potential of Your Microcontroller

Prototyping Module Datasheet

BIG8051. Development system. User manual

SANKALCHAND PATEL COLLEGE OF ENGINEERING, VISNAGAR. ELECTRONICS & COMMUNICATION DEPARTMENT Question Bank- 1

BV511 Hardware Guide ByVac ByVac Revision 1.0

Freedom FRDM-KV31F Development Platform User s Guide

ARDUINO BOARD LINE UP

Anadigm FPAA Solutions Training Class III

Trends in Prototyping Systems. ni logic Pvt. Ltd., Pune, India

THE MICROCOMPUTER SYSTEM CHAPTER - 2

D115 The Fast Optimal Servo Amplifier For Brush, Brushless, Voice Coil Servo Motors

Laboratory of Sensors Engineering Sciences 9 CFU

ECE 471 Embedded Systems Lecture 2

EMCP 4.4 Simulator Manual. Author: Lucas Tolbert CIC Engineering 345 Center Street East Peoria, IL

Computer Hardware Requirements for Real-Time Applications

Betrouwbare Elektronica ontwerpen en Produceren

Introducing the 32 bit Micro Experimenter

Wireless OBD II CAN Bus Embedded System Design

Goal: We want to build an autonomous vehicle (robot)

Embedded Development Platform

Embedded Systems Lab Lab 1 Introduction to Microcontrollers Eng. Dalia A. Awad

SUB-SYSTEM BOARD 5562 Campbell (MAXREFDES4#): 16-Bit High-Accuracy 4-20mA Input Isolated Analog Front End (AFE)

Mechatronics and Measurement. Lecturer:Dung-An Wang Lecture 6

Design Document. May Logging DC Wattmeter. Team Member: Advisor : Ailing Mei. Collin Christy. Andrew Kom. Client: Chongli Cai

Project Number: P15452

Development of a digital instrument as a motivational component in teaching embedded computers

DFI 7000 DIGITAL FORCE INDICATOR USER S GUIDE 1.0 INTRODUCTION 2.0 DESCRIPTION. 2.1 Configuration. 2.2 Specifications

C:\Users\jacob\Documents\MtSAC\ELEC74 Mt SAC - chipkit\homework Sheets.docx

EMBEDDED SYSTEMS: Jonathan W. Valvano INTRODUCTION TO THE MSP432 MICROCONTROLLER. Volume 1 First Edition June 2015

Pic24f Family Reference Manual Section 14. Timers

Wall Industries SMPS and Microcontrollers

An open source, modular, robotic control system for building 3D printers, CNC routers, and other robotics applications

Multifunction Controller less STN LCD Software Library and Reference Hardware

Introduction to PoliArd

HZX N03 Bluetooth 4.0 Low Energy Module Datasheet

MTRX3700 Mechatronics

ARDUINO MICRO WITHOUT HEADERS Code: A000093

Lecture 5: Computing Platforms. Asbjørn Djupdal ARM Norway, IDI NTNU 2013 TDT

DSP Research Project

Freescale Semiconductor Inc. Microcontroller Solutions Group. FRDM-KL46Z User s Manual FRDM-KL46Z-UM Rev. 1.0

突破 8-/16-/32- 位和 DSP 界限的 ARM MCU 解决方案

MAXREFDES24EVSYS User Manual

Part Number: PCB-STM32-F4B1 (unpopulated PCB with Discovery module sockets, no other parts) STM32-F4B1 (assembled board, not presently available)

Adafruit Metro Mini. Created by lady ada. Last updated on :12:28 PM UTC

DESIGN OF A CUBESAT PAYLOAD INTERFACE. Jason Axelson Department of Electrical Engineering University of Hawai i at Mānoa Honolulu, HI ABSTRACT

CMS-8GP32. A Motorola MC68HC908GP32 Microcontroller Board. xiom anufacturing

User Manual. LPC-StickView V1.1. for LPC-Stick. Contents

ME 3210: Mechatronics Signal Conditioning Circuit for IR Sensors March 27, 2003

HC12 Built-In Hardware

Table of Contents. Introductory Material

Intel Galileo gen 2 Board

DEV-1 HamStack Development Board

Introducting Itsy Bitsy 32u4

Programming in the MAXQ environment

K10 Intrinsically Safe Electro-Pneumatic Positioner Operating Manual

Introduction to L.A.P. 1

Real Time Operating Systems Application Board Details

Chapter 5 - Input / Output

Transcription:

A Control System Plant Simulator utilizing the mbed NXP LPC1768 Microcontroller For: NXP mbed Design Challenge Sponsors: NXP/mbed/Elektor/Circuit Cellar Date: February 28, 2011 By: NXP-3892

Motivation There are many tools available to the engineer to assist them with the analysis, design and tuning of control systems. Many of these tools are specially designed software packages to model the controller and plant. In some cases, they create virtual solutions without coming in contact with actual hardware. These methods use assumptions and software to create nice solutions at your desk. They most likely will need to be tweaked or perhaps redone when they are combined with the actual system components such as a controller, sensors and actuators. One difficulty with this approach is the lack of understanding of the true characteristics of the plant. Along with this, the software solution doesn t answer the question of how the controller components will interface to the plant. Another concern is that sometimes the characteristics of the sensors will play a role in the overall solution. Three-mode or PID controllers are very common in industry today because of their low cost and ease of applicability. They seem to be the first choice of application toward a solution and work well when the system is rather simple. What happens when parameters start to vary with time or change relative to other parameters such as temperature or pressure? Do we retune? Do we use gain scheduling, or perhaps do we use a system that is adaptive? Do we use a more complicated control strategy? If we had a better understanding of the plant dynamics or process characteristics we could explore other possibilities in the lab instead of at the customers expense. Furthermore, at some point during the development phase of a control system, the control strategy will need to be ported into the controller and tested against the actual plant. If the actual plant is not available because it has not yet been built, could we just use software to simulate the plant? The answer is NO. We can simulate the overall control/plant system using software tools but the control strategy warrants testing and debug when the final program is loaded into the target hardware. The project may not have enough time allocated to accomplish this. If there were a piece of hardware available that interconnects and interacts with the controller that can simulate the plant/process operation, this would allow you to test the overall system in a shorter time and place you much closer to the finish line with a higher level of confidence. The mbed rapid prototyping tool for micro-controllers is an excellent way of creating an actual platform to simulate a process or plant that is to be controlled. In this approach, the engineer will use data acquisition to gather information about the plant or process and use it to derive an approximate model that can be used to develop a controller and/or control strategy. Once a physical plant model has been attained, the engineer can use it to asses different types of controls that are necessary to achieve their objectives. The control system can be tested in the laboratory under changing parameters (temperature, pressure, flow, etc.) and not during a time the customer is trying to maintain production.

This idea of creating an actual piece of hardware that simulates the plant can allow you to test the controller and achieve with absolute certainty that your control strategies will work and the system will interface to the plant without any surprises. Hardware The NXP mbed design challenge hosted by Circuit Cellar provided an opportunity to take a look at a really great prototyping platform, the mbed NXP1768. This small micro-controller board is based on the ARM Cortex-M3 operating at a speed of 96MHz with 512K bytes of Flash memory and 64K of RAM. The mbed design places the ARM processor on a 40-pin DIP package with 0.1 spacing and a 0.9 width. The mbed board is designed to plug directly into a solderless breadboard. I chose a Futuelec protoboard to house the circuitry for this project. The mbed board hosts a load of interfaces including: (2) SPI ports, (3) serial ports, (2) I2C ports, (6) Analog inputs, (1) analog output, (6) PWM outputs, (1) CAN, (1) Ethernet and (1) USB interfaces. (26) of the pins may be used as bidirectional digital I/O. The board can be powered through the USB connection or by an external voltage source in the range of 4.5 to 9V. The mbed microcontroller board is the heart of this project but provides quite a punch at a low cost for any project. The pin-out shown below shows the capabilities of the microcontroller board. It can be found on the website: www.mbed.org. A visit to this website will immediately get you hooked on this great product.

Below is a block diagram of the circuit build to host this application. This block diagram along with a schematic for the system and bill of material may be found in the appendix of this paper. The example that I used to explain this idea uses only two analog inputs and a single analog output. I have added the Microchip MCP4822 to provide an additional two analog output using the SPI bus. Below is a brief description for each element of the system. ANALOG INPUTS I wired all (6) of the analog inputs to the mbed micro-controller board to a connector in the event that a more complex process involving multiple inputs is to be simulated. In this example only two inputs were considered. AI0 is used to accept the command signal from the controller. The second analog input can be used to simulate the effects on the plant for changes in temperature. Providing an analog signal on this input can simulate this condition.. ANALOG OUTPUT The Plant Simulator uses two analog outputs. Analog Output channel 1 is the simulated transducer output with a range of 0-6V. The pressure transducer being simulated has a range of 1-6VDC. Analog Output channel 2 is used to monitor the systems dynamic response with a scope. It is adjusted to have a 0-10V range. As a future note, this second output can also be used to simulate a plant with two outputs if need be.

This system uses one of the two SPI ports available from the mbed package. Pins 5, 7 and 8 provide the MOSI, SCK and SSEL signals necessary for a SPI device to operate. The Microchip MCP-4822 is a 12 bit SPI input DAC chip that is used to produce a 0-5V output with a 0-4096 code input on both channels. Each channel uses ½ of a Microchip TC913A op-amp package. Both amplifiers can provide a gain of up to 3.3 and are both adjustable, DIGITAL INPUTS Digital Input at pin P21 was used to assist with testing when the software was being written. When this input is brought low, It forces a step function to be loaded into the input array. It can be used but serves as no other purpose. SERIAL PORT One of the three serial ports of the mbed controller is used with this simulator. Pins P9 and P10 perform transmit and receive functions that are used to communicate with a PC running a terminal emulator program for command control entry and data extraction. Since the system has no display or keyboard, all communications are implemented through the serial port. Hyperterminal (bundled with windows XP) was used in the development of this system. ETHERNET INTERFACE The Ethernet interface has been included on the schematic for this project and was wired but is not used for the simulator. I had a lot of fun working with the Ethernet interface with all of its capabilities but decided that I didn t have enough knowledge to make it work well. Since MBED is a great learning tool, I was able to gain some knowledge in this area. Software The Plant/Process Simulator doesn t have a display or keyboard. All communication with the system is done over the serial interface. A buffered, interrupt based serial driver that has been made available on the mbed.org website by developer Andy Kirkham of the United Kingdom was used in this application (Thank You Andy). Getting the serial interface functioning was very easy once the driver was setup. The application was slightly modified to support the simulator. The main program is shown below in flowchart form. When the MAIN program starts its execution, the first tasks to occur are: SPI port is initialized Variables are initialized The TIC Handler is detached Pull up resistor for DIN is enabled

A display is written to the PC connected to the serial port indicating the program has been started and is ready for command entry. A prompt for HELP is also displayed. The system waits for a command to be entered. If a message is sent from the serial port, it will be processed by a call to the messageprocess () subroutine. This can be seen in the block diagram. The main program will also interacts with the TIC handler which calls the plant() subroutine and the acquisition function. When a plant simulation runs, the system will put data into two arrays: the input array U[] and the output array Y[]. These arrays are 2000 points each. They are circular in that there is no beginning or end. The TIC handler is launched when the command RUN is executed. The commands will be explained in a later section of this report. If the RUN command is not executed, the system waits indefinitely for a command to be entered, When the command is given to RUN the simulation, the RUN_FLAG is set. The main program watches to see if an acquisition is requested. If no acquisition is requested, the main program does nothing. The system will continue to run the simulation in the background. When the ACQ command is entered, the system will start to acquire data. The circular array pointer ia is saved in ACQ_Index. This marks the beginning of the acquisition record. During this time, the main program simply monitors the event and keeps track of when a valid data record is stored; then count is incremented. The acquisition is complete when (count > samplesize-1). Upon completion, a file is opened and data is written starting at the ACQ_Index pointer until the number of requested records is saved (samplesize). After data has been written, the file is closed and the ACQ_Start flag is cleared.

Using the System Connect the serial port of the system to a PC using a strait though cable. Any terminal emulator program may be used to setup the interface. I used Hyperterminal (bundled with window XP) for the development of this system. After hitting the reset pushbutton or powering the sytem up, you will see the following prompt: NXP mbed Design Challange Date: 28-Feb-2011 By: NPX-3892 CONTROL SYSTEM PROCESS/PLANT SIMULATOR HELP or? for command listing Typing the HELP command or the? followed by a <CR> will show the following screen.? PLANT SIMULATOR - Help > Commands are single line. > Commands may be issued upper/lower case. RUN Start the Simulation. STOP Stop the Simuation. ACQ Acquire N-Samples of INPUT/OUTPUT data from the simulation. Stores data in file "data.txt" on the MBED flash. POST Sends the Acquired data out the serial port. SAVE Saves Parameters in file "PARM.txt" on the MBed flash. LOAD Loads the Parameters from file "PARM.txt" on the MBed flash. AOCAL Calibrate the Analog Output Amplifiers (both channels) AICAL Calibrate the Analog Input Channels ACH0 and ACH1. AORAMP Generate (1Hz) sawtooth ramps out Aout-A(increasing slope) and Aout-B (decreasing slope). TF Demonstrates the Transfer between Analog Input and Analog Output. HELP/? Send this help file out the serial port. SET Sets the Simulation Parameters. Ts - Sample Rate (ms) Kp - Plant Gain Tp - Plant Time Constant (ms) 0p - Delay (ms) N - Acquisition Sample Size Example: SET: Ts=100 Each command will have a dialog screen. The following gives information on what each command means.

COMMAND LIST RUN Typing RUN you will get the prompt: Simulation Has Started! This indicates that the simulation has STARTED. You may start an acquisition only after the simulation has begun. STOP Typing the STOP command, you will get the prompt: Simulation Has Stopped! This indicates that the simulation has STOPPED. You cannot acquire data when the simulation is not running. ACQ If you type ACQ when the simulation is not running, you will get the following messge: Cannot Acquire Data!!! Simulation did not start...use RUN command to start simulation. If you started the simulation and then typed ACQ, the message will be: Collecting 1000 samples Indicating that 1000 samples will be acquired then save to the data file data.txt on the local drive. The file may be posted to the serial port and collected using Hyperterminal.

POST When you type the POST command, the system will dump the file named data.txt out the serial port. You can capture the text file using Hyperterminal. The prompt will be: Writing Data out Serial Port. 0 0.000000 0.000000 1 0.000000 0.000000 2..... Lots of data in here...... 1999 0.000000 0.000000 Post Complete!!! SAVE After the command SAVE is typed, the system will save all parameters to the file parm.txt located on the local drive of the mbed board. The file is in flat ascii fomat. Saving parameters to the file parm.txt Parameters Saved!!! LOAD After typing the LOAD command, the system will attempt to load the parm.txt file if it is present on the local drive. If the file is present, the prompt will be: Loading parameters from the file parm.txt Parameters Loaded!!! If the file doesn t exist on the local drive, the prompt will be: Loading parameters from the file parm.txt File cannot be opened (may not exist)!!!

HELP/? Typing either HELP or? will yield the following results: PLANT SIMULATOR - Help > Commands are single line. > Commands may be issued upper/lower case. RUN STOP ACQ POST SAVE LOAD AOCAL AICAL AORAMP TF HELP/? SET Start the Simulation. Stop the Simuation. Acquire N-Samples of INPUT/OUTPUT data from the simulation. Stores data in file "data.txt" on the MBED flash. Sends the Acquired data out the serial port. Saves Parameters in file "PARM.txt" on the MBed flash. Loads the Parameters from file "PARM.txt" on the MBed flash. Calibrate the Analog Output Amplifiers (both channels) Calibrate the Analog Input Channels ACH0 and ACH1. Generate (1Hz) sawtooth ramps out Aout-A(increasing slope) and Aout-B (decreasing slope). Demonstrates the Transfer between Analog Input and Analog Output. Send this help file out the serial port. Sets the Simulation Parameters. Ts - Sample Rate (ms) Kp - Plant Gain Tp - Plant Time Constant (ms) 0p - Delay (ms) N - Acquisition Sample Size Example: SET: Ts=100 SET Typing the SET command will allow you to set the internal parameters. The parameters are: Ts - Sample time limit in ms. Kp - Plant gain Tp - Plant time constant in ms. Op - Plant Dead time in ms. N - Number of samples to take As and example typing the following will yield: set:ts=10 Setting Parameters: Ts=10(ms)

The last four commands are used to set the adjustments on the Plant/Process simulator board. The first two commands allow you to trim the Analog Output amplifier (op-amps), the Analog Input attenuation networks. The third command generates a ramp out both of the analog ports. While the last command transfers the voltage from channels Ain0 to Aout0 and Ain1 to Aout1. AOCAL Typing the AOCAL command yields: Calibrate DAC Outputs: Both DAC's are set to a 4095 count input. Trim output amplifier to desired maximum level (10V). DACOut0 = 4095 DACOut1= 4095 AICAL Typing the AICAL yields the following prompt: AICAL Calibrate ADC Inputs ACH0 and ACH1: Set the input signal to 10V. Then adjust SPAN pots RP3 and RP4 to display 0xFFFF for each channel. Press <ENTER> key to end test. ACH0f = 0.000 ACH0i = 0 ACH1f = 0.000 ACH1i = 0 AORAMP Typing the AORAMP command caused the system to generate analog ramps. This dialog is: Aoramp Generate 1Hz Ramp Signals out both Analog Ports. Aout-A (Positive Ramp) Aout-B (Negative Ramp). Press <ENTER> key to end test. DACOut0 = 3960 DACOut1= 1464 TF Typing the TF command yields the following: TF Read Analog input channels ACH0 and ACH1. Transfer these values to Analog Output channels Aout-A and Aout-B. Press <ENTER> key to end test. ACH0i = 0 ACH1i = 0

Test Results The next four graphs show the results of running the simulator and collecting data for the conditions that were discovered using the data acquisition process presented at the beginning of this paper. The curves below show the results of simulations for changing the speed of the motor 20%, 30%, 40% and 50%. They may have slightly different Kp values than the actual values.