FYS3240
PC-based instrumentation and microcontrollers
Introduction
Spring 2013 – Lecture #1
Bekkeng 8.1.2013
FYS 3240
Two main parts:
1. Computer based instrumentation and DAQ Data acquisition (DAQ) systems
LabVIEW
2. Practical introduction to microcontrollers for
instrumentation
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 .
Lecturer
• Jan Kenneth Bekkeng (Senior Scientist FFI, Ass. prof-II UIO)
• Email:
– j.k.bekkeng[at]fys.uio.no
T&E
Sounding rockets
DAQ
About the lectures and Labs
• Lectures given in Norwegian (English if requested)
• 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(s)
• Nominally three weeks are assigned to each lab assignment
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 project, make sure that you get your planned project work approved by the TA (teaching assistant) before you start on the lab!
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)
– Principles, concepts and implementation strategies
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
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)
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
• GPS & INS
• FPGAs and GPUs
• Instrumentation under Linux
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
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
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 the 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/
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
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
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
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
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
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
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
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
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.
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!
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
LabVIEW Hardware targets
• Standard PC
• Real-time PC
• Embedded controller (in a PXI system)
• FPGA
• 8-, 16-, and 32-bit microprocessors
• ARM Microcontrollers
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
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
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 7 : 192 GB
• Windows 8 : 512 GB
Update 2012: HP Z820: 16 cores, up to 512 GB
DDR3 RAM, four internal HDDs