; PicBasic Pro Compiler 2.46, (c) 1998, 2005 microEngineering Labs, Inc. All Rights Reserved. _USED EQU 1 INCLUDE "C:\PBP\18F452.INC" ; Define statements. #define OSC 4 RAM_START EQU 00000h RAM_END EQU 005FFh RAM_BANKS EQU 00006h BANK0_START EQU 00080h BANK0_END EQU 000FFh BANK1_START EQU 00100h BANK1_END EQU 001FFh BANK2_START EQU 00200h BANK2_END EQU 002FFh BANK3_START EQU 00300h BANK3_END EQU 003FFh BANK4_START EQU 00400h BANK4_END EQU 004FFh BANK5_START EQU 00500h BANK5_END EQU 005FFh BANKA_START EQU 00000h BANKA_END EQU 0007Fh R0 EQU RAM_START + 000h R1 EQU RAM_START + 002h R2 EQU RAM_START + 004h R3 EQU RAM_START + 006h R4 EQU RAM_START + 008h R5 EQU RAM_START + 00Ah R6 EQU RAM_START + 00Ch R7 EQU RAM_START + 00Eh R8 EQU RAM_START + 010h FLAGS EQU RAM_START + 012h GOP EQU RAM_START + 013h RM1 EQU RAM_START + 014h RM2 EQU RAM_START + 015h RR1 EQU RAM_START + 016h RR2 EQU RAM_START + 017h RS1 EQU RAM_START + 018h RS2 EQU RAM_START + 019h PB01 EQU RAM_START + 01Ah _angleVar EQU RAM_START + 01Bh _counterVar EQU RAM_START + 01Dh _timingVar EQU RAM_START + 01Fh _PORTL EQU PORTB _PORTH EQU PORTC _TRISL EQU TRISB _TRISH EQU TRISC #define _gateState PB01, 001h #define _closeGate PB01, 000h #define _PORTC_3 PORTC, 003h #define _PORTD_2 PORTD, 002h #define _PORTD_3 PORTD, 003h #define _PORTD_6 PORTD, 006h #define _PORTB_7 PORTB, 007h ; Constants. _minAngle EQU 0006Eh _maxAngle EQU 000C8h _refreshPeriod EQU 0000Ah INCLUDE "SERVO_~4.MAC" INCLUDE "C:\PBP\PBPPIC18.LIB" OUTPUT?T _PORTC_3 OUTPUT?T _PORTD_2 OUTPUT?T _PORTD_3 OUTPUT?T _PORTD_6 INPUT?T _PORTB_7 LOW?T _PORTC_3 MOVE?CT 000h, _gateState MOVE?CW 001h, _counterVar MOVE?CW 000h, _timingVar LABEL?L _main SUB?WCW _counterVar, 001h, _counterVar CMPNE?WCL _counterVar, 000h, L00001 MOVE?CW 014h, _counterVar CMPNE?TCL _PORTB_7, 001h, L00003 MOVE?CT 001h, _gateState LABEL?L L00003 LABEL?L L00001 CMPNE?TCL _gateState, 001h, L00005 CMPGE?WCL _timingVar, 0C8h, L00007 ADD?WCW _timingVar, 001h, _timingVar PULSOUT?TC _PORTC_3, _maxAngle HIGH?T _PORTD_2 LOW?T _PORTD_3 FREQOUTPIN?T _PORTD_6 FREQOUTTIME?C 00Ah FREQOUT?C 02328h GOTO?L L00008 LABEL?L L00007 MOVE?CW 000h, _timingVar MOVE?CT 000h, _gateState LABEL?L L00008 GOTO?L L00006 LABEL?L L00005 PULSOUT?TC _PORTC_3, _minAngle LOW?T _PORTD_2 HIGH?T _PORTD_3 PAUSE?C _refreshPeriod LABEL?L L00006 GOTO?L _main END