如何从传感器数据计算速度?
问题描述:
我从“缺齿”传感器获取数据以进行速度测量。有什么办法可以获得速度与时间的瞬态图吗?通过计算指示传感器齿轮中“缺齿”的过零点的数量,我可以获得测量的平均速度,但我更感兴趣的是看到时间历程图。 在此先感谢。如何从传感器数据计算速度?
答
% I will first generate a example sensor output
Ts = 0.001;
t = 0:Ts:10;
freq = linspace(2, 5, length(t)); % increase the tooth frequency from 2Hz to 5Hz.
theta = cumsum(freq*2*pi*Ts);
x = sin(theta);
figure('Name', 'missing tooth sensor') % plot the sensor output
plot(x)
% Now, I will perform the actual calculations.
iCrossings = find(sign(x(1:end-1)) ~= sign(x(2:end))); % finds the crossings
dtCrossing = diff(t(iCrossings)); % calculate the time between the crossings
figure('Name', 'tooth frequency')
hold on
plot(t, freq, 'g'); % plot the real frequency in green
plot(t(iCrossings(1:end-1)), 1./(2*dtCrossing), 'b'); % plot the measured frequency in blue.
可以由频率与tooths之间的距离乘以所述齿频率转换成速度。滤波器可能有助于消除(采样)噪声。
欢迎来到SO!请看[问],因为你的问题太广泛了。请向我们展示您拥有的数据(可能包括情节),您正在使用的一些代码以及您遇到困难的确切问题。你有问题阴谋吗?数据处理?估计? –