Top Banner
Mini Project- USB Temperature Logging Mini Project – USB Temperature Logging Author: University of Hertfordshire Date created: Date revised: 2009 Abstract The following resources come from the 2009/10 BEng in Electrical Engineering (course number 2ELE0066) from the University of Hertfordshire. All the mini projects are designed as level two modules of the undergraduate programmes. The objectives of this module are to demonstrate within an industrial environment: •To use USB development Kit •To programme with VB •To integrate the logging system The aim of this project is to develop a temperature logging system based on USB development Kit. The temperature logging system should collect ambient temperature samples, sample manipulation and display the data in a text and/or graphic format. Students design and programme GUI using VB. © University of Hertfordshire 2009 This work is licensed under a Creative Commons Attribution 2.0 License .
27

Mini Project- USB Temperature Logging

Dec 23, 2014

Download

Education

The following resources come from the 2009/10 BEng in Electrical Engineering (course number 2ELE0066) from the University of Hertfordshire. All the mini projects are designed as level two modules of the undergraduate programmes.

The objectives of this module are to demonstrate within an industrial environment:
To use USB development Kit
To programme with VB
To integrate the logging system

The aim of this project is to develop a temperature logging system based on USB development Kit. The temperature logging system should collect ambient temperature samples, sample manipulation and display the data in a text and/or graphic format. Students design and programme GUI using VB.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Mini Project – USB Temperature Logging

Author: University of HertfordshireDate created:Date revised: 2009

AbstractThe following resources come from the 2009/10 BEng in Electrical Engineering (course number 2ELE0066) from the University of Hertfordshire. All the mini projects are designed as level two modules of the undergraduate programmes.

The objectives of this module are to demonstrate within an industrial environment:•To use USB development Kit•To programme with VB•To integrate the logging system

The aim of this project is to develop a temperature logging system based on USB development Kit. The temperature logging system should collect ambient temperature samples, sample manipulation and display the data in a text and/or graphic format. Students design and programme GUI using VB.

© University of Hertfordshire 2009 This work is licensed under a Creative Commons Attribution 2.0 License.

Page 2: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Contents Introduction 4 Module Format 5 Project Day 1 Tasks 8 Project Day 2 Tasks 10 Project Lecture 11

Temperature Sensor 12 USB Protocol 13 USB Development Kit 19 Visual c# 20 Summary 27

Credits 28

In addition to the resources found below there are supporting documents which should be used in combination withthis resource. Please see:

Mini Projects - Introductory presentation. Mini Projects - E-Log. Mini Projects - Staff & Student Guide. Mini Projects - Standard Grading Criteria. Mini Projects - Reflection.

You will also need the Mini Project USB Temperature Logging Word document.

Page 3: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

During this mini project the design of a temperature acquisition system is to be considered.In order to design this system the following subjects need to be considered:

•What type of sensor can be implemented for a specific application

•What is a data acquisition system and how can it be constructed?

•How to acquire, analyse and present measurements o the user.

The temperature system you are going to design should be able to measure temperatures from ?°C and up to ?°C and have a resolution of at least ?°C.

Page 4: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

General Module Introduction

Project 1 Project 2(USB

temperature logging)

Project 3

3 weeks 3 weeks 3 weeks

Page 5: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

In week 1: •A two-hour introductory lecture•A 3-hour preparation session

Weeks 2 & 3•6-hour practical session •Find out goal for the day when you arrive•Deliver solution by the end of the day

Page 6: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

What is it?•Given a task•Work out how to solve it yourself –just like you will have to at work•Staff try to help you to work it out rather than giving answer

Why use Problem based approach?•Extremely powerful and effective technique•Can increase self-confidence and resourcefulness •Skills highly valued by employers

Page 7: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Page 8: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Page 9: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Page 10: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Page 11: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

•Features for the LM35•Calibrated directly in Celsius(centigrade)•Linear +10.0 mV/°C•0.5°C accuracy•Rated for full -55°C to +150°C range.•Suitable for remote applications•Operates from 4 V to 30 V•Less than 60 μA current drain•Low self-heating 0.08°C in still air•Nonlinearity only 1/4°C typical•Low impedance output, 0.1 Ω for 1 mA Load

Page 12: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Most computers have at most two RS232 serial ports, and they are relatively slow. Devices that needed faster connections came with their own interface cards, which had to fit in a card slot inside the PC’s case. Unfortunately, the number of card slots is limited and installing the software for some of these cards is far from trivial.

The main goal for the USB is to resolve all of these headaches. The Universal Serial Bus offers a single, standardized, easy-to-use way to connect up to 127 devices to a computer!!

Page 13: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Many USB devices come with their own build-in cable, and the cable has either an A-type connection on it or there is a socket on the device that accepts a B-type connector (both types are shown below).

A-type connector“Upstream” PC side

B-type connector“Downstream” Devise

side

Page 14: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

PC is acting as the host•Up to 127 devices can connect to the PC.•Individual USB cables can run as long as 5 meters.

•USB 2 supports a maximum data speed rate of 480Mb/sec. (Supported speeds are: 1.5, 12 and 480 Mb/sec).A USB cable has two wires for power and a twisted pair of wires to carry the data (shown below).

Red: +5 Volts White: DataBlack: Ground Green: Data

01992 451101

Page 15: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

•USB devices are “hot”-swappable, which means that they can plug and unplug to the bus at any time.•On the power wires, the computer can supply up to 500 mA of power at 5V.•High-power devices have their own power supplies and draw minimal power from the bus.•Hubs can have their own power supplies to provide power to devices connected to the hub.•Many USB devices can be put to sleep by the host computer when the computer enters a power-saving mode.

Page 16: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

When the PC powers up, it queries all of the devices connected to the bus and assigns for each one an address. This process is called enumeration. Devices are also enumerated when they connect to the bus. The PC also finds out from each device what type of data transfer it needs to perform:

•Interrupt- A device which will be sending very little data, would choose the interrupt mode.•Bulk-A device which receives data in one big packet, uses the bulk transfer mode.•Isochronous- Data streams between the device and the PC in real-time, and there is no error correction. The PC can also send commands or query parameters with control packets.

Page 17: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

As devices are enumerated, the PC is keeping track of the total bandwidth that all of the isochronous and interrupt devices are requesting. They can consume up to 90 percent of the 480 Mbps of bandwidth that is available. After 90%is used up, the host denies access to any other isochronous or interrupt devices. Control packets and packets for bulk transfers use any bandwidth left over (at least 10%). The Universal Serial Bus divides the available bandwidth into frames, and the host controls the frames. Frames contain 1,500 bytes, and a new frame starts every millisecond. During a frame, isochronous and interrupt devices get a slot so they are guaranteed the bandwidth they need. Bulk and control transfers use whatever space is left.

Page 18: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

01992 451101

•5 Digital Inputs•2 Analogue inputs•8 Digital outputs (open collector)•2 Analogue Outputs•General conversion time 20ms per command

Page 19: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

“C# is a type-safe object-oriented language that enables developers to build a wide range of secure and robust applications that run on the .NET Framework. You can use C# to create traditional Windows applications, XML Web services, distributed components, client-server applications, database applications, and much, much more.

Microsoft® Visual C# 2005 provides an advanced code editor, convenient user interface designers, integrated debugger, and many other tools to facilitate rapid application development based on version 2.0 of the C# language and the .NET Framework.”1

1MSDN Microsoft Developer Network (MSDN) Visual Studio 2005 Library

Microsoft® Visual C# Intro

Page 20: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

In Visual C#, the most rapid and convenient way to create your user interface (UI) is to do so visually, using the Windows Forms Designer and Toolbox. There are three basic steps in creating all user interfaces:

•Adding controls to the design surface.•Setting initial properties for the controls.•Writing handlers for specified events.

Although you can also create your UI by writing your own code, designers enable you to do this work much more rapidly than is possible by manual coding.

Microsoft® Visual C# Intro

Page 21: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Integrated Developer Environment

ToolboxWindows Form

Designer/

Code Editor

Task List

Solution Explorer

Properties

Microsoft® Visual C# Intro

Page 22: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

In the designer, you use the mouse to drag , such as buttons and text boxes, onto a design surface that represents your form. The following illustration shows a combo box that has been dragged from the Toolbox window onto a form in the Windows Forms Designer.

As you work visually, the designer translates your actions into C# source code and writes them into a project file called <name>.designer.cs where <name> is the name you gave to the form (Form1.cs in this example). When the application runs, that source code will position and size your UI elements so that they appear just as they do on the design surface. For more information, see Windows Forms Designer.

Toolbox

Windows Form Designer

/Code Editor

Task List

Solution Explorer

Properties

Microsoft® Visual C# Adding Control

Page 23: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

within an IDE interface you can do the following:Setting PropertiesAfter you add a control to your form, you can use the Properties window to set its properties, such as background colour and default text. The values that you specify in the Properties window are simply the initial values that will be assigned to that property when the control is created at run time. In many cases, those values can be accessed or changed programmatically at run time simply by getting or setting the property on the instance of the control class in your application. The Properties window is useful at design time because it enables you to browse all the properties, events, and methods supported on a control. For more information, see Properties Window.

Handling EventsPrograms with graphical user interfaces are primarily event-driven. They wait until a user does something such as entering text into a text box, clicking a button, or changing a selection in a list box. When that happens, the control, which is just an instance of a .NET Framework class, sends an event to your application. You have the option of handling an event by writing a special method in your application that will be called when the event is received.You can use the Properties window to specify which events you want to handle in your code; select a control in the designer and click the Events button, with the lightning bolt icon, on the Properties window toolbar to see its events. The figure on the side shows the events button.

When you add an event handler through the Properties window, the designer will automatically write the empty method body for you, and it is up to you to write the code to make the method do something useful. Most controls generate a large number of events, but in most cases an application will only need to handle a few of them, or even only one. For example, you probably need to handle a button's Click event, but you do not need to handle its Paint event unless you want to customize its appearance in some advanced way.

Microsoft® Visual C#

Page 24: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Where to get more information on visual studio C# MSDN Visual Studio 2005 Library

You can find further information on MSDN help files by looking it up on Microsoft® website.

Microsoft® Visual C#

Page 25: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

Topics to Read Practice Progress

1 Review the Data sheet for the LM35

2 Review the Data sheet for the LM324

3 Review the “Manual_K8055_UK.pdf” manual and make sure you run the example programme for the USB kit.

4 Review the “Manual_UK_K8055_DLL” and familiarise yourself with the possible operation of the USB kit

5 Go through the “Creating and Application in c#.pdf” file.

6 Go through the “C# writing application.pdf” file

7 Create an application in c# to calculate sinusoidal values and display them via a textbox control. A timer control should be used during this step.

You will need to be familiar with the topics above and also be able to access the first 4 files (1, 2, 3 & 4) for future session of the mini project. Make sure you are familiar with topics 5, 6 and 7 as you will not have time to do them during the mini project future sessions

Page 26: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

•Turn up to and for everything – there is no referral for the practical, only repeat!•Plan – Break down the day’s objective into a series of smaller tasks each morning before you start work.•Monitor your own progress during the day•Submit everything in the correct format, correct template and on time.•Use reflection to improve your performance as the course progresses.

Page 27: Mini Project- USB Temperature Logging

Mini Project- USB Temperature Logging

This resource was created by the University of Hertfordshire and released as an open educational resource through the Open Engineering Resources project of the HE Academy Engineering Subject Centre. The Open Engineering Resources project was funded by HEFCE and part of the JISC/HE Academy UKOER programme.

© University of Hertfordshire 2009

This work is licensed under a Creative Commons Attribution 2.0 License.

Microsoft product screen shots reprinted with permission from Microsoft Corporation. Microsoft and Visual C# are either registered trade marks or trade marks of Microsoft Corporation in the United States and/or other countries.

The name of the University of Hertfordshire, UH and the UH logo are the name and registered marks of the University of Hertfordshire. To the fullest extent permitted by law the University of Hertfordshire reserves all its rights in its name and marks which may not be used except with its written permission.

The JISC logo is licensed under the terms of the Creative Commons Attribution-Non-Commercial-No Derivative Works 2.0 UK: England & Wales Licence.  All reproductions must comply with the terms of that licence.

The HEA logo is owned by the Higher Education Academy Limited may be freely distributed and copied for educational purposes only, provided that appropriate acknowledgement is given to the Higher Education Academy as the copyright holder and original publisher.