首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何根据传感器数据计算速度?

如何根据传感器数据计算速度?
EN

Stack Overflow用户
提问于 2017-03-09 13:29:27
回答 1查看 102关注 0票数 0

我有一个“缺牙”传感器的数据,可以用来测量速度。有没有办法可以得到速度与时间的瞬变曲线图?我可以通过计算传感器齿轮中指示“缺齿”的过零点的数量来获得测量的平均速度,但我更感兴趣的是查看时间历史曲线图。提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-03-11 20:41:10

代码语言:javascript
复制
% 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.

该代码生成以下图:

您可以通过将频率与齿之间的距离相乘来将齿频率转换为速度。滤波器可能对消除(采样)噪声很有用。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42687464

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档