;# ;# handbox.asm - LX200 compatible telescope control software for the PIC16F84A uC ;# Copyright (C) 2005 Hanno Rein (http://hanno-rein.de) ;# ;# This program is free software; you can redistribute it and/or ;# modify it under the terms of the GNU General Public License ;# as published by the Free Software Foundation; either version 2 ;# of the License, or (at your option) any later version. ;# ;# This program is distributed in the hope that it will be useful, ;# but WITHOUT ANY WARRANTY; without even the implied warranty of ;# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;# GNU General Public License for more details. ;# ;# You should have received a copy of the GNU General Public License ;# along with this program; if not, write to the Free Software ;# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;# ;# list p=16f84 #include __CONFIG _PWRTE_ON & _WDT_OFF & _XT_OSC ;************************************************************** Temp Equ 0x20 cycl_1 Equ 0x21 ; Zähler cycl_2 Equ 0x22 ; Zähler Byte equ 0x23 LastKey equ 0x24 NowKey equ 0x25 Ini_con Equ B'00000000' ; Interupt disable Ini_opt Equ B'00000010' ; pull-up einschalten out EQU 2 ; RS-232 out ist RA2 ;************************************************************** Init bsf STATUS, RP0 ; unschalten auf Bank 1 movlw Ini_opt ; pull-up Widerstände ein movwf OPTION_REG movlw B'00111011' ; RA2 output movwf TRISA ; movlw B'00011111' ; RB's outputs movwf TRISB ; bcf STATUS, RP0 ; zurückschalten zur Bank 0 clrf PORTA ; movlw Ini_con ; Interupt einstellen (disable) movwf INTCON Loop clrf NowKey bcf PORTB,5 bsf PORTB,6 bsf PORTB,7 nop nop call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; btfsc PORTB,0 bsf NowKey,0 ;Foc- ; btfsc PORTB,1 ; bsf NowKey,1 btfsc PORTB,2 ;Ms bsf NowKey,1 bsf PORTB,5 bcf PORTB,6 bsf PORTB,7 nop nop call Warte_s call Warte_s call Warte_s call Warte_s call Warte_s call Warte_s btfsc PORTB,0 bsf NowKey,2 ;Speed btfsc PORTB,1 bsf NowKey,4 ;Stop btfsc PORTB,2 bsf NowKey,3 ;Mw bsf PORTB,5 bsf PORTB,6 bcf PORTB,7 nop nop call Warte_s call Warte_s call Warte_s call Warte_s call Warte_s call Warte_s btfsc PORTB,0 bsf NowKey,5 ;Foc+ btfsc PORTB,1 bsf NowKey,7 ;Mn btfsc PORTB,2 bsf NowKey,6 ;Me movfw NowKey XORWF LastKey,1 btfss LastKey,0 goto weiter0 call rson movlw ':' call Send_RS movlw 'F' call Send_RS movlw 'Q' btfss NowKey,0 movlw '-' call Send_RS movlw '#' call Send_RS call rsoff weiter0: btfss LastKey,1 goto weiter1 call rson movlw ':' call Send_RS movlw 'Q' btfss NowKey,1 movlw 'M' call Send_RS movlw 's' call Send_RS movlw '#' call Send_RS call rsoff weiter1: btfss LastKey,2 goto weiter2 btfsc NowKey,2 goto weiter2 call rson movlw ':' call Send_RS movlw 'R' call Send_RS movlw 'H' call Send_RS movlw '#' call Send_RS call rsoff weiter2: btfss LastKey,3 goto weiter3 call rson movlw ':' call Send_RS movlw 'Q' btfss NowKey,3 movlw 'M' call Send_RS movlw 'w' call Send_RS movlw '#' call Send_RS call rsoff weiter3: btfss LastKey,4 goto weiter4 btfsc NowKey,4 goto weiter4 call rson movlw ':' call Send_RS movlw 'Q' call Send_RS movlw '#' call Send_RS call rsoff weiter4: btfss LastKey,5 goto weiter5 call rson movlw ':' call Send_RS movlw 'F' call Send_RS movlw 'Q' btfss NowKey,5 movlw '+' call Send_RS movlw '#' call Send_RS call rsoff weiter5: btfss LastKey,6 goto weiter6 call rson movlw ':' call Send_RS movlw 'Q' btfss NowKey,6 movlw 'M' call Send_RS movlw 'e' call Send_RS movlw '#' call Send_RS call rsoff weiter6: btfss LastKey,7 goto weiter7 call rson movlw ':' call Send_RS movlw 'Q' btfss NowKey,7 movlw 'M' call Send_RS movlw 'n' call Send_RS movlw '#' call Send_RS call rsoff weiter7: movfw NowKey movwf LastKey goto Loop ;******************************************************* ; Schaltet Pin RA2 ein/aus rson bsf STATUS, RP0 ; movlw B'00111011' ; movwf TRISA ; bcf STATUS, RP0 ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; return rsoff call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; call Warte_s ; bsf STATUS, RP0 ; movlw B'00111111' ; movwf TRISA ; bcf STATUS, RP0 ; return ;************************************************************* ; RS232 Ausgabe nach SPRUT Send_RS ; Ausgabe eines Bytes seriell movwf Byte ; Byte in w movlw 8 ; es werden 8 Bit gesendet movwf cycl_1 bsf PORTA, out call Warte_s ; 1 Stopbit (1) bcf PORTA, out call Warte_s ; 1 Startbit (0) Send_1 rrf Byte, f ; aktuelles Bit in das Carry-Flag schieben btfsc STATUS, C bsf PORTA, out ; Lo wenn Bit = 1 btfss STATUS, C bcf PORTA, out ; Hi wenn Bit = 0 call Warte_s ; 1 Bit lang warten decfsz cycl_1, f ; waren das schon 8 Bit? goto Send_1 ; nein, es geht weiter bsf PORTA, out ; Byte zuende, 1 Stoppbit (1) senden call Warte_s ; return ;********************************************************** Warte_s movlw D'15' movwf cycl_2 Warte1 nop nop nop decfsz cycl_2, 1 goto Warte1 return end