Preview only show first 10 pages with watermark. For full document please download

Servo Motors (with Sensordaq)

   EMBED


Share

Transcript

Project 7 Servo Motors co py (SensorDAQ only) ua tio n Servos are small, relatively inexpensive motors known for their ability to provide a large torque or turning force. They draw current proportional to the mechanical load, which means the heavier the load, the larger the current draw. Servo motors are controlled by pulse-width modulation or PWM. In PWM, the shaft of the motor is oriented to specific angular positions within about a ±90° range by sending the servo a square wave voltage pattern. The length of time that the square wave is at the high voltage controls the shaft position. The servo motor will hold its position firmly as long as the square wave continues. A servo horn or arm is often attached to the shaft of the motor to convert the motor’s rotational motion to linear motion. Servo motors are used in small-scale robotics applications, in rack and pinion steering, and in radio-controlled models to adjust the flaps on a plane or the rudder of a boat. While servo motors can be used for steering, they are not normally used for driving the wheels of a car, because they cannot continuously rotate without internal modification. al The photo above shows the Challenge for this chapter. PROJECT DESIGN REQUIREMENTS Ev In this Project, you will investigate the principle of pulse-width modulation by writing a LabVIEW program to control the position of a servo motor. You will use the Vernier Digital Control Unit (DCU) to provide a square-wave signal. Your program should allow the user to vary the motor position from a front panel control for its full range of motion (approximately ±90°). Note: You cannot control a servo motor with the LabQuest or LabQuest Mini due to the lack of a pulse output mode on these interfaces. MATERIALS SensorDAQ LabVIEW computer USB cable Engineering Projects with NI LabVIEW and Vernier Vernier Digital Control Unit (DCU) LabQuest or LabPro power supply servo motor servo horn © Vernier Software & Technology P7 - 1 Project 7 PROJECT SETUP Wire the servo motor to the DCU 1. Wire the servo motor to the DCU 9-pin cable as shown in the diagram below. Figure 1 Servo motor wiring diagram 2. Plug the DCU cable into the 9-pin socket on the side of the DCU. 3. Mount a servo horn to the shaft of your motor. Connect the DCU to the interface 1. Connect the DCU to the DIG port on the interface. 2. Connect a power supply to the DCU. 3. Connect the interface to the computer. PROJECT BACKGROUND INFORMATION Servo motors have three wires: ground (usually black), power (usually red), and input signal (usually white or yellow). Small servos that are frequently used for hobbies or small projects operate between 4.8–6 volts, which allows the power line of the servo motor to be connected to the DCU’s +5V terminal if powered by a LabQuest or LabPro power supply. The output shaft of a standard servo motor is limited to turns within a ±90° range, with the exact location determined by the duration, or width, of a square-wave pulse sent to the input signal line. Servo motor square wave pulses usually have widths between 0.5 to 2.5 milliseconds as shown in the figure below. If the high voltage lasts 1.5 milliseconds, for example, it causes the servo to move to 0° degrees – also known as the neutral position. Figure 2 Pulse width/degree correlation for a servo motor P7 - 2 Engineering Projects with NI LabVIEW and Vernier Servo Motors In order for a servo to hold its position, pulses must be sent continuously at a rate of about one every 20 milliseconds (50 Hz). Figure 3 Pulse train for a servo motor held at the neutral position As long as the pulse width of the pulse train remains constant, the servo will hold its position. If the pulse width is modified, the servo will rotate to, and hold, the new position until the signal is changed again or the program is stopped. As before, the duration of the high voltage part of the pulse train controls the servo motor position. The Digital Express VI for SensorDAQ, located in the Vernier functions palette, can automatically generate the pulse train to control a servo motor. Place the Digital Express VI on the block diagram. A configuration window will appear. Under Device Selection, choose Control Servo Motor under the DCU listings. The configuration window is now customized for servo motors. You can test your servo motor by setting the Position (degrees) control and clicking the Run button. This will briefly move the servo motor to this position. You should not have to modify the Servo Pulse-Width Parameters; they have been set to match the most commonly used servo motors. Consult your manufacturer’s specifications before making modifications. The Digital Express VI has an input terminal where you can wire a control for servo motor position. Place the Express VI in a loop for continuous operation. PROJECT TIPS 1. Placing a white mark on the tip of the servo horn will help your see its rotation. 2. Refer to Appendix E for additional information on the Vernier DCU. PROJECT TROUBLESHOOTING 1. Even though your servo motor may appear to have a slightly greater range than 180°, the Vernier Digital Express VI requires that angles be limited to ±90°. 2. The servo motor’s input signal line must be wired to DCU line D1. Engineering Projects with NI LabVIEW and Vernier P7 - 3 Project 7 CHALLENGE DESIGN REQUIREMENTS Note: Do not attempt the Challenge until you have completed the Project Design Requirements. Build a motorized track and fulcrum to automatically roll a small ball back and forth. You should mount a Vernier Photogate at the midpoint of your track to detect the presence of the ball as it passes the midpoint. Your LabVIEW program should cause a servo motor to raise and lower one end of the track so that the ball can pass through the arms of the gate. When the Photogate detects the ball, it should signal the servo motor to reverse the incline of the track. ADDITIONAL MATERIALS Vernier Digital Proto Board Connector Vernier Photogate support structure for track breadboard jumper wires small ball CHALLENGE SETUP Build a motorized track to roll a ball back and forth 1. Build a shallow track at least a half meter in length that will allow a ball to roll freely along the length. The longer the track, the easier the Challenge will be. 2. Position the servo motor at one end of the track. Mount the servo horn to the end of the track so that the track will raise and lower as the servo turns. 3. Mount the Photogate in the center and just above the track so that as the ball rolls along the track, it will pass through and block the beam on the Photogate. Connect the Photogate to the SensorDAQ 1. Insert a Vernier Digital Proto Board Connector into a breadboard. 2. Wire the Digital Proto Board Connector to the SensorDAQ screw terminal using jumper wires as shown in the figure below. Figure 4 Digital Proto Board Connector pin-out to SensorDAQ screw terminal 3. Connect the Photogate to the Digital Proto Board Connector. P7 - 4 Engineering Projects with NI LabVIEW and Vernier Servo Motors CHALLENGE BACKGROUND INFORMATION In this Challenge, you are asked to use a Photogate to detect when the ball has rolled past the midpoint on the track. The Vernier Photogate is an electronic sensor that sends a beam of light between the two arms of the gate. When this light beam is blocked, the voltage from the photogate changes. Since there is only one DIG port on the SensorDAQ, you must monitor these blocked and unblocked transitions from the general-purpose counter/timer on the screw terminal (screw terminal 7) using the DAQ Assistant Express VI. When the DAQ Assistant (located in the Measurement I/O ► DAQmx – Data Acquisition palette) is placed on the block diagram a configuration window appears asking you to select the type of task. You will be Acquiring a Signal using the Counter Input. For this Challenge, you should choose the Pulse Width option. Figure 5 Configuration window for the DAQ Assistant Next you must select the channel. If the SensorDAQ is connected to the computer and powered on, the channel name “ctr0” will appear in the configuration window. The final step is to configure the Pulse Width parameters in the DAQ Assistant. The Starting Edge is Falling, the Max Signal Input Range is 1 second, and the Min Signal Input Range is 100m. The “m” is shorthand notation for “milliseconds.” CHALLENGE TIPS 1. Consider the weight of your building materials when designing your track, and keep the power limitations of the DCU in mind. You should not exceed 1000 mA total. In general, you will not damage the DCU by trying to draw too much current, but your servo motor may not be able to lift and hold the track in the desired position. 2. Control the flow of your program by wiring together the Error Out and Error In terminals of the two Express VIs. 3. Small elevation changes will give you greater control of the ball and prevent it from rolling off the track. 4. Refer to Appendix E for additional information on the Vernier Photogate and Digital Proto Board Connector. Engineering Projects with NI LabVIEW and Vernier P7 - 5 Project 7 CHALLENGE TROUBLESHOOTING 1. If you get the error message “Error -200474 occurred at DAQmx”, it simply means that the program timed out while waiting for the photogate to be blocked. The DAQ Assistant Express VI, which is used to check the status of the photogate, has a terminal labeled Timeout. By default the Timeout value is 10 seconds. This means that if you do not block the photogate during 10 seconds, you will get the error message. You can change the Timeout to make it longer, or you can set it to -1, which specifies no timeout period. The negative to setting the timeout to -1 is that when you try to stop your VI from executing, it may not stop normally until you block the photogate. You may even have to block the photogate two times. 2. Check the Pulse-Width Parameters in the DAQ Assistant: Starting Edge = Falling; Max Signal Input Range = 1 second; Min Signal Input Range = 100m. The “m” is shorthand notation for “milliseconds.” 3. Make sure you are using the same SensorDAQ that was connected to the computer when you configured the DAQ Assistant. Switching SensorDAQs will cause an error (#-201003 or -200478) when you run your program. See Appendix F for information about how to resolve this problem. P7 - 6 Engineering Projects with NI LabVIEW and Vernier Vernier Lab Safety Instructions Disclaimer THIS IS AN EVALUATION COPY OF THE VERNIER STUDENT LAB. This copy does not include: z Safety information z Essential instructor background information z Directions for preparing solutions z Important tips for successfully doing these labs The complete Engineering Projects with NI LabVIEW™ and Vernier manual includes 12 projects as well as essential teacher information. The full lab book is available for purchase at: http://www.vernier.com/cmat/epv.html Vernier Software & Technology 13979 S.W. Millikan Way • Beaverton, OR 97005-2886 Toll Free (888) 837-6437 • (503) 277-2299 • FAX (503) 277-2440 [email protected] • www.vernier.com