Hello, this is my first post to the list. I have a question about editing a ASM file using Microchip's MPLAB IDE 7.3. I have been working with an ASM file using the PIC 16F84A microchip. The code is written to sense RPM's of a micro turbine engine, and test servo units. I did not write the original file. Currently I can only display from 0 - 99,999 RPM's. I have been told that the chip can count the piulses for an infinite number. I want to change the program to display more than 100K. The LCD module I'm using is an 8 X 2 using a HD44780U controller. The first line displays the 5 digits and the 3 letters "RPM" The second line displays a selectable number of blades from 2 - 5 with the letters "bs" after the numbers. I'm just learning about editing code, programming chip's and converting ASM to HEX files, but at this point I'm stuck and can't seem to get any further. Can anyone off some assistance in editing this ASM file? I've included the ASM with this post for reference and examination. Thanks for your help in advance. Patrick LIST P=16F84A,R=HEX ; ; LCD TACHOMETER FOR R/C MODEL TURBINE ENGINE ; DESMOND, P ; ; VERSION 3.25: 05/11/2006 UPDATE FOR KJ66 ; VERSION 3.24: 1/19/2005 FIX BUG, REC_T CRASH AT 1500uS ; VERSION 3.22: 09/27/2004 MENU, 8*2 LCD,(B) BLADES SECECT ; VERSION 3.2: 09/08/2004 RA,4 CONTROLL +5V OUTPUT ; VERSION 3.1: 09/04/2004 LEAVES SELECT ; VERSION 3.0: 08/30/2004 ADD REC_T V1 FOR RECEIVER TESTING ; VERSION 2.0: 08/26/2004 ADD MID & RANDOM MODES ; VERSION 1.0: 08/25/2004 ; ;-------SYSTEM--------------------- __CONFIG H'3FF1' ;-------DEFINE RAM------------ TMR0 EQU 1 ;TIMER 0 PC EQU 2 ;PROGRAM COUNTER STATUS EQU 3 FSR EQU 4 ;BUFFER OF INDIRECT ADDR RA EQU 5 RB EQU 6 EEDATA EQU 8 ;EEPROM DATA EEADR EQU 9 ;EEPROM ADDR PCLATH EQU H'A' INTCON EQU H'B' ;INTERRUPT CONTROL OPTIONF EQU 1 ;0X81 TRISA EQU 5 ;0X85 TRISB EQU 6 ;0X86 EECON1 EQU 8 ;0X88 IS EEPROM CONTROL1 EECON2 EQU 9 ;0X89 IS EEPROM CONTROL2 ;-------DEFINE BIT------------- ; C EQU 0 W EQU 0 ;d VALUE FOR INCF...... F EQU 1 ;d VALUE OFF EQU 0 ;FLAG BIT 0, RP0 EQU 5 ;STATUS BIT 5 & 6 =REGISTER BANK SELECT RP1 EQU 6 INPUT EQU 7 ;RB7 AS INPUT PORT TOIF EQU 2 ;INTCON TMR0 OVERLOW INT FLAG TOIE EQU 5 ;INTCON TOIF ENABLE GIE EQU 7 ;INTCON GLOBAL INT ENABLE ;-------USER------------------------------------- ;-------REGISTERS------ ; TCNT0 EQU H'C' ;= (0.6SEC /INT* PRESCAL*CLOCK) INTR0 EQU H'D' ;AFTER INT, SAVE W VALUE INTR1 EQU H'E' ;AFTER INT, SAVE STATUS DD1 EQU H'F' ;DATA FOR INPUT RPM DD2 EQU H'10' DD3 EQU H'11' TEMP1 EQU H'12' ; TEMP2 EQU H'13' TEMP3 EQU H'14' SLOW_C EQU H'15' ;100-200 +- 1 EVERY INT_DST INT_C EQU H'16' ;0-255 -1 EVERY INT_DST FLAG_REG EQU H'17' MODE_SEL EQU H'18' PWM_C EQU H'19' PUSH_C EQU H'1A' RAND_HI EQU H'1B' RAND_LO EQU H'1C' TCNT EQU H'1D' ;-------BIT---------------- F_ON EQU 0 F_UP EQU 1 F_TDST EQU 2 F_REC EQU 3 TACHO_SEL EQU 4 ; ;-------VARIABLES----------- ; TMR EQU D'181' ;(PRESCALE 64*1uS) * 75 = 4800 uS TCNT_2 EQU D'125' ;4.8mS*125=600mS,BUT FIX SOME ODD CODE TCNT_3 EQU D'84' ;THIS TWO * PRESCALE 1:64,TO A 0.6 SECOND DURATION TCNT_4 EQU D'62' TCNT_5 EQU D'50' BDELAY EQU D'40' TMR1 EQU D'178' ;(PRESCALE 256*78) = 19968 uS RLIMIT EQU D'200' ;SERVO LIMIT LLIMIT EQU D'100' ;-------LCD SOUTINE------------------------- ;-------REGISTERS--------- ; ADDRESS1 EQU H'41' CHAR1 EQU H'42' TEMP1_LCD EQU H'43' TEMP2_LCD EQU H'44' TEMP3_LCD EQU H'45' TEMP4_LCD EQU H'46' TABLE_INDEX EQU H'47' ; ; ;========== MAIN PROGRAM ========= ; ORG 0 GOTO START ;---------------------------------------- ; ORG 4 ;INTERRUPT BEGIN INTB MOVWF INTR0 ; SAVE W MOVF STATUS,W ; SAVE STATUS MOVWF INTR1 BCF STATUS,RP0 ; MAKE SURE SELECT BANK0 CHECK_TDST BTFSC FLAG_REG,F_TDST ;IF SET GOTO DST MODE GOTO INT_DST ;---------------------------------- ;----- TACHOMETER INTERRUPT ----------- INT_TACHO MOVLW TMR ; RESTORE TIMER0 MOVWF TMR0 ; DECFSZ TCNT0,F ;SKIP IF ZERO GOTO INTEND RELOAD MOVF TCNT,W ;RELOAD TCNT0 MOVWF TCNT0 ;--------------------------------------------------- DISP_RPM MOVLW H'0' CALL DDRAM_ADDRESS MOVLW B'00110000' IORWF DD1,1 IORWF DD2,1 IORWF DD3,1 MOVFW DD1 CALL PRINT_CHAR MOVFW DD2 CALL PRINT_CHAR MOVFW DD3 CALL PRINT_CHAR MOVLW '0' CALL PRINT_CHAR MOVLW '0' CALL PRINT_CHAR MOVLW 'R' CALL PRINT_CHAR MOVLW 'P' CALL PRINT_CHAR MOVLW 'M' CALL PRINT_CHAR RESET_COUNT CLRF DD1 ;DISPLAY DATA CLRF DD2 CLRF DD3 ;------ LEAF MODE SELECT -------- BTFSS RA,1 ;SELECT ? BSF FLAG_REG,TACHO_SEL MOVLW TMR ; RESTORE TIMER0 MOVWF TMR0 ; GOTO INTEND ;------ END OF TACHO INT --------- ;--------------------------------- INT_DST MOVLW TMR1 ;256*78=19968 uS MOVWF TMR0 MOVF PWM_C,W MOVWF TEMP1 ;------------------------------------- BIN2BCD MOVWF DD3 ;1 CLRF DD2 ;10 CLRF DD1 ;100 H1 MOVLW 0X64 ; 100 SUBWF DD3,F ; SUBTRACT 100 FROM NUMBER BTFSC STATUS,C ; NEGATIVE RESULT? GOTO H2 ; NO? GOTO H2 GOTO H3 ; YES? GOTO H3 (100'S DDD3) H2 INCF DD1,F ; INCREMENT DD1 REGISTER GOTO H1 ; & LOOP BACK FOR ANOTHER TEST H3 MOVLW 0X64 ; 100 ADDWF DD3,F ; ADD 100 BACK TO NUMBER T1 MOVLW 0X0A ; 10 SUBWF DD3,F ; SUBTRACT 10 FROM NUMBER BTFSC STATUS,C ; NEGATIVE RESULT? GOTO T2 ; NO? GOTO T2 GOTO T3 ; YES? GOTO T3 (10'S DDD3) T2 INCF DD2,F ; INCREMENT DD2 REGISTER GOTO T1 ; & LOOP BACK FOR ANOTHER TEST T3 MOVLW 0X0A ; 10 ADDWF DD3,F ; ADD 10 BACK TO NUMBER ;-------------------------------------------------- MOVLW H'40' CALL DDRAM_ADDRESS MOVLW B'00110000' IORWF DD1,1 IORWF DD2,1 IORWF DD3,1 MOVLW ' ' CALL PRINT_CHAR MOVFW DD1 CALL PRINT_CHAR MOVFW DD2 CALL PRINT_CHAR MOVFW DD3 CALL PRINT_CHAR MOVLW '0' CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR MOVLW 'u' CALL PRINT_CHAR MOVLW 'S' CALL PRINT_CHAR BTFSC FLAG_REG,F_REC GOTO INTEND BSF RA,3 INT_DST1 ;10 uS LOOP NOP NOP NOP NOP NOP NOP NOP DECFSZ TEMP1,F GOTO INT_DST1 ;END OF LOOP BCF RA,3 DECF INT_C,F ;INCREASE INT_COUNTER ;------------------------------------- INTEND MOVF INTR1,W ; RESTORE STATUS MOVWF STATUS MOVF INTR0,W ; RESTORE W BCF INTCON,TOIF ; RESET FLAG OF INT T0 RETFIE ; ; ;------------------------------------------------- ;============================================ ;LCD SOUTINE ;============================================================== PRINT_DATA BSF RB,2 ;RS=1, DATA MOVWF ADDRESS1 BSF ADDRESS1,2 MOVF ADDRESS1,0 MOVWF RB BSF RB,3 NOP BCF RB,3 CALL LOOP_S ;100 uS RETURN PRINT_CONT MOVWF RB BSF RB,3 BCF RB,3 CALL LOOP_S ;100 uS RETURN CLEAR_DISPLAY MOVLW B'00000000' ;0 CALL PRINT_CONT MOVLW B'00010000' ;1 CLEAR CALL PRINT_CONT MOVLW 1 CALL LOOP_L ;10mS RETURN DDRAM_ADDRESS MOVWF ADDRESS1 BSF ADDRESS1,7 MOVF ADDRESS1,0 ANDLW B'11110000' ; CALL PRINT_CONT SWAPF ADDRESS1,W ;SWAP HALVES F ANDLW B'11110000' ; CALL PRINT_CONT RETURN PRINT_CHAR MOVWF CHAR1 ANDLW B'11110000' ; CALL PRINT_DATA SWAPF CHAR1,W ;SWAP HALVES F ANDLW B'11110000' ;SENT LOW 4 BITS CALL PRINT_DATA RETURN LOOP_S ;100uS LOOP MOVLW D'33' MOVWF TEMP4_LCD LOOP_S1 DECFSZ TEMP4_LCD,1 ; GOTO LOOP_S1 RETURN LOOP_L ;10 mS LOOP MOVWF TEMP1_LCD LOOP_L1 MOVLW D'10' ;10 mS MOVWF TEMP2_LCD LOOP_L2 MOVLW D'249' ;(249*4)+5=1001 MOVWF TEMP3_LCD LOOP_L3 NOP DECFSZ TEMP3_LCD,1 GOTO LOOP_L3 DECFSZ TEMP2_LCD,1 GOTO LOOP_L2 DECFSZ TEMP1_LCD,1 GOTO LOOP_L1 RETURN DISP_MESSAGE MOVWF TABLE_INDEX ;W -> INDEX, THE BEGIN OF MESSAGE CALL MESSAGE1 ANDLW 0FFH SKPNZ ; IF TABLE RETURN 0 , END OF MESSAGE SECTION RETURN CALL PRINT_CHAR ; DOSPLAY INCF TABLE_INDEX,0 GOTO DISP_MESSAGE ;==================================================== MODE_ADDRESS ADDWF PC,F RETLW 0 RETLW 0 RETLW D'9' RETLW D'18' RETLW D'27' MESSAGE1 ADDWF PC,F RETLW 'T' RETLW 'a' RETLW 'c' RETLW 'h' RETLW 'o' RETLW ' ' RETLW ' ' RETLW ' ' RETLW 0 RETLW 'S' ;9 RETLW 'e' RETLW 'r' RETLW 'v' RETLW 'o' RETLW ' ' RETLW 'T' RETLW 'x' RETLW 0 RETLW 'S' ;18 RETLW 'p' RETLW 'e' RETLW 'e' RETLW 'd' RETLW ' ' RETLW 'T' RETLW 'x' RETLW 0 RETLW 'R' ;27 RETLW 'e' RETLW 'c' RETLW 'e' RETLW 'i' RETLW 'v' RETLW 'e' RETLW 'r' RETLW 0 NOP ;36 ;======================================= ;---------- PROGRAM BEGIN ----------- ;---------------------------------------- ; START BSF STATUS,RP0 ;SET 3,5 ENABLE BANK1 MOVLW B'00000001' MOVWF TRISB ;SET RB 1-7 OUTPUT, 0 INPUT MOVLW B'00000111' MOVWF TRISA ;SET RA0-RA2 INTPUT, RA3,RA4 OUTPUT BCF STATUS,RP0 ;ENABLE BANK0 BCF RA,3 ;OUT PWM BSF RA,4 ;OUT +5V OFF CLRF RB BCF INTCON,GIE CLRF FLAG_REG MOVLW D'150' MOVWF PWM_C INIT_LCD MOVLW 5 ;POWER ON DELAY 50mS CALL LOOP_L SET_4BIT_MOD ;SET LCD AT 4 BIT MODEL MOVLW B'00110000' ;3 CALL PRINT_CONT MOVLW 1 CALL LOOP_L ;10mS MOVLW B'00110000' ;3 CALL PRINT_CONT MOVLW B'00110000' ;3 CALL PRINT_CONT MOVLW B'00100000' ;2, 4BIT MODE CALL PRINT_CONT MOVLW B'00100000' ;2 CALL PRINT_CONT MOVLW B'10000000' ;8 4BITS, 2 LINES, FONT 0 CALL PRINT_CONT INIT_DISPLAY MOVLW B'00000000' ;O CALL PRINT_CONT MOVLW B'11000000' ;C SCREEN ON, NO CURSOR, NO BLINKING CALL PRINT_CONT CALL CLEAR_DISPLAY ;CLEAR DISPLAY MOVLW ' ' CALL PRINT_CHAR MOVLW 'K' CALL PRINT_CHAR MOVLW 'J' ;DISPLAY FIRST SECTION MESSAGE CALL PRINT_CHAR MOVLW '-' CALL PRINT_CHAR MOVLW '6' CALL PRINT_CHAR MOVLW '6' CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR MOVLW H'40' CALL DDRAM_ADDRESS MOVLW 'D' CALL PRINT_CHAR MOVLW 'S' CALL PRINT_CHAR MOVLW 'T' CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR MOVLW 'V' CALL PRINT_CHAR MOVLW '3' CALL PRINT_CHAR MOVLW '.' CALL PRINT_CHAR MOVLW '2' CALL PRINT_CHAR MOVLW D'150' CALL LOOP_L ;DELAY 3.0 SECOND CLRF MODE_SEL INCF MODE_SEL,F ;------------------------------------------ MMODE_00 MOVLW H'40' CALL DDRAM_ADDRESS MOVFW MODE_SEL CALL MODE_ADDRESS ;GET MODE NAME BEGINING CALL DISP_MESSAGE ;DISPLAY MODE NAME MOVLW D'50' CALL LOOP_L ;1.0 SECOND CHANGE MODE BTFSS RA,1 GOTO MMODE_01 ;+ PUSH, NEXT MODE BTFSS RA,0 GOTO MMODE_02 ;SELECT PUSH, GOTO MMODE_00 MMODE_01 INCF MODE_SEL,F MOVLW 5 ;MODE_SEL 1-4 ONLY SUBWF MODE_SEL,W SKPZ GOTO MMODE_00 MOVLW 1 MOVWF MODE_SEL GOTO MMODE_00 MMODE_02 ;-------ON MODE_SEL GOTO---------- MOVLW 1 SUBWF MODE_SEL,W SKPNZ GOTO MAIN ;1 TACHO MOVLW 2 SUBWF MODE_SEL,W SKPNZ GOTO DST_MAIN ;2 DST MOVLW 3 SUBWF MODE_SEL,W SKPNZ GOTO SCT_MAIN ;3 SCT MOVLW 4 SUBWF MODE_SEL,W SKPNZ GOTO RECT_MAIN ;4 RECT ;------------------------------------ ;------------------------------------------- MAIN BSF RA,4 ;OUT +5V OFF CALL CLEAR_DISPLAY ;CLEAR DISPLAY MOVLW 0 CALL DDRAM_ADDRESS MOVLW 1 CALL MODE_ADDRESS ;GET MODE NAME BEGINING CALL DISP_MESSAGE ;DISPLAY MODE NAME BSF STATUS,RP0 ;SET 3,5 ENABLE BANK1 MOVLW B'10000101' MOVWF OPTIONF ;INTERNAT CLOCK,TRM0,1:64 BCF STATUS,RP0 ;ENABLE BANK0 CLRF DD1 ;DISPLAY DATA CLRF DD2 CLRF DD3 MOVLW 1 ;DEFAULT 2 LEAVES MOVWF MODE_SEL GOTO T_SEL MAIN01 MOVLW TMR ;75 MOVWF TMR0 MOVLW TCNT ;DEPEND ON LEAVES MOVWF TCNT0 BCF INTCON,TOIF BSF INTCON,TOIE BSF INTCON,GIE ;ENABLE INT ;---------------------------------- MAIN1 BTFSC FLAG_REG,TACHO_SEL GOTO T_SEL BTFSS RA,2 GOTO START BTFSC RB,0 ;IF INPUT=0, SKIP GOTO MAIN1 MAIN2 BTFSC FLAG_REG,TACHO_SEL GOTO T_SEL BTFSS RA,2 GOTO START BTFSS RB,0 ;IF INPUT=1, SKIP GOTO MAIN2 MAIN3 INCF DD3,F MOVLW H'0A' SUBWF DD3,W SKPZ ;DIGITAL 1 =A, MUST AJUST GOTO MAIN1 CLRF DD3 INCF DD2,F MOVLW H'0A' SUBWF DD2,W SKPZ ;DIGITAL 1 =A, MUST AJUST GOTO MAIN1 CLRF DD2 INCF DD1,F ;DIGITAL 3 WILL NOT >9, SO NO CHECK GOTO MAIN1 ;------------------------------------ ;------ TACHO MODE SELECT ----------- T_SEL BCF FLAG_REG,TACHO_SEL BCF INTCON,GIE INCF MODE_SEL,F MOVLW 6 ;MODE_SEL 2-5 ONLY SUBWF MODE_SEL,W SKPZ GOTO T_SEL1 MOVLW 2 MOVWF MODE_SEL T_SEL1 MOVLW H'40' CALL DDRAM_ADDRESS MOVLW H'30' ;CONVERT HEX TO ASCII ADDWF MODE_SEL,W ;CONVERT HEX TO ASCII CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR MOVLW 'B' CALL PRINT_CHAR MOVLW 's' CALL PRINT_CHAR ;-------ON MODE_SEL GOTO---------- MOVLW 2 SUBWF MODE_SEL,W SKPNZ GOTO TMODE_2 ;2 LEAVES MOVLW 3 SUBWF MODE_SEL,W SKPNZ GOTO TMODE_3 ;3 MOVLW 4 SUBWF MODE_SEL,W SKPNZ GOTO TMODE_4 ;4 ;------------------------------------ TMODE_5 ;5 MOVLW TCNT_5 MOVWF TCNT GOTO T_SEL_5 TMODE_4 MOVLW TCNT_4 MOVWF TCNT GOTO T_SEL_5 TMODE_3 MOVLW TCNT_3 MOVWF TCNT GOTO T_SEL_5 TMODE_2 MOVLW TCNT_2 MOVWF TCNT GOTO T_SEL_5 T_SEL_5 MOVLW D'50' ;0.01 SECOND *50 CALL LOOP_L BTFSS RA,1 GOTO T_SEL ;CHANGE MODE GOTO MAIN01 ;------ END OF TACHOMETER -------------- ;==================================================== DST_MAIN BCF RA,4 ;OUT +5V TURN ON BSF FLAG_REG,F_TDST ;IF SET GOTO DST MODE CALL CLEAR_DISPLAY ;CLEAR DISPLAY MOVLW 0 CALL DDRAM_ADDRESS ;-------SETUP_INTERRUPT------- BSF STATUS,RP0 ;SET 3,5 ENABLE BANK1 MOVLW B'10000111' MOVWF OPTIONF ;INTERNAT CLOCK,TRM0,1:256 BCF STATUS,RP0 ;ENABLE BANK0 MOVLW TMR1 ;256*78=19968 uS MOVWF TMR0 BCF INTCON,TOIF BSF INTCON,TOIE BSF INTCON,GIE ;ENABLE INT CLRF MODE_SEL ;----------------------------------------------- MODE_0 INCF MODE_SEL,F MOVLW 7 ;MODE_SEL 1-5 ONLY SUBWF MODE_SEL,W SKPZ GOTO MODE_01 MOVLW 1 MOVWF MODE_SEL ;-------ON MODE_SEL GOTO---------- MODE_01 MOVLW 1 SUBWF MODE_SEL,W SKPNZ GOTO MODE_1 ;MANUAL MOVLW 2 SUBWF MODE_SEL,W SKPNZ GOTO MODE_3 ;FSAT MOVLW 3 SUBWF MODE_SEL,W SKPNZ GOTO MODE_4 ;MIDDLE MOVLW 4 SUBWF MODE_SEL,W SKPNZ GOTO MODE_2 ;SLOW MOVLW 5 SUBWF MODE_SEL,W SKPNZ GOTO MODE_5 ;RANDOM GOTO MODE_6 ;ESCAPE ;------------------------------------------------- MODE_1 MOVLW H'0' CALL DDRAM_ADDRESS MOVLW 'M' CALL PRINT_CHAR MOVLW 'a' CALL PRINT_CHAR MOVLW 'n' CALL PRINT_CHAR MOVLW 'u' CALL PRINT_CHAR MOVLW 'a' CALL PRINT_CHAR MOVLW 'l' CALL PRINT_CHAR MOVLW BDELAY CALL LOOP_L MODE_10 MOVLW D'150' MOVWF PWM_C MODE_11 BTFSS RA,0 GOTO INC_B BTFSS RA,2 GOTO DEC_B BTFSS RA,1 GOTO CENT_B CLRF PUSH_C GOTO MODE_11 INC_B MOVLW RLIMIT SUBWF PWM_C,W SKPNZ GOTO MODE_11 ;=RLIMIT, DO NOTHING INCF PWM_C,F MOVLW D'5' ;CONTINUE 5 STEP, ACCELERATION SUBWF PUSH_C,W SKPNZ GOTO INC_B1 ; MOVLW D'20' ;0.2 SECOND CALL LOOP_L ;CALL 0.1 SECOND LOOP INCF PUSH_C,F GOTO MODE_11 INC_B1 ;FAST INC MOVLW D'6' CALL LOOP_L ;0.06 SECOND GOTO MODE_11 DEC_B MOVLW LLIMIT SUBWF PWM_C,W SKPNZ GOTO MODE_11 ;=LLIMIT, DO NOTHING DECF PWM_C,F MOVLW D'5' ;CONTINUE 5 STEP, ACCELERATION SUBWF PUSH_C,W SKPNZ GOTO DEC_B1 ; MOVLW D'20' ; CALL LOOP_L ;CALL 0.1 SECOND LOOP INCF PUSH_C,F GOTO MODE_11 DEC_B1 ;FAST DEC MOVLW D'6' CALL LOOP_L ;0.06 SECOND GOTO MODE_11 CENT_B MOVLW BDELAY ;0.01 SECOND * 40 CALL LOOP_L BTFSS RA,1 GOTO MODE_0 ;CHANGE MODE GOTO MODE_10 ;------------------------------------------------ MODE_2 MOVLW H'0' CALL DDRAM_ADDRESS MOVLW 'S' CALL PRINT_CHAR MOVLW 'l' CALL PRINT_CHAR MOVLW 'o' CALL PRINT_CHAR MOVLW 'w' CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR MODE_20 ;SLOW 10 SECOND MOVLW D'150' MOVWF PWM_C BSF FLAG_REG,F_UP MODE_21 BTFSS RA,0 GOTO INC_B2 BTFSS RA,2 GOTO MODE_21 BTFSS RA,1 GOTO CENT_B2 GOTO MODE_21 INC_B2 MOVLW 2 ; 2 TIMES MOVWF PUSH_C MOVLW 5 MOVWF INT_C INC_B21 MOVF INT_C,W ;5*100*20mS = 10 SECOND SKPZ GOTO INC_B21 MOVLW 5 ;5*100*20mS = 10 SECOND MOVWF INT_C BTFSS FLAG_REG,F_UP ;UP / DOWN ? GOTO INC_B23 ;COUNT_DOWN INC_B22 MOVLW RLIMIT ;UP SUBWF PWM_C,W SKPNZ GOTO INC_B24 ;TURN_DOWN INCF PWM_C,F BTFSS RA,2 ;STOP ? GOTO MODE_21 GOTO INC_B21 INC_B24 ;TURN_DOWN BCF FLAG_REG,F_UP INC_B23 MOVLW LLIMIT ; SUBWF PWM_C,W SKPNZ GOTO INC_B25 ;TURN_UP DECF PWM_C,F BTFSS RA,2 ;STOP ? GOTO MODE_21 GOTO INC_B21 INC_B25 BSF FLAG_REG,F_UP DECF PUSH_C,F SKPNZ GOTO MODE_21 GOTO INC_B22 CENT_B2 MOVLW BDELAY ;0.01 SECOND * 40 CALL LOOP_L BTFSS RA,1 GOTO MODE_0 ;CHANGE MODE GOTO MODE_20 ;------------------------ MODE_3 MOVLW H'0' CALL DDRAM_ADDRESS MOVLW 'F' CALL PRINT_CHAR MOVLW 'a' CALL PRINT_CHAR MOVLW 's' CALL PRINT_CHAR MOVLW 't' CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR ;FAST 0.5 SECOND MODE_30 MOVLW D'150' MOVWF PWM_C MODE_31 BTFSS RA,0 GOTO INC_B3 BTFSS RA,2 GOTO MODE_31 BTFSS RA,1 GOTO CENT_B3 GOTO MODE_31 INC_B3 MOVLW 5 MOVWF PUSH_C INC_B31 MOVLW RLIMIT MOVWF PWM_C BTFSS RA,2 GOTO MODE_3 MOVLW D'45' ;0.45SECOD +22 INTERRUPT CALL LOOP_L ;CALL 0.1 SECOND LOOP MOVLW LLIMIT MOVWF PWM_C BTFSS RA,2 GOTO MODE_3 MOVLW D'45' CALL LOOP_L DECFSZ PUSH_C,F GOTO INC_B31 GOTO MODE_3 CENT_B3 MOVLW BDELAY ;0.01 SECOND * 40 CALL LOOP_L BTFSS RA,1 GOTO MODE_0 ;CHANGE MODE GOTO MODE_30 ;------------------------ MODE_4 ;MID 2 SECOND MOVLW H'0' CALL DDRAM_ADDRESS MOVLW 'M' CALL PRINT_CHAR MOVLW 'i' CALL PRINT_CHAR MOVLW 'd' CALL PRINT_CHAR MOVLW 'd' CALL PRINT_CHAR MOVLW 'l' CALL PRINT_CHAR MOVLW 'e' CALL PRINT_CHAR MODE_40 MOVLW D'150' MOVWF PWM_C BSF FLAG_REG,F_UP MODE_41 BTFSS RA,0 GOTO INC_B4 BTFSS RA,2 GOTO MODE_41 BTFSS RA,1 GOTO CENT_B4 GOTO MODE_41 INC_B4 MOVLW 5 ; 5 TIMES MOVWF PUSH_C MOVLW 1 MOVWF INT_C INC_B41 MOVF INT_C,W ;1*100*20mS = 2 SECOND SKPZ GOTO INC_B41 MOVLW 1 ;1*100*20mS = 2 SECOND MOVWF INT_C BTFSS FLAG_REG,F_UP ;UP / DOWN ? GOTO INC_B43 ;COUNT_DOWN INC_B42 MOVLW RLIMIT ;UP SUBWF PWM_C,W SKPNZ GOTO INC_B44 ;TURN_DOWN INCF PWM_C,F BTFSS RA,2 ;STOP ? GOTO MODE_41 GOTO INC_B41 INC_B44 ;TURN_DOWN BCF FLAG_REG,F_UP INC_B43 MOVLW LLIMIT ; SUBWF PWM_C,W SKPNZ GOTO INC_B45 ;TURN_UP DECF PWM_C,F BTFSS RA,2 ;STOP ? GOTO MODE_41 GOTO INC_B41 INC_B45 BSF FLAG_REG,F_UP DECF PUSH_C,F SKPNZ GOTO MODE_41 GOTO INC_B42 CENT_B4 MOVLW BDELAY ;0.01 SECOND * 40 CALL LOOP_L BTFSS RA,1 GOTO MODE_0 ;CHANGE MODE GOTO MODE_40 ;--------------------------------------------------------- MODE_5 ;Random MOVLW H'0' CALL DDRAM_ADDRESS MOVLW 'R' CALL PRINT_CHAR MOVLW 'a' CALL PRINT_CHAR MOVLW 'n' CALL PRINT_CHAR MOVLW 'd' CALL PRINT_CHAR MOVLW 'o' CALL PRINT_CHAR MOVLW 'm' CALL PRINT_CHAR MODE_50 MOVLW D'150' MOVWF PWM_C MODE_51 DECFSZ RAND_LO,F ;RANDOM SEED GENERATOR GOTO MODE_52 DECF RAND_LO,F ;MAKE SURE NO ZERO DECFSZ RAND_HI,F GOTO MODE_52 DECF RAND_HI,F ;MAKE SURE NO ZERO MODE_52 BTFSS RA,0 GOTO INC_B5 BTFSS RA,2 GOTO MODE_51 BTFSS RA,1 GOTO CENT_B5 GOTO MODE_51 INC_B5 MOVLW H'20' ;20-30 RANDOM TEST MOVWF PUSH_C INC_B51 MOVLW D'10' ;10 PULSES PER POSITION MOVWF INT_C ;--------------- RANDOM16 RLF RAND_HI,W XORWF RAND_HI,W RLF TEMP1,F SWAPF RAND_HI,F SWAPF RAND_LO,W RLF TEMP1,F XORWF RAND_HI,W SWAPF RAND_HI,F ANDLW 0x01 RLF RAND_LO,F XORWF RAND_LO,F RLF RAND_HI,F ;--------------------------------- MOVLW RLIMIT SUBWF RAND_LO,W SKPNC ;FW , C=1 GOTO RANDOM16 MOVF RAND_LO,W MOVWF PWM_C INC_B52 MOVF INT_C,W SKPZ GOTO INC_B52 BTFSS RA,2 ;STOP ? GOTO MODE_5 DECFSZ PUSH_C,F GOTO INC_B51 GOTO MODE_51 CENT_B5 MOVLW BDELAY ;0.01 SECOND * 40 CALL LOOP_L BTFSS RA,1 GOTO MODE_0 ;CHANGE MODE GOTO MODE_50 ;--------------------------------- MODE_6 ;Random MOVLW H'0' CALL DDRAM_ADDRESS MOVLW 'Q' CALL PRINT_CHAR MOVLW 'u' CALL PRINT_CHAR MOVLW 'i' CALL PRINT_CHAR MOVLW 't' CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR MOVLW ' ' CALL PRINT_CHAR MODE_61 BTFSS RA,0 GOTO START BTFSC RA,1 GOTO MODE_61 MOVLW BDELAY CALL LOOP_L BTFSS RA,1 GOTO MODE_0 GOTO MODE_61 ;------ END OF DST --------------- ;---------------------------------- ;----- SPEED CONTROLLER TESTER -- SCT_MAIN BSF RA,4 ;OUT +5V OFF BSF FLAG_REG,F_TDST ;IF SET GOTO DST MODE CALL CLEAR_DISPLAY ;CLEAR DISPLAY MOVLW 0 CALL DDRAM_ADDRESS MOVFW MODE_SEL CALL MODE_ADDRESS ;GET MODE NAME BEGINING CALL DISP_MESSAGE ;DISPLAY MODE NAME MOVLW BDELAY CALL LOOP_L ;----------------------------------------------- BSF STATUS,RP0 ;SET 3,5 ENABLE BANK1 MOVLW B'10000111' MOVWF OPTIONF ;INTERNAT CLOCK,TRM0,1:256 BCF STATUS,RP0 ;ENABLE BANK0 MOVLW TMR1 ;256*78=19968 uS MOVWF TMR0 BCF INTCON,TOIF BSF INTCON,TOIE BSF INTCON,GIE ;ENABLE INT ;------------------------------------------------- SCT_1 MOVLW D'100' ;MINIMUM MOVWF PWM_C SCT_11 BTFSS RA,0 GOTO ISCT_B BTFSS RA,2 GOTO DSCT_B BTFSS RA,1 GOTO DCENT_B CLRF PUSH_C GOTO SCT_11 ISCT_B MOVLW RLIMIT SUBWF PWM_C,W SKPNZ GOTO SCT_11 ;=RLIMIT, DO NOTHING INCF PWM_C,F MOVLW D'5' ;CONTINUE 5 STEP, ACCELERATION SUBWF PUSH_C,W SKPNZ GOTO ISCT_B1 ; MOVLW D'20' ;0.2 SECOND CALL LOOP_L ;CALL 0.1 SECOND LOOP INCF PUSH_C,F GOTO SCT_11 ISCT_B1 ;FAST INC MOVLW D'6' CALL LOOP_L ;0.06 SECOND GOTO SCT_11 DSCT_B MOVLW LLIMIT SUBWF PWM_C,W SKPNZ GOTO SCT_11 ;=LLIMIT, DO NOTHING DECF PWM_C,F MOVLW D'5' ;CONTINUE 5 STEP, ACCELERATION SUBWF PUSH_C,W SKPNZ GOTO DSCT_B1 ; MOVLW D'20' ; CALL LOOP_L ;CALL 0.1 SECOND LOOP INCF PUSH_C,F GOTO SCT_11 DSCT_B1 ;FAST DEC MOVLW D'6' CALL LOOP_L ;0.06 SECOND GOTO SCT_11 DCENT_B MOVLW BDELAY ;0.01 SECOND * 40 CALL LOOP_L BTFSS RA,1 GOTO START ;CHANGE MODE GOTO SCT_1 ;GOTO BEGINING, 1000uS ;------ END OF SCT ----------------- ;======================================================= RECT_MAIN BSF RA,4 ;OUT +5V OFF BSF FLAG_REG,F_TDST BSF FLAG_REG,F_REC CALL CLEAR_DISPLAY ;CLEAR DISPLAY MOVLW 0 CALL DDRAM_ADDRESS MOVFW MODE_SEL CALL MODE_ADDRESS ;GET MODE NAME BEGINING CALL DISP_MESSAGE ;DISPLAY MODE NAME BSF STATUS,RP0 ; MOVLW B'10000000' MOVWF OPTIONF ;INTERNAT CLOCK,TRM0,1:2 MOVLW B'00001111' ;SET RA,3 INPUT MOVWF TRISA ; BCF STATUS,RP0 ; CLRF PWM_C BSF INTCON,TOIE BSF INTCON,GIE ;ENABLE INT TO DISPLAY XXX uS NOP NOP ;-------------------------------- REC_0 BCF INTCON,TOIF BCF INTCON,TOIE BCF INTCON,GIE ; ;-------START MEASURE------------- REC_2 CLRF PWM_C REC_3 BTFSS RA,1 GOTO REC_B BTFSS RA,3 GOTO REC_3 REC_4 NOP ;10 uS LOOP NOP NOP NOP INCF PWM_C,F SKPNZ GOTO REC_ERROR ;IF PWM_C > 255, ERROR BTFSC RA,3 GOTO REC_4 DECF PWM_C,F ;CORRECT 1-20 uS GOTO REC_5 REC_ERROR ;IF > 255 DISPLAY 255 MOVLW H'FF' MOVWF PWM_C REC_5 BSF INTCON,TOIE BSF INTCON,GIE ;ENABLE INT TO DISPLAY XXX uS GOTO REC_0 REC_B MOVLW BDELAY ;0.01 SECOND * 40 CALL LOOP_L BTFSS RA,1 GOTO START ;CHANGR MODE TO SCT MAUN GOTO RECT_MAIN ;------------------------------------------------- END -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist