digital-brain/content/zettels/position_jitter_due_to_asynchronous_acquisition.md

150 lines
6.2 KiB
Markdown
Raw Normal View History

2023-06-28 10:02:14 +02:00
+++
title = "Position Jitter due to Asynchronous Acquisition"
author = ["Dehaeze Thomas"]
draft = false
+++
Tags
:
## Observed issue {#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.
2023-06-28 10:14:13 +02:00
This is illustrated in Figure [1](#figure--fig:position-jitter-issue).
2023-06-28 10:02:14 +02:00
<a id="figure--fig:position-jitter-issue"></a>
{{< figure src="/ox-hugo/position_jitter_issue.png" caption="<span class=\"figure-number\">Figure 1: </span>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 {#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
2023-06-28 10:15:15 +02:00
The encoder position as well as the stored value on the PEPU and the position used in the controller are shown in Figure [2](#figure--fig:jitter-error-example), left.
The errors associated with the "jitter" is shown in Figure [2](#figure--fig:jitter-error-example), right.
2023-06-28 10:02:14 +02:00
```matlab
%% 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
```
<a id="figure--fig:jitter-error-example"></a>
{{< figure src="/ox-hugo/jitter_error_example.png" caption="<span class=\"figure-number\">Figure 2: </span>Measurement error due to Jitter. 1mm/s velocity scan, Ts_pepu is 60us and Ts_ctrl is 100us" >}}
## Expected error induced by "jitter" {#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:
```matlab
%% 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
```
```text
dx = 60 [nm] with v = 1.0 [mm/s] and Ts_pepu = 60 [us]
```
## Is there an optimal PEPU acquisition rate? {#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":
```matlab
%% 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
```
<a id="figure--fig:jitter-errors-effect-Ts-pepu"></a>
{{< figure src="/ox-hugo/jitter_errors_effect_Ts_pepu.png" caption="<span class=\"figure-number\">Figure 3: </span>Measurement errors due to Jitter. Effect of the refresh rate on the PEPU, different \"patterns\" can appear. Velocity scan is 1mm/s" >}}
<div class="important">
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.
</div>
## Bibliography {#bibliography}
<style>.csl-entry{text-indent: -1.5em; margin-left: 1.5em;}</style><div class="csl-bib-body">
</div>