To simulate and then build a motor controller for position control using a potentiometer.
In the previous laboratory we modeled a motor using a differential equation that did not include friction. To compensate for the effects of friction a deadband compensator was used. If we include friction in the model for the motor it is possible to develop a better motor model that is more accurate. It also makes it possible to develop a simulation that accurately models the system as a whole.
The differential equation is re-derived in Figure 27.1 The torque and inertia in a basic motor model and Figure 27.2 The first-order model of a motor experiencing kinetic friction to include a term for friction. In the derivation it is assumed that the motor is turning, and the friction is dynamic. Clearly the motor will not turn if the motor torque is less than the static friction limit.
Figure 27.1 The torque and inertia in a basic motor model
The coefficients for the differential equation in Figure 27.2 The first-order model of a motor experiencing kinetic friction can be found for the motor in a dynamic case using steady state velocities. The static torque value can be found using the deadband limits.
Figure 27.2 The first-order model of a motor experiencing kinetic friction
Potentiometers measure the angular position of a shaft using a variable resistor. A potentiometer is shown in Figure 27.3 A Potentiometer. A potentiometer is based upon a resistor, normally made with a thin film of resistive material. A wiper can be moved along the surface of the resistive film. As the wiper moves toward one end there will be a change in resistance proportional to the distance moved. If a voltage is applied across the resistor, the voltage at the wiper interpolate the voltages at the ends of the resistor.
The potentiometer in Figure 27.4 A Potentiometer as a Voltage Divider is being used as a voltage divider. As the wiper rotates the output voltage will be proportional to the angle of rotation.
Figure 27.4 A Potentiometer as a Voltage Divider
Potentiometers are inexpensive but have limited accuracy, normally in the range of 1%. They measure absolute position, and are calibrated by rotating the shaft to given angles and measuring the resulting output voltage. The range of rotation is normally limited to less than 360. An example of a potentiometer used for position feedback is given in Figure 27.5 Position control system.
Figure 27.5 Position control system
For the laboratory this week we will use a system like that defined in Figure 27.6 Block diagram of a position control system, with a potentiometer for position feedback.
Figure 27.6 Block diagram of a position control system
A control system can be evaluated numerically using a program similar to the one shown in Figure 27.7 Scilab program to simulate position feedback control and Figure 27.8 Scilab program to simulate position feedback control. The program uses the simple model of the motor, without friction, and proportional feedback control. The program has also been designed to model the potentiometer input and PWM output.
Figure 27.7 Scilab program to simulate position feedback control
Figure 27.8 Scilab program to simulate position feedback control
1. Develop a Scilab worksheet to simulate the differential equation for the motor model including friction.
2. Develop a method for calculating the motor coefficients, including the static and kinetic friction torques.
3. Write a C program to control the motor using the potentiometer for position feedback. The program should use deadband compensation (note: this is the static friction torque when the motor is not moving, but the kinetic friction torque while turning). The program should have a user interface similar to the one used for measuring motor parameters. The motor should start at rest, and when a key is pushed it should be given a new setpoint. The data should be collected, and dump when the user hits another key.
computer with a WinAVR compiler and Megaload
1. Connect the motor and the ATMega32 board so that the PWM output drives the motor with the L293. The motor shaft should be connected to the potentiometer
2. Measure the potentiometer output voltage versus position and develop a graph. Use the slope later to convert values to angles.
3. Measure the motor parameters including friction. Note, if the motor will be used at lower speeds, then determine the motor parameters using the lower speed range.
4. Put the appropriate parameters into the C and Scilab programs.
5. Provide a step input to the ATMega32 controller and measure the response. Compare the actual motor response to the curve simulated in Scilab with the same system conditions. The comparison should be in terms of first/second order characterizations, such as damped frequency, overshoot or time constant.
6. Repeat step 5 for different step sizes in both directions and with different values of Kp.