<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pauljmac.com/projects/index.php?action=history&amp;feed=atom&amp;title=Mails_Here%21</id>
	<title>Mails Here! - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pauljmac.com/projects/index.php?action=history&amp;feed=atom&amp;title=Mails_Here%21"/>
	<link rel="alternate" type="text/html" href="https://pauljmac.com/projects/index.php?title=Mails_Here!&amp;action=history"/>
	<updated>2026-04-21T14:01:07Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.3</generator>
	<entry>
		<id>https://pauljmac.com/projects/index.php?title=Mails_Here!&amp;diff=7&amp;oldid=prev</id>
		<title>Paul: Created page with &quot;== Updates and Status == &lt;section begin=updates /&gt;*After testing and trying many different things I&#039;m afraid that the range on the normal Xbee modules just isn&#039;t strong enough for my application. I will probably be getting some Xbee pro modules soon to try and compensate for this. The device&#039;s operation is just hit and miss with the current setup. Ive tried implementing several solutions to compensate for this but all of which were unacceptable. Im putting this project o...&quot;</title>
		<link rel="alternate" type="text/html" href="https://pauljmac.com/projects/index.php?title=Mails_Here!&amp;diff=7&amp;oldid=prev"/>
		<updated>2024-12-08T16:06:57Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;== Updates and Status == &amp;lt;section begin=updates /&amp;gt;*After testing and trying many different things I&amp;#039;m afraid that the range on the normal Xbee modules just isn&amp;#039;t strong enough for my application. I will probably be getting some Xbee pro modules soon to try and compensate for this. The device&amp;#039;s operation is just hit and miss with the current setup. Ive tried implementing several solutions to compensate for this but all of which were unacceptable. Im putting this project o...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Updates and Status ==&lt;br /&gt;
&amp;lt;section begin=updates /&amp;gt;*After testing and trying many different things I&amp;#039;m afraid that the range on the normal Xbee modules just isn&amp;#039;t strong enough for my application. I will probably be getting some Xbee pro modules soon to try and compensate for this. The device&amp;#039;s operation is just hit and miss with the current setup. Ive tried implementing several solutions to compensate for this but all of which were unacceptable. Im putting this project on hold until my next Mouser purchase when I can get the better modules. --[[User:Paul|Paul]] 15:13, 6 September 2007 (EDT)&amp;lt;section end=updates /&amp;gt;&lt;br /&gt;
&amp;lt;section begin=oldnews /&amp;gt;&lt;br /&gt;
*I have been working on this project for three days straight and have been making good progress. I finally have something im willing to test in the field and will be doing so for the next week. --[[User:Paul|Paul]] 17:42, 30 August 2007 (EDT)&lt;br /&gt;
*Exciting week! My [[Mails Here!]] board arrived on sat and my new [http://www.aoyue.com/en/ArticleShow.asp?ArticleID=415 Aoyue 2702] soldering station arrived Monday. If im happy with the outcome of this new board ill upload the layout to the [[Mails Here!]] page. I have some work ahead of me now! --[[User:Paul|Paul]] 14:12, 14 August 2007 (EDT)&lt;br /&gt;
*My newly designed boards have finally arrived. I was working on porting the code over to the old PIC to the new one (18f8722 to a 18f2550) when I came across a lot of ways I could do things more efficiently so its ending up like a total rewrite than a port, which is fine. Will post some of the good stuff once I`m happy with it. --[[User:Paul|Paul]] 22:37, 6 July 2007 (EDT)&lt;br /&gt;
&lt;br /&gt;
*I ordered the revision 3 of the PCB. This version includes a Dallas/Maxim DS1305 RTC with super capacitor backup. I wanted to include it sense day one but the whole project being such a large step for me I decided against it until now. Now I will be able to implement a RTC easer as well as a full calender. I cant wait for the boards to arrive so I can get back into it. --[[User:Paul|Paul]] 18:11, 1 August 2007 (EDT)&lt;br /&gt;
&amp;lt;section end=oldnews /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Abstract ==&lt;br /&gt;
Mails Here! is a mail notification system consisting of two parts. The first is a device that is placed in a mail box with a photo sensor, button, and RF transmitter/receiver. When light is detected in the box, the MCU makes a decision at to whether it&amp;#039;s mail being delivered or retrieved based on the following actions and transmits the corresponding signal to the base station. The base station is the second part of the system which consists of an LCD, 4 button navigation panel and an RF transmitter/receiver. When a signal is received from the mailbox device, the MCU inside the base station records the activity and updates the display. The MCU also keeps a log of the previous 7 days which can be displayed on the LCD using the navigation buttons.&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
&lt;br /&gt;
=== Mail box device ===&lt;br /&gt;
After the user powers up the device by installing a 9V battery, a 30 second timer will activate allowing them to place the device in the mailbox. After 30 seconds, the device will go into power saving mode and stay there until light is detected. If the amount of light detected is above the threshold that is set by the potentiometer, the device will wake up and begin a 30 second timer. If the button on the device is pressed within this 30 second time frame, the device will assume its someone retrieving the mail and transmit a &amp;quot;Mail Retrieved&amp;quot; code to the base station. The device then provides a 20 second grade period for the user to close the mail box so the device can reset and await another delivery. If no button is pressed within the 30 second time frame, the device will assume its the mail being delivered and will transmit a &amp;quot;Mail Delivered&amp;quot; code to the base station.&lt;br /&gt;
&lt;br /&gt;
== Parts ==&lt;br /&gt;
&lt;br /&gt;
== Circuits ==&lt;br /&gt;
[[Image:Mailshere mailboxpower Page 3.jpg|none|thumb|Mail box device]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Mailshere mailboxpower Page 4.jpg|none|thumbnail|Mail box device power]]&lt;br /&gt;
&lt;br /&gt;
== Code ==&lt;br /&gt;
=== Mail box device ===&lt;br /&gt;
I wrote code for the mail box device in assembly. Intended to run on a PIC16F88. &lt;br /&gt;
[http://pauljmac.com/projects/images/b/b8/Mailbox.zip]&lt;br /&gt;
&lt;br /&gt;
The main code:&lt;br /&gt;
&amp;lt;pre&amp;gt;;**********************************************************************&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;    Filename:	    main.asm                                          *&lt;br /&gt;
;    Date:          04/28/07                                          *&lt;br /&gt;
;    File Version:  1.0                                               *&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;    Author:        Paul Mac                                          *&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;**********************************************************************&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;    Files required:    P16F88.INC                                    *&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;**********************************************************************&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;   Operation: After setup the PIC is put into sleep. A change	      *&lt;br /&gt;
; in the comparator will bring the PIC out of sleep.Light hits the    *&lt;br /&gt;
; photocell the comparator will wakeup the PIC and it will start a 30 *&lt;br /&gt;
; second timer. If the button is pressed within the time limit a      *&lt;br /&gt;
; &amp;quot;mail picked up&amp;quot; routine will be executed. If not after the timer   *&lt;br /&gt;
; is up a &amp;quot;mail delivered&amp;quot; routine will be executed. After both	      *&lt;br /&gt;
; routines the PIC will reset and return to sleep                     *&lt;br /&gt;
;                                                                     *&lt;br /&gt;
;**********************************************************************&lt;br /&gt;
&lt;br /&gt;
	list      p=16f88, r=HEX         ; list directive to define processor&lt;br /&gt;
	#include &amp;lt;p16F88.inc&amp;gt;        ; processor specific variable definitions&lt;br /&gt;
&lt;br /&gt;
	errorlevel  -302              ; suppress message 302 from list file&lt;br /&gt;
&lt;br /&gt;
    __CONFIG    _CONFIG1, _CP_OFF &amp;amp; _CCP1_RB0 &amp;amp; _DEBUG_OFF &amp;amp; _WRT_PROTECT_OFF &amp;amp; _CPD_OFF &amp;amp; _LVP_OFF &amp;amp; _BODEN_OFF &amp;amp; _MCLR_ON &amp;amp; _PWRTE_OFF &amp;amp; _WDT_OFF &amp;amp; _INTRC_CLKOUT&lt;br /&gt;
  	__CONFIG    _CONFIG2, _IESO_OFF &amp;amp; _FCMEN_OFF&lt;br /&gt;
&lt;br /&gt;
;***** VARIABLE DEFINITIONS ********************************************&lt;br /&gt;
	cblock	0x20&lt;br /&gt;
	d1,d2,d3,d4&lt;br /&gt;
	txbyte,rxbyte&lt;br /&gt;
	buttonloopdelay, ticker, repeat&lt;br /&gt;
	endc&lt;br /&gt;
w_temp        EQU     0x71        ; variable used for context saving &lt;br /&gt;
status_temp   EQU     0x72        ; variable used for context saving&lt;br /&gt;
pclath_temp   EQU     0x73	 	 ; variable used for context saving&lt;br /&gt;
&lt;br /&gt;
;**********************************************************************&lt;br /&gt;
	ORG     0x000             ; processor reset vector&lt;br /&gt;
	goto    Initialize              ; go to beginning of program&lt;br /&gt;
&lt;br /&gt;
; *** isr ************************************************************&lt;br /&gt;
	ORG     0x004             ; interrupt vector location&lt;br /&gt;
	movwf   w_temp            ; save off current W register contents&lt;br /&gt;
	movf	STATUS,w          ; move STATUS register into W register&lt;br /&gt;
	movwf	status_temp       ; save off contents of STATUS register&lt;br /&gt;
	movf	PCLATH,W	  ; move PCLATH register into W register&lt;br /&gt;
	movwf	pclath_temp       ; save off contents of PCLATH register&lt;br /&gt;
	; ISR here&lt;br /&gt;
	movf    pclath_temp,w     ; retrieve copy of PCLATH register&lt;br /&gt;
	movwf	PCLATH            ; restore pre-isr PCLATH register contents&lt;br /&gt;
	movf    status_temp,w     ; retrieve copy of STATUS register&lt;br /&gt;
	movwf	STATUS            ; restore pre-isr STATUS register contents&lt;br /&gt;
	swapf   w_temp,f&lt;br /&gt;
	swapf   w_temp,w          ; restore pre-isr W register contents&lt;br /&gt;
	retfie                    ; return from interrupt&lt;br /&gt;
&lt;br /&gt;
;**********************************************************************&lt;br /&gt;
Initialize&lt;br /&gt;
    BANKSEL	OSCCON&lt;br /&gt;
    movlw   b&amp;#039;01110000&amp;#039;     ;select 8-MHz INTOSC clock&lt;br /&gt;
    movwf   OSCCON&lt;br /&gt;
Stable&lt;br /&gt;
	BANKSEL	OSCCON  &lt;br /&gt;
	btfss   OSCCON,IOFS     ;INTOSC frequency stable?&lt;br /&gt;
    goto    Stable          ;no, loop&lt;br /&gt;
ADcon   &lt;br /&gt;
	movlw	b&amp;#039;00000110&amp;#039;		;PORTA 1 and 2 are analog inputs&lt;br /&gt;
	BANKSEL	ANSEL&lt;br /&gt;
    movwf   ANSEL           &lt;br /&gt;
Comparator&lt;br /&gt;
	movlw	b&amp;#039;00000101&amp;#039;		;Setup Comparator, C1 disabled, C2 enabled Vin- is RA1 Vin+ is RA2 output is RA4&lt;br /&gt;
	BANKSEL	CMCON	&lt;br /&gt;
	movwf	CMCON&lt;br /&gt;
Ports&lt;br /&gt;
    movlw	b&amp;#039;00000110&amp;#039;		;PORTA RA1 and RA2 are comparator inputs, RA0 is LED output&lt;br /&gt;
    BANKSEL	TRISA&lt;br /&gt;
    movwf	TRISA&lt;br /&gt;
    movlw	b&amp;#039;010000101&amp;#039;	;PORTB RB7:NA RB6:CTS, Input RB5:UartTX, output RB4:RTS, output RB3:Xbee Reset, output RB2:UartRX, Input RB1:Xbee Sleep, Output RB0:Button, Input&lt;br /&gt;
    BANKSEL	TRISB&lt;br /&gt;
    movwf	TRISB&lt;br /&gt;
Uartsetup&lt;br /&gt;
    movlw	d&amp;#039;51&amp;#039;			;set UART to 9.6k baud&lt;br /&gt;
    BANKSEL	SPBRG&lt;br /&gt;
    movwf	SPBRG&lt;br /&gt;
    movlw	b&amp;#039;00100100&amp;#039;		;setup UARTtx for 8bit-Asynchronous high baud&lt;br /&gt;
    BANKSEL	TXSTA&lt;br /&gt;
    movwf	TXSTA&lt;br /&gt;
    movlw	b&amp;#039;10010000&amp;#039;		;setup UARTrx for enable serial port and continuous receive 8bit&lt;br /&gt;
    BANKSEL	RCSTA&lt;br /&gt;
    movwf	RCSTA&lt;br /&gt;
Interrupts&lt;br /&gt;
	movlw	b&amp;#039;01000000&amp;#039;		;Enable PIE and intrupt			&lt;br /&gt;
	BANKSEL	INTCON&lt;br /&gt;
	movwf	INTCON&lt;br /&gt;
	movlw	b&amp;#039;0010000&amp;#039;		;Enable RCIE Ausart receive interrupt&lt;br /&gt;
	BANKSEL	PIE1&lt;br /&gt;
	movwf	PIE1	&lt;br /&gt;
	movlw	b&amp;#039;01000000&amp;#039;		;Enable Comparator Interrupt&lt;br /&gt;
	BANKSEL	PIE2	&lt;br /&gt;
	movwf	PIE2&lt;br /&gt;
GetReady&lt;br /&gt;
	BANKSEL	PORTA&lt;br /&gt;
	BSF		PORTB,3			;Make sure the xbee reset pin is high	&lt;br /&gt;
;    clrf	PORTA&lt;br /&gt;
;    clrf	PORTB&lt;br /&gt;
	call	Delay_20s		;20 second delay till device is active UNCOMMENT WHEN DONE TESTING&lt;br /&gt;
	movlw	&amp;#039;0&amp;#039;&lt;br /&gt;
	call 	Uart_out&lt;br /&gt;
; Program entry *******************************************************&lt;br /&gt;
Main&lt;br /&gt;
	BANKSEL	PORTA&lt;br /&gt;
	bcf		PORTA,0		;turn the button loop light off if its on&lt;br /&gt;
	bsf		PORTB,1		;Put the Xbee to sleep&lt;br /&gt;
	SLEEP				;gooo to sleeppppp&lt;br /&gt;
	nop					;Prefetched before sleep&lt;br /&gt;
	BANKSEL	CMCON&lt;br /&gt;
	btfss 	CMCON,C2OUT&lt;br /&gt;
	goto	Runlight&lt;br /&gt;
	BANKSEL	PIR1&lt;br /&gt;
	btfsc 	PIR1,TXIF&lt;br /&gt;
	goto	RxInt&lt;br /&gt;
	goto	Main&lt;br /&gt;
Runlight&lt;br /&gt;
	movlw   D&amp;#039;6&amp;#039;		;default value is 255 for with a 6 ticker for ~30 second delay&lt;br /&gt;
	BANKSEL ticker&lt;br /&gt;
	movwf	ticker&lt;br /&gt;
	movlw	D&amp;#039;255&amp;#039;		;default value is 255 for with a 6 ticker for ~30 second delay&lt;br /&gt;
	BANKSEL	buttonloopdelay&lt;br /&gt;
	movwf	buttonloopdelay&lt;br /&gt;
Buttonloop&lt;br /&gt;
	BANKSEL	PORTA&lt;br /&gt;
	movlw	b&amp;#039;00000001&amp;#039;		;toggle RA0, AHH YUP, GOOD TO GO&lt;br /&gt;
	xorwf	PORTA,f&lt;br /&gt;
	btfss	PORTB,0			;Test to see if button has been pressed. &lt;br /&gt;
	goto	Pickup			; If so branch&lt;br /&gt;
	call	Buttonloopdelay		;delay 20ms then poll again.&lt;br /&gt;
	BANKSEL	buttonloopdelay&lt;br /&gt;
	decfsz	buttonloopdelay,f	;decrement a 255 count delay&lt;br /&gt;
	goto	Buttonloop&lt;br /&gt;
	decfsz	ticker,f&lt;br /&gt;
	goto 	Buttonloop&lt;br /&gt;
	movlw	&amp;#039;M&amp;#039;			;Tx the MAILS HERE code&lt;br /&gt;
	BANKSEL	txbyte&lt;br /&gt;
	movwf	txbyte&lt;br /&gt;
	call	Uart_out&lt;br /&gt;
	goto	Main&lt;br /&gt;
Pickup&lt;br /&gt;
	movlw	&amp;#039;R&amp;#039;	;Tx the MAILS RETRIEVED code&lt;br /&gt;
	movwf	txbyte&lt;br /&gt;
	call	Uart_out&lt;br /&gt;
;20s delay to let the user gtfo without rerunning the thing&lt;br /&gt;
			;40000000 cycles&lt;br /&gt;
	movlw	0x6D&lt;br /&gt;
	movwf	d1&lt;br /&gt;
	movlw	0x32&lt;br /&gt;
	movwf	d2&lt;br /&gt;
	movlw	0x58&lt;br /&gt;
	movwf	d3&lt;br /&gt;
Delay_0&lt;br /&gt;
	decfsz	d1, f&lt;br /&gt;
	goto	$+2&lt;br /&gt;
	decfsz	d2, f&lt;br /&gt;
	goto	$+2&lt;br /&gt;
	decfsz	d3, f&lt;br /&gt;
	goto	Delay_0&lt;br /&gt;
&lt;br /&gt;
	goto	Main&lt;br /&gt;
Uart_out&lt;br /&gt;
	BANKSEL	PORTB&lt;br /&gt;
	bcf		PORTB,1		; wake the xbee up&lt;br /&gt;
CTS&lt;br /&gt;
	btfsc	PORTB,6		; make sure shes up and ready&lt;br /&gt;
	goto	CTS			; If she isent, loop till she is. &lt;br /&gt;
	BANKSEL	PIR1&lt;br /&gt;
WaitTX&lt;br /&gt;
	btfss	PIR1,TXIF	;test to see if the Tx buffer is full&lt;br /&gt;
	goto	WaitTX&lt;br /&gt;
	BANKSEL	txbyte&lt;br /&gt;
	movf	txbyte		;moves the byte to be transmitted to the W reg&lt;br /&gt;
	BANKSEL	TXREG&lt;br /&gt;
	movwf	TXREG		;Tx the sucker&lt;br /&gt;
WaitTX_2&lt;br /&gt;
	call 	Buttonloopdelay		; delay before doing it again&lt;br /&gt;
	btfss	PIR1,TXIF&lt;br /&gt;
	goto	WaitTX_2&lt;br /&gt;
	BANKSEL	txbyte&lt;br /&gt;
	movf	txbyte&lt;br /&gt;
	BANKSEL	TXREG&lt;br /&gt;
	movwf	TXREG&lt;br /&gt;
	return&lt;br /&gt;
RxInt&lt;br /&gt;
	movf	RCREG,w&lt;br /&gt;
	movwf	rxbyte		;put the recived byte in the rxbyte register&lt;br /&gt;
	goto	Main&lt;br /&gt;
Clr_Int					;Clr the intruppt flags&lt;br /&gt;
	clrf	PIR1&lt;br /&gt;
	clrf	PIR2&lt;br /&gt;
	return&lt;br /&gt;
Delay_20s&lt;br /&gt;
			;39999993 cycles&lt;br /&gt;
	movlw	0x6C&lt;br /&gt;
	movwf	d1&lt;br /&gt;
	movlw	0x32&lt;br /&gt;
	movwf	d2&lt;br /&gt;
	movlw	0x58&lt;br /&gt;
	movwf	d3&lt;br /&gt;
Delay_20s_0&lt;br /&gt;
	decfsz	d1, f&lt;br /&gt;
	goto	$+2&lt;br /&gt;
	decfsz	d2, f&lt;br /&gt;
	goto	$+2&lt;br /&gt;
	decfsz	d3, f&lt;br /&gt;
	goto	Delay_20s_0&lt;br /&gt;
&lt;br /&gt;
			;3 cycles&lt;br /&gt;
	goto	$+1&lt;br /&gt;
	nop&lt;br /&gt;
&lt;br /&gt;
			;4 cycles (including call)&lt;br /&gt;
	return&lt;br /&gt;
Buttonloopdelay					; 20ms delay with 8Mhz clock&lt;br /&gt;
			;39993 cycles&lt;br /&gt;
	movlw	0x3E&lt;br /&gt;
	movwf	d1&lt;br /&gt;
	movlw	0x20&lt;br /&gt;
	movwf	d2&lt;br /&gt;
Buttonloop_0&lt;br /&gt;
	decfsz	d1, f&lt;br /&gt;
	goto	$+2&lt;br /&gt;
	decfsz	d2, f&lt;br /&gt;
	goto	Buttonloop_0&lt;br /&gt;
&lt;br /&gt;
			;3 cycles&lt;br /&gt;
	goto	$+1&lt;br /&gt;
	nop&lt;br /&gt;
&lt;br /&gt;
			;4 cycles (including call)&lt;br /&gt;
	return&lt;br /&gt;
; initialize eeprom locations&lt;br /&gt;
&lt;br /&gt;
	ORG	0x2100&lt;br /&gt;
	DE	0x00, 0x01, 0x02, 0x03&lt;br /&gt;
	END                   &lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Base station ===&lt;br /&gt;
I&amp;#039;m currently rewriting my code for the base station as I port it over to a 18F2550. Will post it when I&amp;#039;m satisfied with it.&lt;br /&gt;
&lt;br /&gt;
== PCB layout ==&lt;br /&gt;
PCB layout of the mailbox device:&lt;br /&gt;
[[Image:MailsHere mailbox board.jpg|none|thumb|Mail box device]]&lt;br /&gt;
&lt;br /&gt;
PCB layout of the base station:&lt;br /&gt;
I have made some changes to the PCB and am waiting for my prototype to arrive to test it before posting it. &lt;br /&gt;
&lt;br /&gt;
== Pictures ==&lt;br /&gt;
&amp;lt;gallery&amp;gt;&lt;br /&gt;
Image:MailsHere2.jpg|The mailbox system tucked away in its weather proof case. &lt;br /&gt;
Image:MailsHere3.jpg|Overview of the mailbox board with its case.&lt;br /&gt;
Image:MailsHere4.jpg|Closeup of the mailbox board with its case. &lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;/div&gt;</summary>
		<author><name>Paul</name></author>
	</entry>
</feed>