Help With POLLIN Code - falsely triggered
Leo.K
Posts: 21
Hi there,
Please could somebody help me with my code (attached)
I am trying to use the POLL commands to test for pin 3 going low and when it does, run the next EEPROM. It seems to work correctly maybe one in 20-30 times but the vast majority of the time it triggers on the first iteration of my loop.
Currently the system is on breadboard with pin 3 connected to a toggle switch and then to ground. Even with nothing connected to pin 3 at all, the problem is the same
Pins 0-2 have LED's connected. pins 4-7 arent connected.
Any·advice would be much appreciated, Please let me know if I can explain anything better. If it helps, the code is running a GPS device and a three axis accelerometer.
Thank you
Leo
Please could somebody help me with my code (attached)
I am trying to use the POLL commands to test for pin 3 going low and when it does, run the next EEPROM. It seems to work correctly maybe one in 20-30 times but the vast majority of the time it triggers on the first iteration of my loop.
Currently the system is on breadboard with pin 3 connected to a toggle switch and then to ground. Even with nothing connected to pin 3 at all, the problem is the same
Pins 0-2 have LED's connected. pins 4-7 arent connected.
Any·advice would be much appreciated, Please let me know if I can explain anything better. If it helps, the code is running a GPS device and a three axis accelerometer.
Thank you
Leo
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
With regard to the code, the lines you have would indeed enable running slot 1 when pin p3 goes low:
POLLIN 3,0
''POLLRUN 1:GOSUB Get_Time:PUT 0, Word eeprom - 1:PUT 2, i:POLLMODE 3 <-- you had this commented out?
You do realize though that the POLLRUN effect can happen at any time in the program, right in the middle of any process. Maybe that is okay. If you would rather have it happen at a predetermined point in the main program loop, it can be better to start in POLLMODE 10 (which is also in your program initialization), and then check at one point if the switch has been been pressed.
If it is to be a human activated switch, it might not be necessary to use the POLLing instructions at all.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Sorry for my late reply. The pull-up resistor solved the problem·perfectly. Thank you.
Hi Tracey, the commented out code was because it would carry out the commands following POLLRUN 1 even if the poll hadnt been triggered. Thats why I put it in the if statement. I did also use POLLMODE 10 taking your advice from a previous thread :-)
It is a human activated switch. What could I use instead of poll commands?
Thank you very much again
Leo
The advantage of POLLMODE 10 is that it checks the button more often and remembers if it has been pressed until your program gets around to it. That is important if the program loop is long and might otherwise miss the button press. Another way to get around that is to put a capacitor in parallel with the button and with a higher ohms pullup resistor, so the button press discharges the capacitor and the capacitor "remembers" the event, in hardware!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com