PDA

View Full Version : "Analogue" interrupts



anj
- 1st April 2004, 23:56
Gday all
Is it possible to put a 12F675 to sleep and then wake it up when the value on an analogue input changes ( either up or down from the setting when the pic was put to sleep ).
I am controlling the speed and direction of a DC motor from a single pot, using the ADC to tell me speed and direction. When the pot is centered, the motor stops, and as such i cant use the comparator interrupt functions as i dont know which way the user will turn the pot. I know i can do it with external circuitry ( or with two comparators ) but was wondering if there is some sneaky interrupt settings i could use to do this in the 12F675.
ps Mel i'm now up to speed on 12F675 comparators, after my last little exercise, but cant see a way to do it.

Andrew

Melanie
- 2nd April 2004, 14:21
The only things that will wake a PIC are interrupts. They are detailed in the 'Special Features of the CPU' section of the PIC's Datasheet. If you now want the PIC to perform decisions based on the ADC value, it needs to be awake to do this - that's the whole reason you're waking it. After-all, if you need to make a decision isn't it best to make it when you're awake? You will need some external hardware (even if it's just a simple Hall-effect switch on your motor) that will kick the PIC awake if the motor turns whilst it's asleep - or as you rightly say, use a PIC with a couple of Comparators.

Mind you... you can get away with one comparator... feed your input voltage through a Capacitor to remove the primary 'nominal' DC component, then full-wave rectify, and feed that into the Comparator. If then the input voltage goes up or down from the 'nominal' value you can have the comparator detect that a movement has occurred (after all the comparator is simply looking for a voltage above it's reference threshold) and wake the PIC.

Melanie

anj
- 3rd April 2004, 00:20
Gday Mel
Thks for the reply.
I am running a system off a battery so am looking at all ways to reduce the power. And avoid external circuits that draw power.
I understood the interrupt concept so was going to run my ADC on input pin 0 or 1. Doing this i could reset to analogue, initialise the comparator, then put the chip to sleep. When the analogue comparator interrupt wakes it up, i reset to digital and do my ADCs. ( but this requires two comparators ).
A bandpass type interrupt on a single pin would be a really nice feature.
Re hall effect. Wont work. The chip feeds the PWM to drive the motor, and the chips asleep :-)
Re yr last solution, i am reading a pot supplied via the PIC supply rail, hence its pure DC already. Nothing to rectify.

Andrew