38
FYS3240 PC-based instrumentation and microcontrollers Introduction Spring 2014 Lecture #1 Bekkeng 19.1.2014

FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

FYS3240

PC-based instrumentation and microcontrollers

Introduction

Spring 2014 – Lecture #1

Bekkeng 19.1.2014

Page 2: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

FYS 3240/4240

Two main parts:

1. Computer based instrumentation and DAQ

Data acquisition (DAQ) systems

LabVIEW (for DAQ software development)

2. Practical introduction to microcontrollers for instrumentation

Learning by doing

Page 3: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Curriculum

• Lectures

• Laboratory exercises

• The textbook readings complement the lectures

Textbooks:

• Ørjan G. Martinsen: PC-basert instrumentering og mikrokontrollere, 2006.

Gyldendal. ISBN: ISBN-13: 978-82-05-31569-3.

• Gary Johnson and Richard Jennings: LabVIEW Graphical Programming,

Fourth Edition, 2006. McGraw-Hill Professional. ISBN: 978-0071451468 .

Page 4: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Lecturer

• Jan Kenneth Bekkeng (Senior Scientist FFI, Ass. prof-II UIO)

• Email: j.k.bekkeng[at]fys.uio.no

T&E

Sounding rockets

DAQ

Page 5: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

About the lectures and Labs

• Lectures given in English (Norwegian if no English speaking students)

• Notes will be made available on the course home page

• Important messages are made available at the course home page

• 2 lecture hours each week

• 4 (bachelor) / 5 (master) lab assignments - room V442

• Submit the lab reports including the source code to the lab teaching

assistant

• Nominally three weeks are assigned to each lab assignment

TA information:

• Snorre Bjørnstad

• E-mail: snorre.bjornstad[at]fys.uio.no

• Phone: 92077067

• Lab guidance - TA comes to the lab:

• Monday: 9.00 and 14.00

• Tuesday: 10.00 and 13.00

Page 6: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Atmel XMEGA-B1 Xplained evaluation kit

Page 7: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

About the lab work

• Lab 0: LabVIEW introduction with exercises

– Learn basic application development with LabVIEW

• Lab 1: Simple I/O programming

– LEDs and switches

• Lab 2: Control an LCD display

• Lab 3: Control the ADC (analog to digital converter) –

• Lab 4: Project for Master students (FYS 4240)

– Select a microcontroller project or the LabVIEW DAQ project

– If you want to make your own microcontroller project, make sure that you get your planned project work approved by the TA (teaching assistant) before you start on the lab!

Microcontroller

labs

Page 8: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Course background

• Assumes basic knowledge in electronics, computer

architecture and programming. This is covered e.g. by

– FYS1210 (basic electronics)

– FYS3230 (sensor and measurement techniques)

– A programming course (e.g. INF 1000)

– The textbook “PC-basert instrumentering og mikrokontrollere”

• The lectures will focus on:

– DAQ systems

– System design (hardware and software)

– Technology, principles, concepts and implementation

Page 9: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Computer courses with more “theory”

& background information

• INF2270 – Datamaskinarkitektur

– C-programming

– Computer architecture

– Hardware and software interaction

• INF1060 - Introduksjon til operativsystemer og

datakommunikasjon

– C-programming

– OS

– Data communication

• INF3190 – Datakommunikasjon

– Data communication

Page 10: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Other good books:

• LabVIEW for Everyone: Graphical Programming Made

Easy and Fun (3rd Edition) by Jeffrey Travis and Jim

Kring

• The LabVIEW Style Book by Peter A. Blume

• LabVIEW for Data Acquisition by Bruce Mihura (2001)

• The C Programming Language by Brian W. Kernighan,

Dennis M.Ritchie(1988)

Page 11: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Topics you will learn about

• Computer buses and interfaces

• Microcontrollers

• LabVIEW programming

• Instrumentation and data acquisition (DAQ)

• Networked and distributed DAQ systems

• High-speed data streaming

• Parallel programming

• Real-Time and Embedded systems

• FPGAs and GPUs

• Instrumentation under Linux

• Time & timestamping

• GPS

Page 12: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

LabVIEW LEGO MINDSTORMS NXT Module

The Tilted Twister solves

Rubik’s Cubes in 6 minutes!

Can develop LabVIEW programs that run on a host computer and

communicate with an NXT brick. These programs also can run directly on the

NXT.

youtube

Page 13: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Trends in Test and Measurement

• Multicore CPUs and Parallel programming

– Increased CPU performance without increased clock rates

• Software-Defined Instrumentation

– Can easily change functionality

• FPGA-Enabled Instrumentation

– High performance, True parallelism, High determinism,

High reliability, Reconfigurable

• 64 bit operating systems and support

– An “unlimited” address space allows much more RAM

(Random Access Memory) in the computer

• Wireless

Page 14: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Moore’s law

Moore’s law: the number of transistors per square inch on integrated

circuits (or in general, the performance/capability) doubles approximately

every 18 months.

Page 15: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Smartphones and tablets in DAQ

systems (Wireless)

• Remote monitoring

– Send measurement data to a smartphone or

a tablet for viewing data

• Remote control

– Control the DAQ-unit from phone/tablet

• Send data between a DAQ

unit/computer and a smartphone/tablet:

– TCP/UDP/Bluetooth

– Web services

– NI LabVIEW network-published shared

variables

• Smartphone/tablet app

– Custom app development

– NI Data Dashboard app

DAQ unit

Page 16: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

What is LabVIEW

Icon wire

Express VIs

Standard VIs

Data flow direction

Page 17: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Example: a while loop in LabVIEW

Page 18: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

What is LabVIEW II

• LabVIEW is a graphical programming environment

– G programming language

• LabVIEW contains the same programming concepts found in

most traditional languages

– data types, loops, event handling, variables, recursion, and object-oriented

programming

• LabVIEW is a de facto standard for measurement, test, and

control systems (both in industry and academia)

• Graphical icons and wires resemble a flowchart

• Provides easy integration with thousands of hardware devices

• Contains large built-in libraries

• Available for multiple targets and OS (Windows, Mac, Linux

and RTOS)

http://www.ni.com/labview/whatis/

Page 19: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

LabVIEW Operating System (OS)

compatibility

Page 20: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

LabWindows/CVI from National

Instruments

• CVI is short for C for Virtual Instrumentation

• LabWindows/CVI is a software development

environment for C programmers

• LabWindows uses the same libraries and data

acquisition modules as the more famous

National Instrument product LabVIEW and is

thus highly compatible with it

• LabVIEW is targeted more at domain experts

and scientists and CVI more towards software

engineers that are more comfortable with text-

based linear languages such as C

Page 21: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Instrument Control Overview

Control any instrument if you know the following:

– Type of connector on the instrument − Type of cables needed

– Electrical properties involved − Communication protocols used

– Software drivers available

Instruments Computer

Page 22: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Real-Time Computing

• In computer science, real-time computing (RTC) is systems

that are subject to a "real-time constraint“- i.e., operational

deadlines from event to system response.

– the correctness depends not only on the logical result but also on

the time it was delivered

• By contrast, a non-real-time system is one for which there is no

deadline, even if fast response or high performance is desired

or preferred.

FYS4220

Page 23: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Embedded Computing

• An embedded system is a computer system designed to

perform one or a few dedicated functions, often with real-

time computing constraints.

• Embedded systems span all aspects of modern life and there

are many examples of their use: mobile phones, MP3 players,

digital cameras, GPS receivers etc.

• Embedded processors can be microprocessors,

microcontrollers or FPGAs.

• The program instructions written for microcontrollers are

referred to as firmware, and are stored in read-only memory or

Flash memory chips.

• Embedded systems run with limited computer hardware

resources: limited memory, small or non-existent keyboard

and/or screen

FYS4220

Page 24: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Data Acquisition (DAQ) & Control Systems

• The main application domain for Real-Time and Embedded computer systems is within Data Acquisition and Control.

• A dish washer system reads data from a timer, temperature and water level sensors, and controls the water valves and heater

• Data acquisition involves collecting signals from measurement sources and digitizing the signal for storage, analysis and presentation.

– For a Control System the processed data is also utilized for controlling the external process through a feedback loop

Page 25: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Computer-based DAQ system

• Configuration

• Display

• Data Storage

FYS3240/4240

Page 26: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Third generation PC (2004) 6

6 –

80

0 M

Hz

Page 27: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

What is an Operating System (OS)?

• “An operating system (OS) is a collection of programs that acts

as an intermediary between the hardware and its user(s),

providing a high-level interface to low level hardware resources,

such as the CPU, memory, and I/O devices. The operating

system provides various facilities and services that make the

use of the hardware convenient, efficient and safe” Lazowska, E. D.:

Contemporary Issues in Operating Systems , in: Encyclopedia of Computer Science, Ralston, A., Reilly, E.

D. (Editors), IEEE Press, 1993, pp.980

• The OS hides the messy details

• The OS Presents a virtual machine, which is easier to use

• Each program gets time/space on the resource

Page 28: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Protected mode

• In computing, protected mode is an operational mode of x86-

compatible central processing units (CPU)

– The term x86 refers to a family of instruction set architectures based

on the Intel 8086 CPU

– It allows system software to utilize features such as virtual memory,

paging, safe multi-tasking, and other features designed to increase

an operating system's control over application software.

• In protected mode, there are four privilege levels or rings,

numbered from 0 to 3, with ring 0 being the most privileged and

3 being the least. The use of rings allows for system software to

restrict tasks from accessing data or executing privileged

instructions.

• In most environments, the operating system and some device

drivers run in ring 0 and applications run in ring 3

Page 29: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Windows architecture

• Ring 0 : ”all rights”

– operating system (kernel)

• Ring 3 : limited rights e.g. related to I/O

– Applications (user programs)

32 bit Windows XP

Privilege levels in Windows

• Need a device driver in order to

allow hardware I/O operations

from application programs

Page 30: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Device Drivers

• In computing, a device driver or software driver is a computer

program allowing higher-level computer programs to interact

with a hardware device.

• A driver typically communicates with the device through the

computer bus or communications subsystem to which the

hardware connects. When a calling program invokes a routine

in the driver, the driver issues commands to the device. Once

the device sends data back to the driver, the driver may invoke

routines in the original calling program. Drivers are hardware-

dependent and operating-system-specific.

Page 31: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Windows device drivers

Page 32: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

How to make a device driver for

Windows?

• Writing a device driver can be a challenge as it requires

windows (API) programming knowledge

• Different approaches to get the device driver you need:

– Make a complete device driver

– Make the device driver using a program to assist you

making the driver, e.g. a program called “Driver Agent”

– LabVIEW includes custom made drivers (for serial

communication, TCP, UDP, USB, DAQ etc) . In

addition, device drivers for specific instruments etc.

can be downloaded from NI. Therefore, usually no

device driver has to be written!

Page 33: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Using device drivers in LabVIEW

• All NI hardware is shipped with LabVIEW driver software

• After your hardware driver software is installed, it is integrated into

LabVIEW

• It provides a new palette for easy access to the functions

• You simply drag-and-drop the functions to your block diagram to

configure and control the hardware device

Page 34: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

LabVIEW Hardware targets

• Standard PC

• Real-time PC

• Embedded controller (in a PXI system)

• FPGA

• 8-, 16-, and 32-bit microprocessors

• ARM Microcontrollers

– ARM = Advanced RISC Machine

Page 35: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Simple to advanced DAQ systems ….

• DAQ using the PC sound card

– AC, low frequencies (10 – 20 kHz)

• PC with plug-in PCI DAQ card(s)

• PC with a USB DAQ device

• DAQ system with multiple connected PXI systems

and hundreds of measurement channels

Page 36: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Workstation vs. PC

• A workstation is a high-end computer designed for technical or

scientific applications, running numeric- and graphic-intensive

applications

– high-performance computing (HPC)

• Desktops PCs are all about flexibility – they are designed to

meet a much wider variety of computing needs

• As desktop PCs become faster and stronger, the lines between

a high-powered desktop and true workstations become more

blurred

• Workstations typically offered higher performance than

personal computers, especially with respect to CPU and

graphics, memory capacity and multitasking capability

• In addition, workstations typically have more slots for PCI and

PCI Express

Page 37: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Workstation vs. PC II (2011)

HP Z800 Workstation

• 2 x Intel® Xeon® six Core processors (5600 series)

• 192 GB RAM (maximum)

• Rack-mountable (19” rack)

•1 PCI

•1 PCI Express Gen1 (x8 mechanical, x4 electrical)

•1 PCI Express Gen2 (x8 mechanical, x4 electrical)

•2 PCI Express Gen2 (x16 mechanical, x8 electrical)

•2 PCI Express Gen2 x16 (for graphics card)

HP Compaq dc7900

• Intel® Core™2 Quad processor

• 16 GB RAM (maximum)

• 3 PCI

• 1 PCI Express x16

• 2 PCI Express x1

Physical memory limit for 64-bit Windows (X64).

• Windows XP : 128 GB

• Windows 7 : 192 GB

• Windows 8 : 512 GB

Update 2012: HP Z820: 16 cores, up to 512 GB

DDR3 RAM, four internal HDDs

Page 38: FYS3240 PC-based instrumentation and microcontrollers• 1 PCI Express x16 • 2 PCI Express x1 Physical memory limit for 64-bit Windows (X64). • Windows XP : 128 GB • Windows

Intel Processors (2011)

Intel Xeon E7 2012