完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
嗨,我一直在网上搜索关于这个话题的帮助。我用PIC24为一个高级项目,我需要一些帮助,如何使用计时器来计算流过桶线的液体量。我在PIC和NFC读卡器之间有一个UART连接。我认为这样做的方法是:1。UART从代码读取器中断2。卡ID检查,看看用户是否有“学分”和超过21.3岁。如果它们有通路,则用一个阀门来打开桶上的管道。4。在同一中断中,计数液体流量计的脉冲数。5。一旦流程停止5秒,更新桶体积变量和用户液体变量。问题是步骤4。我很困惑如何停止读数流量计,或如何获得脉冲数量后,用户拉动龙头把手。任何见解或建议是受欢迎的。
以上来自于百度翻译 以下为原文 Hi, I've been searching the web for help on this topic. I am using a PIC24 for a senior project, and I need some help as to how to use a timer to calculate the amount of liquid flowing through a keg line. I have a UART connection made between the PIC and a NFC card reader. The way I am thinking this should work is: 1. UART interrupt from Code reader 2. Card ID is checked to see if user has "credits" and over the age of 21. 3. If they have access, a valve is wired up to open the line on the keg. 4. INSIDE of this same interrupt, count the number of pulses from liquid flow meter. 5. Once the flow has stopped for >5 seconds, update keg volume variable and user liquid variable. The problem is with step 4. I'm confused as to how to stop the reading of the flow meter, or how to get the number of pulses after the user pulls the tap handle. Any insight or suggestions are welcome. |
|
相关推荐
1个回答
|
|
步骤4的问题有两个方面:1)如果我去大学的同学有什么路要走,从桶里流出来的水总是连续的(!!!!那是工程系的学生!!!!)2)但是严重的是,在ISR内部做任何事情都是一个设计缺陷。ISR将防止任何相同或较低优先级的中断被服务,直到它完成为止。与其进入中断优先级的混乱世界,不如简单地在ISR内部设置一个标志或执行少量的处理,然后退出。使用主循环中的标志(或其他任何标志)进行真正的处理,尤其是需要超过几微秒时。
以上来自于百度翻译 以下为原文 The problem with step 4 is two fold: 1) If the guys I went to Uni were anything to go by, the flow from the keg was always continuous (!!!! That's engineering students for you!!!) 2) But seriously, it is a design flaw to do ANYTHING much *inside* an ISR. An ISR will prevent any interrupt with the same or lower priority from being serviced until it completes. Rather than getting into the murky world of interrupt priorities, it is MUCH better to simply set a flag or doa very small amount of processing inside the ISR and then get out. Use the flag (or whatever) in the main loop to do the real processing, especially if it takes more than a few microseconds. Susan |
|
|
|
只有小组成员才能发言,加入小组>>
5289 浏览 9 评论
2059 浏览 8 评论
1969 浏览 10 评论
请问是否能把一个ADC值转换成两个字节用来设置PWM占空比?
3233 浏览 3 评论
请问电源和晶体值之间有什么关系吗?PIC在正常条件下运行4MHz需要多少电压?
2277 浏览 5 评论
824浏览 1评论
710浏览 1评论
有偿咨询,关于MPLAB X IPE烧录PIC32MX所遇到的问题
654浏览 1评论
PIC Kit3出现目标设备ID(00000000)与预期的设备ID(02c20000)不匹配。是什么原因
710浏览 0评论
609浏览 0评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-14 06:01 , Processed in 1.016892 second(s), Total 75, Slave 59 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号