完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
问候语,
我想使用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个回答
|
|
嗨,本,
可以使用可用的计时器组件来测量频率。 你能告诉我们你打算测量的最大频率是多少吗? 你必须根据你的要求选择合适的分辨率、时钟和周期。 以上来自于百度翻译 以下为原文 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. |
|
|
|
本,
你所附的项目被修改了。所做的更改如下: 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 |
|
|
|
在这种情况下,计数器组件的使用具有以下优点:
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. |
|
|
|
我在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 ? |
|
|
|
嗨,肖伟,
在所附的投影图中,假设接收到的输入信号是方波。 如果你试图测量一个模拟信号的频率,例如正弦、三角形、锯齿等,那么首先需要把它转换成方波。 这可以使用前端的比较器来完成。 1)必须注意正弦波的振幅在PSoC的VSSA和VDDA电源中。 2)正弦波的Vmin应大于或等于Vssa。正弦波的Vmax应小于或等于VDDA。 3)要测量频率的模拟信号应该连接到比较器的非反相端。反相输入端应该连接到参考电压。它可以是被配置为输入信号的Vmin和Vmax之间的一半电压的VDAC。您也可以使用VREF,例如VDDA/2。 4)比较器的输出应该连接到计数器的捕获输入端。 下图显示了示意图。 以上来自于百度翻译 以下为原文 Hi Xiaowei, In the projecxt attached, it is assumed that the input signal which is received is a square wave. If you are trying to measure the frequency of an analog signal such as sine, triangular, sawtooth, etc, then is necessary to first convert it to a square wave. This can be done using a comparator at the front end. 1) Care must be taken that the amplitude of the sine wave is within the Vssa and Vdda power supply of PSoC. 2) The Vmin of the sine wave should be greater than or equal to Vssa. The Vmax of the sine wave should be less than or equal to Vdda. 3) The Analog signal whose frequency is to be measured should be connected to the noninverting terminal of the comparator. The inverting input terminal should be connected to a reference voltage. It can be a VDAC which is configured to half the voltage between Vmin and Vmax of the input signal. You may also use VRef such as Vdda/2. 4) The output of the comparator should be connected to the capture input of the Counter. The figure below shows the schematic. |
|
|
|
介绍了一种可测量正弦、斜坡、三角形、锯齿等模拟信号频率的改进方案。
VDAC值设置为1V,用户可以根据输入信号的幅值来调整VDAC到任何合适的值。 FuqqRead 289.3 K 以上来自于百度翻译 以下为原文 The modified project which can measure the frequency of analog signal such as sine, ramp, triangular, sawtooth, etc is attached. The VDAC value is set to 1V. The user can adjust the VDAC to any suitable value depending upon the amplitude of the input signal.
|
|
|
|
DASQ,THX!
我已经修改了这个项目。 1)为timer2.0数据表描述,定时器是常用的测量数量的时钟上升沿之间的两个可能atachometer传感器产生的。我想用计数器组件来实现它。thetachometersensor(流量传感器)输出范围:10hz ~ 100Hz,0.5v ~ 4.5V,方波。 2)附件是我的项目文件。它可以显示频率的发生有关,但当我插入在ISR路由一个断点,我发现它没有得到期每250ms.so我不能得到的频率每250毫秒发生有关。我认为代码可能有点bug? 3)现在problemannoy我是如何测量流量的传感器输出频率间隔of250ms(1秒4次),所以我可以近似地计算综合流量1秒。流动sensorlinear方程:f(Hz)= 8.1×Q(升/分钟);Q meansinstantaneous流,每250毫秒根据计算出的流量值(F / 8.1 * 60000)/ 250,所以我可以累积流量值4在1秒的时间。有没有更好的方法来计算综合流量? 以上来自于百度翻译 以下为原文 dasq,thx! i have modified the project. 1)As the timer2.0 datasheet described,the timer is common used to measure the number of clocks between two rising edges as might be generated by a tachometer sensor.i want to use the counter component to achieve it. The tachometer sensor(flow sensor) output rang: 10Hz~100Hz , 0.5V~4.5V , square wave. 2) attachment is my project file. it can display the Frequency collectly ,but when i insert a breakpoint in the ISR Rounting ,i found it doesnt get the period every 250ms.so i cant get the Frequency every 250ms collectly. I think the code may have little bug? 3)Now the problem annoy me is how to measure the flow sensor output frequency at intervals of 250ms(4 times in 1S),so i can approximatly calculate the integrated flow of 1 second. The flow sensor Linear equation: F(hz) = 8.1 *Q(L/Min); Q means instantaneous flow.Calculate the flow value in every 250ms accroding to the (F/8.1 *60,000)/250,so i can accumulate the flow value 4 time in 1 Second. Is there a better way to calculalte the integrated flow ? |
|
|
|
|
|
|
|
你好,小伟。
在查看您的项目并根据您的需求,我的建议是使用定时器组件(UDB),并使用它的“触发器”特性。 你可以产生一个4赫兹的信号(使用PWM)250毫秒,并把它输入到定时器组件的触发输入(上升沿触发)。这就开始计时计时器。捕获特征(上升沿)可以用来确定两个上升沿之间的时间周期,从而确定频率。两个捕获值之间的差异给出了周期。 应当注意,如果在两个捕获之间发生终端计数,则要进行补偿。理想情况下,在下计数器的情况下,先前捕获值应该大于当前捕获值。 以上来自于百度翻译 以下为原文 Hi xiaowei. After looking at your project and going by your requirement, my suggestion is to go with Timer component (UDB Based) and use the "Trigger" feature available in it. You can generate a 4 Hz signal (using a PWM) for 250 ms and feed it to the Trigger input of Timer component (Rising Edge triggered). This starts the Timer down-counting. The Capture feature (Rising Edge) can be used to determine the Time Period between two rising edges and hence the frequency. The difference between the two capture values gives the period. Care should be taken to compensation for if a terminal count occurs between two captures. Ideally, the previous capture value should be greater than the present capture value in the case of a down counter. |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2074 浏览 1 评论
1829 浏览 1 评论
3643 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1765 浏览 6 评论
1517 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
513浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
364浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
413浏览 2评论
360浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
865浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-28 00:40 , Processed in 1.014477 second(s), Total 94, Slave 78 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号