Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Status of a comparator affecting interrupts.

Status
Not open for further replies.

2camjohn

Member
I noticed on my PIC16F628a circuits, the timer slows down and speeds up depending on the status of an input which is connected to the comparator.
The timer is done using interrupts and timer0.


So I added a switch and wired it up so it causes interrupts.
It seems that some interrupts are not being triggered(roughly 6 out of every 10) when the input to the comparator reads low.

When it reads high eveything is fine, timer is fine and every time i push the switch it responds.


I have been through my code with a fine tooth comb, I have reduced the code to 1 very simple timer routine, the comparator and the switch triggered interrupts and I get the same problem.

So I guess its a hardware problem, can anyone suggest anything???
The circuit used is also extremely simple.

Thanks
John
 
My schematic is now extremely simple.
(sorry about the crappy MS paint)


As I said I have removed all but the offending parts and the problem still persists :(


The code is so simple I cant imagine its a code problem. I will post my code later on when I have access to it...


Thanks alot
John
 

Attachments

  • crappysch.jpg
    crappysch.jpg
    16.8 KB · Views: 595
John i assume porb .0 is an input??
i didnt think that you could use port B to set an interrupt ?? i may be wrong..
 
You show 6v as being switched directly to PortB. This is above the capabilities of most PICs.

You probably don't need a SPDT switch there. A simple 10k pullup and a button/switch that shorts it to ground will do it with less wiring and less transition noise. The downside being it always draws current when switched low, a concern for long term battery use.
 
Thanks for the replies guys, I really appreciate it.


Jay Slovak,
Yes I am using the internal reference.


WillB,
PortB.0 is the dedicated interrupt pin on the 628 (not interrupt on change type thing)


Oznog,
Yes I am putting 6V in there, I thought I would be able to put that straight into my PIC as that is what the PIC is powered by.


Nigel,
The comparator is there because originally the phototransistor was a photodiode.
Now you mention it, changing that to a normal input might solve all my problems :D


Cheers for the Ideas guys.
Ill post back later :)
John
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top