简体   繁体   中英

How to calculate speed from sensor data?

I've got data from a 'missing tooth' sensor for speed measurements. Is there any way I can get a transient plot of speed vs time? I can get the average speed for a measurement by counting the number of zero crossings which indicate the 'missing tooth' in the sensor gear, but I'm more interested in seeing a time history plot. Thanks in advance.

% 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.

The code produces the following figures: 在此处输入图片说明

在此处输入图片说明

You can convert the tooth frequency to speed by multiplying the frequency with the distance between the tooths. A filter may be useful to cancel out the (sampling) noise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM