View previous topic :: View next topic |
Author |
Message |
asunca
Joined: 09 Sep 2005 Posts: 36
|
external interrupt rb0 |
Posted: Thu May 04, 2006 4:50 am |
|
|
the output of an LM358 comparator normally swings between 0-5 volts but when i connect the opamp to the rb0 external interrupt pin, the voltage seems to be swinging between 0-1.2 volts so the H to L edge triggering doesnt work and no interrupt is generated. what can i do?
pic 16f628 is used. |
|
|
Ttelmah Guest
|
|
Posted: Thu May 04, 2006 6:41 am |
|
|
First of all, a LM358, is not a comparator, but an op-amp. You can use it as a comparator, but it'll not give the fast transitions that a proper comparator will manage. It also has some severe limitatins. Assuming you are running this from 5v, the quoted output swing, is to +3.5v, not 5v. The real 'danger' one though, is the maximum input voltage. If this goes above Vcc-1.5v, the input stage, effectively switches off, and the output becomes indeterminate.
There are a number of possibilities:
1) You are being hit by one of the limitations of the chip.
2) There is an unexpected load (you are sure that you have set the pin as an input on the PIC?).
Best Wishes |
|
|
asunca
Joined: 09 Sep 2005 Posts: 36
|
|
Posted: Thu May 04, 2006 12:49 pm |
|
|
i have connected lm339 comparator this time and saw the output voltage swinging between 0-5 with no load. when the 16f628's rb0 is connected the same problem appears. and rb0 is adjusted to be input. there must be another problem?? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu May 04, 2006 1:04 pm |
|
|
Quote: | and rb0 is adjusted to be input. |
Post the code that does this. |
|
|
asunca
Joined: 09 Sep 2005 Posts: 36
|
|
Posted: Thu May 04, 2006 1:48 pm |
|
|
#include <16F628.h>
#use delay(clock=4000000)
#fuses NOWDT,INTRC_IO, NOPUT, NOPROTECT, NOBROWNOUT, NOMCLR, NOLVP, NOCPD
int donus1=0;
#INT_EXT
ext_isr()
{
++donus1;
output_high(pin_b3);
}
void main()
{
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
ext_int_edge( H_TO_L ); // Sets up EXT
set_tris_b(1);
port_b_pullups(FALSE);
//delay_ms(2000);
output_b(0);
enable_interrupts(GLOBAL);
enable_interrupts(INT_EXT);
while(donus1<25);
while(1){
output_high(pin_b5);
output_low(pin_b4);
delay_ms(500);
output_low(pin_b5);
output_high(pin_b4);
delay_ms(500);
}
} |
|
|
cmdrdan
Joined: 08 Apr 2005 Posts: 25 Location: Washington
|
|
Posted: Thu May 04, 2006 2:04 pm |
|
|
Get rid of the output_b(0) statement. With standard_io enabled (the default), the compilier is turning rb0 into an output automatically. Initialize your other output pins separately. |
|
|
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
|
|
Posted: Fri May 05, 2006 6:06 pm |
|
|
We don't know what your circuit looks like but since the LM339 has open drain outputs, you will need a pullup resistor on it's output pin. _________________ David |
|
|
|