![]() ![]() ![]() You should not have an interrupt taking this amount of time away from the loop. Maybe another button will have even longer bounce. However, an interrupt is steeling time from your loop, so an interrupt has to be over and done very quickly, preferably in a time period measured in microseconds and quite possibly in less than the 125μs bounce I measured with my cheap button. If you have an event that cannot wait 5ms or 10ms or 50ms or however long your loop takes THEN you use an interrupt. So, given that a button press lasts at least 150ms, even if your code is rather slow and takes 50ms per loop, it is still going to be able to check the button input at least twice per loop, possibly 3 times.Īn interrupt is what you use when you need something to be dealt with faster than your loop time. To be sure you are dealing with bounce you need to check the button input at least twice per press event the first time you see it’s pressed, the second time you see it’s still pressed so you act on the press. ![]() If you program is not getting completely round its loop in 10ms or less then you need to be asking why, and looking to either improve the code or using a faster processor. In detecting a button press you are looking for an event that lasts at least 150ms, this is an absolute age in terms of processor time. Maybe different people using different buttons will get different times, but I’ll go with what I have. With quick presses I typically measured a closed time for the button of around 150ms or more, with a bounce time of around 125μs. I connected a simple, cheap push to make button to a resistor and a power supply and connected an oscilloscope across the button. This is a common subject on these forums, so I did some tests. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |