Sensors

From EG1004 Lab Manual
Revision as of 21:29, 1 February 2006 by Admin (talk | contribs)
Jump to: navigation, search

EG1004 Lab 7: Sensors

1 OBJECTIVES

The experimental objective of this lab is to design two programs. The first is a RoboLAB program that uses light and touch sensors to stop a motor when a yellow brick is detected. The second is a LabVIEW program that uses a thermocouple to measure air temperature in the heating and cooling program you designed in the LabVIEW Lab.

We will learn to use light, touch, and temperature sensors so that we can use these tools in our semester-long design projects.

2 OVERVIEW

RoboLAB Program

Before we can learn to use sensors, we must become familiar with the RCX. Remember that the RoboLAB program is a compiler: a program used to make other programs. Just as a compiler is used when creating and debugging a C++ program, RoboLAB compiles programs for the RCX. The RoboLAB interface is graphic; a text compiler like those used for C++ is not. However, the principle is very much the same. Actions are taken based upon circumstances set by the programmer.

The RCX houses all the programming instructions that control the movement of your robot. Once you have created your program in RoboLAB, it is uploaded to the RCX. The RCX then dictates the robot's motion. If your robot does not do what you intended, you must rewrite the program in RoboLAB and upload the corrected version to the RCX.

LabVIEW Program

The thermocouple records temperatures that are transmitted through the DAC board. LabVIEW uses these values to operate the heating and cooling system you designed in the LabVIEW Lab. To program your heating and cooling system VI to gather information from an outside source (thermocouple), you must add an AI Sample Channel. In order to wire this VI, you must right-click on the icon, select Visible Items, and then Terminals.

Developing advanced programming skills in both RoboLAB and LabVIEW will allow you to successfully complete your semester-long design project. This lab will help you acquire those skills.

3 YOUR ASSIGNMENT

  • A Zip file including all LabVIEW programs (.vi) needs to be submitted to eg.poly.edu. If you don't know how to make a zip file, read the page "How to Compress Your Files" in the "Instructional Presentations" section.

Individual Lab Report

Instead of a lab report his week, you will practice writing computer documentation. Being able to explain how to use software to other people is something you will need to master to be successful in your career. Before you begin, you must read the section titled Writing Software Documentation in the Technical Communication section of this online manual.

  1. Your user, Natasha Gibson, is an electrical engineer who is designing automated systems. She is an experienced computer user who has never tried LabVIEW. When she loads a software package for the first time, she refers to the manual to help her get started. Your job is to write a set of instructions to support Natasha as she learns to program a heating and cooling system VI to gather information from an outside source using LabVIEW.
  2. Prepare a one-paragraph Introduction that describes LabVIEW. You should talk about how it will make Natasha’s job easier. This will provide an incentive for her to learn it. You should describe what LabVIEW is, what a Virtual Instrument (VI) is, and how it helps engineers in the task of data acquisition.
  3. Next, you will write Procedures for Natasha to follow. First, prepare a scenario. This sets up the user to perform the task (e.g. LabVIEW allows you to design a program that simulates a typical household lighting system). List the steps Natasha should follow to program a heating and cooling system VI to gather information from an outside source. To make this easier, perform the task yourself and take notes on each step. You may not copy the steps listed in this manual. Each numbered step must be a complete sentence. Use a standard format. See Writing Software Documentation in the Technical Communication section of this online manual for help in preparing this assignment.

Team PowerPoint Presentation

There is no presentation for this lab

4 MATERIALS AND EQUIPMENT

  • Lab PC
  • RoboLAB and LabVIEW Software
  • USB Tower
  • RCX Unit
  • Light Sensor Array
  • DAC Board
  • Thermocouple

5 PROCEDURE

Program 1: RoboLAB Sensors

In this exercise, you must find a yellow brick out of a collection of multi-colored bricks. The yellow brick has a larger light reflectivity than bricks of other colors. Thus, you can find the yellow brick by searching for the largest light reflectivity among all the candidate bricks. You will be provided with a test assembly that continually moves a light sensor, mounted on a motor, back and forth along a short track. There is a touch sensor at each end of the track that indicates that the end of the track has been reached. The light sensor, the two touch sensors, and the motor are all connected to the RCX.

You must create a RoboLAB program for the test assembly. See Figures 1-3. The test assembly has four main components: a motor, a light sensor, and two touch sensors. The objective of this assignment is to create a RoboLAB program that will move the light sensor side-to-side until it detects the yellow brick. When it does, it will stop running. To move the light sensor, you must run the motor. If you reverse the direction of the motor, the light sensor will move in the opposite direction. If the yellow brick is removed from the test block, then the light sensor must move all the way to one side until it hits the touch sensor, then reverse direction and move to the other side until it hits the other touch sensor. This process must continue until the yellow brick is placed back on the test block and the light sensor detects it. The program ends once the yellow brick is detected

Lab sensors 2.jpg

Figure 1: Test Assembly, angled view

Lab sensors 4.jpg

Figure 2: Test Assembly, side view

Lab sensors 6.jpg

Figure 3: Test Assembly, top view

  1. Before we begin, we need to determine the light percentage that allows the sensor to detect the yellow brick.
  2. Make sure the RCX is turned on, the USB Tower is plugged in, and the RCX is within range of the USB Tower.
  3. Pull down the Project menu, select COM Port, and choose USB1. Click the check mark.
  4. Pull down the Project menu, select Interrogate RCX.
  5. Within a few seconds, the RCX Present indicator will turn green and the battery power meter will begin to read. Notice the small gray buttons labeled 1, 2, and 3 on top of the picture of the RCX. These buttons represent the inputs on the RCX.
  6. Note: If a window opens when you launch RoboLAB with Install Extras highlighted, you must click on the Install Extras button and restart RoboLAB. If Remove Extras is highlighted, click the check box and continue.


  7. Click on the 1 button. A gray box will appear. Click on the box and set the two menus to Reflection and Percent.
  8. Input 1 (Sensor 1) is now set up to receive data from a light sensor. Plug a light sensor onto Input 1 on the RCX. The sensor returns a percentage between 1 and 100. Put the sensor in front of the yellow brick. When the number stabilizes, this percentage is the amount of reflected light given off by the yellow brick. Your screen will look like Figure 4.
  9. File:Lab sensors 7.gif

    Figure 4: Interrogate RCX window

  10. It is a good idea to test the sensor. To do this, shine the light sensor at different colors of Lego blocks. Note the light percentage returned and the factors that affect the reading, e.g., glossiness, distance, and color.
  11. Now you will program the light and touch sensors. For the purposes of this lab, program the motor to Port A, Input 1 is the light sensor, Input 2 is touch sensor 2, and Input 3 is touch sensor 3.
  12. Open the Functions palette and write a program that will use each of the touch sensors to help the light sensor detect the yellow brick. In order to do this, you will need to be familiar with the tools on the Functions palette, shown in Figure 5.

File:Lab sensors 8.gif

Figure 5: The Functions palette

Wait For

File:Lab sensors 9.gif

The Wait For icon allows your program to wait (pause) for a certain amount of time, or until a particular condition is met. The program will run up to the Wait For command and then pause until the set period of time has elapsed or until the specific condition has been met. If a Wait For command needs information from a sensor, the sensor must be wired to a port modifier so RoboLAB knows where to find it.

Forks and Splits

File:Lab sensors 10.gif File:Lab sensors 11.gif

The Fork Split command is in the Structures menu. It will split the path of the program based on a condition you set. For instance, the program will perform one of two tasks depending on the value it receives from the light sensor. Every Fork Split in the program must be accompanied by a Fork Merge. This combination of a Fork Split and a Fork Merge works like a pair of parenthesis. Every open parenthesis must be closed. Sensor Forks must be connected to a port modifier so RoboLAB knows where to look for sensor input.

Task Split

The Task Split command is also located in the Structures menu. It allows you to create two separate tasks that will run simultaneously. When implemented, your original program becomes two separate independent tasks. Each task must end with its own red stop light.

Jumps and Lands

File:Lab sensors 12.gif File:Lab sensors 13.gif

The Jumps menu is found in the Structures menu. When the program reaches a Jump command, it skips to wherever you have placed a Land command. Note that there are six different colored Jump and Land commands. So, the red Jump will always correspond with the red Land, and so on. You can use a Jump and Land with a Fork Split to make a loop.

Loops

File:Lab sensors 14.gif

The Loops menu is under the Structures menu. Hover your cursor over each of the icons to learn what they do. All loops must be used in conjunction with a Loop End command.

Touch Sensors

There are touch sensor structures that use the Wait For, Loop, and Fork structures.

File:Lab sensors 15.gif File:Lab sensors 16.gif

The touch sensor Wait For commands will pause the motor(s) until the touch sensor is released or pushed, depending on the direction of the arrow.

File:Lab sensors 17.gif

The touch sensor Fork takes one input and produces two outputs, splitting the path into two possibilities. The first possibility is the result when the touch sensor is released and the second is the result when the touch sensor is pushed.

File:Lab sensors 18.gif File:Lab sensors 19.gif

The touch sensor Loop executes when the sensor is pushed or released, depending on the direction of the arrow.

Light Sensors

File:Lab sensors 20.gif

A light sensor Fork works in the same way as a touch sensor Fork, except there is an extra connection that is attached to a numeric constant. The RCX decides if the light sensor is returning a value higher or lower than the constant, and chooses a program path based on that information.

File:Lab sensors 21.gif File:Lab sensors 22.gif

The light sensor Loop works just like the touch sensor Loop. Depending on the value the sensor returns, the loop will either continue executing the code inside the loop, or it will move on to the rest of the program.

Timers

File:Lab sensors 23.gif

Timer structures are linked and used like the sensors are used; however, instead of getting values from sensors, they hold values in timer containers. Timers count the time elapsed from when they are reset.

Before using a timer, it must be reset to 0. This is done using the Zero Timer command in the Reset menu. This command takes two inputs and gives one output.

File:Lab sensors 24.gif

The Timer Modifier and value can be found in the same menu as the port and motor modifiers. The timer modifier indicates which timer a structure is referring to. The value of the timer can be used for comparison in a timer loop or a timer fork by using the timer value command.

File:Lab sensors 25.gif File:Lab sensors 26.gif

The Timer Loop executes a selection of code while the timer is less than or greater than a certain value. The structure has four connections: one input for the flow of the program, one output for the flow of the program, one to specify which timer to look at, and one to specify what value the timer is being compared to.

File:Lab sensors 27.gif

The Wait For Timer will pause the program as it waits for the timer value to match the input value. This structure has four connections: one input for the flow of the program, one output for the flow of the program, one to specify which timer to look at, and one to specify what value the timer is being compared to.

File:Lab sensors 28.gif

The Timer Fork works the same as the Light Sensor Fork and the Touch Sensor Fork.

It compares the value of the timer to a set value and pauses the program until the timer equals the value it is being compared to. The structure has five connections: one input for the flow of the program, one output for the flow of the program if the timer is greater than the compared value, one output for the flow of the program if the timer is less than the compared value, one to specify which timer to look at, and one to specify what value the timer is being compared to.

Other Structures

File:Lab sensors 29.gif

The Flip Direction function will change the direction of any motor attached to it.

It has two inputs and one output. The output and the first input control the flow of the program. The other input is the port modifier which indicates which motor's direction should be changed.

File:Lab sensors 30.gif File:Lab sensors 31.gif File:Lab sensors 32.gif

Containers are structures that can be used like Timers, because they hold values and can be reset. They can be compared to loops and forks, and work like variables in C++, because they can be added to and set to be equal to specific values. This structure should be experimented with independently.

Remember, RoboLAB will tell you the name of each icon if you hover your cursor over it. When you are finished, your TA must test your program.

Note: To receive data from an input for a touch sensor, set the two menus to Switch and Boolean and follow the same steps.


Program 2: LabVIEW Temperature Indicator System

  1. Open the heating and cooling program you designed in the LabVIEW Lab. Switch the case to the automatic case.
  2. From the Functions palette select All Functions, NI measurements, and Data Acquisition, then select Analog Input, and then AI Sample Channel.
  3. Drag and drop the AI Sample Channel node into the automatic case on the back panel of your existing program.
  4. Right-click on the AI Sample Channel node and select Visible Items, then Terminals.
  5. Right-click on the AI Sample Channel node and click the Select Type menu. Select Scaled Value.
  6. Wire the AI Sample Channel node as shown in Figure 6.

Lab sensors 33.jpg

Figure 6: AI Sample Channel node.

Wiring the Sample Channel node

  1. Device ID (integer): the DAC board is recognized by the computer as 1.
  2. Channel (string): for our purposes we will always set this to thermocouple.
  3. Upper Limit (real number): for our purposes we will always set this to +5.
  4. Lower Limit (real number): for our purposes we will always set this to -5.
  5. Output.
  6. Change the thermometer to an Indicator by right clicking on it and selecting Change to Indicator.
  7. Connect the output from the Sample Channel to the thermometer.

Testing Your Design

  1. Connect the yellow wire of the thermocouple to pin 3 on the DAC board.
  2. Connect the orange wire of the thermocouple to pin 4 on the DAC board.
  3. Run the program continuously.
  4. Hold the thermocouple between your fingers to make the temperature rise. Confirm that the indicator on your program rises.
  5. Place thermocouple in a cup of cold water to make the temperature fall. Confirm that the indicator on your program falls.

Have all sketches and original data signed by your TA. Your lab work is now complete.

Please clean up your workstation. Return all unused materials to your TA.

Refer to section 3 Your Assignment for the instructions you need to prepare your assignments this week.


Return to Table of Contents