Speed and sensor

More
2 weeks 6 days ago #310 by TIPIKS
Speed and sensor was created by TIPIKS
Hi,

I'm trying to program a speed reading with an inductive sensor. I'm having trouble programming the time between two pulses and then converting it to a minute to get revolutions per minute (RPM). I want an instantaneous reading. My equipment is suitable for this (sensor and input board).

Can you help me, please?

Fabrice

Please Log in or Create an account to join the conversation.

More
1 week 4 days ago #315 by claes
Replied by claes on topic Speed and sensor
Hi Fabrice,

One hint is to use the monotonic time to get the right speed also when the system time is adjusted, eg

static pwr_tTime last = {0,0};
pwr_tTime current;
pwr_tDeltaTime dt;
pwr_tFloat32 time;

if (d1) {
time_GetTimeMonotonic(&current);
if (last.tv_sec != 0) {
time_Adiff(&dt, &current, &last);
time_DToFloat(&time, &dt);
OA1 = 60.0/time;
}
last = current;
}

d1 is pulse edge and OA1 is speed.

/Claes

Please Log in or Create an account to join the conversation.

Time to create page: 0.454 seconds
Powered by Kunena Forum