The Quanser Rotary Servo Base Unit rotary servo plant, shown below, consists of a DC motor that is encased in a solid aluminum frame and equipped with a planetary gearbox. The motor has its own internal gearbox that drives external gears. The Rotary Servo Base Unit is equipped with two sensors: a potentiometer and an encoder. The potentiometer and the encoder sensors measure the angular position of the load gear using different methods.
1
Top plate
12
Encoder
2
Bottom plate
13
Ball-bearing block
3
Posts
14
Motor
4
Motor pinion gear: 72-teeth (low-gear)
15
Motor Gearbox
5
Load gear: 72 teeth (low-gear)
16
Motor connector
6
Potentiometer gear
17
Encoder connector
7
Anti-backlash springs
18
Potentiometer connector
8
Load shaft (i.e. output shaft)
19
Bar inertial load
9
Motor pinion gear: 24-teeth (high-gear)
20
Disc inertial load
10
Load gear: 120-teeth (high-gear)
21
Thumb screws
11
Potentiometer
The Rotary Servo Base Unit incorporates a Faulhaber Coreless DC Motor model 2338S006 and is shown in Figure 1c with ID #9. This is a high-efficiency, low-inductance motor that can obtain a much faster response than a conventional DC motor.
A rotary potentiometer, or pot, is a manually controlled variable resistor. See the example shown below. It typically consists of an exposed shaft, three terminals (A, W, and B), an encased internal resistive element shaped in a circular pattern, and a sliding contact known as a wiper. By rotating the shaft, the internal wiper makes contact with the resistive element at different positions, causing a change in resistance when measured between the centre terminal (W) and either of the side terminals (A or B). The total resistance of the potentiometer can be measured by clamping a multimeter to terminals A and B.
An incremental optical encoder is a relative angular displacement sensor that measures angular displacement relative to a previously known position. Unlike an absolute encoder, an incremental encoder does not retain its position information upon power loss. An incremental encoder outputs a series of pulses that correlate to the relative change in angular position. Encoders are commonly used to measure the angular displacement of rotating load shafts. The information extracted from an incremental encoder can also be used to derive instantaneous rotational velocities.
An incremental optical encoder typically consists of a coded disk, an LED, and two photo sensors. The disk is coded with an alternating light and dark radial pattern causing it to act as a shutter. As shown schematically above, the light emitted by the LED is interrupted by the coding as the disk rotates around its axis. The two photo sensors (A and B) positioned behind the coded disk sense the light emitted by the LED. The process results in A and B signals, or pulses, in four distinct states: (1) A off, B on; (2) A off, B off; (3) A on, B off; (4) A on, B on. Encoders that output A and B signals are often referred to as quadrature encoders since the signals are separated in phase by 90â—¦. The resolution of an encoder corresponds to the number of light or dark patterns on the disk and is given in terms of pulses per revolution, or PPR. In order to make encoder measurements, you need to connect the encoder to a counter to count the A and B signals. Then use a decoder algorithm to determine the number of counts and direction of rotation. Three decoding algorithms are used: X1, X2, X4.
X1 Decoder: When an X1 decoder is used, only the rising or falling edge of signal A is counted as the shaft rotates. When signal A leads signal B, the counter is incremented on the rising edge of signal A. When signal B leads signal A, the counter is decremented on the falling edge of signal A. Using an X1 decoder, a 1,024 PPR encoder will result in a total of 1,024 counts for every rotation of the encoder shaft. X2 Decoder: When an X2 decoder is used, both the rising and falling edges of signal A are counted as the shaft rotates. When signal A leads signal B, the counter is incremented on both the rising and falling edge of signal A. When signal B leads signal A, the counter is decremented on both the rising and falling edges of signal A. Using an X2 decoder, a 1,024 PPR encoder will generate a total of 2,048 counts for every rotation of the encoder shaft. X4 Decoder: When an X4 algorithm is used, both the rising and falling edges of both signals A and B are counted. Depending on which signal leads, the counter will either increment or decrement. An X4 decoder generates four times the number of counts generated by an X1 decoder resulting in the highest resolution among the three types of decoders. Using an X4 decoder, a 1,024 PPR encoder will generate a total of 4,096 counts for every rotation of the encoder shaft.
The angular resolution of an encoder depends on the encoder’s pulses per revolution (PPR) and the decoding algorithm used:
where N = 1, 2, or 4 corresponds to X1, X2, and X4 decoders respectively
While encoders are typically used for measuring angular displacement, they can also measure rotational speeds. The velocity can be found by taking the difference between consecutive angle measurements
In practice, determining rotational speeds by means of derivation of the discontinuous encoder output often results in signal noise. The ripple in the velocity signal due to sampling can be reduced by filtering. Applying a first-order low-pass filter to the measured velocity signal
Rearranging the filter transfer function above,
we can represent the filtering using the differential equation
Follow the steps and build the SIMULINK model below:
Follow these steps to read the motor velocity:
First, download and open q_servo_vel_direct.slx Simulink model.
Configure the model to apply a 0.4 Hz square wave voltage signal going between 0.5V and 2.5V.
Change the simulation time to 5 seconds from Simulation tab, stop time.
Go to Modelling tab and open modelling setting. Check that sample time is set to 0.002s and check that solver is set to ode1 (euler).
The velocity measurement using a direct derivative will be noisy. After the SIMULINK has run for 5 seconds and stopped, note down the velocity ripple (crest to peak or height within ripple). You can use the Cursor Measurements tool in the Scope for more accurate measurements. Save the speed data (wl) to plot in the report. Name the file such as integration_sampletime0.002s.
Increase the control loop rate of the QUARC controller by decreasing the sampling interval to 0.001 s, i.e. increasing the sampling rate to 1 kHz. Build, Connect and run the Simulink. Once SIMULINK has run for 5 seconds and stopped, note down the velocity ripple and examine the change in the ripple velocity measurement. Save the speed data (wl) to plot in the report. Name the file such as integration_sampletime0.001s.
Run the controller for a minute or two (stop time to inf). Depending on the data acquisition device you are using (e.g. Q2-USB or Q8-USB), you may notice a spike or discontinuity that occurs in the velocity estimation, as shown below (once the discontinuity occurs stop the simulation). Save the speed data (wl) to plot in the report. Name the file such as integration_wrapping.
Save the speed data (wl) to plot in the report. Name the file such as integration_lowpass. Save a screenshot of the Simulink model designed (block diagram).
Response plots from Step 7.
Response plots from Step 8.
Response plots with and without encoder wrapping from Step 9.
Compare the measured velocity ripple from Step 8 (without filter) with the measured velocity ripple from Step 10 (with filter). How much noise does the filter remove?
Completed SIMULINK block diagram with low-pass filter from Step 10.
Response plots from Step 10.
A schematic diagram of the voltage dividing characteristic of a potentiometer is illustrated below. By applying a known voltage between terminals A and B (), voltage is divided between terminals AW and WB where:
When connected to an external shaft, a rotary potentiometer can measure absolute angular displacement. By applying a known voltage to the outside terminals of the pot, we can determine the position of the sensor based on the output voltage or which will be directly proportional to the position of the shaft. One of the advantages of using a potentiometer as an absolute sensor is that after a power loss, position information is retained since the resistance of the pot remains unchanged. While pots are an effective way to obtain a unique position measurement, caution must be used since their signal output may be discontinuous. That is, after a few revolutions potentiometers may reset their signal back to zero. Another disadvantage of most pots is that they have physical stops that prevent continuous shaft rotation.
​where represents the position measurement sample and is the sampling interval of the control software. The resolution or ripple in the velocity measurement is given by
is rotational speed (rad/s) and is the resolution of the encoder given in Equation 1.1, and is the sampling interval. Note that the ripple velocity increases when the sampling period decreases.
​where is the measured signal, is the filtered signal, and is the filter time constant. Low-pass filters are also often represented in terms of cutoff frequency :
where . The low-pass filter attenuates the high-frequency components of the signal higher than the cut-off frequency specified, i.e. passes signal with frequencies
​The derivative can be approximated by the difference between the currently measured sample, , and the previous sample, :
​Solving for ,
Thus the high-frequency error is reduced by a factor of . The ripple in the filtered velocity signal caused by the encoder is
Note: Filtering does add dynamics to the signal, i.e. small delay, as given by the term in Equation 1.3.
Encoder counters on data acquisition (DAQ) devices have a rated number of bits, n. For example, a DAQ with an 8-bit signed counter has a range between −128 and +127 (i.e. and ). When the encoder counts go beyond this range, the measured counts from the DAQ ends up wrapped. Consider the following example. If the encoder is measuring 100 counts, then the DAQ counter will output 100 (no wrapping). However, if the encoder is measuring 150 counts, then the 8-bit signed counter will read counts. Thus the encoder wraps and causes a discontinuity. This can be very problematic in closed-loop feedback control. The QUARC software includes an Inverse Modulus block that unwraps the counter signal and keeps a continuous signal. For more information, see the Inverse Modulus block in the QUARC documentation.
To build the model, click the down arrow on Monitor & Tune under the Hardware tab and then click Build for monitoring . This generates the controller code.
Click the Deploy button under Monitor & Tune, next click the Connect button, also under Monitor & Tune and then run SIMULINK by clicking Start .
This encoder wrapping is due to the range of the DAQ encoder counter. To remove the wrapping and maintain a continuous signal, use the QUARC Inverse Modulus block before Encoder: count to rad block. Build, connect and run your QUARC controller and ensure the signal is now continuous (i.e. no spike occurs). Save the speed data (wl) to plot in the report. Name the file such as integration_no_wrapping. Note : The Inverse Modulus block should be added to the output of the HIL Read Encoder and set to the where n is the bits of the DAQ encoder counter. Quanser Q2-USB has 16-bit encoder counter and Quanser Q8-USB has 24-bit encoder counter.
Add a low-pass filter with a time constant of s using the Simulink Transfer Fcn block. This translates into having a filter with a cutoff frequency of 1/0.01 = 100 rad/s. Run it for 5 seconds.
Given that the Rotary Servo Base Unit rotary encoder has 1024 PPR and the quadrature (X4) decoding is used in the DAQ, find the resolution of the encoder () using Eq. 1.1. Using this encoder resolution and Eq. 1.2, find the estimated velocity ripple of the Rotary Servo Base Unit for sampling interval 0.002 s. Compare this estimated velocity ripple with the measured velocity ripple from Step 7.
Using the encoder resolution () found in Result A.1 and Eq. 1.2, find the estimated velocity ripple for sampling interval 0.001 s. Compare this estimated velocity ripple with the measured velocity ripple from Step 8.
Using found in Result A.1, along with Eq. 1.4, and , find the estimated velocity ripple with filter. Compare the estimated velocity ripple with the measured velocity ripple from Step 10.