“Cube” Alarm Receiver

This is a portable receiver which responds to signals from the gate switch by making tunes and illuminating a 3-color LED.

The speaker, the LED,  and the antenna are fastened to the box.  A metal chassis holds the 5 NiMh AA-size batteries and the charging and programing connectors. A flange at is front holds it down, and another on the side helps. The electronics board fits into a slot and has a bracket at the top for the antenna connector.  There is a wooden back.

The LM317 provides a constant 250 MA charging current, The battery voltage is measured at pin B.2 while pin B.3 measures the charging voltage,

The LP 2951 is a low-dropout regulator to provide 5V for the microcontroller and the receiver.

The LM385 audio amplifier is only powered briefly while making sounds,

Definitions and Declarations

#rem Alarm_Receiver2024.BAS  This is for the wood cube with the speaker

The Receiver gets a 433 Mhz signal from the gate transmitter or the 6-button Transmitter

The main loop of 1/10 sec times LED on duration, blinking and flashing

The command codes accepted are in Rcvr_Val and have correspondinf OpCodes as inteces to the parameter tables in EEPROM:

e:0 Flashes blue LED battery volts in morse code

D:1 Flashes green LED battery tenth volts in morse code 

A;2 Lights red LED

H:3 Turns off the LEDs

Q:4 Lights red LED and plays Gate Open tun

B:5 Lights red LED and plays Gate Closed tune

h:6 Flashes red LED and plays Siren tune

John Saunders 10/2/2024

#endrem


#PICAXE 14M2


'Input Ports

symbol Rcvr_In      = B.1        'Idle low

symbol Batt_Mon     = B.2        '1/2 of the battery voltage

symbol Chg_Mon      = B.3        '1/4 of the charging voltage

symbol Reg_Err      = pinC.3        'Goes low if the 5V regulator drops below 5V


'Output Ports

symbol Outport      = B.0

symbol Aud_Cont     = B.4

symbol Aud_Tune     = B.5

symbol Red_LED      = C.1

symbol Green_LED    = C.2

symbol Blue_LED     = C.4

    

'Variables 

'Interrupt variables

symbol Temp          = b1        

symbol Rcvr_Val      = b2

symbol LenCode       = b3


'Specific variables

symbol MorseStep        = b10

symbol Loop_Cnt        = b11        'Count of main loop of 1/10 sec

symbol DataAddr        = b12

symbol Tune_Indx        = b13        'Index into the tune branch table; 0 - 9

symbol OpCode        = b14        'Index into parameter tables

symbol Steplen        = b15

symbol DigitVal        = b16

symbol DecVal        = b17

symbol Batt_Mv        = w10        'ADC output

symbol PauseVal        = w11


'General variables

symbol Scratch          = b4



'Constants

symbol V_Charged        = 1000    '1.33 volts/cell

symbol V_Min        = 825        '1.1 V/cell

symbol MorseInterval    = 50



rem EEPROM tables: 

rem morse code for 0-9

DATA   0,(60,60,60,60,60)

DATA   5,(20,60,60,60,60)

DATA  10,(20,20,60,60,60)

DATA  15,(20,20,20,60,60)

DATA  20,(20,20,20,20,60)

DATA  25,(20,20,20,20,20)

DATA  30,(60,20,20,20,20)

DATA  35,(60,60,20,20,20)

DATA  40,(60,60,60,20,20)

DATA  45,(60,60,60,60,20)



rem LED on duration in loops:

DATA 60,(0,0,5,10,199,10,10,4,3,4)

rem Tune index , 0 is no tune

DATA 80,(0,0,4,1,2,5,3 ,0,0,0)

Init and Main

Init:

SETFREQ m8

LOW Aud_Cont

LOW Aud_Tune

LOW Outport

LET Rcvr_Val = "x"

LET OpCode = 11

SETINT %00000001,%00000001    'Interrupt when Rcvr_Int high


Main:


FVRSETUP FVR4096            '1000 count at battery 8V

ADCCONFIG $03            'Use fixed internal reference

READADC10 Batt_Mon,Batt_mv    'Battery tap 1/2, scale is 8 mv/count

LET DigitVal = Batt_mv / 125

LET DecVal = Batt_mv // 125

LET DecVal = 2 * DigitVal

LET DecVal = DecVal/25

IF OpCode < 2 THEN

    SERTXD (#DigitVal,".",#DecVal,13,10)

    FOR MorseStep = 0 TO 4

        IF OpCode = 0 THEN

            LOW Blue_LED

            LET DataAddr = 5 * DigitVal + MorseStep 

        ELSE

            LET DataAddr = 5 * DecVal + MorseStep 

            LOW Green_LED

        ENDIF

        READ DataAddr,StepLen 

        SETINT OFF

        FOR Scratch = 0 TO StepLen

            PAUSE MorseInterval

        NEXT

        HIGH Blue_LED

        HIGH Green_LED

        FOR Scratch = 0 TO 50

            PAUSE MorseInterval

        NEXT

    NEXT

    SETINT %00000001,%00000001

    LET OpCode = 11

ENDIF


IF OpCode <  2 OR OpCode > 10 THEN

    GOTO Main

ENDIF

LET Tune_Indx = 0

LET DataAddr = OpCode + 60

READ DataAddr, Loop_Cnt

LET DataAddr = OpCode +80

READ DataAddr, Tune_Indx

SERTXD ("Index = ",#Tune_Indx,13,10)    

HIGH Blue_LED

HIGH Green_LED

LOW Red_LED

IF Tune_Indx > 0 THEN

    HIGH Aud_Cont

    PAUSE 250        'Time for the audio amp to stabilize

ENDIF

SETINT OFF

BRANCH Tune_Indx,(NoMore,Acquarious,Chime,Tone4,Siren,ShortTune,Tone2,Tone3,BaBa,Okay)

Tone3:

TUNE Aud_tune,6,($40,$40,$40,$40,$40,$40,$77,$77,$75,$77,$72,$72,$74,$70,$70,$40,$40,$40,$40,$40,$40,$77,$77,$75,$77,$72,$72,$74,$70,$70)

GOTO NoMore

Chime:

TUNE Aud_tune,2,($04,$07,$05,$AB) 

GOTO NoMore

ShortTune:

TUNE Aud_tune,5,($40,$05,$49,$05,$40,$2BC7,$45,$04,$47,$04,$64,$29,$C5,$40,$05,$49,$05,$40,$2B,$C7,$45,$04) 

GOTO NoMore

Tone2:

TUNE Aud_tune,5,($40,$02,$44,$85,$40,$42,$44,$45,$AC,$42,$44,$46,$47,$AC,2,$44,$46,$47,$2C,$42,$44,$46,$47,$2C,$00,$44,$85) 

GOTO NoMore

Acquarious:

TUNE Aud_tune,2,($34,$36,$B7,$39,$37,$76,$34,$32,$B4,$32,$74,$36,$F6,$34,$74,$32,$72,$B4)'Aquarious

GOTO NoMore

Tone4:

TUNE Aud_tune,8,($30,$75,$75,$35,$77,$79,$79,$39,$79,$77,$79,$3A,$34,$37,$35,$7C,$40,$40,$79,$02,$40,$40,$7A,$3A,$7A,$7A,$77,$00,$7A,$7A,$79,$39,$7C,$70,$75,$75,$35,$77,$79,$79,$39,$79,$77,$79,$3A,$34,$37,$35,$3C) 'boom

GOTO NoMore

BaBa:

TUNE Aud_tune,2,($30,$30,$37,$37,$79,$7B,$40,$79,$37,$3C,$35,$35,$34,$34,$32,$32,$30) 'Ba Ba

GOTO NoMore

Siren:

SOUND Aud_Tune,(86,300,95,300,86,300,95,300,86,300,95,300,86,300,95,300,86,300,95,300,86,300,95,300,86,300,95,300) 

GOTO NoMore

Okay:

SOUND Aud_Tune,(25,30)

NoMore:

LOW Aud_cont

LET Tune_Indx = 0 

LET OpCode = 11

SETINT %00000001,%00000001    'Interrupt when Rcvr_Int high    


FOR Scratch = 0 TO Loop_Cnt

    PAUSE 124

NEXT

HIGH Red_LED

LET OpCode = 11    


GOTO Main

Interrupt

Interrupt:


LET Rcvr_Val = "z"

LET LenCode  = "x"

LET temp = 0        

DO WHILE PinC.0 = 1

    LET temp = temp + 1    'Twice as fast as INC Usual count is 15

LOOP

IF temp < 12 THEN 

    'LOW Red_LED

    GOTO End_Interrupt    'Minimises the time to recover from a noise interrupt

ENDIF

LET bptr = 28

's message:   Key Code| , | Msg Len| ,   |   temperature   |  , |  humidity   |  , |  solar current  | , |   batt volts           |   ,    |  hex checksum   |  CR    |   LF

SERIN [40],Rcvr_In,N2400_8,("14L1776"),Rcvr_Val,temp,LenCode,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc, @bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptrinc,@bptr

IF Rcvr_Val = "O" OR Rcvr_Val = "z" THEN End_Interrupt


LOOKDOWN Rcvr_Val,("e","D","A","H","Q","B","h"),OpCode

End_Interrupt:

'HIGH Red_LED

SETINT %00000001,%00000001    'Interrupt when Rcvr_Int high

RETURN