That will be hard to setup PIC18F1320 analog comparator, as he don't have any
BUT... PIC18F2220 and lots other have some already built-in.
Internal analog comparator works as regular voltage comparator (LM393 and so on), you set a voltage reference on one input pin (voltage divider, trim pot, whatever else fancy stuff), and you apply your signal on the other input pin, then you just monitor the voltage comparator output.
In a PIC, when the output of the comparator change, it can trigger an interrupt event, so it's done in background. Once in the Interrupt handler, you do what you need to do.
Have a look at Darrel's Instant interrupt, this will save you some headaches. There's also some code-example on how to use'em with Timer.
http://www.pbpgroup.com/modules/wfse...p?articleid=19
From there, you should be able to begin some experiments.
Last edited by mister_e; - 1st February 2009 at 19:29.
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Bookmarks