Sei sulla pagina 1di 4

Software: The program (listed at bottom of page) is written in PIC assembly language which can be edited and compiled

using Microchip's development software (MPLAB) available from www.microchip.com. The development software will generate a compiled HEX file to be loaded into the processor. Also needed is a hardware programmer to download the HEX file into the PIC processor. I used a homemade programmer and DOS software by David Tait available from http://www.nomad.ee/PIC/. Filename (PIC84V05.ZIP). The only program changes needed are the entries for the phone number and the total digits to use. The assembly code phone number table looks like this which represents a dummy number of 656-7459. Note the digits are in reverse order (top to bottom). Phone ; Phone Number Table, in reverse order addwf nop retlw retlw retlw retlw retlw retlw retlw PC,1 ; No operation d'9' ; Last digit d'5' d'4' d'7' d'6' d'5' d'6' ; First digit

The total digits used (7 in this case) are stated in the Dial section. To use a 3 digit area code, a 7 digit number, and a "1" to begin, the entry would change to ( movlw d'11' ). Dial ;------- Change this value to indicate total digits ----movlw movwf d'7' COUNTER ; Use 7 digit phone number

The call duration is assigned on the line (movlw d'100 ; 30 second tone timer) just above the "Timeout" section. Increase the "100" value for longer durations (i.e. 200 = 2 minutes). Parts List: PIC 16F628 microcontroller 5 Volt Reed relay Modem transformer 5 Volt wall transformer 470 Ohm Resistor (1) 680 Ohm Resistor (1) 330 Ohm Resistor (2) 10K Resistors (2) Small Signal Diode (1) Red LED (1) 2N2222A transistor (1) Allied Allied Mouser Jameco Allied Allied Allied Allied Allied Allied Allied 383-0398 681-0156 838-TTC-5023 320303PS 296-4682 895-3150 895-3145 895-0633 431-0618 670-1224 248-1005

;********************* AutoCall.asm 12/25/07 ********************** ;******************************************************************** LIST P=16F628 ; Device number (PIC16F628)

ERRORLEVEL -224 ; suppress annoying message because of tris ERRORLEVEL -302 ; suppress message because of page change

;--------------------- Configuration --------------------------------_BODEN_OFF _CP_OFF _PWRTE_ON _WDT_OFF _LVP_OFF _INTRC_OSC_NOCLKOUT _MCLRE_OFF equ equ equ equ equ equ equ H'3FBF' H'3FFF' H'3FF7' H'3FFB' H'3F7F' H'3FFC' H'3FDF' ; ; ; ; ; ; ; Brown out detection off Code protection off Power-on reset enabled Watch dog timer off Low Voltage programming off Use Internal RC Oscillator Use RA5 as functional input

__CONFIG _CP_OFF & _WDT_OFF & _INTRC_OSC_NOCLKOUT & _PWRTE_ON & _LVP_OFF & _BO DEN_OFF & _MCLRE_OFF ;--------------------- Define Variables ----------------------------INDF FSR CMCON INTCON OPTION_REG STATUS TRISA TRISB PORTB PORTA PC COUNTER COUNTER1 COUNTER2 COUNTER3 COUNTER4 TEMP bsf bcf movlw movwf movlw movwf bcf bcf bcf bcf movlw movwf clrf goto equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ equ STATUS,5 STATUS,6 b'00000010' TRISB b'00100000' TRISA STATUS,5 STATUS,0 STATUS,2 STATUS,1 07h CMCON PORTB Loop 00h 04h 1Fh 0Bh 81h 03h 85h 86h 06h 05h 02h 20h 21h 22h 23h 24h 25h ; ; ; ; ; ; ; ; ; ; ; ; Indirect file File select register Comparator Control Address Interrupt control register Option register Status register I/O control for port A I/O control for port B Address of port B Address of port A Program counter General purpose Counters

; Temporary register

; Select memory bank 1 (01) ; Select memory bank 1 (01) ; ; ; ; ; ; ; Set port B as output, RB1 = Input Set port A as output, RA5 = Input Reset to bank 0 Clear carry bit Clear zero flag

; Comparators off ; Main loop

Phone ; Phone Number Table, in reverse order (656-7459) addwf nop retlw retlw retlw retlw retlw retlw PC,1 ; No operation d'9' ; Last digit d'5' d'4' d'7' d'6' d'5'

retlw

d'6' ; First digit

Loop ;------------------- Main Loop ----------------movfw btfsc goto bsf movlw movwf Off_Hook_Delay call decfsz goto PORTB PORTB,1 ; Read pin 7, skip if clear Loop PORTB,2 ; Close relay d'3' ; 3 sec Delay COUNTER4 ; 3 sec delay Digit_Delay COUNTER4,f Off_Hook_Delay

Dial ;------- Change this value to indicate total digits ----movlw movwf Next movfw call call call decfsz goto call movlw movwf movwf movwf Timeout movfw movwf Tone bsf call bcf call decfsz goto decfsz goto bcf PORTB,3 Tone_Delay PORTB,3 Tone_Delay COUNTER1,f Tone COUNTER2,f Timeout PORTB,2 ; ; ; ; Set pin 9 high Wait 1.5mS Set pin 9 low Wait 1.5mS COUNTER COUNTER1 COUNTER Phone Output Digit_Delay COUNTER,f Next Digit_Delay d'100' COUNTER COUNTER1 COUNTER2 ; Get Digit from table ; Dial the digit ; Wait 1 second ; Do next (1 of 7 digits) ; Wait 1 second ; 30 second tone timer d'7' COUNTER ; Use 7 digit phone number

; Generate tone for 30 seconds

; Repeat until COUNTER2=0 ; End call, On Hook, Done

Switch_Open ;------------------ Wait for switch open movfw btfss goto call goto PORTB PORTB,1 Switch_Open Digit_Delay Loop ; ; ; ; Look at pin 7 Loop until pin 7 is high Wait 1 second Restart

;------------------ End sequence, restart from top ------

Tone_Delay movlw movwf Loop_4 nop nop nop decfsz goto return d'255' TEMP

; 300 Hz Tone

TEMP,f Loop_4

;------------------------------------------------------------Output movwf Next_Pulse bcf call bsf call decfsz goto return Pulse_Delay movlw movwf Loop_1 movwf Loop_2 decfsz goto decfsz goto return Digit_Delay movlw movwf Loop_3 call decfsz goto return end Pulse_Delay COUNTER3,f Loop_3 d'16' COUNTER3 ; 1 sec Delay COUNTER2,f Loop_2 TEMP,f Loop_1 COUNTER2 d'150' TEMP ; 60 mS Delay PORTB,2 ; Set Pin 8 low Pulse_Delay PORTB,2 ; Set pin 8 high Pulse_Delay COUNTER1,f Next_Pulse ; Repeat until COUNTER1=0 COUNTER1 ; Open relay for each pulse ; Number of pulses

Potrebbero piacerti anche