PDA

View Full Version : PICBASIC Pro commands for using analog comparator module for PIC16F628



steng
- 1st October 2008, 07:36
I would like to use the analog comparator module so that 2 input into the comparator will result in one output from it. But I have problems with the syntax used in the PICBASIC Pro.

Can anyone please kindly help me for the commands that i need and also any circuit diagrams in using the analog comparator that may help.

Thanks a lot for help..:)

skimask
- 1st October 2008, 13:31
But I have problems with the syntax used in the PICBASIC Pro.

What problems with what syntax? Show us!

sougata
- 1st October 2008, 14:40
Hi,

First of all you need to configure your comparator modes through the CMCON register.
Syntax : CMCON = %0x0xxxxx
You would find the details from the datasheet about the different modes. Now if you are using the internal reference for your comparator then you need to setup the VRCON register to specify the reference voltage. Same way VRCON =

Now in your application you need to poll the Comparator Output bit CMCON.6 for the comparator status. If you need interrupts then you need to setup the peripheral interrupt registers as well along with the PIE bit in the INTCON. Any change in the comparator status causes an interrupt.

paul borgmeier
- 4th October 2008, 02:46
see post #3 here for possible help

http://www.picbasic.co.uk/forum/showthread.php?p=62459#post62459

steng
- 5th October 2008, 09:11
Thanks a lot. I'll try to read the links provided and write the commands that you all had provided. Will come back if I face any problems.

Thanks again..:)