Zeeshan Haider CHEM 3411.1 Prof. Ed Look 10/09/18 Lab 1-3: Programming a robot with LabVIEW Introduction: Modern science relies heavily on technology to perform various tasks needed in order to further advance the understanding of the workings of matter. Almost all forms of technology in some way depend on computers, which in turn, are run by programming languages. It is essential then to understand the connection between the machine and the underlying language that it runs on. In this experiment, National Instrument’s (NI) LabVIEW was used to construct a program (VI) that controlled the motion of LEGO Mindstorms NXT modulated robot. The software used were NI LabVIEW version 8.0 with Lego NXT toolkit and Lego Mindstorms NXT module. Method/Procedure: VI Interface: First, an interface (front panel) was created in LabVIEW. The purpose of this was so that a user can easily control the robot by clicking on one of the available buttons on the front panel. To create the front panel, first a cluster was created, and then five Boolean buttons with different labels were created and placed in it. Clusters are used to group together different types of data such as numeric, strings, Booleans, and so on. The Boolean data type contains only two types of values: true and false. When a button in the front panel is pressed, the value of the Boolean becomes true, and false when it is depressed. Next, a sting indicator was created to display which button was being pressed. String indicators are sort of variables that display whatever that is being passed onto them via wire connections in the case of LabVIEW. Lastly, a “Quit” Boolean button was created to stop the further execution of the VI (and consequently of the movement of the robot). See figure 1 (front panel). Blockdiagram: A ‘while loop’ was created and everything (i.e. cluster, strings, variables, etc.) placed inside it. ‘While loop’ runs the program/function until a certain condition is met after which it stops executing the function. In this case, when the QUIT button was pressed on the front panel, the function stopped executing any further. Shift registers were added to the ‘while loop’ and a value of -1 was assigned to the left shift register. Shift registers passes on information between the different iteration of the loop. It must be initiated properly (i.e. have some value assigned to it) otherwise the program throws an error. Next, the cluster was converted into a 1 dimensional array containing all the buttons. Arrays can be 1D or 2D used for storing information. The information can be obtained from array by calling on the different indices of each ‘element’ it stores. For example, if an array contains three values A, B, and C, then to output A onto the screen, element with index of 0 will be called upon, to display B, index of 1 will be called upon, and so forth. Each element in an array is linked to an index number. The index can also be anything other than numbers (i.e. user created values) for more complex arrays. To convert the cluster into array, the function “Clusters to Array” was used. This was then connected to the ‘search 1D array’ block. The function of ‘search 1D array’ is to search a value in an array, and if found, pass it on forward. Zeeshan Haider CHEM 3411.1 Prof. Ed Look 10/09/18 A ‘case structure’ was created to which the cluster’s output was connected. A case structure is simply a function that displays different output depending on the ‘case’ that is selected. So for example, pressing the forward button (which had an index of 0 in the array) will select the zeroth case for which some particular code was written. Pressing different buttons the front panel will result in different case being selected. Inside the code for each case, a string variable was created to display some user defined text onto the front panel’s screen (in the string indicator box). To stop the ‘while loop’ and ultimately the motion of the robot, the Quit button on the front panel was connected to a Boolean ‘not true’ constant, which when initiated (i.e. when the button is pressed) stops the while loop from executing any further. See figure 2 (blockdiagram). Program-Robot connection: After creating the front panel VI, LabVIEW’s built-in programs (or subVIs) were used to make connection between the front panel controls and the actual physical movement of the robot. The robot was connected to the computer via a USB wire connection. First, the NXT programs for motion (i.e. forward, reverse, left, right, and stop) were uploaded onto the robot using NXT terminal (see figure) to test that was working. Next step was to place these motion programs inside the blockdiagram in order to control the robot. All the NXT programs were taken from the output palette of NXT library. Inside each case structure, an ‘NXT Object’ block was placed, which refers to the robot itself. To this ‘object’ an action was assigned. To forward motion case, forward.vi was wired to the NXT Object, to the reverse motion case, reverse.vi was wired to the object, and so on. Thus, when the forward button is pressed on the front panel, it selects the zeroth case (i.e. forward motion case) which then calls upon the ‘forward.vi’ to execute causing the robot to move forward and at the same time a text is displayed on the string indicator showing the direction of the movement. When the button is released, the case structure reverts back to ‘-1’ case, which is the default case where the machine (robot) does nothing but standby. Lastly, a stop.vi was wired to the Quit button on the front panel. The stop.vi was placed outside the ‘while loop’ so that when the Quit button is pressed, the ‘while loop’ stops executing. This renders the front panel motion controls useless until the ‘while loop’ is initiated again. Thus, the Quit button is akin to car keys, which turns the car on and off. Data/Results: Zeeshan Haider CHEM 3411.1 Prof. Ed Look 10/09/18 Figure 1 - Front panel consisting of the stop, forward, left, right, reverse, and quit (stop) buttons. A string indicator is also included which displays some defined text with pressing of each button. The red STOP button serve as the “ignition” button, turning the controls “on” and “off”. Constructed in NI LabVIEW v8.0. Zeeshan Haider CHEM 3411.1 Prof. Ed Look 10/09/18 Figure 2 - The blockdigram behind the front panel interface before any motion Vis were added to it. A ‘case structure’ inside a ‘while loop’ can be seen. Case structures output different data depending on the case selected. While-loops repeated execute until certain condition is met, after which the program stops executing. Constructed in LabVIEW v8.0. Figure 3 shows LabVIEW NXT's built-in motion programs being uploaded to the robot module. Zeeshan Haider CHEM 3411.1 Prof. Ed Look 10/09/18 Figure 4 shows the blockdiagram of the final VI. It includes LabVIEW NXT’s motion programs connected to the different cases of the case structure. It shows that the machine is in the zeroth state (case), and thus not in motion. Discussion: National Instrument’s LabVIEW proved to be a powerful tool for controlling Lego Mindstorms’s NXT robot. The purpose of the experiment was to write a program (VI) in LabVIEW to control the motion or movement of the Lego’s NXT robot. A front panel comprising of joystick-like buttons for motion control and an indicator serving as a readout device was created as shown in figure 1. A VI was then written to give function to the front panel controls by making use of LabVIEW’s powerful built-in programs. One powerful feature of LabVIEW is its ability to convert analog signal to digital signal (A/D) and vice versa. It does so by collecting the raw signal as a continuous waveform resulting from the attached robot sensors (i.e. light, sound, and touch sensors). The raw analog signal is then converted to digital signal by making use of the built-in analog to digital VI found in the “Waveform VIs” palette in LabVIEW’s NXT Library. Similarly, digital signal can also be converted to analog signal by making use of the same VI. In this experiment, controlling of the robot using the front panel buttons is an example of D/A conversion where a digital signal in the form of a button press was converted to an analog signal resulting in some sort of motion of the robot. LabVIEW also allows for temperature measurements using the temperature sensor. The temperature sensor is a digital sensor powered by the NXT intelligent brick. The temperature is measured by inserting the temperature sensor/probe into the desired compound and the reading is instantaneously displayed on the NXT intelligent brick in degree Kelvins or degree Celsius. Thus, LabVIEW and Lego Mindstorms NXT modules/sensors, combined together, can be very useful toolkits when conducting different scientific experiments. Zeeshan Haider CHEM 3411.1 Prof. Ed Look 10/09/18 References: Eliott, A., Vijaykumar, V., SLAS TECHNOLOGY: Translating Life Sciences Innovation. 12(1), pg. 1724. 2001.