comparator with interrupt

Thread Starter

gdallas

Joined Apr 25, 2012
74
I’m looking to implement a comparator with interrupt to sense a increased level on my sensor which is just a voltage analogue input and then trigger an interrupt to wake my pic. What I plan to do is use a standalone DAC to provide a dynamic voltage ref for my inverting input of my comparator. Just before my PIC is sent to sleep, I will write to the DAC and which will serve as a method of saving the last value sensor state before the sleep. Then from there on In should the sensor increase its position the comparator will detect the differential and trigger an interrupt. Eventually I will use two comparators to detect an increase AND a decrease in position. I need to detect an increase of 0.036V before I care to wake the PIC. This needs to be constant regardless of what the ref voltage is. My plan was to use a voltage divider circuit to bias my inverting input, but as the voltage is dynamic, im not sure this is a viable solution.

Anyone got any ideas to configure a static voltage value deviation (i.e. 0.036v) on my inverting input?


If Vsens > Vref+0.036V then output high, else output low. pleaser fer to attacged image too


thanks
 

Attachments

praondevou

Joined Jul 9, 2011
2,942
Good idea of yours.
Why would it not work?

The uC is awake and you decide to put it to sleep, so you write the sensor data +a little offset to the DAC.
The comparator output goes LOW. You sent the PIC to sleep.

The sensor output increases above the DACs output value, the comparator output goes HIGH. You wake the uC up.

This is an internal comparator of the uC, right? Is it active even when the uC is in sleep?
 

Thread Starter

gdallas

Joined Apr 25, 2012
74
Hi I wasn't suggesting it wouldn't work. I just wasn't sure how I'd implement the consistent offset but you've just cracked it I think :) don't just write the last real value to the dac value , write the last plus 10 levels extra. Great idea mate. Only problem is while this is good for going up this doesn't help going down... Unless if course I used a dual dac and subtracted 10 levels of resolution this time.

It's good to talk. :)
 

Thread Starter

gdallas

Joined Apr 25, 2012
74
And yes internal comparators, which can be selectively enabled so my software engineer tells me on sleep mode
 

THE_RB

Joined Feb 11, 2008
5,438
Having an external DAC increases parts count, size, cost, energy usage, time to assemble etc.

What's the big gain from having an external DAC?

You can just wake the PIC up on the watchdog timer every X mS, and run the PIC ADC to detect the sensor value. Then if the sensor is > blah the PIC stays awake and does the task.

That "wake and check ADC" task can be done so quickly as to use very little power.
 

Thread Starter

gdallas

Joined Apr 25, 2012
74
THE_RB, i fear ou dont fully understand my problem. you say "Then if the sensor is > blah the PIC stays awake and does the task" well "blah" is not a static reference. Also the only additional part required would be one dual DAC and a decoupling cap. its a a very cheap part and only burns 1.5uA per DAC in operation. Using this method, i can disbale the PIC ADC which would normally be 210uA typical and every other PIC peripheral other than 2No. Comparators. A watchdog timer would not provide an efficent method of waking the device since the instrument could go days, or weeks without ever needing to wake therefore i only want to wake it if somethign changes.
 

THE_RB

Joined Feb 11, 2008
5,438
I just checked a PIC datasheet, the internal comparator module draws 11.5uA typical (using 5v Vdd).

So your "1.5uA DAC" will use up an extra 11.5uA in the PIC because the comparator has to be turned on ALL the time!

What I was suggesting was a very normal system to use minimal power. The PIC spends almost all it's time in sleep mode, with the ADC module turned off. Then it wakes up every X mS and turns on the ADC, and takes a reading of your analogue sensor voltage.

That only takes a tiny bit of time, and because it is done infrequently it uses almost no power.

Then when it reads the ADC, only IF the ADC > blah, then it can stay awake for a while and do your task.

You should also answer Sensacell's questions as they are important in deciding the best way to do this task. :)
 

ErnieM

Joined Apr 24, 2011
8,377
Anyone got any ideas to configure a static voltage value deviation (i.e. 0.036v) on my inverting input?
It's always easier to do one thing then to do two things.

Set your D2A to the high deviation, then pray your low deviation is a fixed ratio below that so a simple voltage divider gives you your 2nd point.

If not a fixed ratio below then you'll need to provide more details.
 
Top