'**************************************************************** '* Name : UNTITLED.BAS * '* Author : [select VIEW...EDITOR OPTIONS] * '* Notice : Copyright (c) 2006 [select VIEW...EDITOR OPTIONS] * '* : All Rights Reserved * '* Date : 3/4/2006 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** Device 16F877A Declare XTAL 4 Config wdt_off,xt_osc,pwrte_off,debug_off,cpd_off,lvp_off,boden_off ON_INTERRUPT GoTo pulso Declare LCD_DTPORT PORTD Declare LCD_DTPIN PORTD.0 Declare LCD_ENPIN PORTC.5 Declare LCD_RSPIN PORTC.4 Declare LCD_INTERFACE 8 Declare LCD_LINES 2 Dim botao As Byte Dim FREQ As Word Dim FREQ2 As Word Dim FREQ_EST As Word Dim freq2_hi As FREQ2.HighByte Dim freq2_lo As FREQ2.LowByte Dim temp As Word Dim loop As Word Dim x As Byte Dim VARI As Byte Dim WVARI As Word Dim dut As Word Dim i As Byte Dim vel As Byte Dim var1 As Byte Dim Vrot As Byte Dim Tretardo As Word Dim Tdatador As Word Dim Tmassagem As Byte Dim Tgarfo As Byte Dim Vesteira As Byte Dim total As DWord Dim pre As Byte Dim post As Byte Dim separador As Byte Symbol sobe= PORTC.1 Symbol desce=PORTC.2 Symbol funcao=PORTC.0 Symbol partida=PORTA.1 Symbol parada=PORTA.2 Symbol datador=PORTB.7 Symbol pistao = PORTB.6 Symbol TMR1IF PIR1.0 Symbol TMR1IE PIE1.0 Symbol GIE INTCON.7 Symbol TMR1ON T1CON.0 Symbol TMR2ON T2CON.2 Symbol PEIE INTCON.6 Symbol T0IF INTCON.2 Symbol T0IE INTCON.5 Symbol tmr2if PIR1.1 Symbol tmr2ie PIE1.1 Symbol tmr1cs T1CON.1 Symbol PS0 OPTION_REG.0 Symbol PS1 OPTION_REG.1 Symbol PS2 OPTION_REG.2 'SETUP DOS REGISTRADORES INTCON=%00000000 ADCON1=%00000111 OPTION_REG=7 TRISC=%11001111 TRISD=0 TRISB=%00000001 TRISA=%00011111 TRISE=%001 T1CON=%00110000 T2CON=%01111001 High PORTB GIE=1 PEIE=1 tmr2ie=1 tmr2if=0 Low PORTB.5 '***********apresentaçao********** EData 156,0,0,156,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 apresentacao: Cursor 1,1 Print "Tudela Ind e Com" Cursor 2,1 Print "F: (11)2941-6930" DelayMS 1000 Vrot=ERead 0 Tretardo=ERead 1 Tdatador= ERead 4 Vesteira= ERead 7 total= ERead 10 FREQ_EST= (0.83 * Vesteira)/10 FREQ2=65536-(625000/FREQ_EST) ' calculo velocidade esteira FREQ =((15637/(8*Vrot))*100) ' calculo velocidade cabeçote TMR1L=freq2_lo TMR1H=freq2_hi TMR1IF=0 TMR1IE=1 TMR1ON=1 tmr1cs=0 PEIE=1 TMR1IF=0 Cls Cursor 1,1 Print "Total=" Cursor 1,7 Print Dec total GoTo inicio ajuste1: EWrite 10,[total] Cls Vrot=ERead 0 Cursor 1,1 Print "Vrotulo:" Cursor 2,1 Print DEC3 Vrot var1=Dig Vrot,0 Cursor 2,3 Print ",",@var1," m/min." x= 0 VARI=Vrot GoSub teclado2 Cls Cursor 1,1 Tretardo=ERead 1 Print "Tretardo:" Cursor 2,1 Print DEC3 Tretardo ," ms" x=1 WVARI=Tretardo GoSub teclado22 Cls Cursor 1,1 Tdatador=ERead 4 Print "Tdatador:" Cursor 2,1 Print DEC3 Tdatador," ms." x=4 WVARI=Tdatador GoSub teclado22 Cls Cursor 1,1 Vesteira=ERead 7 Print "Vesteira:" Cursor 2,1 Print DEC3 Vesteira var1=Dig Vesteira,0 Cursor 2,3 Print ",",@var1," m/min." x=7 VARI=Vesteira GoSub teclado2 Cls Cursor 1,1 Print "'F' 1 toque sai" Cursor 2,1 Print "'F' 2seg total=0" TECLA: If funcao=0 Then DelayMS 2000 If funcao=0 Then GoSub zera GoTo apresentacao Else GoTo TECLA EndIf zera: total =0 EWrite 10,[total] Cursor 1,7 Print Dec total Return teclado2: If sobe=0 Then DelayMS 250:GoSub soma2 If desce=0 Then DelayMS 250:GoSub subtrai2 If funcao=0 Then DelayMS 100:Return GoTo teclado2 soma2: While sobe=0 GoSub somas2 Wend somas2: VARI=VARI+1 If VARI>=250 Then VARI=0 EWrite x,[VARI] Cursor 2,1 Print DEC3 VARI var1= Dig VARI,0 Cursor 2,3 Print ",", @var1 DelayMS 50 Return subtrai2: While desce=0 GoSub subtrais2 Wend subtrais2: VARI=VARI-1 If VARI>=255 Then VARI=250 EWrite x,[VARI] Cursor 2,1 Print DEC3 VARI var1= Dig VARI,0 Cursor 2,3 Print ",", @var1 DelayMS 50 Return teclado22: If sobe=0 Then DelayMS 250:GoSub soma22 If desce=0 Then DelayMS 250:GoSub subtrai22 If funcao=0 Then DelayMS 100:Return GoTo teclado22 soma22: While sobe=0 GoSub somas22 Wend somas22: WVARI=WVARI+1 If WVARI>=1000 Then WVARI=0 EWrite x,[WVARI] Cursor 2,1 Print DEC3 WVARI DelayMS 50 Return subtrai22: While desce=0 GoSub subtrais22 Wend subtrais22: WVARI=WVARI-1 If WVARI>=65535 Then WVARI=999 EWrite x,[WVARI] Cursor 2,1 Print DEC3 WVARI DelayMS 50 Return inicio: If partida=0 Then DelayMS Tretardo GoTo gera_pulso EndIf If funcao=0 Then DelayMS 100 segura: If funcao=0 Then segura GoTo ajuste1 Else GoTo inicio EndIf gera_pulso: High PORTB.5 DelayUS FREQ Low PORTB.5 DelayUS FREQ If parada=0 Then GoTo inter GoTo gera_pulso inter: High PORTB.5 DelayUS FREQ Low PORTB.5 DelayUS FREQ If parada=0 Then GoTo inter Low datador DelayMS Tdatador High datador GoSub contador inter2: If partida=0 Then inter2 GoTo inicio contador: Inc total EWrite 10,[total] Cursor 1,7 Print Dec total Return pulso: Context SAVE PULSO2: TMR1ON=0 If PORTB.6=1 Then LIGA GoTo DESLIGA LIGA: Low PORTB.6 TMR1L=freq2_lo TMR1H=freq2_hi TMR1IF=0 TMR1ON=1 GoTo SAIDA DESLIGA: High PORTB.6 TMR1L=freq2_lo TMR1H=freq2_hi TMR1IF=0 TMR1ON=1 GoTo SAIDA SAIDA: Context Restore