ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: •...

22
1 ENGG*44200 Real Time System Design Lab One Real Time Simulation/Experimentation TA: Matthew Mayhew, Mahdi Elghazali TA hour: Tuesday : 5:20 pm - 6:20pm Thursday: 2:20pm – 3:20 pm in the lab 2 Activities of Today Fill in swap card form, make groups (max 3 students per group). Lab1 introduction. Do LabView exercises.

Transcript of ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: •...

Page 1: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

1

1

ENGG*44200 Real Time System Design Lab One

Real Time Simulation/Experimentation

TA: Matthew Mayhew,Mahdi Elghazali

TA hour: Tuesday : 5:20 pm - 6:20pm Thursday: 2:20pm – 3:20 pm in the lab

2

Activities of TodayFill in swap card form, make groups (max 3 students per group).Lab1 introduction.Do LabView exercises.

Page 2: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

2

3

Lab1 Introduction

4

Overview of Lab1

Page 3: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

3

5

Lab1 Development Environment

PC Embest IDE Embest ARM Development Board Labview8.0 softwareAD/DA BoxData Acquisition Card (PCI-6024E)HyperTerminal tool software

6

Overview of Lab1 Architecture

LabView: Manual & Auto Mode simulation of Hot Air Blower Plant

Data Acquisition Card

AD/DA Box

Embest Board: PID control, Human Interface,Air Inlet Close Control

Page 4: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

4

7

Interfacing LabView and Embest

AD/DA Box

Embest Board: PID control, Human Interface,Air Inlet Control

Digital I/O Port (8 bits)

Analog Temperature

Signal<2.5V

Digital Signals

AD Converter

Digital Input Analog Output

Analog Inlet close/open

Signal<2.5V

8

Lab 1 Requirements/Steps (1/2)(Labmanual section1.2)

Step 1: Implement manual and auto mode control (formula 1.2 in Labmanual) of Hot Air Blower simulation in Labview using formula nodes.Step 2: Implement auto mode temperature control of Hot Air Blower simulation in Labview, create a task of PID control algorithm for temperature control on the Embest Board (use formula 1.2 in the Labmanual), interfacing Embest to Labview

Page 5: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

5

9

Lab 1 Requirements/Steps (2/2)(Labmanual section1.2)

Step3: Implement Bumpless Transfer control on EmbestBoard (refer to section 4.4 of Real-Time Computer Control book).Step 4: Implement sending and receiving Air Inlet close/open signal from Labview to the Embest Board, still controlling the Inlet manually in Labview.Step 5: Implement a Simple Human Interface (set point temperature using keyboard for input) on Embest Board.Step 6: Implement more advanced control algorithms and environment simulation (optional).

10

Embest Evaluation Board

Page 6: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

6

11

Embest Board Devices2M bytes 16-bit Flash Memory8M bytes 16-bit SDRAMTwo UART portsTwo interrupt buttons and two LEDsA/D converter (0V-2.5V)320x240 LCD & 4x4 keyboardJTAGUSB connector10M Ethernet interfaceIIS Interface: Speaker & Microphone

12

Embest IDE pro 2004Click EmbestIDE icon on PC destopAll examples are located at C:\embest\EmbestIDE\Examples

Page 7: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

7

13

uC/OS-II is a highly portable, ROMable, very scalable, preemptive real-time, deterministic, multitasking kernel.It can manage up to 64 tasks (56 user tasks available)It has connectivity with uC/GUI and uC/FS.It is ported to more than 100 microprocessors and microcontrollers.It supports all type of processors from 8-bit to 64-bitIt is free when there is no commercial application involved

For a demo on multitasking, refer to the example in \ucos-II directory

14

LabVIEW Introduction to LabVIEW:• Click on Labview8.0 icon on PC desktop • Graphical development environment.• Test and measurement, data acquisition, measurement analysis, report generation applications.• Icons to create your application (VIs).• Front panel (User interface) and Block diagram.

Page 8: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

8

15

Front Panel Controls and Indicators

Difference between control and indicator.

Num controls: Various numerical controls like Knob, Dial, Fill slide, Pointer slide etc.

16

Buttons: Various button controls like Toggle switch, Push button, Slide switch.

Numerical indicators: Various indicators like Progress bar, Meter, Gauge, Numerical indicator.

Page 9: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

9

17

LED: Square & Round type led.

Graph Indicators: Graph indicators like Chart, Graph, XY graph.

All Controls: All Control Palette menus.

18

Block Diagram Tools

Input: DAQ Assist, Prompt User, Simulate Signal.

Output: DAQ Assist, Display Msg, Report generation.

Page 10: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

10

19

Analysis: Perform Spectral analysis, Tone, Amplitude&level measurement, Filter.

Execution control: While loop, Flat Sequence, Case, Time Delay.

20

Arith/Compare: Numeric expressions, Boolean, Comparison etc.

Numeric expressions like add, subtract, multiply, divide etc.

Boolean expressions like OR, AND, XOR etc.

Comparison like >, <, >=0 etc.

Page 11: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

11

21

Signal Manipulation: Split signal, merge signals, data type conversion.

All Functions: All Function palette menus.

22

Labview Notes

Occasionally, you may need to convert data for interconnectivity. This can be done using conversion blocks. Some useful conversion blocks can be found in the numerical functions palette and in “express signal manipulation”Local Variables can be used to give inputs to controls. They can be found in the “structures” section of the function palette. You can configure them to be either read or write depending on what you need. Right click and “select item” to assign them.When setting up a feedback node, you need to wire in a constant from outside the loop for initialization. Generally, a constant 0 should suffice.

Page 12: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

12

23

Other Notes

Avoid fast LCD refreshing--- DO NOT PRINT TOO FAST TO LCD. Pay attention to the chip temperature.When connecting the Embest board to the NI board, remember to connect a ground (note that the Digital I/O ports share a ground).Make one set of controls for auto/manual mode. On the front panel make one set of controls for air opening/heater current to be used in both auto and manual control.

24

How to implement Lab1? (1/4)

1. Preparation1: Do some Labview exercises (Following Labmanual section 1.8.1, 1.8.2, 1.8.3, and “Get started with LabView”--Chapter 4)2. Implement Lab1 Requirement A, B (in Lab Manual section 1.2): Implement manual and auto mode control (formula 1.2 in Labmanual) of Hot Air Blower simulation on Labview using formula nodes. (need to get used to graphical programming)3. Preparation2: Do some exercises on Embest Board (Read Lab2, sections 2.2, 2.3 and 2.4.1, 2% will be marked). To do the examples and exercises referenced in 2.4.1, you will need to refer to the book “Embedded System Development and Labs for ARM”, (see course website), the first exercise is located in section 3.1.

Page 13: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

13

25

How to implement Lab1? (conn. 2/4)

4. Implement Lab1 Requirement C (in Lab Manual section 1.2):Do the following first:a: make a folder at H:\your-project-nameb: copy C:\EmbestIDE\Examples\ucos-II\(everything) to H:\ your-project-name \Using manual mode temperature control and inlet control of the Hot Air Blower in the Labview simulation, create a task to implement a PID control algorithm for temperature using the Embest Board (implement formula 1.2 in Labmanual), interfacing Embest with Labview.

26

How to implement Lab1? (conn.3/4)

5. Implement sending an Air Inlet close/open signal(see Lab Manual section 1.4) from Labview and receiving the Air Inlet close/open signal on the EmbestBoard. Continue to manually control the Inlet in Labview.6. Implement Bumpless Transfer control (in Lab Manual section 1.4) on Embest Board, refer to section 4.4 of the book “Real-Time Computer Control”. 7. Implement Human Interface (set point temperature in Lab Manual section 1.7) on Embest Board.

Page 14: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

14

27

How to implement Lab1? (conn.4/4)

8. (Optional) Implement more advanced control algorithms (in the book “Real-Time Computer Control”) and environment simulation (in Lab Manual section 1.6).

28

Lab Organization

Lab1 total marks is 12%.2% lab example requirements, 4% report, 3% LabView demo, 3% Embest demo.The Lab1 Simulation and Embest Demo due to Oct. 9/11, 2007 in the Lab. Lab Report Due Oct. 11.

Page 15: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

15

29

Questions?

30

FAQ1: How to set up Hyper Terminal? (1)

Start All Programs Accessories CommunicationHyper Terminal Give a name of your hyper terminal

select COM1 select 115200, 8, none, 1, None.

(Or refer to Page140 in the book “Embedded System Development and Labs for ARM” to set up Hyper Terminal.)

Page 16: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

16

31

FAQ2: How can I do Digital input and DA Output using Labview?

For Digital Input, an input DAQ assistant will be used. It can be found at Express Input DAQ assistant.

For DA, an output DAQ assistant will be used. It can be found at Express Output DAQ assistant.(should select 1 sample)

Alternatively, a general configurable DAQ assistant can be found by going to Measurement I/O NI-DAQmx

DAQAssist, then configure for Digital I/O or DA output.

32

FAQ3: Our course hasn’t covered tasks yet , how can I modify the multitasking code?

In ucos-II main.c, there are 4 tasks for displaying led display, 7seg display, etc. For now just delete task2, task3, and task4 related code and also delete the multitask communication code like semaphores, etc. Recompile and download the downloadable file and see if the remaining task1 is still working. If yes, then implement your PID control, inlet close/open information processing and set point temperature code in task1.

Page 17: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

17

33

FAQ3: Where is the I/O and A/D Pinout Diagram? (3)

The diagrams are at page 50, in the book “Embedded System Development and Labs for ARM”.

34

FAQ4: What pins I can be used for AD and I/O?

For AD converter, AN1 to AN7 can be used.For I/O ports, some I/O ports are multiplexing used by ucos-II project like LCD, UART. (more details are in books or hardware specs) If you use these ports/pins for I/O, there could be problems on those devices. Some ports like port C are not used by the ucos-II project, so you can reconfigure and use it. Only reconfigure the bits you are going to use.

Page 18: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

18

35

FAQ5: Where is the information for programming AD converter?

The information can be found from page 220, in the book “Embedded System Development and Labs for ARM”.More information can be found at 13-1, in the specification “USER'S MANUAL S3C44B0X 16/32-Bit RISC Microprocessor”.

36

FAQ5 : A/D Programming Example

unsigned int temperature = 0;…rADCCON = 0x1| (0x01 <<2); // start AD conversionwhile(rADCCON & 0x1); //to avoid first flag errorwhile(!(rADCCON & 0x40))for(i=0;i<rADCPSR;i++) //to avoid the second

flag errortemperature = rADCDAT; //get the temperature valueuHALr_printf("Input temperature value %d from

analog channel 0. \n", temperature);

Page 19: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

19

37

FAQ6: Where is the information for programming I/O port?

The information can be found from page 145, in the book “Embedded System Development and Labs for ARM”.

More information can be found at 8-1, in the specification “USER'S MANUAL S3C44B0X 16/32-Bit RISC Microprocessor”.

38

FAQ6 : Port C Example

/*initialize Port C*/rPCONC &= 0x0ff05555; // use PC0-PC7...

/* send data E to port C */rPDATC |= 0x00ee; //change bits 1-8rPDATC &= 0xffee; //change bit 0uHALr_printf(" Send current data 0xEE to port C\n\n");

Page 20: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

20

39

FAQ7: Polling or Interrupt?

In Lab1, we are not focusing on multitasking and time critical tasks. So one task with polling (in a while loop) is OK for processing the AD and I/O data.

40

FAQ8: The Range of Temperature Number?

The range of temperature around the set point should not be very large, like 0 to 10000, if you want to observe temperature changes close to the set point. A better range would be 0 to 50 or 21 to 100.

Page 21: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

21

41

FAQ9: mn Range?

The output of PID algorithm mn is just a series of positive and negative numbers that can represent current. The current has 256 (+/- 128) values. So a proper number range need to be found to represent the 256 values while scaling the error in a reasonable range. Is it a linear relation?i.e. set a reasonable cap for your error value and then make use of the full scale range for accuracy.Implement the PID with all 3 constants together—kp, ki, and kd. Then test with different values to try for better results. These values are constants. We are not taking into consideration the Ts, Ti time (sampling time etc), so no exact values.

42

FAQ10: Some time the data acquisition card is not stable? (10)

When data acquisition period is too short, the card could be in an unstable state. Another case is when a multi channel AD acquisition is performed using many DAQ Assistants, the card will not work in a stable state. To solve these problems, you need to put multi AD channels in one DAQ Assistant and the period of data acquisition should be long enough according to your application.

Page 22: ENGG*44200 Real Time Simulation/Experimentation · 2007-09-04 · Introduction to LabVIEW: • Click on Labview8.0 icon on PC desktop • Graphical development environment. • Test

22

43

FAQ 11: Obtaining input data

You will need to split the 8 channels that are coming out of the input DAQ. You can use a splitter or an indexed array to do the job.