Keypad with email and pul-up resistor.

siafu

Active Member
http://cocoontech.com/forums/topic/24995-pull-up-resistor-wiring/
 
Hello All,
 
I accidentally posted the above questions to the wrong forum, I received some help, but not enough to fix my issue.
 
Basically i wanted to know how to hook up a resistor so it stops sending more than one email every time someone used the keypad to open the door.
 
Now after installing the resistor, I get continuous emails one every second. The keypad still works, when the correct code is entered, but just sends email after email.
 
Below is what I hooked up and the PLC code.
 
Can someone help me with this further?
 
 
START    
    TSTEQ RAM1 0  
    CALLSUB SET_OP1   
    CALLSUB CHK4LOW   
    TSTEQ OP1[1000] 1  
    SET OP1 0  
    TSTGT IP2 0  
    CALLSUB KEYMAIL   
    NOP    
    END    

CHK4LOW:
    TSTEQ IP2 0  
    SET RAM1 0  
    RET    

SET_OP1:
    TSTEQ IP2 1 RAM1
    SET OP1 1  
    RET    

KEYMAIL:
    EMAIL EM5   
    RET
 
DOORMAIL:
    EMAIL EM1   
    RET
 
 

Attachments

  • 7-12-2013 11-34-49 AM.jpg
    7-12-2013 11-34-49 AM.jpg
    85.5 KB · Views: 15
You may want to wait for one of the gurus, but maybe something like this:
 
 

START
    SET RAM1 0
    SET RAM2 0
LOOP:
    CALLSUB CHKIP2
    CALLSUB CHKIP1
    GOTO LOOP
END    

CHKIP2:
    TSTEQ IP2[10] RAM2   //if input 2 (debounced) is the same as when we last checked it
    GOTO CHKIP2_E     //goto end
    SET RAM2 IP2         //otherwise, store the new value of input 2
    TSTEQ RAM2 0         //if the input has changed to 0
    GOTO CHKIP2_E     //goto end
    SET OP1 1            //otherwise it has changed to 1, so set output 1
    EMAIL EM5            //and send email 5
CHKIP2_E:
    TSTEQ OP1[1000] 1   //if output 1 has been set to 1 for 1 second
    SET OP1 0 //set it to 0
RET    
    
CHKIP1:
    TSTEQ IP1[10] RAM1   //if input 1 (debounced) is the same as when we last checked it
    GOTO CHKIP1_E      //goto end
    SET RAM1 IP1         //otherwise, store the new value of input 1
    TSTEQ RAM1 1         //if the input has changed to 1
    EMAIL EM1            //then send email 1
CHKIP1_E:
    RET
 
 

 
 
Please see my comment on the other thread.
 
As far as your resistor.  You must have it wired in such that you are bringing IP1 voltage up to the threshold of being "on" (or 1).  This is why it is firing off emails non-stop.  I would just get rid of that resistor and use the non-blocking delay as I stated.  
 
When your keypad is closing the circuit, you are probably getting an on/off/on.  The delay function will cause it to ignore the first on.
 
Thank you Lou, I resolved the massive emails, but still have trouble with the two emails per push.
 
Lou, you think that tuning a delay is preferable to detecting only changes in state?  Not to mention the poor readability of that other code.
 
az1324 said:
Lou, you think that tuning a delay is preferable to detecting only changes in state?  Not to mention the poor readability of that other code.
 
No, you are right.  I only quickly looked at the code at first and thought I saw this issue taken care of, but it was setting ram values for something un-related.  I commented on the other thread he started a while ago correcting the issue.
 
Using a circuit like this attached picture, you could use one analog input to decode which button is pushed. Just need to be careful those resistors value.
 

Attachments

  • adc-keypad.jpg
    adc-keypad.jpg
    72.7 KB · Views: 1
Hi Cai,
 
This looks like something complicate to me, but I don't have much knowledge about electronics, just learning bit by bit from folks on this site.
 
Back
Top