CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

external interrupt rb0

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
asunca



Joined: 09 Sep 2005
Posts: 36

View user's profile Send private message

external interrupt rb0
PostPosted: Thu May 04, 2006 4:50 am     Reply with quote

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







PostPosted: Thu May 04, 2006 6:41 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu May 04, 2006 12:49 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu May 04, 2006 1:04 pm     Reply with quote

Quote:
and rb0 is adjusted to be input.

Post the code that does this.
asunca



Joined: 09 Sep 2005
Posts: 36

View user's profile Send private message

PostPosted: Thu May 04, 2006 1:48 pm     Reply with quote

#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

View user's profile Send private message

PostPosted: Thu May 04, 2006 2:04 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Fri May 05, 2006 6:06 pm     Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group