Abstract

This paper presents a precise macromodel of a signal-phase meter, which allows continuous phase measurement during simulation. It has been developed as a support tool during the design process of a signal-conditioning circuit for incremental position encoders. The development of a signal conditioning circuit requires precise measurements of small signal phases, amplitudes and offsets using the analog/digital circuit simulator. The phase measurement cannot be performed directly with a simulator, therefore an appropriate macro-model is needed for a circuit simulator. The structure of the signal-phase meter is based on the conventional signal-phase measuring method and is intended for the measuring of a cosine-signal phase with a known frequency. It recommends that the time variations of an input signal’s parameters (amplitude, phase, frequency, and offset voltage) are slow and small as possible. Rapid change of a signal’s parameters decreases the simulation result’s accuracy. A macro-model’s precision mainly depends on the chosen parameters for the macro-model and for the simulation. We show that with the proposed meter’s model, the phase angle can be measured with an accuracy of more than ±0,02%.

1. Introduction

Position encoders are sensors that convert their linear or rotary displacements into appropriate electrical signals and are widely used in many computer-controlled machines. Position signals can be generated by magnetic, capacitive, or optical means, and represent displacement information in absolute or incremental forms [1, 2].

Ideally, the linear optical incremental position encoders produce two 90° shifted analog signals, which enable us to detect the position of an encoder’s head. However, due to encoder’s and optical grating’s mechanical limitations, these signals have unideal sine/cosine shapes, variable amplitudes, offset voltages, and additional phase shifts. The influences of such various unwanted effects are reduced and corrected by a signal-conditioning circuit, which is usually an encoder’s integral part, realized as an integrated circuit. Thus, the signal-conditioning circuit is an analog/digital circuit, generally developed using an analog/digital circuit simulator. The development of such circuit, always requires very precise signal-phase measurements, which cannot be performed directly by a simulator.

This paper deals with the SPICE macromodel of signal-phase meter, which enables a precise phase measurement whilst simulation is running. It is based on well-known practically implemented conventional phase-measurement techniques, as described in [37]. Although structures, similar to our model, can be found in [8], to our knowledge, this type of model has never been developed.

This paper is organized as follows. Section 2 briefly describes the conventional signal-phase measurement techniques. A detailed description of the proposed macromodel is given in Section 3. Section 4 comprises examples of signal-phase measurement using the proposed model and the SPICE simulator. This model’s accuracy and other properties are also described. The conclusions are given in Section 4.

2. Conventional Signal-Phase Measurement Techniques

Conventional phase-measurement techniques between two signals of the same frequency [3] usually apply a square wave-conversion to signals. Phase is then determined by measuring the time difference, either between the zero crossing-points or between the pulse centers [47]. Due to certain disadvantages of conventional phase measurement methods, especially in cases of harmonically distorted signals, many authors suggest signal digitalization and further digital signal processing. The author in [6] presents a theory of high-precision phase measurement and a practical algorithm for phase calculation between two signals. The possibility for its implementation is described in [7]. Similarly, improved ways of phase measuring can also be found in [4, 9, 10].

3. Macromodel Description

The proposed phase meter macromodel consists of basic components (resistors, capacitors, etc.) and analog behavioral functions (differentiators, multipliers, etc.). Their real circuit implementation would be difficult, but usage within a simulator is simple. It is intended for the phase-measurements of cosine signals with known frequencies and excludes measurement of the sine-signal phase. It could however, also be generalized for such cases.

A generalized expression of macromodel’s input cosine signal 𝑣𝑐(𝑡) can be written using the equation: 𝑣𝑐(𝑡)=𝐴𝑐(𝑡)cos(2𝜋𝑓(𝑡)𝑡+𝜑(𝑡))+𝑉𝑐(𝑡),(1) where 𝐴𝑐(𝑡): amplitude time waveform, 𝑓(𝑡): frequency time waveform, 𝑉𝑐(𝑡): offset voltage time waveform, and φ(t): signal phase time waveform.

Figure 1 shows a block diagram of the phase meter macromodel. The input signals are the voltage signals 𝑣𝑐(t) and f(t). The signal f(t) in volts is proportional to the input-signal frequency in hertz. The output signal φ(t) in volts quantifies a measured phase in degrees. The phase is measured between the input 𝑣𝑐(t) and internally generated cosine signal (the latter is not shown in this figure).

The model does not measure the frequency f(t). It is presumed that f(t) is known in advance. This simplifies the model’s structure. It also requires a quantification of the following expected maximal input signal parameters: the frequency 𝑓max, the amplitude 𝐴max, and the phase 𝜑max.

The macromodel was developed modularly with appropriate sub models:(i)peak-detector,(ii)offset voltage corrector and amplitude corrector,(iii)signal-phase calculator.

The peak detector generates both the maximal (𝑣𝑐max) and minimal (𝑣𝑐min) input-signal time values. They are required for input signal amplitude normalization performed using the offset voltage corrector and the amplitude corrector. The normalized signal 𝑣𝑐norm(𝑡) drives the phase calculator, where the phase difference is calculated between the input signal and the internally generated ideal cosine signal. The ideal cosine signal has the amplitude 1 V and the same frequency as the input-signal 𝑣𝑐(t).

The entire signal-phase meter macromodel was constructed in the ICAP (ICAP/4 for Windows 8.1.11) SpiceNet as detailed in the following subsections. The usage of the macromodel requires a schematic form (*.dng file) conversion to the text netlist form (*.cir file) and its inclusion to the SPICE library file (*.lib file) as shown in Figure 2.

3.1. Peak Detector

The main task of the peak detector is the detection and holding back of those extreme values from input signal 𝑣𝑐(t). The current peak value is kept constant until the next peak-value occurs.

The peak detector sub-model works as an analog memory of peak values. Therefore, it could also be used in the other cases [11], where the analog peak values should be temporarily stored.

Figure 3 presents the structure of peak detector sub-model. It has two inputs (in, Vfreq) and two outputs (peak, npeak). in is driven by cosine signal 𝑣𝑐(t), from which the minimal 𝑣𝑐min(𝑡) and maximal 𝑣𝑐max(𝑡) time values are generated. Since the concept of the macromodel requires knowledge of the frequency, there is a second voltage driven input Vfreq. The Vfreq input voltage in volts must be proportional to the input signal frequency in hertz. Other than Vfreq, additional parameters (dv, Amax, maxfreq) are required for the peak detector to operate. They are further described in this sub section.

Capacitor C1 is needed for temporal storage of the input signals’ local minimum values, whilst capacitor C2 stores its local maximum values. Appropriate control of switches X1 and X2 ensures, that both capacitors are timely charged to the input-voltages’ local extremes. The charging period is followed by a hold-back period, when the capacitors’ voltages are kept constant. Capacitors C1 and C2 are connected to outputs npeak and peak.

The input-voltages’ extreme values occur during the time instants when the first derivative of the input signal is equal to zero. A second derivative sign is required in order to distinguish between the local minimum and maximum.

Although the input signal parameters could be time variable values, it was assumed that they are constant, in order to simplify the model. In this case, the first derivative of the input signal 𝑣𝑐(t) can be written using the equation: ̇𝑣𝑐(𝑡)=𝑑𝐴𝑐(𝑡)𝑑𝑡cos(2𝜋𝑓(𝑡)𝑡+𝜑(𝑡))𝐴𝑐(𝑡)2𝜋𝑓(𝑡)+2𝜋𝑑𝑓(𝑡)𝑑𝑡𝑡+𝑑𝜑(𝑡)𝑑𝑡sin(2𝜋𝑓(𝑡)𝑡+𝜑(𝑡))+𝑑𝑉𝑐(𝑡).𝑑𝑡(2) If it is assumed that 𝐴𝑐(𝑡)=𝐴𝑐, 𝑉𝑐(𝑡)=𝑉𝑐, 𝜑(𝑡)=𝜑, 𝑓(𝑡)=𝑓, (2) can be simplified to ̇𝑣𝑐(𝑡)2𝜋𝐴𝑐𝑓sin(2𝜋𝑓𝑡+𝜑).(3)

Switches X1 and X2 are controlled by input-signal derivative values which have been previously normalized. According to (3), the derivative of the input signal can be normalized using constant (2𝜋𝐴max𝑓), where 𝐴max stands for the expected maximal input-signal amplitude. The first and second derivatives’ normalizations are performed using the voltage-controlled sources B4 and B5, respectively. Both sources B4 and B5 are linked to sources B1 and B2, which generate the control voltages for switches X1 and X2. X1, X2 are switched “ON” at a positively control voltage, otherwise they are switched “OFF”.

The “ON” resistances (𝑅ON) of switches X1 and X2 are inversely-proportional to the values of their control voltages. By choosing a value for the control voltage equal to 1/𝑅ON and 𝑅ON equal to 1 Ω, the “ON” time constant 𝜏ON=𝑅ON𝐶, only depends on capacitance C.

X1 is “ON” when the values of the second and first derivatives are correspondingly positive and negative. Simultaneously, the value of the first derivative must be greater than the negative reference voltage 𝑉ON. Vice versa applies for switch X2. X2 is “ON” if the second derivative is negative and the first derivative is positive. Simultaneously, the value of the first derivative must be smaller than the reference voltage 𝑉ON, generated by source B3.

The reference voltage 𝑉ON is the threshold value of the first derivative, when the switches X1 and X2 must be toggled “ON” to ensure adequate charging time Δt for capacitors C1 and C2. In Δt the capacitors are charged to input voltage extreme values with Δv tolerance.

Since the capacitor’s charging-time is substantially shorter than the input signal period, it can be presume that during the charging periods, the input signal voltage is constant. In the worst-case scenario, at maximal frequency 𝑓max and maximal amplitude 𝐴max, capacitor C is charging from 0 V to 𝐴max. At the permitted tolerance Δv, the capacitor will be charged to the value (𝐴maxΔv) within the time interval: Δ𝑡=𝜏ON𝐴lnmax.Δ𝑣(4)

Since, within the time Δt, the cosine signal will reach the value: 𝑣𝑐(Δ𝑡)=𝐴maxΔ𝑣=𝐴maxcos2𝜋𝑓maxΔ𝑡,(5) the capacitor’s charging time can be written as Δ𝑡=𝑎cos1Δ𝑣/𝐴max360𝑓max.(6)

Equalizing (4) and (6), the capacitances C1 and C2 are 𝐶=𝐶1=𝐶2=𝑎cos1Δ𝑣/𝐴max360𝑓max𝑅ON𝐴lnmax/Δ𝑣.(7)

Choosing 𝑅ON equal to 1 Ω, the capacitances depend solely on the permitted tolerance Δv, and the expected 𝑓max and 𝐴max.

C1 and C2 start to charge at the time instant: 𝑡ON=𝑇21Δ𝑡=2𝑓Δ𝑡,(8) For example, for the time Δt before extreme-value occurrence. According to (6), (8), and the normalized (3), the reference voltage 𝑉ON can be calculated using 𝑉ON=̇𝑣𝑐𝑡=𝑡ONsin2𝜋𝑓𝑡ON1=sin2𝜋𝑓𝜋2𝑓Δ𝑡=sin1𝑎cos1Δ𝑣/𝐴max.180(9)

After the charging period Δt, the switches X1 and X2 disconnect the connections between the input and capacitors C1 and C2, correspondingly. Whilst the switches are “OFF”, the capacitors remain charged to the input signals’ extreme values. Since switches X1 and X2 are “OFF”, the resistances are very high (e.g., 𝑅OFF = 1 GΩ), during the “OFF” period the voltages on the capacitors will not change significantly.

Using the sub-model requires setting the parameters: Δv, 𝑓max, and 𝐴max, which are labeled in Figure 3 as dv, maxfreq, and Amax, consecutively. These parameters enable the calculation of reference voltage 𝑉ON according to (9), and the capacitances C1 and C2 according to (7).

3.2. Offset/Amplitude Corrector

The offset voltage corrector removes the offset voltage 𝑉DC from the input cosine signal 𝑣𝑐(t). Assuming a constant offset voltage, it can be written as 𝑉DC=𝑉𝑐min+𝑉𝑐max2,(10) where 𝑉𝑐min stands for the minimal and 𝑉𝑐max stands for the maximal input cosine signal amplitudes.

The cosine-time waveform without offset voltage can thus be expressed as 𝑣AC(𝑡)=𝑣𝑐(𝑉𝑡)𝑐min+𝑉𝑐max2.(11)

The absolute minimal and maximal peak values are equal and are 𝐴𝑐0=||𝑉𝑐max𝑉DC||=||𝑉𝑐min𝑉DC||.(12) The signal 𝑣AC(t) is normalized with 𝐴𝑐0, thus providing a constant equalizer output amplitude of value 1 V. The normalized signal waveform describes (13): 𝑣𝑐norm𝑣(𝑡)=𝑐𝑉(𝑡)𝑐min+𝑉𝑐max/2𝐴𝑐0=2𝑣𝑐(𝑡)𝑉𝑐min𝑉𝑐max||𝑉2𝑐max𝑉DC||=2𝑣𝑐(𝑡)𝑉𝑐min𝑉𝑐max𝑉𝑐max𝑉𝑐min.(13)

The offset voltage corrector and amplitude corrector sub-model is shown in Figure 4. The inputs’ peak and npeak are connected to the peak detector. The output signal 𝑣𝑐norm(𝑡) is the normalized cosine signal with a constant amplitude value of 1 V and a frequency f.

The offset voltage and amplitude correction are performed by controlled voltage source B17, which generates voltage according to (13). B17 additionally limits the output signal’s amplitude within the range [1V,1V]. Limitation is performed for the cases of variable input-signal amplitude, which will be described later. Should the output voltage exceed the permitted range [1V,1V], the signal phase calculation would not be feasible. The process of amplitude limitation does not affect the signal phase measurements, since they are always performed at zero crossing instant.

3.3. Signal-Phase Calculator

The signal phase calculator calculates the phase difference φ(t) between the normalized cosine signal 𝑣𝑐norm(𝑡) and the internally generated cosine signal of amplitude 1 V. The signals frequencies are equal and known in advance. The ideal cosine signal is generated using a voltage-controlled oscillator modeled with Laplace transformation and a voltage-controlled source, as proposed in [12]. Figure 5 shows the signal phase calculator sub-model.

The calculation of phase difference is periodic within the period T = 1/f, according to the following: 𝑣𝜑(𝑡)=𝑎cos𝑐norm(𝑡)2𝜋𝑓𝑡180𝜋.(14) It is performed using the controlled voltage source B9. When the switch X3 is switched ON, the capacitor C3 charges to a voltage value proportional to the phase difference measured over the previous period. When the switch X3 is switched OFF, the precharged value is held constant at the Vphase output. X3 is controlled by the source B7. It ensures that the switch is turned on once per period. This event occurs when a second derivative of input signal 𝑣𝑐(t) is negative and the value of the normalized signal 𝑣𝑐norm(𝑡) is within the range: 0<𝑣𝑐norm(𝑡)<𝑉ON1. Here, 𝑉ON1 stands for the reference voltage, provided by the source B11, according to (9).

When the signal 𝑣𝑐norm(𝑡) reaches zero value, X3 switches OFF. The voltage of C3 remains constant. Its value in volts is proportional to the phase-difference value φ(t) in degrees. For the same reason described for the peak-detector sub-model, the X3 switch “OFF” resistance has to be high enough. This ensures that the voltage on C3 will not change significantly until the next toggle of the switch X3.

The capacitance of C3 is calculated using an equation similar to (7) where 𝐴max is replaced with the predicted maximum value of the input-signal phase fimax. In the worst case scenario, C3 must be charged to the voltage value proportionally to the fimax value in degrees, with the permissible phase-tolerance dφ. The same values of the permissible tolerances were used for the phase calculator and the peak detector in order to reduce the number of model parameters.

3.4. Macromodel Parameters

An entire macromodel of the precise signal-phase meter, suitable for SPICE simulators consists of all previous described sub-models. It performs precise cosine signal phase measurements at any frequency, amplitude, and offset voltage on condition that the input signal-frequency time waveform is known in advance. The model’s operation is based on the assumption that the input-signal parameters are constant. However, its usefulness in situations of time variable parameters was also examined. The signal phase measurement, whilst the signal’s frequency, amplitude, and offset voltage are time-variable, is a very problematic task [13] and in general it has not been fully explored as yet.

Using the macromodel of the signal-phase meter requires knowledge of the four model parameters that have an influence on its accuracy and precision. These parameters are(i)Amax: expected maximum input-signal amplitude;(ii)maxfreq: expected maximum input-signal frequency;(iii)max: expected maximum input-signal phase;(iv)dv: admissible tolerance of input signal peak values (equal to the admissible tolerance for the measured signal phase).

The accuracies of signal-phase measurements depend on the macromodel’s accuracy, and on the simulation parameter values. They are transient (.TRAN) analysis parameters:(i)tstart: time to start recording data;(ii)tstop: total analysis time;(iii)tstep: data-step time;(iv)tmax: maximum time-step.

The most influential simulation parameter is tmax. It must be lower or equal to the capacitors’ C1–C3 charging-times. Using (6), the recommended maximum time step can be calculated as tmaxΔ𝑡=𝑎cos(1𝐴),360maxfreq(15) where 𝐴 stands for the smallest values: 𝐴=𝑑𝑣;Amax𝑑𝑣<Amax𝑑𝜑,max𝑑𝜑;max𝑑𝑣>Amax𝑑𝜑.max(16)

Any increase of model’s accuracy can be achieved with a decrease in the parameters dv or dφ. According to (15), this decreases tmax which reduces the integration step time. Therefore, more accurate results prolong the simulation duration.

4. Phase-Measurement Simulation Results

The following section presents the phase measurement simulation results using the proposed macromodel for the SPICE simulator. The focus was on the phase measurements of the input-cosine signal with constant and time-variable parameters. In the further described simulation examples the transient analysis (.TRAN) with the GEAR integration method was used, with a relative error tolerance RELTOL=106.

4.1. Phase Measurements of the Input Signal with Constant Parameters

This example focused on the phase measurement of a cosine signal with constant parameters, which were 𝐴𝑐(t) = 1 V,  𝑓(𝑡)=1kHz, φ(t) = 0.1°, and 𝑉𝑐(𝑡)=1mV. Using these parameters the following macromodel parameters were defined: Amax=1V, maxfreq = 1 kHz, and max = 0.1°. Simulations were performed at three different tolerances dv of values: 104 V, 105 V, and 106 V. Using (15) and (7), the simulation parameters tmax: 2.25 μs, 712 ns and 225 ns, were calculated. The rest of simulation parameters were tstart = 5 ms, tstop = 100 ms, and tstep = 10 μs.

Figure 6 shows the simulation results at three different permissible tolerances dv. Δφ(t) is the phase error between measured and the actual phase of the input signal.

Despite the constant input signal parameters, Δφ is time variable. Its time variability is the consequence of the simulator’s internal integration time step, which varies whilst the transient analysis is running. The integration time-step automatically adapts to the time changes of circuit signals. Therefore, Δφ(t) are not constant-time waveforms.

Table 1 shows the worst case results for all three examples.

From Figure 6 and Table 1, it can be concluded that reducing the parameter dv decreases the phase error Δφ.

4.2. Phase Measurements of Input Signal with Time-Variable Parameters

At the macromodel development stage, it was assumed that the input signal parameters are not time variable. Nevertheless, its suitability for cases of time variable parameters has also been verified.

The chosen intervals of the time-variable input signal parameters were as follows: 0.8 V ≤ 𝐴𝑐(t) ≤ 1.1 V; 0 ≤ 𝑉𝑐(𝑡)100 mV; 100 Hz ≤ f(t) ≤ 10 kHz; −2° ≤ φ(t) ≤ +5°. Figure 7 shows the parameters’ time waveforms used in our example.

According to the intervals of the input-signal parameters, the following macromodel parameters were set: maxfreq = 10 kHz, Amax = 1.1 V, and max = 5°. The value of the permissible tolerance dv was chosen as dv = 104 V. According to (15) the maximum time step was calculated as tmax = 101 ns. The transient analysis results are shown in Figure 8.

Δφ(t) waveform shows the phase error between the actual φ(t) and measured 𝜑𝑖(t) signal phases. Noticeable, the phase error is a result of an assumption that the input-signal parameters are constant. Consequently, the derivatives in (2) are equal to zero which, in our case, is untrue. Rapid changes in input-signal parameters increase the phase-error. This clearly illustrates the time waveform 4 within the time-range from 20 ms to 80 ms, when simultaneous changes in amplitude, frequency, phase, and offset voltage occur. In continuation, the time variations of the parameters were moderate and the phase error Δφ was significantly reduced. Therefore, the highest precision signal phase can only be measured under stationary conditions, when the smallest possible phase error can be expected.

5. Conclusion

The objective of this paper was to present a new macromodel of a precise signal-phase meter, as required for the development of integrated circuits, implemented within linear position encoders. The macromodel is suitable for precise phase measurements whilst transient analysis is running. Namely the reduction of various unwanted effects of an encoder’s head requires very accurate signal-phase measurements during the encoder development stage.

In order to simplify the concept of a macromodel, it was assumed that signal parameters are not time-variable values. As shown in Section 4, as such a signal phase was measured within an accuracy of more than ±0.02%. Simulations also showed a substantial decrease in the results’ accuracies due to the rapid-time change of the signal parameters. The signal-phase measurement under such conditions is a very problematic task [13] and has not yet been fully explored. Therefore any improvement in the presented macromodel in this direction would not be meaningful. However, this macromodel concept represents an idea for real-world implementation of a precise signal-phase meter.