ISR on analog too or only digital?

Go To Last Post
8 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Is there a way to use the pin change interrupt service request on and analog signal from the ADC or does the ISR only work on a digital signal? If you can, what needs to be done differently?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If you must save power, but read an analog input, there was a nice trick:

Start the watchdog in interrupt mode and on every interrupt start an AD-conversion to check, if you can sleep again or must do something.
The latency was given by the selected watchdog timeout interval (16ms .. 8s).

Peter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

If you must save power, but read an analog input, there was a nice trick:

Start the watchdog in interrupt mode and on every interrupt start an AD-conversion


Hmmm--saving power???

Depending on the model, the ADC+reference draws several hundred microamps when all warmed up and ready.

So frequent ADC work + lowest power don't fit well together.

And if you shut it down completely with PRR etc., then you need at least two conversions after re-enabling to get a good result.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
Depending on the model, the ADC+reference draws several hundred microamps when all warmed up and ready.

Exact thus why I suggested, let the AVR in power down with ADC off, CPU stopped, most of the time.

And use the watchdog to awake periodically, do a conversion and sleep again.

Peter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

When did the OP say anything about saving power and what could it possibly have to do with the question actually asked?

You will want to use the pin change ISR only with digital signals. If you put an analog signal on the pin (within the range of what the pin expects) then it will trigger the interrupt, but there will be no certain voltage that this will happen, plus you could get multiple interrupt when the voltage is hanging around in the middle range between a 0 and a 1.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

When did the OP say anything about saving power

OK, I'm guilty--scanning the new postings I replied to danni's post. Given his track record, I was sure it was on-topic--even if he does his debouncing horizontally instead of vertically. :twisted:

Quote:

You will want to use the pin change ISR only with digital signals.

True. But...

Depending on the AVR model, one can generate the equivalent of a pin-change at an arbitrary level on a single pin. This uses the analog comparator, and in some models an ADC channel can be selected as one leg.

Many/most late-model AVRs have pin-change on nearly all I/O pins anyway, including the ADC pins. So OP should tell more about which model and what needs to be done.

Lee

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Koshchi wrote:
When did the OP say anything about saving power and what could it possibly have to do with the question actually asked?

It was only my assumption, since typically the pin change interrupt was used to awake from power down.

So I was thinking, the OP want to wake up the AVR on a certain voltage level.

Peter

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Voltage level for the pin change interrupt would be very low, I'm talking .38~.4v pulled down to .10~.05v when the beam is broken, so not enough for digital which is why I asked about iterrupts on analog. I am using HSDL-5420/4420 series IR detector and emitters along with allegro hall sensors, all of them produce an analog signal. I will be replacing them soon with latched IR detectors and latched hall sensors so that I can go entirely digital as it allows greater efficiency in this application and I have no need for an analog signal as I only want to know an instance, not linear positioning.

Its an ATMega88PA running at 20mhz. I have not even touched power saving yet, but I do want to work on that soon, there are other things that need to be finished first and this is the first time I have done anything with the C language, or any language other than industrial ladder logic, and i wasn't able to find anything about interrupts on an analog signal.