Unit 2: Mechatronics ENGR 1000, Introduction to Engineering Design Lesson 2.3: Controlling Independent Systems Hardware: 12 VDC power supply Several lengths of wire NI-USB 6008 Device with USB cable Digital I/O Interface Board for the NI-USB 6008 Device Solid State Relay and 120 VAC light Ping-pong ball shuffler with 3 or more balls Objectives: Work effectively in a cooperative learning environment. Explain the characteristics and function of the digital line I/O on the NI USB- 6008 device. Explain the characteristics and function of a solenoid. Explain the characteristics and function of a solid state relay. Wire a solid state relay to control 120 VAC circuit. Write a simple program in LabVIEW using multiple inputs to control multiple systems using the following new command: DAQ Assistant (digital line input and output) Programming LabVIEW Controlling Multiple Systems Introduction In this lesson we will control two separate systems so they operate independently of each other. A 120 VAC light will serve as one system and a ping pong ball feeder will serve as the second system. To control the 120VAC light we will use 12 VDC from the NI USB-6008 Digital Interface which will switch a solid state relay to turn on and off the 120 VAC light. A solid state relay acts as a switch with no moving parts to wear. It consists of an electronic circuit that typically controls a larger current with a smaller current or a signal current. In this case we will control 120 VAC (up to 10 amps) with a 12 VDC signal. 1
The ping pong ball feeder is a tube set at 45 degrees that uses gravity and two solenoids to control the delivery of balls. A solenoid is an actuator that produces a short, light, quick linear motion. The motion is the result of the attraction and movement of a steel rod into a magnetic field created when current is passed through a coil of wire. A spring is typically used to return the solenoid to its original position after the current is discontinued. The solenoids used in the ball feeder will extend a steel pin when energized and block the flow of balls. When not energized, the pin is retracted allowing the flow of balls. Example 1a Our first example will use the 120VAC solid state relay. It will perform the following function. Conditions Switch 1 is high Switch 1 is low the light turns on the light turns off 120 VAC Light Wire port 0 to control the 120 VAC Light. Connect switch 1 to port 0 line 0, and the solid state relay to port 0 line 1 (be sure to match the polarity required of the relay s input). Wiring Diagram for the Solid State Relay??? Programming a DAQ Assistant as a Digital Line Input Our first step will be to create a While Loop (with a stop button) large enough to hold two Case Structures, one for each system. As in previous lessons, create a DAQ Assistant to sense inputs on port0/line0. Remember to check the Invert Line box. To help with the interpretation of your program, rename the DAQ P0.0 IN, identifying it as an input controlling port 0 line 0. At the moment, this array only has one Boolean element. As in the previous lesson, place an Index Array command, along with an accompanying constant, next to the DAQ. Create an indicator, place it in a convenient location and rename it. Notice that the indicator created is a Boolean indicator, showing only whether the value of port 0/line 0 is True or False, high or low. Now create a Case Structure to the right of the Boolean indicator. See the previous lesson for the instructions to create a Case Structure. Wire the output of the Index Array to the selector terminal (question mark) of the Case Structure. Your program should look similar to the graphic below. 2
Programming a DAQ Assistant as a Digital Line Output Place another DAQ Assistant inside the True case of the Case Structure. Configure it for port0/line1. Leave the Invert Line box unchecked. To once again help with the interpretation of your program, rename the DAQ, P0.1 OUT, identifying it as an output controlling port 0 line 1. Create a constant to control the DAQ by right clicking on the data bar and selecting Create and Constant from the submenu. As in the first lesson, we will remove the Index Display and only deal with the first element. Use the Operate Value (finger) tool to change the value of the constant to True. Copy and paste both the DAQ Assistant and the accompanying constant into the False case. Change the constant s value to false in this case. Your program should look similar to the graphic below. Remember to save your program. It can be run now and will control the 120 VAC Solid State relay. The 120 VAC lamp should turn on and off with the change of state of the switch. Example 1b An easier way 3
The DAQ Assistants are designed to be able to communicate directly. In this simple case our program can be simplified because (1)we only have the same number of inputs and outputs and (2)the inputs and outputs are always the same. (Meaning that if the input is true than the corresponding output is true and if the input is false than the corresponding output is also false.) These conditions only occur in very simple programs, but since our program meets these criteria we can simplify our program by rearranging it to be as in the graphic below. This program is identical to the previous. If the input is high, the output will also be high and if the input is low the output will be the same. Example 2a Our second example will incorporate the ping pong ball feeder. It will perform the following function. Switch 2 is high Switch 2 is low Conditions Ping Pong Ball Feeder a ball is fed every 3 seconds no balls are fed Note: These two systems DO NOT operate independent of each other. We will separate them in example 2b. Connect switch 2 to port 1 line 0, the lower solenoid of the ball feeder to port 1 line 1, and the upper solenoid to port 1 line 2. Wiring diagram for the ping pong ball feeder??? Adding Lines to a DAQ Assistant 4
In order to continue, we need to reconfigure the DAQ Assistant to deal with multiple line inputs. Right click on the input DAQ and select Properties. The same DAQ Assistant window will open as the one that opens when building a DAQ Assistant. Notice the section in the upper left (see figure to the right). Click on the double arrows next to the Show Details command. The section will expand and list Dev1/port0/line0 as the 0 th DigitalIn channel in the task. Add a channel by clicking on the blue plus (+) in the top options bar. The Add Channels To Task window will open. Select port 1/line 0. Select OK at the bottom of the window. Notice that these two lines now appear as channels in the DAQ task. The second column in the task details shows you which line comes in which order. Our newly added input is listed as the 1 st channel in the DAQ. Click on the double arrows again to hide the details of the task. These input lines should already have the Invert Line box in the Settings section checked. Double check to make sure this is the case by selecting each DigitalIn line and assuring the check box is marked. Once this is done, click OK in the lower right side. The DAQ will once again configure. Rename this DAQ Assistant, P0.0, 1.0 IN, to better reflect what it does (the automatic feature of the tool palette needs to be on if using a left double click to rename). The DAQ Assistant now has two available channels, the 0 th element and the 1 st element of the Boolean array. The 0 th element is still being used by the first system, the 120 VAC light bulb. In order to be able to use the 1 st element it needs to be isolated from the Boolean array. Place another Index Array command below the first and wire the Boolean array from the DAQ Assistant to the array node of the new Index Array command. Right click on the index node and select Create and Constant in the sub menu. Change the constant to a one. Right click on the element node and select Create and Indicator in the sub menu. To help with the interpretation of your program rename this indicator P0.1 IN. Remember to place your indicator on the Front Panel in a convenient location. Your program should look similar to the graphic below. 5
Insert a second Case Structure below the first and wire the right side of the Index Array command to the Selector Terminal of the second Case Structure. Inside the True case, add a Stacked Sequence Structure. Build a DAQ Assistant as a Line Output using lines port 1/line1 and port 1/line 2. Do not invert the lines because it is an output device. Build a Boolean Constant to control the DAQ. This time, hover over the bottom edge of the array and expand it so that it shows two Boolean values. (Make sure your not trying to hover over the Boolean value inside the array to expand it, but that you are actually hovering over the outer edge of the array to make it show more values.) With the Operate Value tool make the first value False and the second True. Remove the Index Display from the Boolean Array. Add a Wait (ms) timer and give it a value of 1500 (1.5 seconds). Duplicate the frame and change the Boolean Array in frame 1 to have a True value for the first element and a False value for the second element. Copy the DAQ Assistant and accompanying array in frame 1 and paste them into the False case of the Case Structure. This sequence will feed one ball through the ball feeder every time it executes. The wait timer will ensure that it executes every three seconds as long as the switch is high. Remember to save your program. The finished product should look similar to the diagrams below. Front Panel 6
Block Diagram Top Boolean Case Structures Bottom Boolean Case Structures 7
Notice that these two systems are not independent. While the ping pong ball feeder is in operation the light will only change states after the ball feeder has completed one cycle. Example 2b Making them independent To make these two systems truly independent we need to separate them into two separate while loops. First create a second While Loop under the first. Using a click-and-drag technique highlight everything that works with the ping pong ball feeder with the exception of the DAQ Assistant. Move these objects into the second While Loop. Your program should look similar to the graphic below. Edit P0.0, 1.0 IN and remove the line for port1/line0. Change the name to reflect the change in programming. Create a second DAQ Assistant in the second While Loop that will control this same line and rename it to help with the interpretation of your program. Wire the new DAQ Assistant to the Index Array in the second loop and change its constant to 0. Press ctrl+b to clear any remaining broken lines. With some organization, your program should look similar to the graphic below. 8
The two systems are now independent of each other. Even while the ping pong ball feeder is active the light will still turn on and off without having to wait. 9
Team Assignment As a team, write a program to control the following two systems and their sequences depending on the conditions of three toggle switches. Refer to lesson 2.2 for extra help. Conditions 120 VAC Light Switch 1 is high the light turns on Switch 1 is low the light turns off Conditions Ping Pong Ball Feeder Switch 2 is high & Switch 3 is low a ball is fed every 3 seconds Switch 2 is low & Switch 3 is high a ball is fed every 4 seconds Switches 2 & 3 are high a ball is fed every 6 seconds Switches 2 & 3 are low no balls are fed Wire the solid state relay controlling the 120 VAC light to port 0 line 0. Wire the lower solenoid of the ball feeder to port 0 line 1, and the upper solenoid to port 0 line 2. Connect switch 1 to port 0 line 3, switch 2 to port 0 line 4 and switch 3 to port 0 line 5. Save your program on a removable storage device under the name HW2-3T# (use your team number in place of the # symbol). Have the next person representing your team turn in your team assignment at the beginning of the next lab. Each person in your team should be able to perform this assignment and the lesson s objectives independently. Each of you will have an opportunity to demonstrate your knowledge independently on a quiz. A team is successful when all members are able to demonstrate the objectives. Have fun with the control technology and helping each other learn the material. 10