Hello,
I am trying to get the Comparator to work in Flowcode 6 on a PIC16F627A. I want to use the single comparator mode (CMCON <2:0> = 101) and trigger a custom interrupt when the Comparator switches.
I have based the Custom Interrupt code on the code from Benj here:
http://www.flowcode.co.uk/mmforums/viewt ... =23&t=4780
I am using the VRef module on RA2 with the input on RA1. I have measured 2.5V on RA2 as expected.
Varying the voltage on RA1 above and below this doesn't light the LED on RB7.
Can anyone spot what I have done wrong please?
Thanks, Dave.
Custom Interrupt for Comparator
Moderator: Benj
-
Dave Squibb
- Flowcode v5 User
- Posts: 104
- Joined: Fri Oct 10, 2014 11:15 am
- Has thanked: 27 times
- Been thanked: 22 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: Custom Interrupt for Comparator
Hi Dave,
It looks to me like it should be working. However I did spot this line in the datasheet.
It looks to me like it should be working. However I did spot this line in the datasheet.
So you might have to use cmcon = 2 rather than cmcon = 5 like you have now.The internal reference signal is used when the comparators are in mode CM<2:0>=010 (Figure 10-1). In this mode, the internal voltage reference is applied to the VIN+ pin of both comparators.
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
-
Dave Squibb
- Flowcode v5 User
- Posts: 104
- Joined: Fri Oct 10, 2014 11:15 am
- Has thanked: 27 times
- Been thanked: 22 times
Re: Custom Interrupt for Comparator
Thanks for that Benj. Despite that it DOES still work with CMCON = 5.
The problem was the test line FCV_C2 = test_bit(cmcon, C2OUT);
That doesn't work but FCV_C2 = cmcon.C2OUT; does.
Is that something that has changed between the original V2/V3 post and V6?
The problem was the test line FCV_C2 = test_bit(cmcon, C2OUT);
That doesn't work but FCV_C2 = cmcon.C2OUT; does.
Is that something that has changed between the original V2/V3 post and V6?
Re: Custom Interrupt for Comparator
Hello... Benj, Dave Squibb, and all
1) I am just starting and keen to learn about how to implement flow-code to this comparator 16F627A/16F628A topic..
2) I have downloaded the attached flow-code file and start as a beginner to figure out on Dave Squibb problem and solution
from Benj, and I have search thru' the data sheet 16F627A on the 10.1 comparator module configuration to understand
the topic discussion.. But I still in doubt and could not get the downloaded flow-code running when I start the simulation run..
3) Here is my question :-
i) Can someone help me to update/ correct the flow-code codes and test for proper functioning then upload new file for my learning..
ii) How to do testing in the start run mode as there is no ADC component knob connected in the view panel. I only see there is
one output led connected to RB7.. Seriously, I am a novice and I need help to get started on this comparator topic..
4) Many thanks, should someone educates me and I appreciate that... [email-deleted]
1) I am just starting and keen to learn about how to implement flow-code to this comparator 16F627A/16F628A topic..
2) I have downloaded the attached flow-code file and start as a beginner to figure out on Dave Squibb problem and solution
from Benj, and I have search thru' the data sheet 16F627A on the 10.1 comparator module configuration to understand
the topic discussion.. But I still in doubt and could not get the downloaded flow-code running when I start the simulation run..
3) Here is my question :-
i) Can someone help me to update/ correct the flow-code codes and test for proper functioning then upload new file for my learning..
ii) How to do testing in the start run mode as there is no ADC component knob connected in the view panel. I only see there is
one output led connected to RB7.. Seriously, I am a novice and I need help to get started on this comparator topic..
4) Many thanks, should someone educates me and I appreciate that... [email-deleted]
-
kersing
- Valued Contributor

- Posts: 2045
- Joined: Wed Aug 27, 2008 10:31 pm
- Location: Netherlands
- Has thanked: 553 times
- Been thanked: 1081 times
Re: Custom Interrupt for Comparator
This flowchart contains C code icons, C code icons do not simulate, so you will not be able to simulate this flowchart. As the comparator requires C code there are no interface components on the panels.But I still in doubt and could not get the downloaded flow-code running when I start the simulation run..
The only way to try this is on hardware.
“Integrity is doing the right thing, even when no one is watching.”
― C.S. Lewis
― C.S. Lewis