3. The Engineer Environment

The Engineer programming environment transcends the limitations of Builder by incorporating many of the features and capabilities of a traditional programming language. Programs are written by Picking & Placing command icons from a palette onto a diagram window. Stringing them together creates a graphical program that looks similar to a block diagram or flow chart. This flexible framework gives students the ability to create programs with limitless possibilities.

 

How to work in Engineer

To help you become familiar with Engineer, open Engineer from the introductory screen. Several items should appear on your screen after clicking on Engineer.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Front Panel Window

The front panel window is a place where you can have real-time feedback from your sensors as well as write notes on your programs.

Command Menu

The command menu contains the command icons that are used for programming. The command icons are picked from the command menu and placed on the diagram window.

Diagram Window

Programs are created in the diagram window

Programming in the Engineer environment can appear to be difficult and confusing, but the unlimited programming capabilities make it well worth pursuing. The next few pages are aimed at helping you work within LabVIEW. Several of the common observations are addressed.

Try this: Click anywhere on the front panel window. The command menu window disappears. Click anywhere in the diagram window to show the command menu window. The command menu window is the window that says "Functions" in its title bar.

Whether or not the command menu window is displayed depends on whether the diagram window or the front panel window is currently active.

 

Try this: Close the front panel window. (PC users, click on the X in the upper right corner. Mac users, click on the square in the upper left corner.) A window opens asking if you want to save changes that you’ve made. Selecting Yes or No will close the program, after saving it if requested, and return you to the introductory screen.

Return to the introductory screen by closing the front panel window.

Try this: Close the command menu window. (PC users, click on the X in the upper right corner. Mac users, click on the square in the upper left corner.) The command menu window can be reopened by selecting ‘Show Controls and Functions’ from ‘Windows’ on the diagram menu bar, or by right-clicking or command-clicking in the diagram window.

The names may seem confusing, but they are LabVIEW convention.

If you enjoy programming with the Engineer Environment, and would like more LabVIEW functionality or experience, we recommend obtaining the LabVIEW Student Edition software.

Tools

The mouse cursor can behave as any of several different tools. Switching between tools is done by using the space bar or tab key.

 

Pressing the space bar toggles back and forth between the select tool and the string tool. These are the two you are most likely to use.

Try this: press the space bar several times and observe the cursor.

 

Pressing the tab key cycles through the Select tool, Hand tool, Text tool, and String tool.

Try this: press the tab key several times and observe the cursor.

 

Try this: Instead of using the space bar and tab key to change the cursor, a window with all of the cursors can be opened. Select ‘Show Tools Palette’ from ‘Windows’ on the diagram menu bar. We highly recommend NOT using this window! It has some higher level functions that are not necessary in the

Engineer Environment.

 

 

Help

Turning the help function on provides information about the command icons. Help provides a description, any default information, and shows the string connection points. Turn

help on from the diagram window menu bar. The help

window will display information about the command icon that the cursor is over.

 

 

 

 

 

 

 

 

 

 

If you want to leave the Engineer environment and return to the LEGO Engineer introductory screen, close the panel window. (PC users, click on the X in the upper right corner. Mac users, click on the square in the upper left corner.)

A save changes window opens. Selecting Cancel will return you to your Engineer program. Selecting No will close the program and return you to the introductory screen.

 

The Programming Sequence:

Programs are created by picking command icons from the command menu and placing them onto the program window. Commands may be moved around after placement. After they are arranged in the desired sequence, they must be connected using the string tool before the program will run.

Basic Programming Order:

Pick & Place command icons

Arrange command icons

Remove any unwanted command icons

String command icons together

Run the program

 

 

 

 

Picking & Placing Commands

Use the select tool to pick the command icon you want from the command menu. Once it has been picked, the select tool arrow becomes the placement hand.

Move the hand to the program window. Click to place the command in the program window.

Arranging Commands

After you place all the commands onto the program window, they must be arranged in sequence. Use the select tool to move the commands.

 

Removing Unwanted Commands

Use the select tool to pick commands you want to delete from the program. After clicking once on the command, use the delete key to remove it. Strings may be removed with the same method. (PC users - only use the left mouse button.)

 

Stringing Commands Together

The commands must be connected in the sequence in which you want them to run. The left side is the input. The right side is the output. Use the string tool to connect from the right side of one command to the left side of the next one.

 

 

You must click on each command to make the connection. Connecting the string from the start icon to the end icon will not run your program. One way to test if each icon is connected is to drag the icon around on the diagram window. If the string moves with it, it is connected.

While you are stringing, any section of the string that is not attached it looks like a dashed line. The string should be attached to the command’s blue string. (Remember: Pressing the space bar toggles between the select tool and the string tool.)

 

If you have connected the string to a location it should not have been attached to, the string will be a broken black line. The run arrow will also appear as a broken image. Until the bad string has been removed, the program can not run.

Click on the broken arrow image to see the list of errors in the program.

 

 

 

 

 

The string tool has a couple of tricks of which to be aware:

 

 

Try this: As you are connecting command icons together, move the cursor so that the string has a bend in it. Before clicking on another icon, press the space bar to see how the bend direction changes.

 

 

 

 

 

Running the Program

Click on the run button to run the program on the Serial Interface Box.

 

 

 

 

Troubleshooting

If the run does not work and an error message appears make sure that the Serial Interface Box is connected to a COM Port on the computer, and that the same COM Port is selected when you double-click on the Green Light icon in your diagram window. If the wrong COM Port is selected inside the Green Light icon, simply select the correct port with the Hand Tool, select 'Make Current Values Default' from the 'Operate' Menu, and then select 'Save' under the 'File' Menu.

File Access

Saving Your Program

Select ‘Save As’ under ‘File’ on the diagram window menu bar. Enter a name for your program and select the location to which to save it.

 

Opening a Previously Saved Program

Open your file by selecting ‘Open’ under ‘File’ on the main menu bar. Locate your program, select it and click on the open button. Once the program is open you must then select ‘Show Diagram’ under ‘Windows’ on the panel’s main menu bar. Your program should now be showing in the window.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Engineer Programming - the Essentials

Introduction: Creating your own Engineer Programs

Now that you have a basic understanding of the LabVIEW environment and the structure of a LEGO Engineer program, you are ready to learn how to program.

This section will provide you with all the knowledge you need to create basic, working programs in the Engineer programming environment. You will learn the meanings of the different command and modifier icons, and you will learn how to string them together into a working Engineer program. You will also learn how to access the example and demonstration programs available in LEGO Engineer.

The Advanced Topics section, which follows, will introduce you to more tools, such as programming structures, mathematical constructs, templates, and the Front Panel. You will learn how to use these powerful tools in order to take full advantage of the power and flexibility of LEGO Engineer.

To get started, look at this example program, which turns on motor A and lamp C until the touch sensor on port 1 is pushed in.

Programs are created in a diagram window, as shown. The traffic lights are always the beginning and ending of the program. The LEGO motor icon with the "A" on it turns on the motor connected to Serial Interface Box port A. The lamp icon with the "C" on it turns on a lamp connected to Serial Interface Box port C. Motor A and Lamp C remain on until the touch sensor on port 1 is pushed in.

 

Note: Engineer does not need to use the stop sign to stop power to ports A - H. Just like in Builder the power will always be stopped when the program ends. Even if you don’t have the stop sign in Engineer, the power to ports A - H will not continue after the program ends.

Inputs and Outputs can also be designated by using general command icons in conjunction with modifier icons, as shown below.

The general command icons specify the kind of part (motor, lamp, touch sensor, etc.). The modifier icons specify port locations and power levels, and are strung to the bottom of the command icons.

Here is an example of an Engineer program that uses general command icons and modifier icons. It turns motor A and lamp B on at power level five until the touch sensor on port 1 is pushed in.

Notice the commands have their modifiers strung below them. Instead of using fixed port mappings and default power settings, programming with modifiers allows you to easily change the port locations and power levels. If the modifiers are left out, Engineer will default to port A and maximum power.

Command Icons

The first step in learning to program in Engineer is to become familiar with the command icons. Use the select tool to pick the command icons you want from the command menu or command sub-menus.

The Command Menu

Engineer’s Command menu is composed of two command icons and sixteen sub-menus. The command sub-menus are the ‘Simple Outputs,’ the ‘Wait For’ conditions, general 'Outputs,' the command ‘Modifiers,’ and the 'Sensors,' including a sub-menu for 'Vernier' sensors (the LEGO-Vernier adapter is required to use Vernier sensors with the Serial Interface Box). There are six sub-menus of LabVIEW programming structures and elements. Following the LabVIEW sub-menus is an icon that functions as a 'File Open' button, making it able for you to place a command of your own from your computer onto the diagram window. The four sub-menus on the bottom of the command menu are 'Exercises', 'Demos', 'Examples' of the seven Control Lab models, and 'Templates' to create your own commands.

Click on any sub-menu to view it.

Clicking on the pushpin keeps a command sub-menu visible.

Simple Outputs

The Simple Outputs sub-menu contains commands to turn

outputs on and off.

Wait For Commands

The Wait For sub-menu contains commands which cause the

Engineer program to wait for a certain sensor value or a certain

amount of time. The sensors include the touch sensor,

light sensor, angle sensor, and the

temperature sensor, as well as a

'Wait For Voltage' for use with Vernier

sensors and the LEGO-Vernier adapter.

The time commands have both preset

times and an option to specify your own

amount of time.

To use many of the commands in the

Wait For sub-menu, you will need to

string a numeric constant from the

Numeric sub-menu to specify the sensor

value or time value for which to wait (see

Numeric Constant, below).

While the program is running, you can double-click on a wait-for command to see the current sensor value.

Outputs

The motor, lamp, and sound device commands, shown on

the top row of the Outputs menu, are general, and require

modifiers to specify port location and power level. The

commands with gray backgrounds are used in conjunction with

the front panel to control the output settings. By combining the command that looks like the output side of the Serial Interface Box with the command that looks like a watch, you can specify an amount of time for the outputs to be on. This method is more accurate than the 'Wait for Time' commands since it uses the timer inside of the Serial Interface Box (This is similar to the command 'onfor' in the Control Lab software). See the motor example in the Demos sub-menu for an example.

 

 

Modifiers

The modifiers are used to specify port locations, power levels, and sensor modes. The modifiers must be strung to the commands that they modify.

 

 

The Numeric Constant

The numeric constant is used to specify sensor and time values. It is found in the Numeric sub-menu.

As soon as the numeric constant is placed on the Diagram Window, you may type in its value. Afterwards, you must use the text tool to edit the numeric constant value.

Remember that the tab key can be used to switch between the select tool, the hand tool, the string tool, and the text tool.

Sensors

The sensor commands allow you to use input values from

sensors in your program. For example, a sequence of

commands can be repeated until the touch sensor is hit,

or the value of the temperature sensor can be used to control the LEGO greenhouse and the temperature can be monitored on the front panel.

While the program is running, you can double-click on a sensor command to see the current sensor value.

The reset command is used to reset the angle/rotation sensor to zero. This is useful when establishing a reference or starting point. The reset command can be used anywhere in the program.

Exercises

The exercises sub-menu contains 17 sample problems for you to practice your Engineer programming skills. They are divided into three categories: beginner, intermediate, and advanced. To try an exercise, bring the exercise icon onto the diagram window and double-click on it. Then, go to the Windows menu and select "Show Diagram." In the diagram you will see instructions for the program you are to write. All of the commands that you will need to write the program are given in the diagram window of each exercise, but feel free to experiment and add more! The exercise commands cannot be used inside of an Engineer program.

Demos

Like the Exercises, the commands in the Demos sub-menu cannot be used inside of an Engineer program. The Demos include programs such as turning on a motor or monitoring the temperature from the temperature sensor. Viewing these programs will help you understand how some basic functions are done in the Engineer environment.

Examples

The Examples sub-menu contains programs for the 7 LEGO Dacta models in the 9701 Control Lab Building Set. Like the Exercises and Demos, the Examples commands cannot be used inside of an Engineer program. The Templates sub-menu will be described in the next section.

Stringing Your Program Together

In order to run your program, you must string the commands together in sequence. The left side is the input. The right side is the output. Use the string tool to connect from the right side of one command to the left side of the next one.

 

Connecting Modifiers

Serial Interface Box port locations (A - H or 1 - 8) must be connected to the lower left corner of a command. Power level modifiers must be connected to the lower right corner. A broken string will appear if the modifiers are accidentally connected to the wrong location.

 

String Indicators

When the string tool is placed over a command icon, an area under the cursor will light up if a string can be attached at that point. A label also appears to specify what kind of connection is needed on that part of the icon. This information can also be seen in the help screens. Turn help on by selecting ‘Show Help’ under ‘Help’ on the main menu bar.

 

It is possible to apply a command to more than one port location. Stringing a series of port location modifiers to a command icon will make all the specified ports active. This example turns lamps B & C on with a power level of 2.

Stringing more than one power level to a command will generate an error. The string will appear as a broken line, and the program will not run.