Cypress技术论坛
直播中

蒋喜玲

7年用户 170经验值
私信 关注
[问答]

怎么使用Timer进行频率测量

问候语,
我想使用Psoc创建者的计时器来确定信号的周期,并从中推断出它的频率。我知道我可以使用一个带有PWM的频率计数器,但我不想使用这种技术。我希望有一个非常快速更新我的频率测量,以便在控制法中实施。
我已经附上了一个非常简单的项目,用来理解计时器功能。我试着用Read Cype()函数读取信号周期,但不管怎样,它总是显示0xFFFF。我已经尝试了大部分其他的功能,我无法理解它们,我已经阅读了文档,我认为这个Read Read()是走的路。有人能帮我正确设置计时器,告诉我如何读取信号的周期吗?
谢谢,


以上来自于百度翻译


     以下为原文
  Greetings,
    I would like to use the a Timer in Psoc creator to determine the period of a signal and to deduce from it its frequency. I know I can use a frequency counter with a PWM but I do not want to use this technique. I would like to have a very fast update on my frequency measurement in order to be implemented in a control law.
    I have attached a very simple project where I try to make sense of the Timer function. I have tried to read the signal Period using the ReadPeriod() function but it always display 0xFFFF no matter what. I have tried most of the other functions and I cannot make much sense of them, I have read the documentation and I thought this ReadPeriod() was the way to go. Can somebody help me seting up the Timer correctly and tell me how to read the period of the signal?
    Thanks a lot,
    Ben

回帖(9)

马昱

2019-4-3 13:59:57
嗨,本,
可以使用可用的计时器组件来测量频率。
你能告诉我们你打算测量的最大频率是多少吗?
你必须根据你的要求选择合适的分辨率、时钟和周期。

以上来自于百度翻译


     以下为原文
  Hi Ben,
     
    It is possible to measure frequency using the Timer component available.
    Can you please let us know what is the maximum frequency you are intending to measure?
     
    You'll have to choose the proper resolution, clock and period of the Timer according to your requirement.
举报

马昱

2019-4-3 14:06:21
本,
你所附的项目被修改了。所做的更改如下:
1)时钟设置为1兆赫
2)周期设置为10000
3)定时器分辨率设置为16位
4)增加了一个ISR组件,它连接到计时器组件的CAPUTIOXOUT终端。
操作:
1)当触发CopTraceOUT时,在ISR中设置标志并将定时器计数重置为10000。
2)在主要功能中,标志被标记。如果设置,则读取捕获值。
3)由于定时器是向下计数器,从10000减去捕获值,以在微秒(时钟为1 MHz)获得测量周期。
4)测量值显示在LCD上,标志被重置。
在这种情况下可以测量的最大周期是10000 US(100Hz信号)。
该项目是附加的。
当做
频率测量
256.5 K

以上来自于百度翻译


     以下为原文
  Ben,
     
    The project you had attached is modified. The changes done are as follows:
     
    1) The clock is set to 1 MHz
    2) The period is set to 10000
    3) The Timer resolution is set to 16 bits
    4) An ISR Component is added which is connected to the capture_out terminal of the Timer component.
     
    Operation:
     
    1) A flag is set and Timer Count is reset to 10000 in the ISR when the capture_out is triggered.
    2) In the main function, the flag is plooed. If set, then the captured value is read.
    3) Since the Timer is a down counter, the captured value is subtracted from 10000 to obtain the measured period in micro seconds (as the clock is 1 MHz).
    4) The measured value is displayed on LCD and the Flag is reset.
     
    The max period that can be measured in this case is 10,000uS (100Hz signal).
     
    The project is attached.
     
    Regards


举报

马昱

2019-4-3 14:19:05
在这种情况下,计数器组件的使用具有以下优点:
1)有一个选项将其配置为UP计数器。因此,捕获的值将是在微秒内直接测量时间周期。
2)有一个重新加载捕获和终端计数的选项。这将使用户免于使用API进行相同的操作。这将特别有利于诸如频率测量的时间关键应用。在捕获时,计数器将重新加载到零。
附上使用计数器的项目。
频率测量
258.2 K

以上来自于百度翻译


     以下为原文
  The use of Counter Component has the following advantage in this context:
     
    1) There is an option to configure it as an Up Counter. Hence the captured value will be the direct measure of the time period in micro seconds.
    2) There is an option to reload on Capture and Terminal Count. This will free the user from doing the same using APIs. This will be particularly advantageous in time critical applications such as Frequency Measurement. Upon Capture, the counter will reload to zero.
     
    The project using Counter is attached.


举报

刘嵘

2019-4-3 14:33:47
我在CY8CKIT-030上使用了“定时器频率测量”附加码,但它的工作效率很高。
我在P27中输入函数发生器100Hz信号,但LCD显示值不正确。并且我改变频率,显示值跟随变化。代码有问题吗?
同时,我在P27中插入了我的示波器,正弦容器并不完美(有点失真),但是我删除了它们(函数生成器和示波器探针)。

以上来自于百度翻译


     以下为原文
   i use the attach code" Frequency measurement using Timer"  on my CY8Ckit-030,but it dosent work well.
    i inject the Function Generator 1000Hz signal in P27,but LCD display value is incorrect. And i change the frequency ,the display value doesnt follow change. Is the code have some Problem?
    At tht same time,i plug my oscilator proble in P27,the sine wareform is not perfect(a little distortion), but i remove them(Function Generator  and oscilator probe).the wareform is perfect .why ?
举报

更多回帖

发帖
×
20
完善资料,
赚取积分