Version 1.1 1 of 15 BEFORE YOU BEGIN EXPECTED KNOWLEDGE Basic Circuit Analysis EQUIPMENT AFG Oscilloscope Programmable Power Supply MATERIALS Three 741 Opamps TIP41 NPN power transistor TIP42 PNP power transistor Thermal Conductor Pad 12 Volt Fan LM78L05 voltage regulator Hall Effect Sensor ¼ spherical magnet 1 x 1 magnet viewing film Motor Plate Two #4-40 x ¼ Machine Screws Sensor Bracket 2 x 4 x 12 board ¼ x ¼ x 6 pendulum 1/8 ID 3/8 OD Shaft Collar #8-32 x ¾ machine screw #8-32 nut Six 3/16 ID fender washers Small Tube of Superglue ECE 203 LAB 6: INVERTED PENDULUM OBJECTIVES After completing this lab you should know how to: Build and control an inverted pendulum system
Version 1.1 2 of 15 INTRODUCTION In the previous labs, you developed a system to control the speed of a motor. In this lab you will use those same concepts to develop a system to control the position of a motor. The device you will be building is shown in Figure 1. Figure 1: Inverted Pendulum Plant Your plant will operate something like the servos found in remote controlled cars and planes. The plant output is the position of the inverted pendulum. You will be using a Hall effect sensor and magnet to determine the position of the pendulum. This sensor produces a voltage proportional on the strength and polarity of the magnetic field present on the sensor. In the previous lab, you estimated the transfer function of the plant using data obtained from step and sinusoidal responses. These were measured without any feedback, which is often called open loop. In this lab, the plant is unstable without feedback so open loop measurements are not possible. In this lab you will use a proportional controller for your plant and the best gain for your controller will be determined experimentally.
Version 1.1 3 of 15 LAB PARTS IDENTIFICATION Figure 2: Parts Identification 1 Figure 3: Parts Identification 2
Version 1.1 4 of 15 MOTOR AND SENSOR ASSEMBLY You will need to orient the magnet on the end of your shaft so that the Hall Effect sensor can determine the position of your shaft. When a spherical magnet is placed on a piece of ferrous metal, the magnet will always turn itself so that a line drawn from the north pole to the south pole of the magnet is perpendicular to the surface of the metal. The following steps will orient your magnet so that the north-south line is perpendicular to your motor shaft. 1. Place your magnet on the lab bench. 2. Pick up the magnet using the end of your Allan Wrench as in Figure 4. Figure 4: Magnet on Allan Wrench 3. Place a small drop of Superglue on the end of the motor shaft opposite the power terminals. 4. Hold the magnet TIGHTLY in your fingers with the Allan Wrench pointing straight up. 5. Place the magnet on the motor shaft opposite the power terminals as in Figure 5 and hold the magnet in this position for AT LEAST 60 SECONDS. Be careful not to glue your fingers to the magnet or shaft. Try to center the magnet on the shaft as accurately as possible. Power Terminals Figure 5: Attaching Magnet to Motor
Version 1.1 5 of 15 6. Remove your Allan Wrench from the magnet. Place the piece of green magnet field viewing film in front of the magnet perpendicular to the motor shaft as in Figure 6. Magnetic Field Viewing Film Figure 6: Motor with Magnetic Field Viewing Film 7. If your magnet is oriented correctly, you should see a pattern something like Figure 7 in the viewing film. Figure 7: Viewing Film With Correct Magnet Placement 8. If your magnet is oriented incorrectly, you will see something like Figure 8 in the viewing film. If you see this pattern, remove the magnet and repeat steps 1 8.
Version 1.1 6 of 15 Figure 8: Magnet Film Showing Incorrect Magnet Placement 9. Attach the Sensor Bracket and Motor Plate to the motor using the small screws as in Figure 9. Scratch Here Motor Plate Sensor Bracket Figure 9: Motor Plate and Sensor Bracket Attached to Motor 10. Scratch the Sensor Bracket directly beneath the magnet. This mark will allow you to position the Hall Effect Sensor correctly. 11. Remove the Sensor Bracket and place a small drop of glue on the scratch. The Hall Effect Sensor is EXTREMELY static sensitive. Do not handle the sensor unless the leads are inserted into a small piece of conductive foam.
Version 1.1 7 of 15 12. Place the Hall Effect Sensor onto the glue with the printing facing upward and hold in place for at least 1 minute. 13. Finally, screw the sensor bracket back onto to the motor plate and motor as in Figure 10. As you screw the sensor bracket onto the motor plate, be careful that you don t touch the screwdriver to the magnet. You magnet is powerful enough to pull itself off of the shaft if you try pulling the screwdriver off of the magnet without holding the magnet. Figure 10: Completed Motor with Sensor and Magnet 14. Place the motor flat against the your 2 x 4 x 12 piece of wood as in Figure 11. Figure 11: Motor Flat on Wood 15. Slide the motor plate flat against the side of the wood piece. The motor plate should be in the center of your board. 16. Start the two dry-wall screws at the bottoms of the holes in your motor plate. Screw the two dry-wall screws through the two bottom holes on the Motor Plate as in Figure 12.
Version 1.1 8 of 15 PENDULUM ASSEMBLY Figure 12: Motor Plate Attached to Wood You will need to pre-glue your pendulum before you attach the shaft collar. 17. Saturate the wood with three drops of glue as indicated in Figure 13. This saturation allows the glue to hold several millimeters into the wood, rather than just the outer layer of the wood. Allow the saturated glue to dry for about one minute. Saturate with glue here Figure 13: Pre-gluing Pendulum 18. Place one drop of glue on one of the flat sides of your shaft collar. 19. Orient the set-screw so that it makes an angle of approximately 45 degrees with the pendulum as in Figure 14. Hold the shaft collar in place for at least two minutes.
Version 1.1 9 of 15 Shaft Collar approximately 45 degrees Figure 14: Set-Screw Oriented at Approximately 45 Degrees 20. Place the #8-32 screw through one washer, the hole in your wood strip, and through the remaining 5 washers. Hold the #8-32 nut with your finger and tighten the screw as much as possible. The completed assembly should look something like Figure 15. Figure 15: Complete Pendulum Before you attach your pendulum, you must be sure your motor is in the correct position. To do this, you will need to connect your Hall Effect Sensor to power and to your Oscilloscope. Figure 16 gives the pin-out for your sensor. 21. Connect +5 volts and Ground to output 3 of your power supply.
Version 1.1 10 of 15 22. Connect your scope probe to Vout and to the sensor s ground. 23. Connect your motor to +6 volts (at 1 amp) from output 1 on your power supply and enable the power supply. AUGN 3503U 051 +5v Ground Vout Figure 16: Pinout for Hall Effect Sensor 24. Set your Channel 1 input to DC coupling and adjust your scope settings until you see something like Figure 17.
Version 1.1 11 of 15 Linear Region Saturation Region Figure 17: Hall Effect Sensor Output Figure 17 shows the linear and saturation regions of your Hall Effect Sensor output. Your sensor will saturate when the magnetic field applied to the sensor gets too high. This happens when one of the magnet s poles is pointing towards the sensor. If you output looks more like a sine wave, your sensor is not saturating. You will need to bend your sensor bracket so that the sensor is closer to the magnet. In the linear region, your sensor output voltage is proportional to the position of the shaft. This is where you will operate your plant. If your output looks like a sinusoid on one side and a square wave on the other, your magnet is probably not centered on your shaft. If the magnet wobbles badly when the motor turns, you need to remove the magnet and glue it on again. Answer Questions 1 3. The midpoint of the linear region is the average value of the voltage in the linear region. You need to attach the pendulum to the motor in such a way that the pendulum points straight up when the Hall Effect sensor s output is at its average value. 25. Remove the power leads from the motor. 26. Rotate the motor until the voltage from the Hall effect sensor is equal to the average value that you calculated.
Version 1.1 12 of 15 27. Have your lab partner hold the motor shaft in this position while you attach the pendulum. Use the Allan Wrench to tighten the setscrew on the shaft collar as much as possible. The finished plant should look like Figure 18. Figure 18: Completed Plant As you swing your pendulum from left to right, you should find that your sensor saturates at approximately the same angle on either side of vertical. (i.e. start with your pendulum vertical and move the pendulum to the left to the point where the sensor saturates. Note the angle of the pendulum with respect to vertical. Then move it to the right to the point where the sensor saturates. Again, note the angle with respect to vertical. You should find that the two noted angles are about the same.) 78L05 5 VOLT REGULATOR When you build your circuit, you will want to use your 78L05 5v regulator to power your Hall effect sensor. The 78L05 takes any voltage ranging from 7 to 35 volts and converts it to a steady 5 volts (DC). To make the device work properly, you need to install two bypass capacitors, a 10 µf and a 10 nf in parallel from the output of the 78L05 to ground as in Figure 21. These capacitors remove all AC voltages from the output. You should be able to find a copy of the 78L05 s datasheet through an online web search. At the time of writing, a copy of the datasheet was available at http://ece.pdx.edu/~ieee/store/components/linear_ics/lm78lxx.pdf. CURRENT AMPLIFIER The maximum current of a 741 operational amplifier is insufficient to drive your motor. To boost the current output of your controller, you will use a simple current buffer created from two bipolar junction transistors (BJT) as shown in Figure 19.
Version 1.1 13 of 15 TIP41 Vcc Vin 741 opamp 1k Ω Vout TIP42 -Vcc Figure 19: Current Amplifier This current buffer is capable of both sourcing and sinking current. You need to adjust your 1 kω potentiometer so that your source and sink current is the same. To do this: 1. Connect Vout through a 100 Ω resistor to ground. 2. Apply a 10 Hz, 20 volt peak to peak square wave to the + input on the op amp. (i.e. set the amplitude on the AFG to 10 v and do not use a 50 Ω load resistor) 3. Set Vcc and Vcc to +/-12 volts (at 1.5 Amps on Ch. 1 and Ch. 2) for the transistors and the op-amp. 4. Measure the voltage across the 100 Ω resistor with your oscilloscope. (Be sure that your coupling is set to DC) 5. Adjust the 1 kω potentiometer so that the square wave on your oscilloscope is symmetric across zero volts. (This will happen when the source and sink current is the same.) Be careful as you remove the resistor as it will probably be hot. BUILDING THE CONTROLLER You in this lab you will use a proportional compensator to control your plant shown in Figure 20.
Version 1.1 14 of 15 Hall effect sensor output 10 k 1 Meg Pot. Reference Voltage - + To Current Amplifier Figure 20: Proportional Controler The function generator will provide the reference voltage for this circuit. With negative feedback, the op amp adjusts its output voltage so that the voltage on the negative terminal is equal to the voltage on the positive terminal. The 1 MΩ potentiometer sets the gain for this circuit. Connect the circuit shown in Figure 21. Be sure to attach a heat sink to both the TIP41 and TIP42 transistors. You may need to use the fan to cool the transistors. Use 12 volts for Vcc and -Vcc. Vcc 78L05 Vin +5v Gnd Hall Effect Sensor +5v Out Gnd 10 k 1 Meg Pot. Vcc 10 uf 10 nf Reference Voltage - + Q1 + - Q2 TIP41 1k Ω Vout TIP42 -Vcc Figure 21: Complete Proportional Control Circuit Connect Vout in Figure 21 to one of the motor terminals and the other motor terminal to ground. Set your function generator to produce a DC voltage equal to the voltage you found for question 5. You will need to use your 50 Ω load so that the voltage displayed on the AFG will be the voltage applied to your circuit. Set your 1 MegΩ potentiometer to maximum resistance. (This will give your circuit maximum gain.) Apply power to your circuit. You should not see anything happen because your pendulum is too heavy for your motor to lift from horizontal. Your motor is only powerful enough to lift the pendulum from about 20 degrees on either side of vertical. You will need to manually lift your pendulum until it is within this range every time your pendulum falls over.
Version 1.1 15 of 15 Swing your pendulum back and forth across vertical. You should feel the motor trying to push the pendulum to vertical. If it feels like the motor is pushing the pendulum away from vertical, switch the power clips on your motor. If it feels like the motor is pushing only in one direction, check the reference voltage on Q1 in Figure 21. Once the motor feels like it is behaving properly, bring the pendulum to vertical and let go. Answer Questions 4 5. Reduce the gain of your circuit until the pendulum stops oscillating. Slowly increase the gain of your circuit until the pendulum just begins to oscillate again. We will call the point where the pendulum just begins to oscillate critical gain. Answer Question 6. When your system is stable (not oscillating), your pendulum should be vertical. If it is not, adjust your reference voltage (from the function generator) until the pendulum is vertical. You will be using only the step response to characterize this plant. In general, a well-controlled plant has minimum rise time, minimum overshoot, minimum steeling time, and minimum steady state error. To generate the step input, you will use the up and down arrows on the function generator to increase the DC level 0.1 volts. You will always be stepping from 0.1 volts below vertical to vertical. (i.e. If your reference voltage is 2.5 volts when your pendulum is vertical, you would step from 2.4 volts to 2.5 volts.) Use your oscilloscope with time scale set to 1 second per division and DC coupling set to zero to measure the output of your Hall effect sensor. (The Hall effect sensor s voltage output is proportional to the position of the pendulum.) Experiment with your plant to determine its response to the step input. Vary your gain as you send step signals to the controller. You can determine your gain by dividing the resistance of the 1 MΩ potentiometer by 10,000 (R2/R1). Answer Questions 7 11.