PDA

View Full Version : PicBasic e Interrupt



Alx PD
- 20th January 2008, 11:05
Hi All
I'm evalutating the real capability of PBP
and a future use for my projects...

The first App that i need to test is a control of a position
by an encoder and write the number of pulse on a LCD ( HD44780 )

i'm using a 16F628A and the frquency of the square signals of the
encoder is about 1Khz timed 90 between them

I'm using PortB as interrupt on change by PortB.4 e PortB.5
A complete movements is 7200 pulses

The problem is this:
If i write on LCD at the end the complete movement the
counting is ok and I read 7200

If i write on LCD *during* the movement the
counting is not ok: it losts some pulses
( about 10-20 for every write )

Is possible that the LCDOUT stop the Interrupt ???

I'tryed to write using the HSEROUT on a PC and the problem
remain the same...

If i use assemble language interrupt handler mode
( ref ASMINT.BAS ) con I' totaly resolve this problem ?

Thank You
Ciao
Alx PD (it)

HenrikOlsson
- 20th January 2008, 14:59
Hi Alx,
If you're using PBP's built in interrupt then yes, the LCDOUT can make it loose counts. PBP way of doing interrupts is to always finish the current command and THEN jump to the Interrupt handler. Depending on how much info you're writing to the display the LCDOut statement may take several milliseconds to complete.

Moving to an assmebler based interrupt handler will probably fix you up but an easier way, if your not that familiar with assembler is to use Darrel Taylors Instant Interrupt routines. Do a search on the forum and you'll find it. It will let you write your interrupthandler in Basic without the limitations of PBP's way of handling the interrupts and is very easy to setup and use.

Another approach might be to switch PIC to a 18F2431 for example. It has built in hardware counter for quadrature encoders so you don't have to keep track of with software.

Hope it helps.
/Henrik Olsson.