Pull Up resistor wiring

Lou Apo said:
I wrote this using bitwise concept.  I haven't run it, but I think it should work.  Give it a try and let me know.
 
START
TESTEQ IP2[500] 1
CALLSUB KEYMAIL
TESTEQ IP2 0
CALLSUB SETBIT3   
END
 
 
KEYMAIL:
ANDB 4 RAM1   (sets the 0 bit to 1 if 3rd bit is 1, otherwise 0)
BNZ ABORT       (if 0 bit from above is not zero (it is thus 1), it branches to abort)
EMAIL EM5       (otherwise email gets sent)
ORB 4 RAM1 RAM1    (sets 3rd bit to 1, which blocks future emails)
RET
 
ABORT:
RET
 
SETBIT3:
ANDB 4 RAM1   (checks to see if 3rd bit is already 0)
BZ ABORT          (if it is 0, it aborts)
XORB 4 RAM1 RAM1   (if it is not zero this flips it to 0 so email can be sent)
RET
 
By the way, tell me exactly what your code is doing, I am quite certain you could have this program significantly shortened/simplified.
Hi Lou, Yes this works, it sends one email, but that's it it does nothing else.
 
Basically here is what the desired outcome is.
 
IP1 is hooked up to my door buzzer, and when someone presses the button I just want one email to be sent to me from email1
 
IP2 is hooked up to the keypad, and when someone enters the correct code, OP1 is triggered for 1 second, that sends a signal to the door strike that opens the door, then sends an email from email5
 
That's basically it.
 
START    
    TSTEQ IP2[500] 1  
    CALLSUB KEYMAIL   
    TSTEQ IP2 0  
    CALLSUB SETBIT3   
    END    

KEYMAIL:
    ANDB 4 RAM1  
    BNZ  ABORT  
    EMAIL EM5   
    ORB 4 RAM1 RAM1
    RET    

ABORT:
    RET    

SETBIT3:
    ANDB 4 RAM1  
    BZ  ABORT  
    XORB 4 RAM1 RAM1
    RET
 
I have other code that you helped me with some time ago, where it controls the heat, and will also like to implement that into a code that works with the keypad and the door buzzer.
 
Thanks for your continued help.
 
Lou Apo said:
I wrote this using bitwise concept.  I haven't run it, but I think it should work.  Give it a try and let me know.
 
START
TESTEQ IP2[500] 1
CALLSUB KEYMAIL
TESTEQ IP2 0
CALLSUB SETBIT3   
END
 
 
KEYMAIL:
ANDB 4 RAM1   (sets the 0 bit to 1 if 3rd bit is 1, otherwise 0)
BNZ ABORT       (if 0 bit from above is not zero (it is thus 1), it branches to abort)
EMAIL EM5       (otherwise email gets sent)
ORB 4 RAM1 RAM1    (sets 3rd bit to 1, which blocks future emails)
RET
 
ABORT:
RET
 
SETBIT3:
ANDB 4 RAM1   (checks to see if 3rd bit is already 0)
BZ ABORT          (if it is 0, it aborts)
XORB 4 RAM1 RAM1   (if it is not zero this flips it to 0 so email can be sent)
RET
 
By the way, tell me exactly what your code is doing, I am quite certain you could have this program significantly shortened/simplified.
Hi Lou, Yes this works, it sends one email, but that's it it does nothing else.
 
Basically here is what the desired outcome is.
 
IP1 is hooked up to my door buzzer, and when someone presses the button I just want one email to be sent to me from email1
 
IP2 is hooked up to the keypad, and when someone enters the correct code, OP1 is triggered for 1 second, that sends a signal to the door strike that opens the door, then sends an email from email5
 
That's basically it.
 
START    
    TSTEQ IP2[500] 1  
    CALLSUB KEYMAIL   
    TSTEQ IP2 0  
    CALLSUB SETBIT3   
    END    

KEYMAIL:
    ANDB 4 RAM1  
    BNZ  ABORT  
    EMAIL EM5   
    ORB 4 RAM1 RAM1
    RET    

ABORT:
    RET    

SETBIT3:
    ANDB 4 RAM1  
    BZ  ABORT  
    XORB 4 RAM1 RAM1
    RET
 
I have other code that you helped me with some time ago, where it controls the heat, and will also like to implement that into a code that works with the keypad and the door buzzer.
 
Thanks for your continued help.
 
Try
 
START
  TSTEQ IP2[250] 0
  CALLSUB KEYMAIL
  TSTEQ IP2]250] 1
  CALLSUB SETBIT3 (which is a odd name since it CLEARS the bit - perhaps you should rename it to CLRBIT3)
 
Frederick C. Wilt said:
Try
 
START
  TSTEQ IP2[250] 0
  CALLSUB KEYMAIL
  TSTEQ IP2]250] 1
  CALLSUB SETBIT3 (which is a odd name since it CLEARS the bit - perhaps you should rename it to CLRBIT3)
 
Fred, 
 
In truth it doesn't matter which way you do it, both should work almost exactly the same.  The difference will be whether the email gets sent when someone pushes the buzzer button, or when someone releases the buzzer button.  Since that is probably only about 1 or 2 seconds and emails aren't an instantaneous thing, you shouldn't be able to tell the difference.
 
siafu said:
Hi Lou, Yes this works, it sends one email, but that's it it does nothing else.
 
Basically here is what the desired outcome is.
 
IP1 is hooked up to my door buzzer, and when someone presses the button I just want one email to be sent to me from email1
 
IP2 is hooked up to the keypad, and when someone enters the correct code, OP1 is triggered for 1 second, that sends a signal to the door strike that opens the door, then sends an email from email5
 
That's basically it.
 
START    
    TSTEQ IP2[500] 1  
    CALLSUB KEYMAIL   
    TSTEQ IP2 0  
    CALLSUB SETBIT3   
    END    

KEYMAIL:
    ANDB 4 RAM1  
    BNZ  ABORT  
    EMAIL EM5   
    ORB 4 RAM1 RAM1
    RET    

ABORT:
    RET    

SETBIT3:
    ANDB 4 RAM1  
    BZ  ABORT  
    XORB 4 RAM1 RAM1
    RET
 
I have other code that you helped me with some time ago, where it controls the heat, and will also like to implement that into a code that works with the keypad and the door buzzer.
 
Thanks for your continued help.
 
 
Try This, I used bit 2 for the buzzer and left bit 3 for the keypad, so still only one ram used and your have 29 more "flags" left.  The same subroutine can both trigger your doorlock and send the email, so I merged them.  
 
START
TESTEQ IP2[500] 1
CALLSUB KEYMAIL
TESTEQ IP2 0
CALLSUB SETBIT3
TESTEQ IP1 1
CALLSUB BUZMAIL
TESTEQ IP1 0
CALLSUB SETBIT2
END
 
BUZMAIL:
ANDB 2 RAM1
BNZ ABORT
EMAIL EM1
ORB 2 RAM1 RAM1
RET
 
KEYMAIL:
ANDB 4 RAM1   (sets the 0 bit to 1 if 3rd bit is 1, otherwise 0)
BNZ ABORT       (if 0 bit from above is not zero (it is thus 1), it branches to abort)
EMAIL EM5       (otherwise email gets sent)
ORB 4 RAM1 RAM1    (sets 3rd bit to 1, which blocks future emails)
SET OP1[1000] 1
RET
 
ABORT:
RET
 
SETBIT3:
ANDB 4 RAM1   (checks to see if 3rd bit is already 0)
BZ ABORT          (if it is 0, it aborts)
XORB 4 RAM1 RAM1   (if it is not zero this flips it to 0 so email can be sent)
RET
 
SETBIT2:
ANDB 2 RAM1
BZ ABORT
XORB 2 RAM1 RAM1
RET
 
Lou Apo said:
Try This, I used bit 2 for the buzzer and left bit 3 for the keypad, so still only one ram used and your have 29 more "flags" left.  The same subroutine can both trigger your doorlock and send the email, so I merged them.  
 
START
TESTEQ IP2[500] 1
CALLSUB KEYMAIL
TESTEQ IP2 0
CALLSUB SETBIT3
TESTEQ IP1 1
CALLSUB BUZMAIL
TESTEQ IP1 0
CALLSUB SETBIT2
END
 
BUZMAIL:
ANDB 2 RAM1
BNZ ABORT
EMAIL EM1
ORB 2 RAM1 RAM1
RET
 
KEYMAIL:
ANDB 4 RAM1   (sets the 0 bit to 1 if 3rd bit is 1, otherwise 0)
BNZ ABORT       (if 0 bit from above is not zero (it is thus 1), it branches to abort)
EMAIL EM5       (otherwise email gets sent)
ORB 4 RAM1 RAM1    (sets 3rd bit to 1, which blocks future emails)
SET OP1[1000] 1
RET
 
ABORT:
RET
 
SETBIT3:
ANDB 4 RAM1   (checks to see if 3rd bit is already 0)
BZ ABORT          (if it is 0, it aborts)
XORB 4 RAM1 RAM1   (if it is not zero this flips it to 0 so email can be sent)
RET
 
SETBIT2:
ANDB 2 RAM1
BZ ABORT
XORB 2 RAM1 RAM1
RET
Hi Lou, This worked, But I needed to add the [500] to input 1, as it was sending 2 emails, but after that all is working, thank you very much.
 
START    
    TSTEQ IP2[500] 1  
    CALLSUB KEYMAIL   
    TSTEQ IP2 0  
    CALLSUB SETBIT3   
    TSTEQ IP1[500] 1  
    CALLSUB BUZMAIL   
    TSTEQ IP1 0  
    CALLSUB SETBIT2   
    END    

BUZMAIL:
    ANDB 2 RAM1  
    BNZ  ABORT  
    EMAIL EM1   
    ORB 2 RAM1 RAM1
    RET    

KEYMAIL:
    ANDB 4 RAM1  
    BNZ  ABORT  
    EMAIL EM5   
    ORB 4 RAM1 RAM1
    SET OP1[1000] 1  
    RET    

ABORT:
    RET    

SETBIT3:
    ANDB 4 RAM1  
    BZ  ABORT  
    XORB 4 RAM1 RAM1
    RET    

SETBIT2:
    ANDB 2 RAM1  
    BZ  ABORT  
    XORB 2 RAM1 RAM1
 
Well that pretty much settles it then.  Your switch is "bouncing" when it first sets.
 
Glad to hear that the bitwise works.  That is actually the first bitwise code I have ever written.  I've been wanting to try it out. . . so you gave me the chance.  Obviously, it is just a matter of copying the same code over and over again for each bit you want to work with increasing by multiple of 2 for the next bit up.
 
If there is a slicker way to do bitwise than this, I would love to hear.  Like I said, this is my first endeavor and there very well may be tricks that I didn't think of.
 
Part of the problem is that "language" provided with the unit is somewhat primative, which makes things that should be simple a bit harder then needs be.
 
For example one automation controller that I worked with had commands just to handle transitions on input. Basically you would define, for a given input, if you wanted to respond to a falling edge or rising edge (debouncing was built-in) and what sub-routine to execute when that input transitioned. The implementation was such that you always got just one sub-routine call per input transition.
 
If also had commands to treat memory as bytes, words AND bits. So for bits you could SET, RESET, TOGGLE and TEST a bit just by specifing a memory location and a "bit number".
 
This WebControl unit has some significant hardware features that this older unit did not have, such as the network port, email sending, etc. The older unit (many years back) was basically inputs and outputs but the "language" was much "richer".
 
Good job, Lou!
 
Lou Apo said:
Well that pretty much settles it then.  Your switch is "bouncing" when it first sets.
 
Glad to hear that the bitwise works.  That is actually the first bitwise code I have ever written.  I've been wanting to try it out. . . so you gave me the chance.  Obviously, it is just a matter of copying the same code over and over again for each bit you want to work with increasing by multiple of 2 for the next bit up.
 
If there is a slicker way to do bitwise than this, I would love to hear.  Like I said, this is my first endeavor and there very well may be tricks that I didn't think of.
No problem anytime, Lou, :)
 
So if I wanted to add another door buzzer (Bell) for example, I would do the following? (Marked in red)
 
START   
    TSTEQ IP2[500] 1 
    CALLSUB KEYMAIL  
    TSTEQ IP2 0 
    CALLSUB SETBIT3  
    TSTEQ IP1[500] 1 
    CALLSUB BUZMAIL  
    TSTEQ IP1 0 
    CALLSUB SETBIT2  
    TSTEQ IP3[500] 1 
    CALLSUB BELMAIL  
    TSTEQ IP3 0 
    CALLSUB SETBIT4  
    END   
 
BUZMAIL:
    ANDB 2 RAM1 
    BNZ  ABORT 
    EMAIL EM1  
    ORB 2 RAM1 RAM1
    RET   
  
BELMAIL:
    ANDB 6 RAM1 
    BNZ  ABORT 
    EMAIL EM7  
    ORB 6 RAM1 RAM1
    RET   
 
KEYMAIL:
    ANDB 4 RAM1 
    BNZ  ABORT 
    EMAIL EM5  
    ORB 4 RAM1 RAM1
    SET OP1[1000] 1 
    RET   
 
ABORT:
    RET   
 
SETBIT3:
    ANDB 4 RAM1 
    BZ  ABORT 
    XORB 4 RAM1 RAM1
    RET   
 
SETBIT2:
    ANDB 2 RAM1 
    BZ  ABORT 
    XORB 2 RAM1 RAM1
 
SETBIT4:
    ANDB 6 RAM1 
    BZ  ABORT 
    XORB 6 RAM1 RAM1
 
siafu said:
No problem anytime, Lou, :)
 
So if I wanted to add another door buzzer (Bell) for example, I would do the following? (Marked in red)
 
START   
    TSTEQ IP2[500] 1 
    CALLSUB KEYMAIL  
    TSTEQ IP2 0 
    CALLSUB SETBIT3  
    TSTEQ IP1[500] 1 
    CALLSUB BUZMAIL  
    TSTEQ IP1 0 
    CALLSUB SETBIT2  
    TSTEQ IP3[500] 1 
    CALLSUB BELMAIL  
    TSTEQ IP3 0 
    CALLSUB SETBIT4  
    END   
 
BUZMAIL:
    ANDB 2 RAM1 
    BNZ  ABORT 
    EMAIL EM1  
    ORB 2 RAM1 RAM1
    RET   
  
BELMAIL:
    ANDB 6 RAM1 
    BNZ  ABORT 
    EMAIL EM7  
    ORB 6 RAM1 RAM1
    RET   
 
KEYMAIL:
    ANDB 4 RAM1 
    BNZ  ABORT 
    EMAIL EM5  
    ORB 4 RAM1 RAM1
    SET OP1[1000] 1 
    RET   
 
ABORT:
    RET   
 
SETBIT3:
    ANDB 4 RAM1 
    BZ  ABORT 
    XORB 4 RAM1 RAM1
    RET   
 
SETBIT2:
    ANDB 2 RAM1 
    BZ  ABORT 
    XORB 2 RAM1 RAM1
 
SETBIT4:
    ANDB 6 RAM1 
    BZ  ABORT 
    XORB 6 RAM1 RAM1
Actually it works, I just tested this on IP3 and one email was sent.
 
No, not 6.  8.  Code still kind of messy though not well grouped into functions.  Not sure why you want to keep changing working code... I guess just to learn?
 
How about this:
 
Code:
START   
    CALLSUB KEY  
    CALLSUB BUZZ  
    CALLSUB BELL
    END   

KEY:
    AND IP2[500] 1
    BZ KEY_RST
    ANDB 4 RAM1 
    BNZ KEY_RST 
    EMAIL EM5  
    ORB 4 RAM1 RAM1
    SET OP1[1000] 1 
KEY_RST:
    TSTEQ IP2[500] 0
    ANDB 0xFFFFFFFB RAM1 RAM1
    RET

BUZZ:
    AND IP1[500] 1
    BZ BUZZ_RST
    ANDB 2 RAM1 
    BNZ BUZZ_RST 
    EMAIL EM1  
    ORB 2 RAM1 RAM1
BUZZ_RST:
    TSTEQ IP1[500] 0
    ANDB 0xFFFFFFFD RAM1 RAM1
    RET  
  
BELL:
    AND IP3[500] 1
    BZ BELL_RST
    ANDB 8 RAM1 
    BNZ BELL_RST 
    EMAIL EM7  
    ORB 8 RAM1 RAM1
BELL_RST:
    TSTEQ IP3[500] 0
    ANDB 0xFFFFFFF7 RAM1 RAM1
    RET
 
az1324 said:
No, not 6.  8.  Code still kind of messy though not well grouped into functions.  Not sure why you want to keep changing working code... I guess just to learn?
 
How about this:
 

START   
    CALLSUB KEY  
    CALLSUB BUZZ  
CALLSUB BELL
END   

KEY:
    AND IP2[500] 1
  BZ KEY_RST
    ANDB 4 RAM1 
    BNZ KEY_RST 
    EMAIL EM5  
    ORB 4 RAM1 RAM1
    SET OP1[1000] 1 
KEY_RST:
    TSTEQ IP2[500] 0
ANDB 0xFFFFFFFB RAM1 RAM1
RET

BUZZ:
    AND IP1[500] 1
  BZ BUZZ_RST
    ANDB 2 RAM1 
    BNZ BUZZ_RST 
    EMAIL EM1 
    ORB 2 RAM1 RAM1
BUZZ_RST:
    TSTEQ IP1[500] 0
ANDB 0xFFFFFFFD RAM1 RAM1
RET  
  
BELL:
    AND IP3[500] 1
BZ BELL_RST
    ANDB 8 RAM1 
    BNZ BELL_RST 
    EMAIL EM7 
    ORB 8 RAM1 RAM1
BELL_RST:
    TSTEQ IP3[500] 0
ANDB 0xFFFFFFF7 RAM1 RAM1
RET
Hi AZ, actually 6 worked, not sure why, but it did send one email when I shorted (touched input 3 wire with 5+V wire of the WC board.
 
I didn't actually hook it up to the doorbell, because I don't know how properly. In fact I tried hooking one of the inputs of a different WC board some time ago, and I fried the inputs, because later I found out that when someone presses my apartment door (not to be confused with door buzzer discuses earlier) the way I had it hooked up, the AC voltage fluctuated, from low to very high, as high as 50VAC according to my multimeter. and that's how I fried all the inputs to one of my WC board. That board is still in use, but can only use it with the analog inputs, and that's fine for what it does, it controls the outside light that is hooked up to a photo-resistor, and it works very well, thanks to folks on this board that helped me with that project. Now I just need to figure out how to get low signal from my doorbell to trigger IP3, without frying the inputs. Any suggestions welcomed.
 
I will give your code a try as well tomorrow and report back.
 
siafu said:
Now I just need to figure out how to get low signal from my doorbell to trigger IP3, without frying the inputs. Any suggestions welcomed.
Take a look at this Elk Doorbell detector:
 
 
 
Also, if you want to 'lengthen' the pulse to ensure no double emails are sent or to ensure detection by your hardware, you could couple this with an Elk-960.
 
az1324 said:
No, not 6.  8.  Code still kind of messy though not well grouped into functions.  Not sure why you want to keep changing working code... I guess just to learn?
 
How about this:
 

START   
    CALLSUB KEY  
    CALLSUB BUZZ  
CALLSUB BELL
END   

KEY:
    AND IP2[500] 1
  BZ KEY_RST
    ANDB 4 RAM1 
    BNZ KEY_RST 
    EMAIL EM5  
    ORB 4 RAM1 RAM1
    SET OP1[1000] 1 
KEY_RST:
    TSTEQ IP2[500] 0
ANDB 0xFFFFFFFB RAM1 RAM1
RET

BUZZ:
    AND IP1[500] 1
  BZ BUZZ_RST
    ANDB 2 RAM1 
    BNZ BUZZ_RST 
    EMAIL EM1 
    ORB 2 RAM1 RAM1
BUZZ_RST:
    TSTEQ IP1[500] 0
ANDB 0xFFFFFFFD RAM1 RAM1
RET  
  
BELL:
    AND IP3[500] 1
BZ BELL_RST
    ANDB 8 RAM1 
    BNZ BELL_RST 
    EMAIL EM7 
    ORB 8 RAM1 RAM1
BELL_RST:
    TSTEQ IP3[500] 0
ANDB 0xFFFFFFF7 RAM1 RAM1
RET
 
OK, that is the kind of trick I was looking for.  Using the andb 0xFFFFFFF7 to reset the bit.  By using a a hex number that is 32 bits of 1's except the bit that needs changing you dropped a bunch of code. 
 
Back
Top