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?
Analog Comparators and 16F628
Moderator: Benj
-
SHORTCIRCUIT
- Posts: 155
- Joined: Thu Feb 10, 2011 4:39 am
- Location: Las Vegas, Nevada USA
- Has thanked: 40 times
- Been thanked: 19 times
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Analog Comparators and 16F628
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.
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.
Comparitor interrupts can also be enabled by using the custom interrupt functionality. This is explained in the main Flowcode help file.
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;Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
SHORTCIRCUIT
- Posts: 155
- Joined: Thu Feb 10, 2011 4:39 am
- Location: Las Vegas, Nevada USA
- Has thanked: 40 times
- Been thanked: 19 times
Re: Analog Comparators and 16F628
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.....
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.....
-
medelec35
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Analog Comparators and 16F628
I'm not sure if this is what your after, but maybe worth a look:
http://www.matrixmultimedia.com/mmforum ... 81&p=19788
http://www.matrixmultimedia.com/mmforum ... 81&p=19788
Martin
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: Analog Comparators and 16F628
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel