lwgpio+hmi and debounce?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

lwgpio+hmi and debounce?

1,104 次查看
billnd
Contributor IV

Hi All,

I'm working with a project that has a handful of buttons connected to gpio lines. The buttons suffer from some bounce on push and release, and the project is destined to go into an electrically noisy environment. I'm trying to decide how to read these button inputs, in a reliable way that eliminates as much of the bounce/noise as possible. Unfortunately I've not got permission to change the physical hardware, so have to work with software only.

My first idea is to use the HMI interface (and lwgpio), but this doesn't incorporate any debounce capability, just reads directly from the gpio lines. So what is my best option? I could write a modified lwgpio driver layer, that debounces the inputs, and then use the HMI to interface with this. Or I could ignore the HMI / lwgpio altogether and just write my own routines. Has anyone tried either method with any level of success?

Thanks in advance,

BillND

标记 (4)
0 项奖励
回复
3 回复数

889 次查看
c0170
Senior Contributor III

Hello billnd,

there's no debouncing, that's correct. I was asked previously if there's any. You can implement your debouncing routine in the application.

My proposal is:

Set Response time - that's how many reads should be executed, Set threshold - like 3/4 of RESPONSE TIME.

Retrieve a state of lwpgio pin (through hmi/lwpgio driver - your choice) number of response time, do a touch/release decision based on a threshold. Is this sufficient for your use?

Regards,

0xc0170

889 次查看
billnd
Contributor IV

Hi Martin,

Thanks for the response, much appreciated.

So, just to clarify. Your suggestion is to use the MQX functions to read the raw pin data, and then debounce those values within the application software, as a debounce task for instance?

Cheers

BillND

0 项奖励
回复

889 次查看
c0170
Senior Contributor III

Yes, that's what I proposed as a solution (to use lwpgio or hmi for reading the pin value, then do debounce calculation in a task). Let us know how it turned out, probably can share the code snippet :smileywink: 

Regards,

0xc0170

0 项奖励
回复