Searching \ for ' [PIC] Interrupt on change' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ints.htm?key=interrupt
Search entire site for: 'Interrupt on change'.

No exact or substring matches. trying for part
PICList Thread
'[PICLIST] [PIC] interrupt on change???'
2000\10\06@112426 by John Perkinton

flavicon
face
How does the portB interrupt on change work on the 16f84, does it only work
on bits 4-7, or does any change on portB effect it?

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.



'[PICLIST] [PIC] Interrupt on change'
2002\04\10@131358 by Claudio Tagliola
flavicon
face
Hello all,


I know this issue has passed the revue a dozen times already, however, I
can't find any usefull things from the archives.

I have two motion sensors which put out two PWM signals each. I want to
measure the length of those four PWM signals (this is the action
anglular data of the sensors). Now, with the PIC16F874 I use, I have two
options: use a capture register or use interrupt on change. Problem with
the capture is, I only have two. From the IOC ports RB7:RB4, there are
four. However, I remember a lot of words of caution when using the IOC
feature. If I have those four digital input signals only on those ports,
can I use this safely? And what were the all-too-familiar problems with
Interrupt on Change again?


Best Regards,

Claudio

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email spam_OUTlistservTakeThisOuTspammitvma.mit.edu with SET PICList DIGEST in the body


2002\04\10@141758 by Simon-Thijs=20de=20Feber?=

flavicon
face
I use interrupts on change in combination with 2
rotary encoders. PB7 together with PB0 and PB6 with
PB1.
No prob's at all. Use the internal pull-ups. Enable
the Interupt on Change and Global Interupt.
When an interupt occurs you have to check whole portb.

grtz

Simon

--- Claudio Tagliola <.....cptagliolaKILLspamspam@spam@CHELLO.NL> wrote: >
Hello all,
{Quote hidden}

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email .....listservKILLspamspam.....mitvma.mit.edu with SET PICList DIGEST in the body


2002\04\11@010426 by Dmitriy A. Kiryashov

picon face
Hi Claudio.

I think if you are not using PORTB for anything
else but for encoder _reading_ only it should work.

What is maximum PWM frequency those signals have?
Alternatively you can scan them(PORTB7..4 lines)
periodically by TMR0 or similar interrupt.

From my past experience it is not stable to use
PORTB interrupt on change feature so I'm trying
to stay away from it. (too many restrictions)


WBR Dmitry.


Claudio Tagliola wrote:
{Quote hidden}

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspam_OUTspamTakeThisOuTmitvma.mit.edu


2002\04\11@024050 by Claudio Tagliola

flavicon
face
Thx for the responses!

I'm working with the ICD, which is connected on RB7:RB6, would this
interfere with the interrupt also?

Regards,
Claudio

{Original Message removed}

2002\04\11@041104 by Claudio Tagliola

flavicon
face
Hello All Again,

Another IOC question: what happens if a pin on portb changes while i'm busy
with the interrupt handler from a previous pin change? I'm using four timed
PWM modulated signals which could come very close together, so the chance of
collosion is quite high.

Regards,
Claudio

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestspamspam_OUTmitvma.mit.edu


2002\04\11@052309 by Jinx

face picon face
> Another IOC question: what happens if a pin on portb changes
> while i'm busy with the interrupt handler from a previous pin
> change? I'm using four timed PWM modulated signals which
> could come very close together, so the chance of collosion is
> quite high

It might be better if you connect your signals to four general pins
and OR the four signals together into b0 and use the INT function.
When an INT occurs, poll the signal pins to find out which one
caused it. If signals really do come that close (ie closer than you
can process them in an ISR) then there'll have to be some sort
of flagging or logging so that events can be processed at a time
when you know it can be done without interruption

--
http://www.piclist.com hint: To leave the PICList
@spam@piclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2002\04\11@052917 by Kevin Blain

flavicon
face
If your using an '874, how about feeding the 4x PWM into 4x RC network
and measuring the DC level?

The DC level would be proportional to the mark / space ratio, and as
long as you pick the RC values wisely bearing in mind the PWM frequency.

Just a thought


Regards, Kevin

> {Original Message removed}

2002\04\11@063441 by Claudio Tagliola

flavicon
face
To Jinx:

Polling the complete portb won't be any faster then any other port? If two
interrupts come that close, the second one is lost, isn't it? If this is the
case, it's of no use if I connect the signal lines to other ports, by using
IOC I've lost port B anyway.

So I think I just have to take a possible collision into account when
processing the numbers. And at 100 Hz I have some measurements
to spare, so that's ok :)

To Kevin:

I'm not following you completely (I'm more of a s/w guy). Is this the same
technique as to converting all those digital lines into one (or more) analog
line(s), putting it through an A/D and then convert back to the individual
signals?

Regards,
Claudio

--
http://www.piclist.com hint: To leave the PICList
KILLspampiclist-unsubscribe-requestKILLspamspammitvma.mit.edu


2002\04\11@064727 by Kevin Blain

flavicon
face
If you feed the PWM signal into an RC (low pass) filter like so :-


PWM O----/\/\/\----+----o ANALOG IN
                  |
                  =
                  |
GND O--------------+----o GND

With the time constant of the filter say 10 times greater than the
period of the PWM, the DC level at the analog in will be proportional to
the duty cycle.

Therefore, rather than counting the period using interrupts, timers, or
capture module, you could measure the analog input voltage using the
build in A2D module. Seeing as you wish to measure 4 PWM signals, you
have enough A2D to do this.

Examples:

PWM constantly 0V

This will not charge the capacitor at all, and the A2D will read 0V

PWM constantly +5B

This will charge the capacitor to +5V, and the A2D will read +5V

PWM at 50% duty cycle

This will charge the capacitor up half the time, and discharge it the
other half. The A2D will read arounbd 2.5V


Regards, Kevin

> {Original Message removed}

2002\04\11@070851 by Michael Rigby-Jones

flavicon
face
Instead of using IOC on PortB, why not multiplex the four inputs to either
one or both CCP modules? You could use a cheap CMOS multiplexer (4051/4052)
or roll your own with a few logic gates.

The CCP interrupt could take care of switching the multiplexer to the
correct channel and store the previous result in an appropriate variable, so
it would be essentialy invisible to your main loop code.

Mike

> {Original Message removed}

2002\04\11@075058 by Bob Ammerman

picon face
I do not think you can reliably use the interrupt on change feature to
support this requirement. Here is my thinking:

1: an interrupt occurs because, for example RB7 changes

2: your interrupt handler clears the interrupt-on-change interrupt flag.

3: your interrupt handler reads PORTB to determine which pin changed.

4: just as your interrupt handler is reading PORTB, RB5 also changes, but
the 'interrupt-on-change-bug' means that the new value of RB5 will neither
be seen by your read, nor will it set the interrupt-on-change interrupt flag
again.

This is my understanding of how this works. However, I have never used the
interrupt-on-change feature myself, so I could be wrong.

Bob Ammerman
RAm Systems

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestTakeThisOuTspammitvma.mit.edu


2002\04\11@075522 by Bob Ammerman

picon face
> So I think I just have to take a possible collision into account when
> processing the numbers. And at 100 Hz I have some measurements
> to spare, so that's ok :)

Ah... if this is really only 100Hz then I would definitely handle it by
polling in a timer interrupt.

Bob Ammerman
RAm Systems

--
http://www.piclist.com hint: To leave the PICList
spamBeGonepiclist-unsubscribe-requestspamBeGonespammitvma.mit.edu


2002\04\11@080137 by Thomas McGahee

flavicon
face
What you want to do is clear the interrupt flag right after you
save the registers at the beginning of the ISR and determine that
the source of the interrupt was the interrupt-on-change. As soon
as you finish processing the interrupt check the flag again to
see if ANOTHER interrupt occured during processing. If so, handle
it by doing a GOTO to the place where you initially cleared the
flag in the interrupt before. If the flag is NOT set, then
you exit the ISR in the usual way. This will catch as many
interrupts as possible, but ANY method is going to fail if
the interrupts come in so fast you can't process them!

Fr. Thomas McGahee

{Original Message removed}

2002\04\11@100144 by Claudio Tagliola

flavicon
face
It's only 100 Hz, but every pulse has a width with a 14 bit resolution. So a
simple pulse counter won't do. I have to have the start and stop time of
that pulse, in as high a resolution as possible. I want to use timer0
without prescaler and it's a 20 Mhz PIC, so that's a 5 Mhz counter. That's
why I have to do it in an interrupt, if it's in the main code, i can't do
anything else.

So the sport is to clear the int check flag and get a poll of the port as
close together as possible, check the isr flag again on my way out of the
isr and just hope for the best :) That way, only an interrupt in two or
three instruction cycles could be lost.

Regards,
Claudio

-----Oorspronkelijk bericht-----
Van: pic microcontroller discussion list
[TakeThisOuTPICLISTEraseMEspamspam_OUTMITVMA.MIT.EDU]Namens Bob Ammerman
Verzonden: Thursday, April 11, 2002 12:52 PM
Aan: RemoveMEPICLISTspamTakeThisOuTMITVMA.MIT.EDU
Onderwerp: Re: [PIC] Interrupt on change


> So I think I just have to take a possible collision into account when
> processing the numbers. And at 100 Hz I have some measurements
> to spare, so that's ok :)

Ah... if this is really only 100Hz then I would definitely handle it by
polling in a timer interrupt.

Bob Ammerman
RAm Systems

--
http://www.piclist.com hint: To leave the PICList
piclist-unsubscribe-requestEraseMEspam.....mitvma.mit.edu

--
http://www.piclist.com hint: To leave the PICList
EraseMEpiclist-unsubscribe-requestspammitvma.mit.edu


2002\04\11@101313 by Bob Ammerman

picon face
I am beginning to understand better. Here is yet another idea:

If you don't need to get every pulse on every channel then you could do
something like this:

1: wire the four channels to RB4, RB5, RB6 and RB7 via a 10K resistor.

2: TRIS RB4 as an input and RB5, RB6 and RB7 as outputs

3: Use interrupt on change to get the first channel.

4: TRIS RB5 as an input and RB4, RB6 and RB7 as outputs

5: Use interrupt on change to get the next channel

etc.

Note:

The 10K resistors make sure that you don't get a collision  when a pin is
driven as an output.

Pins set to outputs do not participate in interrupt-on-change.

Bob Ammerman
RAm Systems

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestEraseMEspamEraseMEmitvma.mit.edu


2002\04\11@111013 by John Dammeyer

flavicon
face
My guess is he is using the 4 inputs to read two quadrature encoders.
These encoders output a square wave that is 90 degress out of phase and
from that information it's possible to determine both speed and
direction.  An analog solution won't work nor will setting the the
outputs as inputs.

John


> {Original Message removed}

2002\04\11@111646 by Kevin Blain

flavicon
face
He does say he is interested in duty cycle (specifies that the period is
100H and the duty cycle has a 14 bit resolution)

Sounds more like a strain guage than a rotary encoder, but I'm not
willing to speculate. He seems to not be to worried about relative phase
either.

It's just an idea anyway, it may, or may not be suitable for his needs,
but if it is, it is very easy to implement.

Regards, Kevin

> {Original Message removed}

2002\04\11@120707 by Claudio Tagliola

flavicon
face
To Kevin & John:

Hey, it's rude to talk about someone else in 3rd person while he is in
the room!

FYI; it's about the ADXL202 tilt sensor output. An ADXL202 has two tilt
sensor axis, each with a DCM which generates a PWM modulated signal.
Normal operations of the chip will result in a DC between 25% and 75%,
maybe even a smaller range. Zero g is 50% DC, 1 g is a 12.5% DC change.
The DC signals of the two axis are both centered around the center of
the pulse. It is therefore not strickly necessary to measure all 4 lines
at the same time, although measuring every pulse would be nice.

As we need two of those, we have 4 PWM outputs. The resolution of the
DCM in the ADXL chip is 14 bits, although this is higher then the
internal signal. But with Timer0 this is easily obtained on a 20 Mhz
chip.

To Bob:

Nice idea, easy to implement, no expensive components either. Only con
is that it reduces the frequency by a factor 4.


Regards,
Claudio

{Original Message removed}

2002\04\11@123954 by Jinx

face picon face
> If two interrupts come that close, the second one is lost, isn't it?

Yes, but the faster you can detect a signal (and process later)
the fewer you'll lose, so the ISR would have to be as short as
possible.

If you absolutely want to guarantee never missing a signal you'll
need some form of sample and hold that needs to account for
the worst case - all four signals arriving simultaneously. The s&h
can be digital (eg monostable). Each signal has a s&h that will
flip as a flag that an event has happened. As soon as the s/w
has finished working on the previous event you can move on to
the new one. As the PIC is looking serially at dynamic parallel
signals I don't think you have much choice. The other option is
parallel processing. Assign each signal a (small) PIC of its own

--
http://www.piclist.com hint: To leave the PICList
RemoveMEpiclist-unsubscribe-requestspam_OUTspamKILLspammitvma.mit.edu



'[Bulk] Re: [PIC] Interrupt on Change Pin'
2008\12\08@053542 by Isaac Marino Bavaresco
flavicon
face
William "Chops" Westfield escreveu:
> On Dec 7, 2008, at 6:01 PM, solarwind wrote:
>  
>> http://pastebin.com/f286b7121
>>    
>
>
>          GIE = 0;                //(INTCON[7]) Disable global interrupts
>          RABIE = 1;              //(INTCON[3]) Enable PORTA/PORTB  
> change interrupt
>          RABIF = 0;              //(INTCON[0]) Change interrupt flag  
> bit - clear
>          C1ON = 0;               //Disable comparators 1 and 2
>          C2ON = 0;
>
> Hmm.  Those are sort of interesting, since the left-side symbols are  
> single bits.  Does HTC actually let you do that sort of thing?  I  


Yes, it is perfectly legal and compiles to bsf and bcf instructions.

__________________________________________________
Faça ligações para outros computadores com o novo Yahoo! Messenger
http://br.beta.messenger.yahoo.com/

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...