Basic Stamp 2's IO Pin Keeps Going Low From High Randomly / How Can I Fix ???
BCLITKEI
Posts: 11
Hello Basic Stamper's, I have a Basic Stamp 2's and my IO pin's keeps going from high to low randomly / how can I fix this if possible ??? The stamp basically has a real time clock connected to it and two relay control boards with 4 push button to set the time. the whole thing controls an AC and a Heater. The 4 four push buttons set the real time clock and after the time is set I reload the the code with the buttons being used to control the AC and heater on/off. Everything works perfectly the: auto on/off, the buttons, even a water sensor for AC, the problem is randomly, maybe 2 to 3 hours of being on it will just randomly shut off or turn on. I'am at work at the moment or i would upload the code with this post, I have tried all sorts of code for the buttons and i'am at the point of considering another method for my push button all together. This has also been affecting another project of mine as well in the same fashion but has not been a problem till this project. If anyone has any thoughts or similar experiences any help would be greatly appreciated. I have been trying to figure this particular problem over a year with no success, thanks in advance and help or comments would be greatly appreciated.
Comments
What about that relay board, how is it connected? Do you have a flyback diode across each coil? How are you powering your project and the relays? Relays can be noisy, and introduce spikes on the power and ground lines, which "might" cause inputs to change.
Do you have a schematic?
We'll see what the code reveals.
In reality, the BUTTON command is not very useful. It doesn't debounce (as claimed in the stamp manual) and takes a lot of program space and variables. Instead, it is easier to write one subroutine to check all your buttons, and put them in a single variable (one bit per button). If all your button pins are sequential, and in one of the four pin groups 0-3, 4-7, 8-11, 12-15 then all you need are a nib to hold the current states. Calling the subroutine will read the pins, and update the states. Then anywhere in the program you can get the current button state by reading a variable.
You can use btn.bit0, btn.bit1, btn.bit2, etc to check just one button.
If so, are you sure that LED is just 'on' or 'off' and not multiplexed.