完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我正在使用一个PIC24EP512GU810的应用程序。特别是,我需要测量一个旋转篮的周期/频率,每次一个完整的圆(或一部分)完成。通过读取数据表(HTTP://WW1.MICCHIP.COM/DeLoSs/En/DeViCIDOC/70616G.PDF),虽然输入捕获模块(第14节)可能是解决方案。离子。但是,我不确定。如果我理解正确,ICXTMR寄存器随着所选时钟源的每一个上升沿递增。假设我从time3得到这个源。每个计时器都有一个2位的预分频器,允许我最多把系统频率除以256。我的应用程序运行在60MHz(FCY),这意味着一个234×375赫兹的源到我的ICXTMR,它将在大约300毫秒内溢出16比特。现在,我需要处理的最低速度可以在脉冲之间给我一个200毫秒的间隔,这仍然足够快,以测量我是否重置了ICxTMR。每次注册。在这一点上,尽管我质疑这是否是这项工作的正确工具。总结一下,我的问题是:1。我理解正确吗?2。我知道,输入捕获模块是测量这种低频的正确工具吗?或者我最好用一个简单的中断在一个全局计数器上用A~1ms定时器单独增加。
以上来自于百度翻译 以下为原文 I'm working on an application with a PIC24EP512GU810. In particular, I need to measure the period/frequency of a rotating basket with a pulse every time a full circle (or a fraction of it) is completed. By reading the Datasheet (http://ww1.microchip.com/downloads/en/DeviceDoc/70616g.pdf) I though the Input Capture module (section 14) could be the solution. However, I'm not sure about it. If I understand correctly, the ICxTMR register is incremented with every rising edge of the selected clock source. Let's say I get that source from the Timer3. Every timer has a 2 bit prescaler, allowing me to divide the system frequency by 256 at most. My application is running at 60MHz (Fcy), which means a source for 234'375 Hz to my ICxTMR, which would overflow the 16 bit in about 300 milliseconds. Now, the lowest speed I need to handle could get me an interval of 200ms between pulses, which is still fast enough to measure if I reset the ICxTMR register every time. At this point though I'm questioning whether this is the right tool for the job. Summing up, my questions are: 1. Do I understand correctly? 2. Granted I understand, is the Input Capture Module the right tool to measure such low frequencies, or would I be better off using a simple interrupt on edge with a global counter to be incremented separately by a ~1ms timer? |
|
相关推荐
4个回答
|
|
使用32位捕获模式来正确处理较低的输入频率。
以上来自于百度翻译 以下为原文 Use a 32-bit capture mode to correctly handle the lower input frequencies. |
|
|
|
嗨,是的,你的理解主要是正确的。为了测量长周期信号,你可以安排处理来自定时器(TMR3)和捕获模块的中断。如果在中断CP之前发生定时器中断,在32位整数变量UIT32 32中添加65536,清除中断标志和LE。当中断捕获发生时,将捕获寄存器的值添加到上述变量中,也可以将捕获寄存器值存储在单独的16位无符号变量UUT1616中,用作下一个间隔的开始时间。这样,你可以精确地捕捉每一个脉冲,而不必重置计时器。周期时间计算可能是这样的:间隔=(CopTraceEndo-CopTrimeRead)+(TimeRyLoop**xx10000);然后用无符号整数类型变量进行计时器和捕获值的计算,然后Calc。即使在一段时间内定时器翻转到零时,被调整的间隔也可以是正确的。或者,这些设备具有定时器和输入捕获,可以安排在32位模式下一起工作,参见寄存器ICXCON2 IC32位的数据表,以及寄存器TXCON-T32位。迈西尔
以上来自于百度翻译 以下为原文 Hi, Yes, you understanding is mostly correct. To measure long period signals, you may arrange to handle interrupts from both the timer (TMR3) and the capture module. If interrupt from Timer happen before interrupt from CP, add 65536 in a 32 bit integer variable, uint32_t, clear the interrupt flag and leave the interrupt handler. When Capture interrupt happen, add value of capture register to the variable mentioned above. You may also store the capture register value in a separate 16 bit unsigned variable, uint16_t to use as start time for the next interval. This way, you may capture every pulse precisely, without having to reset the Timer. Period time calculation may be something like this: Interval = (Capture_End - Capture_Previous) + (timer_cycles * 0x10000); Do all calculations of timer and capture values with unsigned integer type variables, then calculated intervals may be correct even when timer roll around to zero during a period. Alternatively, These devices have Timers and Input Capture, that may be arranged to work together in 32 bit mode, See Datasheet about Register ICxCON2 IC32 bit, and Register TxCON T32 bit. Mysil |
|
|
|
一个32位定时器(例如级联T2+T3)在捕获模式下使用16 MHz时钟(FCY)在大约268秒(4min 28秒)后翻滚。作为上升沿上的一个输入捕获,它将给你一个分辨率为62.5纳秒的周期时间。我在输入捕获中使用一个GPS PPS脉冲来确定我的CPU时钟偏离16兆赫,这样我就可以计算出输出脉冲的周期时间。我在输出比较模式中使用这个来产生非常精确的输出脉冲。
以上来自于百度翻译 以下为原文 A 32 bit timer (for example concatenate T2+T3) in capture mode using a 16 MHz clock (FCY) rolls over after approximately 268 seconds (4min 28s). Used as an input capture on the rising edge it will give you the period time with a resolution of 62.5 ns. I use a GPS PPS pulse in Input Capture to determine my CPU clock's deviation from 16 MHz so I can calculate the period time of an output pulse with the accuracy of the crystal taken out of the picture. I use this in Output Compare mode to generate extremely accurate output pulses. |
|
|
|
你不需要重置计时器。让它自由运行,然后减去连续捕获。如果测得的间隔小于定时器周期,则得到正确的结果。只需确保使用无符号变量.& lt;Edg≫此外,如果您知道间隔不能小于某个阈值,那么通过这样做,您可以扩展您的捕获范围,甚至超过定时器周期。
以上来自于百度翻译 以下为原文 You do not need to reset the timer. Let it free run. Then subtract the consecutive captures. If the interval being measured is less than the timer period, you'll get the correct result. Just make sure you use unsigned variables. if (captured_value < threshold) captured_value += timer_period; |
|
|
|
只有小组成员才能发言,加入小组>>
5228 浏览 9 评论
2026 浏览 8 评论
1950 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3199 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2253 浏览 5 评论
770浏览 1评论
658浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
585浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
668浏览 0评论
570浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-18 12:49 , Processed in 1.373917 second(s), Total 82, Slave 66 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号