0% found this document useful (0 votes)
7 views15 pages

Report 7

The document outlines Experiment #7 for EE-383, focusing on the use of an incremental optical encoder as an angular displacement sensor. It details the encoder's functionality, decoding algorithms (non-quadrature, X1, X2, X4), and the procedure for measuring angular displacement and calibrating the encoder. The experiment includes practical analysis of encoder performance and the effects of different decoding methods on angular measurements.

Uploaded by

ahmadmanahil80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views15 pages

Report 7

The document outlines Experiment #7 for EE-383, focusing on the use of an incremental optical encoder as an angular displacement sensor. It details the encoder's functionality, decoding algorithms (non-quadrature, X1, X2, X4), and the procedure for measuring angular displacement and calibrating the encoder. The experiment includes practical analysis of encoder performance and the effects of different decoding methods on angular measurements.

Uploaded by

ahmadmanahil80
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Department of Electrical Engineering

EE-383-Instrumentation and Measurements

Faculty Member: Abdul Rehman Dated: 27-10-23


Hussnain

Semester: 5th Section: BEE-13 B

Experiment # 7

Encoder: Angular Displacement Sensor

PLO4/ PLO5/ PLO8/ PLO9/ CLO7


CLO4 CLO5 CLO6

Name Reg. No Viva / Analysis of Modern Ethics and Individual


Quiz / data in Tool Safety and Team
Lab Lab Usage Work
Perfor Report
mance
5 Marks 5 Marks 5 Marks 5 Marks 5 Marks
Muhammad Ahmad
370307
Nazir

Eaman Safdar 388110

Rimsha Jawad
385345

Sundas Rathore 366636


Lab no. 7: Encoder

What is an Encoder?

An incremental optical encoder, shown in Figure 2-1, is a relative angular displacement sensor which
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 which correlate to the relative change in angular position. Encoders are
commonly used to measure angular displacement of rotating load shafts. Information extracted from
an incremental encoder can also be used to derive instantaneous rotational velocities.

Figure 2-1: An incremental rotary encoder manufactured by US Digital

An incremental optical encoder typically consists of a coded disk, an Infrared (IR) LED, and two
photosensors. The disk is coded with an alternating light and dark radial pattern causing it to act as a
shutter. As shown schematically in Figure 2-2, the light emitted by the IR LED is interrupted by the
coding as the disk rotates around its axis.
Figure 2-2: Output of an incremental encoder showing signals A and B when rotating in a clockwise
manner

The two photosensors (A and B) positioned behind the coded disk sense the infrared light emitted by
the IR LED, which results in A and B signals/pulses, in four distinct states as outlined in Table 2-1:

Table 2-1: Different quadrature states

State Signal A Signal B

1 OFF ON

2 OFF OFF

3 ON OFF

4 ON ON
Encoders which output A and B signals are often referred to as quadrature encoders since the signals
are separated in phase by 90° and result in four distinct states. Non-quadrature encoders have only
one output signal and thus are unable to detect direction. The resolution of an encoder is determined
using the number of light or dark patterns on the disk, a measure that is given in terms of pulses per
revolution, or PPR.

Some encoders utilize an index pulse (Z channel), which is triggered once for every full rotation of the
disk (see Figure 2-3). The index pulse can be used for calibration or so-called homing of a system, as
well as a revolution counter. Depending on the encoder, the width of the index plus may be aligned
with any of the four quadrature states. For example, the index pulse may have a width that spans a full
cycle (4 states), a half cycle (2 states), or a quarter cycle (1 state). In the example shown in Figure 2-3,
the width of the index pulse is aligned with a full cycle of the B signal.

There are two methods that an encoder registers the index pulse: (a) using pre-defined states of
signals A and B, or (b) using user-defined states of signals A and B, in which case the user must select a
combination of A and B states that occurs only once during the width of the index pulse.
Figure 2-3: Output of a quadrature encoder with an index pulse
Encoder Decoding
In order to make encoder measurements, you need to connect the encoder outputs to a counter. A
decoding algorithm is then used to determine the number of counts and possibly the direction of
rotation.

Four common decoding algorithms are used: non-quadrature, X1, X2, and X4.
Non-quadrature
When a non-quadrature decoder is used, only the rising edge of signal A is counted as the shaft
rotates. The counter is incremented on the rising edge of signal A. Because signal B is not used, the
encoder cannot detect the direction of rotation. For example, using a non-quadrature decoder, a 9 PPR
encoder will result in a total of 9 counts for every rotation of the encoder shaft. The count will increase
regardless of which direction the shaft is rotated.

X1 Decoder
When an X1 decoder is used, only the rising edge of signal A is counted as the shaft rotates. When a
rising edge of signal A occurs, the algorithm looks at the current state of signal B. If signal B is low, the
counter is incremented. Otherwise, when signal B is high, the counter is decremented. Using an X1
decoder, a 9 PPR encoder will result in a total of 9 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 a rising edge of signal A occurs, the algorithm looks at the current state of signal B. If
signal B is low, the counter is incremented. Otherwise, when signal B is high, the counter is
decremented. When a falling edge of signal A occurs, if signal B is high the counter is incremented,
otherwise when signal B is low the counter is decremented. Using an X2 decoder, a 9 PPR encoder will
generate a total of 18 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.
Using a state machine diagram, Figure 2-4 illustrates how the counter is incremented or decremented
depending on the state of signals A and B. 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 9 PPR encoder will generate a total of 36 counts for every rotation of the
encoder shaft.

Figure 2-4: State machine representation of the X4 decoding algorithm

Measuring Angular Displacement


Pulses generated by an encoder can be converted to angular position (in degrees) using Equation 2-1:

Equation 2-1
𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶𝐶
𝜃𝜃 = ∙ 360°
𝑁𝑁 ∙ 𝑃𝑃𝑃𝑃𝑃𝑃

where Counts is the number of acquired edge counts, N = 1, 2, or 4 corresponds to non-quadrature/X1,


X2, and X4 decoders respectively, and PPR is the encoder’s PPR value.
The angular resolution of an encoder (not to be confused with encoder resolution, or PPR) depends on
the encoder’s PPR and the decoding algorithm used, and can be calculated using Equation 2-2:

Equation 2-2
360°
∆𝜃𝜃 =
𝑁𝑁 ∙ 𝑃𝑃𝑃𝑃𝑃𝑃
Figure 2-5 compares the number of counts generated by each of the non-quadrature, X1, X2, and X4
decoders.

Figure 2-5: Comparison of the number of counts generated by different decoding algorithms

Procedure
The Virtual Instrument (VI) used to collect data from and calibrate the encoder is
shown in Figure 5.
Figure 5: VI used to collect data from and calibrate the encoder.
Analysis of Non-quadrature Decoding
1. Open QNET Mechatronic Sensors.lvproj .
2. From the Project Explorer window, open QNET Sensors Encoder.vi .
3. From the Device drop-down menu, select the device name.
4. From the Decoding Algorithm drop-down menu, select non-quadrature (no index) .
5. Run the VI.
6. In non-quadrature decoding only A signal is used. Rotate the encoder knob in the
clockwise direction. How does the Edge (counts) numeric display change?
Note : The index pulse is not used in non-quadrature decoding.
7. Rotate the knob in the counterclockwise direction. How does the Edge (counts)
numeric display change?

Ans: On every positive edge of the encoder, the edge


counter increases.

Note: At any time, you can press the Reset button to reset the counter. This will rest the
Edge (counts) and Angle (deg) numeric displays to zero.
8. Using the Edge (counts) numeric display, measure the number of pulses the
encoder generates per each full revolution (PPR).

Ans: We get 9 counts after a full rotation. For verification


the experiment was done three times with varying starting
positions and the counts were the same.

(Note: PPR is determined in non-quadrature mode. It refers to the total number of


pulses generated by the A signal when the encoder makes one full revolution. The
value of PPR will be used to calibrate the encoder pulses in terms of angular
displacement in degrees.)
Screenshot:

9. Continue to the next section.


Calibrate the Encoder
1.Calibrate the pulses of the encoder in terms of angular displacement. To do this,
enter the PPR
value which was calculated in the previous section in the Pulses per revolution (PPR)
numeric control and press the Enter key.
2. Verify the accuracy of your calibration. To do this, rotate the encoder knob and
verify that the correct angular position is displayed in the Angle (deg) numeric
indicator.

Screenshot:
3. Calculate the expected angular resolution using Equation 2 in the Concept Review .
Rotate the encoder knob and verify if you measure the same resolution?

𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄 𝟐𝟐
𝜽𝜽 = × 𝟑𝟑𝟑𝟑𝟑𝟑 = × 𝟑𝟑𝟑𝟑𝟑𝟑 = 𝟖𝟖𝟖𝟖°
𝑵𝑵 ⋅ 𝑷𝑷𝑷𝑷𝑷𝑷 𝟏𝟏 ⋅ 𝟗𝟗

𝟑𝟑𝟑𝟑𝟑𝟑 𝟏𝟏
𝚫𝚫𝜽𝜽 = = × 𝟑𝟑𝟑𝟑𝟑𝟑 = 𝟒𝟒𝟒𝟒°
𝑵𝑵 ⋅ 𝑷𝑷𝑷𝑷𝑷𝑷 𝟏𝟏 ⋅ 𝟗𝟗

VERIFIED
4. Continue to the next section.
Analysis of X2 Decoding
1. From the Decoding Algorithm drop-down menu, select X2 .
2. Press the Reset button.
3. In X2 decoding both A and B signals are used. Rotate the encoder knob in the
clockwise direction. How do the Edge (counts) and Angle (deg) numeric displays
change?

Ans: The edge counts decrease and the angle measured is negative

Note : The PPR value remains constant regardless of the decoding algorithm used.

4. Rotate the knob in the counterclockwise direction. How do the Edge (counts) and
Angle (deg) numeric displays change?

Ans: The edges increase positively and the angle increases


positively

Screenshot:
5. Examine the response of the A and B signals.

Ans: On a rising edge of signal A, the algorithm checks signal B: if


B is low, the counter goes up; if B is high, the counter goes down. :
on a falling edge of A, if B is high, the counter increases; if B is low,
the counter decreases.

6. What is the resolution of the measured angular displacement?

Ans: The resolution is doubled, the min count is now 20 per


pulse and edge count.

360 1
Δ𝜃𝜃 = = × 360 = 20°
𝑁𝑁 ⋅ 𝑃𝑃𝑃𝑃𝑃𝑃 2 ⋅ 9
7. Continue to the next section.
2. Analysis of X4 Decoding
1. From the Decoding Algorithm drop-down menu, select X4 .
2. Press the Reset button.
3. Rotate the knob in the clockwise and counterclockwise directions. How do the
Edge (counts) and Angle (deg) numeric displays change?

Ans: On counter clockwise edges decrease and angles decrease and


on clockwise the edges and angles increase.

Screenshot:

4. What is the resolution of the measured angular displacement?

𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄𝒄 𝟏𝟏
𝜽𝜽 = × 𝟑𝟑𝟑𝟑𝟑𝟑 = × 𝟑𝟑𝟑𝟑𝟑𝟑 = 𝟏𝟏𝟏𝟏°
𝑵𝑵 ⋅ 𝑷𝑷𝑷𝑷𝑷𝑷 𝟒𝟒 ⋅ 𝟗𝟗
5. Continue to the next section.
Analysis of the Index Pulse
1. Before using the index pulse, you must first determine the unique combination of
signal A and signal B that occurs only once during the width of the index pulse. It is
preferred to select a unique state that occurs closer to middle of the index pulse.
2. Slowly turn the encoder until you see a full index pulse. Immediately stop the VI
using the Stop button.

Figure 6: Response of the index pulse.


3. Figure 6 shows a typical response. If needed, use the Graph Palette to zoom into the
waveform chart. In this example, several unique combinations of signal A and signal B
occur during the width 3 of the index pulse. For example, one combination is when
both signal A and signal B are high. Determine the unique state based on your results.

Ans: From out observations we can see that there is no state


whre both A and B are both Low.
Screenshot:

4. Re-run the VI.


5. Press the Reset button.
6. Enable the Enable Index button.
7. Set the A Polarity and B Polarity buttons based on your analysis of the index pulse.
For example, to select a high state for both signal A and B, enable both A Polarity and B
Polarity buttons.
8. Rotate the encoder knob a few full revolutions. How does enabling the index to
affect the readings? What can this be used for?

Ans: When A polarity is turned on we can see that all combinations of A


and B are repeated in a single revolution. This can be used to calibrate the
encoder further and can be used to measure speed of rotations as well.
9. If no further experiments are required, press the Stop button and power
down the experiment.
Note: To observe the effect of the index pulse, you must rotate the encoder knob at
least one full revolution.

Screenshot:

Conclusion:
In this lab, we dealt with encoder which measure the angular displacement. We
studied about non-quadrature and quadrature decoders.

You might also like