Debounce used in conjunction with "Select Case" and reserved word (INA)
Zeus
Posts: 79
All,
Is the above even possible, and if so does anyone have an example of how it would be employed? I am working with the following code and I have tried several configurations just to get it to compile without generating errors but yet I do not seem to be get a debounced input.
Thanks, Zeus
Is the above even possible, and if so does anyone have an example of how it would be employed? I am working with the following code and I have tried several configurations just to get it to compile without generating errors but yet I do not seem to be get a debounced input.
' -----[ Subroutines ]----------------------------------------------------- Set_Mode: SEROUT LCD, Baud, [22, 17, $0C] ' "$0C" Clears LCD Display. SEROUT LCD, Baud, ["Enter 2 digit year"] BUTTON INA, 0, 200, 200, wkspc ,1 , Set_Mode DO UNTIL (IN4 = 0) SELECT INA & 3 ' Possibilities are 00, 01, 10 and 11. CASE = 0 ' Default year = 13 CASE = 1 ' Count down year = year - 1 SEROUT LCD, Baud, [148, DEC2 year] CASE = 2 ' Count up year = year + 1 SEROUT LCD, Baud, [148, DEC2 year] ENDSELECT PAUSE 250 LOOP
Thanks, Zeus
Comments
--->what do expect to happen with the code that you've shown?
Armed with that information, there may be someone able to help out.
You've got the BUTTON command wrong. It only debounces the input on 1 single pin, not the pin group inA. You will not get what you expect. It will read the value on the 4-bit port inA, and use that value as a pin number to debounce. Also, I doubt if you need the autorepeat function. Actually, the BUTTON command is not at all what you want. You could individually debounce pins p0 and p1, but you really do want to do it as a group. Maybe something like the following for a debounce subroutine, looking for inA&3 to be in a stable state for 0.2 second...
I need to debounce my inputs (4 total) and my stamp is reading multiple button strikes currently. I would like to use the BUTTON auto-repeat function as well. I am having trouble specifically using the BUTTON command with the "INA & 3" statement (I am not sure how to incorporate this with a "Select Case" statement either). What I would like to happen is to press the inputs for a reasonable amount of time without multiple detections being registered, and if the input is held down then take advantage of the auto-repeat function as this code is for setting the time on a clock project that I am working on.
Tracy,
Always happy when I see that you have replied to one of my posts but your latest reply has got me running in circles a bit. I am still trying to understand the BUTTON command so your code above is lost on me right now. To back up for a minute, I want to use the auto-repeat function, so is the BUTTON command still the wrong choice given what I am trying to accomplish?
Thanks to the both of you.
Zeus
I see why you want to have the autorepeat to move the time values up and down. You'll need two BUTTON commands and two workspace variables (bytes), also a special condition to detect when both buttons are down.
The separate button commands implement the autorepeat separately on the two pins, p0 and p1. Like I said above, you can't put inA in the spot where a pin number belongs. There are two separate workspace variables and a special condition for both buttons down at once. The loop executes rapidly over and over, but only executes the autorepeat at the programmed frequency (once every 200th time around the loop). You'll have to play with the autorepeat parameters to get the right feel.
A few things... very helpful to know that I cannot globally debounce all five of my buttons with one statement.This explains once and for all why I cannot get it to compile no matter what the configuration. You are correct I really only need the three buttons debounced; up, down and enter. Also, I really don't need the two button command, that was just a nice to have. The bigger issue by far is debouncing the up and down values.
Your latest bit of code is much more my speed, the more I look at it the more I like it. There is quite a bit going on yet at the same time it is still easy to follow. Thank you again for helping me out.
Zeus