digital-brain/content/zettels/position_jitter_due_to_asynchronous_acquisition.md

6.2 KiB

+++ title = "Position Jitter due to Asynchronous Acquisition" author = ["Dehaeze Thomas"] draft = false +++

Tags :

Observed issue

Sometime the controller is not compatible with the encoder protocol. In that case a PEPU can be used in between the encoder and the controller to convert the encoder value to something readable by the controller. This is illustrated in Figure 1.

{{< figure src="/ox-hugo/position_jitter_issue.png" caption="<span class="figure-number">Figure 1: Measurement Setup: an encoder working with BISS protocol is read by a PEPU (every \(T_{s,\text{pepu}}\) seconds) and the controller reads the stored encoder value in the PEPU every \(T_{s,\text{ctrl}}\) seconds" >}}

When scanning the device (i.e. changing rapidly the read value on the encoder), some "jumps" on the encoder value read by the controller can be seen. This effect is due to some "jitter" between the PEPU acquisition rate and the controller rate as will be explained bellow.

Visual display of jitter issue

Let's make a simulation to understand what is going on. Let's choose the following parameters:

  • \(T_{s,\text{pepu}} = 60\,\mu s\): the acquisition rate of the encoder on the PEPU (very typical for a 32bit absolute encoder)
  • \(v = 1\,mm/s\): the scan velocity
  • \(T_{s,\text{ctrl}} = 100\,\mu s\) the "sampling rate" of the controller

The encoder position as well as the stored value on the PEPU and the position used in the controller are shown in Figure 2, left. The errors associated with the "jitter" is shown in Figure 2, right.

%% Simulation parameters
v = 1e-3; % Scanning velocity [m/s or rad/s]
Ts_pepu = 60e-6; % Sampling time of PEPU [s] i.e. time to get a new encoder value
Ts_ctrl = 1e-4; % Sampling time of controller [s]

t_sim = 10*Ts_ctrl; % Total simulation time [s]
t = 0:1e-6:t_sim; % Time vector used for simulation [s]
x = v*t; % Suppose linear position [m, rad]

%% Compute position stored in PEPU as every time step
x_pepu = Ts_pepu*floor(t/Ts_pepu)*v;

%% Compute position get on the controller at each control period
t_ctrl = 0:Ts_ctrl:t_sim; % Time vector [s]
x_ctrl = zeros(size(t_ctrl)); % Position stored on the controller [m]
x_error = zeros(size(t_ctrl)); % Position error due to "jitter" [m]
for i = 1:length(t_ctrl)
    [~, i_t] = min(abs(t - t_ctrl(i))); % Find the stored encoder value in the PEPU at the time of the controller period
    x_ctrl(i) = x_pepu(i_t);
    x_error(i) = x_pepu(i_t) - x(i_t);
end

{{< figure src="/ox-hugo/jitter_error_example.png" caption="<span class="figure-number">Figure 2: Measurement error due to Jitter. 1mm/s velocity scan, Ts_pepu is 60us and Ts_ctrl is 100us" >}}

Expected error induced by "jitter"

Th "position jitter" depends on:

  • \(T_{s,\text{pepu}}\): the "sampling time" of the encoder on the PEPU
  • \(v\): the scan velocity in [unit/s]

The obtain "jitter" can be as large as (expressed in the same units as \(v\)):

\begin{equation} dx = v \cdot T_{s,\text{pepu}} \end{equation}

Let's make a numerical example:

%% Simulation parameters
v = 1e-3; % Scanning velocity [m/s or rad/s]
Ts_pepu = 60e-6; % Sampling time of PEPU [s] i.e. time to get a new encoder value
dx = 60 [nm] with v = 1.0 [mm/s] and Ts_pepu = 60 [us]

Is there an optimal PEPU acquisition rate?

Changing the readout time of the PEPU (its clock for instance) changes the jitter amplitude as well as its "pattern":

%% Longer simulation than before to better see the pattern
t_sim = 50*Ts_ctrl; % Total simulation time [s]
t = 0:1e-6:t_sim; % Time vector used for simulation [s]
x = v*t; % Suppose linear position [m, rad]
t_ctrl = 0:Ts_ctrl:t_sim; % Time vector [s]

%% Large Ts_pepu to try to match with controller sampling time
Ts_pepu = 95e-6; % Sampling time of PEPU [s] i.e. time to get a new encoder value
x_pepu = Ts_pepu*floor(t/Ts_pepu)*v;
x_error_1 = zeros(size(t_ctrl)); % Position error due to "jitter" [m]
for i = 1:length(t_ctrl)
    [~, i_t] = min(abs(t - t_ctrl(i))); % Find the stored encoder value in the PEPU at the time of the controller period
    x_error_1(i) = x_pepu(i_t) - x(i_t);
end

%% Small Ts_pepu as possible to reduce jitter amplitude
Ts_pepu = 30e-6; % Sampling time of PEPU [s] i.e. time to get a new encoder value
x_pepu = Ts_pepu*floor(t/Ts_pepu)*v;
x_error_2 = zeros(size(t_ctrl)); % Position error due to "jitter" [m]
for i = 1:length(t_ctrl)
    [~, i_t] = min(abs(t - t_ctrl(i))); % Find the stored encoder value in the PEPU at the time of the controller period
    x_error_2(i) = x_pepu(i_t) - x(i_t);
end

%% Small Ts_pepu as possible to reduce jitter amplitude
Ts_pepu = 10e-6; % Sampling time of PEPU [s] i.e. time to get a new encoder value
x_pepu = Ts_pepu*floor(t/Ts_pepu)*v;
x_error_3 = zeros(size(t_ctrl)); % Position error due to "jitter" [m]
for i = 1:length(t_ctrl)
    [~, i_t] = min(abs(t - t_ctrl(i))); % Find the stored encoder value in the PEPU at the time of the controller period
    x_error_3(i) = x_pepu(i_t) - x(i_t);
end

{{< figure src="/ox-hugo/jitter_errors_effect_Ts_pepu.png" caption="<span class="figure-number">Figure 3: Measurement errors due to Jitter. Effect of the refresh rate on the PEPU, different "patterns" can appear. Velocity scan is 1mm/s" >}}

For high velocity / high precision scans, it is important to reduce the timing jitter of the measured position (i.e. "position jitter").

Ideally, this is the control system (i.e. where the feedback controller is implemented) that triggers the readout of all the sensors.

Having a intermediate electronic device (here the PEPU) that triggers the readout of the encoders not in sync with the controller can affect quite negatively the quality of the motion.

Bibliography