C编程如何找到事件之间的时间间隔
我使用手写板和交互式 C 软件,任务是使用车轮上的红外“光束”传感器实时查找乐高电机的转速。我正在考虑找到光束被破坏之间的时间间隔,然后从那里计算转速,但我无法确切地弄清楚如何做到这一点。任何帮助将不胜感激,谢谢。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
确实是这样的意思: http://www.cplusplus.com/reference/clibrary/ctime /
我相信有更好的解决方案(正如尼尔所暗示的那样),但这是最简单的。
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.
如果您有权访问 Win32,则可以使用 QueryPerformanceFrequency 计算间隔时间。它还经常用于确定游戏中每秒的帧数,因此非常精确。
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.
我自己有一个方便的板,因为你使用的是 v9 电机,不是吗?
我相信您可以根据施加到电机上的电压来计算它。
另外一个很好的参考,机器人探索
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