Difference between revisions of "Sensors"
(No difference)
|
Revision as of 15:47, 11 February 2005
EG1004 Lab 6: Sensors
6.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 Lab 4.
We will learn to use light, touch, and temperature sensors so that we can use these tools in our independent projects.
6.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 Lab 4. 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 independent project. This lab will help you acquire those skills.
6.3 YOUR ASSIGNMENT
Team PowerPoint Presentation, Individual Lab Report (one report per student), Component Testing, and Progress Presentation.
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.
In addition, Milestone 2 is due this week. Refer to your specific Independent Project description for more information.
- 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.
- 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.
- 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 assingment.
Component Testing
After making the PowerPoint presentation described in Milestone 2, Component Testing for your specific project will take place. Robot models will be tested for functionaliy, and RoboLAB programs will be tested for accuracy. Similarly, where applicable, the lighting system and heating and cooling systems for your supermarket design must be fully functional. Your LabVIEW programs will be tested for their accuracy.
6.4 MATERIALS AND EQUIPMENT
- Lab PC
- RoboLAB and LabVIEW Software
- USB Tower
- RCX Unit
- DAC Board
- Thermocouple
6.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 6.1-6.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.
- Before we begin, we need to determine the light percentage that allows the sensor to detect the yellow brick.
- Make sure the RCX is turned on, the USB Tower is plugged in, and the RCX is within range of the USB Tower.
- Pull down the Tools menu, select COM Port, and choose USB1. Click the check mark.
- Pull down the Tools menu, select Interrogate RCX.
- 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.
- Click on the 1 button. A gray box will appear. Click on the box and set the two menus to Reflection and Percent.
- 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 6.4.
- 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.
- 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 A, and Input 3 is touch sensor B.
- 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 6.5.
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.
Wait For
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:Lab6 10.gif File:Lab6 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:Lab6 12.gif File:Lab6 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
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:Lab6 15.gif File:Lab6 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.
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:Lab6 18.gif File:Lab6 19.gif
The touch sensor Loop executes when the sensor is pushed or released, depending on the direction of the arrow.
Light Sensors
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:Lab6 21.gif File:Lab6 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
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.
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:Lab6 25.gif File:Lab6 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.
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.
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
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:Lab6 30.gif File:Lab6 31.gif File:Lab6 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
- Open the heating and cooling program you designed in Lab 4. Switch the case to the automatic case.
- From the Functions palette select All Functions, NI measurements, and Data Acquisition, then select Analog Input, and then AI Sample Channel.
- Drag and drop the AI Sample Channel node into the automatic case on the back panel of your existing program.
- Right-click on the AI Sample Channel node and select Visible Items, then Terminals.
- Right-click on the AI Sample Channel node and click the Select Type menu. Select Scaled Value.
- Wire the AI Sample Channel node as shown in Figure 6.6.
Wiring the Sample Channel node
- Device ID (integer): the DAC board is recognized by the computer as 1.
- Channel (string): for our purposes we will always set this to thermocouple.
- Upper Limit (real number): for our purposes we will always set this to +5.
- Lower Limit (real number): for our purposes we will always set this to -5.
- Output.
- Change the thermometer to an Indicator by right clicking on it and selecting Change to Indicator.
- Connect the output from the Sample Channel to the thermometer.
Testing Your Design
- Connect the yellow wire of the thermocouple to pin 3 on the DAC board.
- Connect the orange wire of the thermocouple to pin 4 on the DAC board.
- Run the program continuously.
- Hold the thermocouple between your fingers to make the temperature rise. Confirm that the indicator on your program rises.
- 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 6.3 Your Assignment for the instructions you need to prepare your assignments this week.