Can Analogue value be used to trigger an interrupt?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 4.
To post in this forum you must have a registered copy of Flowcode 4 or higher. To sign up for this forum topic please use the "Online Resources" link in the Flowcode Help Menu.

Moderator: Benj

Post Reply
daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times

Can Analogue value be used to trigger an interrupt?

Post by daveb0360 »

Hi,
Just curiosity as I am trying to learn how to use iterrupts for a small project. (Using 16F876 on internal oscillator at 4Mhz)

I need to know if an analogue value into ADC can be used to trigger an interrupt. For example, a mid rail voltage that falls below or above a threshold whilst executing other parts of a program, calls an iterrupt to perform a variable update or something like this.

Is there a way of doing this.

Thanks
Dave

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: Can Analogue value be used to trigger an interrupt?

Post by Benj »

Hi Dave,

Most PIC microcontrollers with analogue inputs have a comparator peripheral which does the job you have detailed. Flowcode does not support comparators directly though this is planned for the future but you can use C code embedded in a custom interrupt to setup the comparator module. There should be examples on the forum of how to do this but if your struggling then we should be able to help.

daveb0360
Posts: 139
Joined: Mon Sep 21, 2009 10:17 am
Location: Leicester
Has thanked: 35 times
Been thanked: 12 times

Re: Can Analogue value be used to trigger an interrupt?

Post by daveb0360 »

Thanks Ben,
I have NO knowledge of C so will be trawling the forum for input.

Hopefully I will find something I can decipher but will probably come back for direct advice &or examples once I establish that this is truly a way to go as I suspect it is.
My circuit will need to react to this analogue level immediately and regardless of anything else it is doing so interrupt / comparator would seem the way to do this.

Thanks

Dave

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times

Re: Can Analogue value be used to trigger an interrupt?

Post by Spanish_dude »

Hi,

An alternative to this would be using a Timer interrupt where you would check the value of the ADC using if statements.
Once the condition is "true", do something, else go back to main loop.

Seems pretty easy to do.

BR,

Nicolas L. F.

Post Reply