All you've done is include the file.
You haven't defined the interrupt sources or the handlers.
Take a look here for a basic example.
http://www.darreltaylor.com/DT_INTS-14/hello.html
All you've done is include the file.
You haven't defined the interrupt sources or the handlers.
Take a look here for a basic example.
http://www.darreltaylor.com/DT_INTS-14/hello.html
DT
Thanks...
Compiled and worked (not I was expected), but thereīs my fault.
Before interrupts, with a 25Hz signal Iīve read a 1500 rpm.
Now, with led blinking, Iīve read is 120~180.
The code
Code:'**************************************************************** '* Name : UNTITLED.BAS * '* Author : Mauro Perides * '* Notice : Copyright (c) 2008 Mauro Perides * '* : All Rights Reserved * '* Date : 25/11/2008 * '* Version : 1.0 * '* Notes : * '* : * '**************************************************************** '@ device pic16F887, HS_OSC, WDT_OFF, LVP_OFF INCLUDE "DT_INTS-14.bas" ' Base Interrupt System INCLUDE "ReEnterPBP.bas" ' Include if using PBP interrupts 'Define MHZ Crystal DEFINE OSC 20 ' Set LCD DEFINE LCD_DREG PORTB ' Set starting Data bit (0 or 4) if 4-bit bus DEFINE LCD_DBIT 0 ' Set LCD Register Select port DEFINE LCD_RSREG PORTB ' Set LCD Register Select bit DEFINE LCD_RSBIT 4 ' Set LCD Enable port DEFINE LCD_EREG PORTB ' Set LCD Enable bit DEFINE LCD_EBIT 5 ' Set LCD bus size (4 or 8 bits) DEFINE LCD_BITS 4 ' Set number of lines on LCD DEFINE LCD_LINES 2 ' Set command delay time in us DEFINE LCD_COMMANDUS 2000 ' Set data delay time in us 'DEFINE LCD_DATAUS 50 SYMBOL LED1 = portd.1 symbol rpmIn = portd.0 rpm VAR word ASM INT_LIST macro ; IntSource, Label, Type, ResetFlag? INT_Handler TMR1_INT, _ToggleLED1, PBP, yes endm INT_CREATE ; Creates the interrupt processor ENDASM T1CON = $31 ; Prescaler = 8, TMR1ON @ INT_ENABLE TMR1_INT ; enable Timer 1 interrupts :main CM1CON0 = 0 ' Comparators off (Do I need these?) CM2CON0 = 0 ' Comparators off 'ANSEL = 0 ANSELH = 0 ' Configure other AN pins as digital I/O output PORTB INPUT PORTD.0 PORTC = 0 TRISC = 0 LCDOUT $FE, 1, " prdTURBO " LCDOUT $FE, $C0, " FUEL COMPUTER " pause 2000 LCDOUT $FE, 1 while 1=1 COUNT rpmIn, 100, rpm LCDOUT $FE,1, "PULS/S ", DEC(RPM) LCDOUT $FE, $C0, "RPM ", DEC(rpm)*60 wend '---[TMR1 - interrupt handler]-------------------------------------------------- ToggleLED1: TOGGLE LED1 @ INT_RETURN
Hi,
Just disable interrupts before and re-enable them after the "COUNT" command ... but issue expected if blinking the Led @ more then 5 Hz ...
Note you do not need interrupts to blink your Led ... COUNT in a loop gives a correct ( read convenient enough ) timebase !!!
Alain
Last edited by Acetronics2; - 26th November 2008 at 12:59.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi. I would recommend for the sake of experimantation to increase the sampling of the count command to say 2000msec and see what happens.
The timer1 interrupts the count every 105 msec and is obvious that there is interference since the Count also samples at 100 msec. Remember that the Interrupts are not Instant with the exact meaning. There is an overhead to save and restore the variables and program counter.
Also at your program:
make it asCode::main
andCode:main:
make it as:Code:while 1=1 COUNT rpmIn, 100, rpm LCDOUT $FE,1, "PULS/S ", DEC(RPM) LCDOUT $FE, $C0, "RPM ", DEC(rpm)*60 wend
this is much faster.Code:rpm var word LCDOUT $FE,1, "PULS/S ", $FE,$C0,"RPM:" while 1=1 COUNT rpmIn, 2000, rpm:rpm=rpm*60 LCDOUT $FE, $80,dec," ", rpm,$FE,$C5, DEC rpm," " wend
Ioannis
Last edited by Ioannis; - 26th November 2008 at 13:57.
Hi,
W/ no interrupts using ...
so simple as that ... ( LCDOUT spaces avoid resetting the LCD ... which is toooooooo long ! )Code:.... while 1 TOGGLE LED1 COUNT rpmIn, 100, rpm LCDOUT $FE,2, "PULS/S ", DEC(RPM ), " " LCDOUT $FE, $C0, "RPM ", DEC(rpm)*60 , " " wend END
... BTW : How many pulses per rev. ???
Alain
Last edited by Acetronics2; - 26th November 2008 at 14:22.
************************************************** ***********************
Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
************************************************** ***********************
IF there is the word "Problem" in your question ...
certainly the answer is " RTFM " or " RTFDataSheet " !!!
*****************************************
Hi...
Working fine now. Thanks for the directions.
I know I donīt need interrupts to just blink a led (and donīt need for most of things). Just to see how it works.
In future I expect this code will read some sensors (pressure, air temp, rpm and a pot), do some calculation and provide near exact extra fuel needed for an aftermarkt turbo charged engine runing at high revs. At this time I think that Iīll need interrups, since in this case, time is critical
Donīt know yet... need to check. Using 1 at this time.... BTW : How many pulses per rev. ???
Last edited by perides; - 26th November 2008 at 14:40.
Canīt figure by myself.
Can someone explain me tachometer maths??
Engine will run up to 5500 revs. 1 pulse for revolution.
Bookmarks