Page 1 of 1

Analog Comparators and 16F628

Posted: Tue Feb 22, 2011 2:49 pm
by SHORTCIRCUIT
I understand that you can write C code to overcome the deficiency of Flowcode not supporting analog comparison on a chip like the 16F877.
The 16F877 allows you to put an analog device in the panel and then by C code manipulation, you can achieve analog comparison.
However, with the 16F628 there is NO ADC and therefore Flowcode will not allow you to put an analog input device (such as a pot) in the panel. Is there
a way to overcome this shortcoming?

Re: Analog Comparators and 16F628

Posted: Wed Feb 23, 2011 5:20 pm
by Benj
Hello,

There certainly is, basically you will have to setup the comparator module to allow you to do the analogue comparison.

The device datasheet details which registers you will need to modify to allow for the comparator to be setup.

Code: Select all

cmcon = 0x04;   


For example sets up the comparator module for two independant comparators, the first being on RA0, RA3 and the second being on RA1, RA2.

To read the output from each comparator module you can use the following code assuming you have Flowcode variables called compA and compB.

Code: Select all

FCV_COMPA = (cmcon & 0x40) >> 6;
FCV_COMPB = (cmcon & 0x80) >> 7;
Comparitor interrupts can also be enabled by using the custom interrupt functionality. This is explained in the main Flowcode help file.

Re: Analog Comparators and 16F628

Posted: Thu Feb 24, 2011 1:50 am
by SHORTCIRCUIT
Hi Ben

Please help me, because now, I'm really extremely confused. My question was, how do you put an analog component on the panel when using a pic that does not have an ADC in it like the 16F628. I don't think you answered the question, but if I'm wrong, please show me where I'm not getting it. Eagerly awaiting your reply.....

Re: Analog Comparators and 16F628

Posted: Thu Feb 24, 2011 2:38 am
by medelec35
I'm not sure if this is what your after, but maybe worth a look:
http://www.matrixmultimedia.com/mmforum ... 81&p=19788

Re: Analog Comparators and 16F628

Posted: Thu Feb 24, 2011 9:12 am
by Benj
Hello,

The link looks like a good answer to me, You cannot use Analogue inputs if the device does not have the analogue to digital peripheral. It does however have analogue comparators which was what I was explaining how to setup.