Mark
Mark

Reputation:

C Programming How to find the time interval between events

Im using a handyboard and interactive c software and the task is to find the rpm of a lego motor in real time using an Infrared "Break Beam" Sensor on the wheel. I was thinking about finding the time interval between the beam being broken and then from there calculating the rpm but i cant figure out exactly how to do that. Any help would be much appreciated thanks.

Upvotes: 0

Views: 1434

Answers (3)

cwoebker
cwoebker

Reputation: 3288

I have a handy board myself, since you are using a v9 motor, arent you? I am sure you could jsut calculate it from the voltage thats being applied to the motor. Additionally a good reference, Robotic Exploration

Upvotes: 0

Charles
Charles

Reputation: 2661

If you have access to Win32 then you can use QueryPerformanceFrequency to calculate the time of the interval. It's also often being used to determine the amount of frames per seconds in games, so it's very precise.

Upvotes: 0

Glenn
Glenn

Reputation: 5342

Do mean something like this: http://www.cplusplus.com/reference/clibrary/ctime/

I believe there a better resolution ones out there (as Neil is implying), but this is the simplest.

Upvotes: 1

Related Questions