完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
我需要读开关在输入的两个边缘改变状态。我放置中断,但不能解决问题的尖峰。
任何使跳动的代码都会被欣赏。 以上来自于百度翻译 以下为原文 I need read switch that change status on both edges of input. I placed interrupt but can't solve problem with spikes. Any of code that make debounce is appreciate. |
|
相关推荐
15个回答
|
|
你好,
在一些PSoC 4设备中有一个DununCar组件,您可以利用它。 请参阅以下提供更多信息的应用说明 HTTP://wwwyCypC./DooptOnt/Appult- NoSe/AN600 24PSOC-3-PSOC-4-PSOC-5Lp开关DeunCal-GLITH-CHIVER滤波器 以上来自于百度翻译 以下为原文 Hi, There is a Debouncer component in some PSoC 4 devices which you can make use of. Please refer following application note which provides more information- http://www.cypress.com/documentation/application-notes/an60024-psoc-3-psoc-4-psoc-5lp-switch-debouncer-and-glitch-filter |
|
|
|
我使用PROC,所以我不能使用组件 以上来自于百度翻译 以下为原文 I use PROC so I can't use components |
|
|
|
应用说明还提供了用于固件中去抖动的代码。请参阅第5条。 -拉吉夫 以上来自于百度翻译 以下为原文 The application note also provides code for debouncing in firmware. Please refer section 5. -Rajiv |
|
|
|
卓别林 消除开关可能是件棘手的事情。我推荐一种叫“垂直计数器”的方法: HTTPS://www. 代码非常简短和有效。为了检测按下/按下事件,查找最后一段“一个精致的去抖动例程”。 ODISSEY1 以上来自于百度翻译 以下为原文 chaplin.u, Debouncing a switch can be a tricky thing. I recommend approach called 'vertical counter': https://www.compuphase.com/electronics/debouncing.htm The code is very short and effective. For detecting press / depress events look for last paragraph "A refined debouncing routine". /odissey1 |
|
|
|
我试试看。我看到许多陌生的符号,我不熟悉… 以上来自于百度翻译 以下为原文 I'll try. I see many strange symbols that I don't familiar ... |
|
|
|
垂直计数器是一个经典,我过去使用过,它工作得很好。 使用中断通常只是对某些类型的信号的一个好主意,锁存或不改变“根据它的意愿”。现在,对于简单的按钮,我通常以周期性的间隔检查按钮状态的变化,当我检测到一个变化时,我再次读取状态~50ms后,假设这是状态。 如果你坚持使用中断,因为什么原因(节电?)然后,我会设置中断状态改变,在中断,禁用PIN更改中断,设置一个计时器唤醒在50ms,读取状态,然后,如果你想要一些拖延时间,设置另一个-50ms定时器,然后重新启用中断。开关弹跳通常会发生在第一毫秒内,所以中断被禁用,使CPU“盲目”的反弹。 以上来自于百度翻译 以下为原文 That vertical counter is a classic , I've used in the past and it works very well. Using an interrupt is usually a good idea only for some types of signals, latched or that don't ever change "on its will". Nowadays, for simple buttons, I usually check for button state change at periodic intervals and when I detect a change, I read the state again ~50ms after and assume that's the state. If you insist in using interrupts, for what ever reason (power saving?), then I would set the interrupt on state change and, on interrupt, disable the pin change interrupt, set a timer to wakeup in ~50ms, read the state and then, if you want some hold-off time, set another ~50ms timer before re-enablig the interrupt. The switch bounce will typically occurr within the 1st 50ms, so the interrupt is disabled to make the CPU "blind" to the bounces. |
|
|
|
wulanghua 发表于 2018-9-21 21:17 一种方法是禁用状态变化中断,设置一个小的定时轮询去抖动按键的状态,或延迟50ms到跳了,然后重新使能中断状态改变一次按钮的状态已被确定。 我自己的应用程序,我可以离开中断状态改变时启用,只是添加一个定时器中断投票按钮。然后执行按钮去抖每当任何一个中断,直到达到稳定状态,然后使用结果中的应用。这允许多个按键中断在反跳时间不思念他们,和/或有反跳的时间比必要的(拯救了全反跳时间段的活动,这是高达50 %基于随机性节能)。 以上来自于百度翻译 以下为原文 An approach is to disable the state-change interrupt, setup a small timer to either poll the button state for debouncing, or to delay 50 ms until bouncing is done, and then to re-enable the interrupt on state change once the state of the button has been determined. With my own application, I was able to leave the interrupt on state-change enabled, and merely add another timer-interrupt for polling the button. I then perform button debouncing whenever either one interrupts until a steady-state is achieved, and then use the results in the application. This allows for multiple button interrupts within the debouncing time period without missing them, and/or having to debounce for longer than necessary (saving up to a full debounce time period of activity, which is up to 50% power savings based on randomness). |
|
|
|
卓别林
附件是一个演示项目显示单按钮DeBuncND使用垂直计数器的方法。按钮在250赫兹左右不断地被轮询,并在按下释放事件的按钮上更新标志。这是裸代码,而不是组件,因此也应该在PROC上运行。 ODISSEY1 ButoNo.SWYP4Y01C-9000.CyWrk.CaseVo.01.Zip 76.9 K 以上来自于百度翻译 以下为原文 chaplin.u, Attached is a demo project showing single button debouncind using vertical counters approach. The button is continuously polled at about 250 Hz, and flags are updated on button pressed an released events. This is bare code, not a component, thus should run on PRoC as well. /odissey1 |
|
|
|
nvwuwy 发表于 2018-9-21 21:53 我试过所有以前的变种,它不如需求好。 让我们试试这个。 谢谢! 以上来自于百度翻译 以下为原文 I tried all previous variants and it's was not as good as need. Let's try this. Thanks ! |
|
|
|
这个工作吗? ODISSEY1 以上来自于百度翻译 以下为原文 Did this one work? /odissey1 |
|
|
|
还没有。我在度假 以上来自于百度翻译 以下为原文 not yet. I'm in vacation |
|
|
|
我使用PRO,所以我不能使用UDB 以上来自于百度翻译 以下为原文 I use PROC so I can't use UDB |
|
|
|
你可以用一个简单的WDT来代替T-触发器,以固定的轮询速率进行去抖动,因为我相信这是图片中唯一使用UDB的东西。 以上来自于百度翻译 以下为原文 You can replace the T-Flip-Flop with just a simple WDT to debounce at a fixed polling rate instead, as I believe that is the only thing using UDBs in the picture. |
|
|
|
我看到它连续中断,所以它可以非常快地完成电池。 对我没有好处。 以上来自于百度翻译 以下为原文 I see that it's make interrupts continuously so it can finish battery very fast. No good for me. |
|
|
|
更改按钮,使按钮直接中断ISR。然后,当发生按钮中断时,可以设置1毫秒计时器来检查10个按压器的按钮,并确定按钮是否跳动。然后,一旦你确定按钮是否不再弹跳,你可以关闭1毫秒计时器,设备可以回到深度睡眠。 以上来自于百度翻译 以下为原文 Change it so that the button interrupts fire an ISR directly. Then, when a button interrupt occurs, you can set a 1 ms timer to check the button for 10 presses or so and determine if the button is bouncing or not. Then, once you determine whether the button is no longer bouncing, you can turn off the 1 ms timer and the device can go back into deep sleep. |
|
|
|
只有小组成员才能发言,加入小组>>
752个成员聚集在这个小组
加入小组2070 浏览 1 评论
1826 浏览 1 评论
3639 浏览 1 评论
请问可以直接使用来自FX2LP固件的端点向主机FIFO写入数据吗?
1761 浏览 6 评论
1513 浏览 1 评论
CY8C4025LQI在程序中调用函数,通过示波器观察SCL引脚波形,无法将pin0.4(SCL)下拉是什么原因导致?
510浏览 2评论
CYUSB3065焊接到USB3.0 TYPE-B口的焊接触点就无法使用是什么原因导致的?
360浏览 2评论
CX3连接Camera修改分辨率之后,播放器无法播出camera的画面怎么解决?
410浏览 2评论
357浏览 2评论
使用stm32+cyw43438 wifi驱动whd,WHD驱动固件加载失败的原因?
857浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-24 00:38 , Processed in 1.152835 second(s), Total 75, Slave 69 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号