Gate Switch

The Gate Switch is always on to monitor opening the gate which gives access to the rear of the house. It cannot be locked because 3 utilities have the right of access anytime without warning.

A magnet is fastened to the gate and the control box has a reed switch embedded in its top. When the gate is closed the magnet is positioned above the switch, closing it.

The control box is hermetically sealed with an o-ring.

When the gate is opened an “Open” code is transmitted periodically. Upon re-closing a single “Open” code is transmitted. 

The electronics is composed of two boards which are transversly inserted into slots.

Circuit Diagram

.The circuit uses a Picaxe 08M2 which is off if the gate is closed using 2 transistors for low current drain of 1 microamp. The NPN transistor provides more drive to support the transmitter.

Normally the microcontroller runs at 5 MHz for compatibility with the transmitter, but durning the intervals the operating fraquency is reduced to 31 KHz to minimize battery drain if the gate is left open.  

Program

#rem Gate-2.bas is the program for the box fastened to the gatepost.

When the gate opens this program starts and the sense pin is high.

RF signals are sent until the gate closes, then the program exits

Jphn Saunders 8/16/2016

#endrem

#Picaxe 08M2


rem Input

symbol Gate_sense = pinC.3

rem Outputs

symbol Keep_alive = C.4

symbol Tx_Key     = C.1


rem Variables

symbol Gate_Open  = bit0

symbol Tx_Code    = b1

symbol Tx_Gap     = b2

symbol Tx_Number  = b3

symbol Iter       = b4


rem Constants

symbol Key_Open   = "Q"

symbol Key_Closed = "B"

symbol Gap_Open   = 700

symbol Gap_Closed = 1200

symbol Open_Num   = 3

symbol Closed_Num  = 2


Init:

SETFREQ m4

OUTPUT Keep_Alive

HIGH Keep_Alive

OUTPUT Tx_Key

LOW Tx_Key


Still_Open:

GOSUB Transmit

SETFREQ k31

PAUSE 65

SETFREQ m4

IF Tx_Code = Key_Open THEN Still_Open

LOW Keep_Alive

END


Transmit:

LET Gate_Open = Gate_Sense

IF Gate_Open = 0 THEN

    LET Tx_Code = Key_Closed

    LET Tx_Gap = Gap_Closed

    LET TX_Number = Closed_Num

ELSE

    LET Tx_Code = Key_Open

    LET Tx_Gap = Gap_Open

    LET TX_Number = Open_Num

ENDIF

FOR Iter = 0 TO Tx_Number

    HIGH Tx_Key

    PAUSE 20

    LOW Tx_Key

    PAUSE 10

    SEROUT Tx_Key,N2400_4,("14L1776",Tx_Code,13,10)

    PAUSE Tx_Gap    

NEXT Iter

RETURN