Tachometer with Interrupts


Results 1 to 15 of 15

Threaded View

  1. #1
    Join Date
    Oct 2008
    Posts
    14

    Default Tachometer with Interrupts

    I tried to make a tachometer using RB0 and Timer1 interrupt. I simulated on ISIS with a Pulse generator... I choose 200mS from pulse generator, but on LCD it shows always different values. I cannot find the reason. Pls help...

    DEFINE LCD_DREG PORTB' LCD Data Port
    DEFINE LCD_DBIT 4 ' LCD Data Bit
    DEFINE LCD_RSREG PORTA ' LCD RS Port
    DEFINE LCD_RSBIT 0 ' LCD RS Bit
    DEFINE LCD_EREG PORTA ' LCD Enable Port
    DEFINE LCD_EBIT 1 'LCD Enable Bit
    DEFINE LCD_BITS 4 ' LCD Data Bit Sayisi
    DEFINE LCD_LINES 2 ' LCD Satir Sayisi
    SONUC1 VAR WORD
    SONUC2 VAR WORD
    X VAR WORD ' 1mS
    EK VAR WORD
    PIE1.0=1 ' 1 = Enables the TMR1 overflow interrupt

    TRISB.0=1
    T1CON=%00000001 ' bit 7-6 Unimplemented - bit 5-4=00 1:1 Prescale value - bit 0= 1=Disables Timer1
    OPTION_REG.7=1 ' 1 = PORTB pull-ups are disabled
    OPTION_REG.6=1 ' 1 = Interrupt on rising edge of RB0/INT pin
    INTCON.4=1 ' 1 = Enables the RB0/INT external interrupt
    INTCON.6=1 ' 1 = Enables all unmasked peripheral interrupts
    INTCON.7=1 ' 1 = Enables all unmasked interrupts
    CMCON=7 ' Turn comparators off and enable pins for I/O functions
    ON INTERRUPT GOTO KESME ' Kesme Durumunda Gidecegi Alt Yordam
    x=0

    Basla:
    @NOP
    goto basla

    DISABLE
    KESME:
    IF PIR1.0 THEN
    IF X<1000 THEN X=X+1
    PIR1.0=0
    endif


    IF INTCON.1 THEN
    SONUC2=TMR1H*256+TMR1L
    SONUC2=SONUC2/1000

    SONUC1=X**65535
    X=DIV32 1000
    sonuc2=SONUC2+X
    LCDOUT $FE,1,DEC SONUC2," mS Passed"

    INTCON.1=0
    X=0
    endif

    RESUME
    ENABLE
    Last edited by Archangel; - 13th September 2015 at 00:43. Reason: removed dead image link

Similar Threads

  1. Continuous Interrupts when using DT_INTS and an INCLUDE file
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 15th January 2010, 21:42
  2. Tachometer with DT Interrupts?
    By DanPBP in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th November 2009, 19:51
  3. Clock using Instant Interrupts
    By PICpocket in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 16th February 2009, 21:43
  4. DT's Instant Interrupts trouble
    By Tomexx in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 24th November 2008, 20:48
  5. help: TMR0 interrupts disabling PORTAchange interrupts???
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th August 2008, 15:10

Members who have read this thread : 2

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts