Custom Interrupt for Comparator

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
Dave Squibb
Flowcode v5 User
Posts: 104
Joined: Fri Oct 10, 2014 11:15 am
Has thanked: 27 times
Been thanked: 22 times

Custom Interrupt for Comparator

Post by Dave Squibb »

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.
Attachments
Comparator.fcfx
(6.43 KiB) Downloaded 424 times

User avatar
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

Post by Benj »

Hi Dave,

It looks to me like it should be working. However I did spot this line in the datasheet.
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.
So you might have to use cmcon = 2 rather than cmcon = 5 like you have now.

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

Post by Dave Squibb »

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?

skquah
Posts: 39
Joined: Fri Dec 12, 2014 3:57 pm
Has thanked: 26 times
Been thanked: 10 times

Re: Custom Interrupt for Comparator

Post by skquah »

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]

kersing
Valued Contributor
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

Post by kersing »

But I still in doubt and could not get the downloaded flow-code running when I start the simulation run..
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.
The only way to try this is on hardware.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

skquah
Posts: 39
Joined: Fri Dec 12, 2014 3:57 pm
Has thanked: 26 times
Been thanked: 10 times

Re: Custom Interrupt for Comparator

Post by skquah »

Thanks, Kersing

Post Reply