PDA

View Full Version : DT Instant Interrupts help



perides
- 26th November 2008, 11:46
Hi... trying to make a test code to see how it works.

First Iīve made a single tachometer. Worked fine, but when tryied to port then to use interrupts (with Darrel Taylor helps) since the code will make another things in future Iīve get


Error c:\proga~1\pbp\pbppic14.lib 1160: [225] Undefined Symbol 'INT_ENTRY'
Error c:\proga~1\pbp\pbppic14.lib 1162: [225] Undefined Symbol 'INT_ENTRY'

errors when compiling

MPASM box checked and PIC is 16F887.

Just in case, follows the code:



'@ device pic16F887, HS_OSC, WDT_OFF, LVP_OFF
include "DT_INTS-14.bas" ' Base Interrupt System

' set Crystal MHZ
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 rpmIn = portd.0
rpm VAR word

:main
CM1CON0 = 0 ' Comparators off
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, 10, rpm
LCDOUT $FE,1, "PULS/S ", DEC(RPM)
LCDOUT $FE, $C0, "RPM ", DEC(rpm)*60
wend



Iīm a dumb ass newbie so please donīt blame me if this is a stupid question but:
Wath I missing to make DTīs Interrupts to compile?

Best regards,
Mauro

Darrel Taylor
- 26th November 2008, 12:01
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

perides
- 26th November 2008, 12:43
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



'************************************************* ***************
'* 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

Acetronics2
- 26th November 2008, 12:54
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

Ioannis
- 26th November 2008, 13:54
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:



:main


make it as


main:


and


while 1=1
COUNT rpmIn, 100, rpm
LCDOUT $FE,1, "PULS/S ", DEC(RPM)
LCDOUT $FE, $C0, "RPM ", DEC(rpm)*60
wend


make it as:


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


this is much faster.

Ioannis

Acetronics2
- 26th November 2008, 14:15
Hi,

W/ no interrupts using ...




....


while 1
TOGGLE LED1
COUNT rpmIn, 100, rpm
LCDOUT $FE,2, "PULS/S ", DEC(RPM ), " "
LCDOUT $FE, $C0, "RPM ", DEC(rpm)*60 , " "
wend

END



so simple as that ... ( LCDOUT spaces avoid resetting the LCD ... which is toooooooo long ! )

... BTW : How many pulses per rev. ???

Alain

perides
- 26th November 2008, 14:38
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


... BTW : How many pulses per rev. ???

Donīt know yet... need to check. Using 1 at this time.

perides
- 26th November 2008, 18:41
Canīt figure by myself :mad: .
Can someone explain me tachometer maths??
Engine will run up to 5500 revs. 1 pulse for revolution.