Sine and Cosine Encoder Angle with Gain and Offset
2026-11-25

Sine and Cosine Encoder Angle with Gain and Offset

A controller that receives analog sine and cosine encoder signals can estimate the phase inside one signal period. In a simple model, the pair traces a circle and the angle of its radius gives the phase. Offsets in the electronics shift the centre of that trace, while unequal gains stretch its axes. A worked sample shows how both effects can change a sine and cosine encoder angle estimate.

Read the circular reference in the correct order

Assign the centred and scaled cosine signal to the horizontal coordinate and the centred and scaled sine signal to the vertical coordinate. The two-argument arctangent atan2 takes the vertical value first in common mathematical conventions. It returns the angle using both signs, which preserves the quadrant. Check the chosen programming interface and the sign convention of the physical measurement before comparing an estimate with a reference.

For a sample at 60 degrees of signal phase, the ideal pair is about 0.5000 for cosine and 0.8660 for sine. A sample at 150 degrees would instead have a negative cosine and a positive sine. These examples refer to phase within one electrical period. If a mechanical revolution contains multiple signal periods, the within-period phase repeats. A separate count of periods and a declared mechanical reference can connect that local estimate to shaft position.

Apply an invented gain and offset to each channel

Suppose the measured cosine channel equals 0.2 plus 1.2 times the ideal cosine. Suppose the measured sine channel equals minus 0.1 plus 0.8 times the ideal sine. The 60 degree sample now gives a horizontal value of 0.8000 and a vertical value of about 0.5928. Applying atan2 directly to this measured pair gives about 36.54 degrees. The illustrative pair is affected by both the shifted centre and the axis scale difference.

A raw ellipse and corrected circular trace show the same sample at 36.54 and 60 degrees respectively.
Per-channel centring and scaling restores the intended angle in this simple model. Source: Zhilianhai editorial desk, original AI-assisted conceptual illustration.

Subtract each channel's own offset and divide by its own gain before finding the angle. The corrected horizontal value is (0.8000 minus 0.2) divided by 1.2, which is 0.5000. The corrected vertical value is (0.5928 plus 0.1) divided by 0.8, which is about 0.8660. The result returns to about 60 degrees, with any small difference in the displayed example due to rounding. The two raw channels use the same sample instant in this model.

Use extrema to illustrate the per-channel estimates

If ideal samples cover full periods and the extrema are observed, the midpoint of a channel's minimum and maximum estimates the offset. Half the difference between the maximum and minimum estimates its amplitude. In the example, the horizontal range is minus 1.0 to 1.4, giving midpoint 0.2 and amplitude 1.2. The vertical range is minus 0.9 to 0.7, giving midpoint minus 0.1 and amplitude 0.8.

The two ranges have offsets 0.2 and minus 0.1 and amplitudes 1.2 and 0.8, respectively.
Use a separate midpoint and half-range for each signal in this example. Source: Zhilianhai editorial desk, original AI-assisted conceptual illustration.

A capture containing only a small segment of a period can have a much narrower observed range. Clipping and outliers can also affect extremum-based estimates. For a diagnostic record, note the number of covered periods, the known bounds of the converter, and the conditions under which the samples were acquired. Preserve the original signal values since they help show whether a large estimated correction came from a real change in the sensors or from the chosen capture.

Use one scale for both axes when plotting the corrected pairs. If each axis is autoscaled separately, a trace with unequal amplitudes may appear circular on screen. Report the axis limits with the plot so an independent reviewer can judge the signal geometry.

Check what remains after the simple correction

Plot the measured horizontal and vertical samples on the same axes. A shift in the trace centre suggests channel offsets, and the width and height reveal axis amplitude differences. After correction, check the phase error against a suitable reference across a full period. An acquisition delay between channels, phase separation error, waveform distortion, or noise can still affect the result. Offset and gain corrections address the two specific terms in the illustrated channel model.

Document the argument order, angle units, wrap convention and treatment of out-of-range data with the calculation. This makes it easier for another engineer to reproduce the same within-period angle and connect it to the correct mechanical period when reviewing a motion log.

For a second clean model check, evaluate the pair at one quarter of a signal period. The ideal horizontal sample is zero and the vertical sample is one. The invented measurement model yields 0.2 and 0.7 respectively. Removing the two offsets and the two gains recovers the ideal pair and a phase of 90 degrees. This case checks that a positive sine value with corrected cosine at zero is handled consistently.

Sources and related reading

The Texas Instruments design guide examines interpolation and the effects of offset, gain, phase and quantization. Interface to Sin/Cos Encoders

The Beckhoff reference explains phase-shifted sine signals, periods per mechanical revolution and within-period interpolation. Principle of the Sine/Cosine Measurement

Browse the technology section and the industry section for more measurement examples.

18028484626 CONTACT US

公司:智联海(惠州)科技有限公司

地址:惠州仲恺高新区陈江街道白云山工业大道 5 号六楼 601

Q Q:18028484626

Copyright © 2002-2026

粤xxx

咨询 在线留言 电话:18028484626
微信 微信扫码添加我