如何确定微控制器中执行算法的时间(时间)?,(PID控制器的采样时间) [英] How I can determine the the period (time) for executing algorithm in micro controllers?,(sampling time for pid controllers)

查看:279
本文介绍了如何确定微控制器中执行算法的时间(时间)?,(PID控制器的采样时间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定微控制器中执行算法的时间(时间)((PID控制器的采样时间)

How I can determine the the period (time) for executing algorithm in micro controllers,(sampling time for pid controllers)

推荐答案

通常,微控制器没有对这种事情的大量支持(这是他们在没有正常执行的情况下可以做的开销).因此,不幸的是,您几乎有两个选择:

1)依次运行该功能很多次,并使用任何实时时钟工具来对总间隔进行计时.然后除法为您提供执行时间的近似值.

2)坐下来阅读手册和代码清单,并计算出每条指令的执行时间.然后计算出各种执行路径的时间,然后(假设您的程序是确定性的,因为它不会由于外部输入而改变执行路径),就可以计算出方法的确切执行时间.

第二种方法更准确-如果正确完成-则要浪费很多时间.但是,如果您需要剃除毫秒或纳秒,那么这几乎是唯一的方法.
Generally microcontrollers do not have a lot of support for this kind of thing (it is an overhead they can do without in normal execution). So, unfortunately, you pretty much have two options:

1) Run the function a considerable number of times sequentially, and use any real time clock facilities you may have to time the total interval. Then division gives you an approximation to the execution time.

2) Sit down with the manual, and a list of your code, and work out the executions time(s) for each instruction. Then work out the various execution paths times, and from that (assuming your program is deterministic in that it does not change execution path as a result of external inputs) you can work out the exact execution time of your method.

The second is more accurate - if done correctly - but a lot more time consuming. However, if you need to shave milliseconds, or nanoseconds then it is pretty much the only way to go.


这篇关于如何确定微控制器中执行算法的时间(时间)?,(PID控制器的采样时间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆