lwgpio+hmi and debounce?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

lwgpio+hmi and debounce?

841 Views
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

Tags (4)
0 Kudos
3 Replies

626 Views
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

626 Views
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 Kudos

626 Views
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 Kudos